Action_Thermostats
        Add_AtomRandomPerturbation
        Add_RotateAroundBondAction
        Add_SelectAtomByNameAction
        Adding_Graph_to_ChangeBondActions
        Adding_MD_integration_tests
        Adding_StructOpt_integration_tests
        Automaking_mpqc_open
        AutomationFragmentation_failures
        Candidate_v1.6.0
        Candidate_v1.6.1
        Candidate_v1.7.0
        ChangeBugEmailaddress
        ChangingTestPorts
        ChemicalSpaceEvaluator
        Combining_Subpackages
        Debian_Package_split
        Debian_package_split_molecuildergui_only
        Disabling_MemDebug
        Docu_Python_wait
        EmpiricalPotential_contain_HomologyGraph_documentation
        Enable_parallel_make_install
        Enhance_userguide
        Enhanced_StructuralOptimization
        Enhanced_StructuralOptimization_continued
        Example_ManyWaysToTranslateAtom
        Exclude_Hydrogens_annealWithBondGraph
        FitPartialCharges_GlobalError
        Fix_ChronosMutex
        Fix_StatusMsg
        Fix_StepWorldTime_single_argument
        Fix_Verbose_Codepatterns
        ForceAnnealing_goodresults
        ForceAnnealing_oldresults
        ForceAnnealing_tocheck
        ForceAnnealing_with_BondGraph
        ForceAnnealing_with_BondGraph_continued
        ForceAnnealing_with_BondGraph_continued_betteresults
        ForceAnnealing_with_BondGraph_contraction-expansion
        GeometryObjects
        Gui_displays_atomic_force_velocity
        IndependentFragmentGrids_IntegrationTest
        JobMarket_RobustOnKillsSegFaults
        JobMarket_StableWorkerPool
        JobMarket_unresolvable_hostname_fix
        ODR_violation_mpqc_open
        PartialCharges_OrthogonalSummation
        PythonUI_with_named_parameters
        QtGui_reactivate_TimeChanged_changes
        Recreated_GuiChecks
        RotateToPrincipalAxisSystem_UndoRedo
        StoppableMakroAction
        Subpackage_CodePatterns
        Subpackage_JobMarket
        Subpackage_levmar
        Subpackage_mpqc_open
        Subpackage_vmg
        ThirdParty_MPQC_rebuilt_buildsystem
        TremoloParser_IncreasedPrecision
        TremoloParser_MultipleTimesteps
        Ubuntu_1604_changes
        stable
      
      
      
| Line |  | 
|---|
| 1 | /* | 
|---|
| 2 | * Zombie.hpp | 
|---|
| 3 | * | 
|---|
| 4 | *  Created on: Sep 5, 2013 | 
|---|
| 5 | *      Author: heber | 
|---|
| 6 | */ | 
|---|
| 7 |  | 
|---|
| 8 | #ifndef ZOMBIE_HPP_ | 
|---|
| 9 | #define ZOMBIE_HPP_ | 
|---|
| 10 |  | 
|---|
| 11 | // include config.h | 
|---|
| 12 | #ifdef HAVE_CONFIG_H | 
|---|
| 13 | #include <config.h> | 
|---|
| 14 | #endif | 
|---|
| 15 |  | 
|---|
| 16 | #include "CodePatterns/Observer/Observable.hpp" | 
|---|
| 17 |  | 
|---|
| 18 | #include <boost/shared_ptr.hpp> | 
|---|
| 19 |  | 
|---|
| 20 | class Graveyard; | 
|---|
| 21 |  | 
|---|
| 22 | /** Zombie wraps an Observable and is allowed to set the graveyard. | 
|---|
| 23 | * | 
|---|
| 24 | */ | 
|---|
| 25 | class Zombie | 
|---|
| 26 | { | 
|---|
| 27 | //!> only Graveyard may create zombies | 
|---|
| 28 | friend class Graveyard; | 
|---|
| 29 |  | 
|---|
| 30 | typedef boost::shared_ptr<Zombie> ptr; | 
|---|
| 31 | friend class boost::shared_ptr<Zombie>; | 
|---|
| 32 | private: | 
|---|
| 33 | /** Constructor of class Zombie. | 
|---|
| 34 | * | 
|---|
| 35 | * Is private to allow only Graveyard to instantiate them. | 
|---|
| 36 | * | 
|---|
| 37 | * \param _observable observable to wrap, ptr is NULL'd | 
|---|
| 38 | * \param _graveyard_informer callback when Observers are signOff()'ing | 
|---|
| 39 | */ | 
|---|
| 40 | Zombie( | 
|---|
| 41 | Observable *& _observable, | 
|---|
| 42 | Observable::graveyard_informer_t *_graveyard_informer) : | 
|---|
| 43 | m_observable(_observable) | 
|---|
| 44 | { | 
|---|
| 45 | m_observable->setGraveyardInformer(_graveyard_informer); | 
|---|
| 46 | _observable =  NULL; | 
|---|
| 47 | } | 
|---|
| 48 |  | 
|---|
| 49 | /** Returns the wrapped ptr. | 
|---|
| 50 | * | 
|---|
| 51 | * \param ptr to wrapped up Observable instance | 
|---|
| 52 | */ | 
|---|
| 53 | const Observable * getPtr() const | 
|---|
| 54 | { return m_observable; } | 
|---|
| 55 |  | 
|---|
| 56 | public: | 
|---|
| 57 | /** Destructor of class Zombie. | 
|---|
| 58 | * | 
|---|
| 59 | * Is made public for convenience, to allow boost::shared_ptr access to it. | 
|---|
| 60 | * We could pass shared_ptr a befriended deleteFunction but this is overkill | 
|---|
| 61 | * as long as cstor is private. | 
|---|
| 62 | */ | 
|---|
| 63 | virtual ~Zombie() | 
|---|
| 64 | { delete m_observable; m_observable = NULL; } | 
|---|
| 65 |  | 
|---|
| 66 | size_t getNumberOfObservers() const | 
|---|
| 67 | { return  m_observable->getNumberOfObservers(); } | 
|---|
| 68 |  | 
|---|
| 69 | private: | 
|---|
| 70 | Observable *m_observable; | 
|---|
| 71 | }; | 
|---|
| 72 |  | 
|---|
| 73 | #endif /* ZOMBIE_HPP_ */ | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.