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 | * Graveyard.hpp | 
|---|
| 3 | * | 
|---|
| 4 | *  Created on: Sep 5, 2013 | 
|---|
| 5 | *      Author: heber | 
|---|
| 6 | */ | 
|---|
| 7 |  | 
|---|
| 8 | #ifndef GRAVEYARD_HPP_ | 
|---|
| 9 | #define GRAVEYARD_HPP_ | 
|---|
| 10 |  | 
|---|
| 11 | // include config.h | 
|---|
| 12 | #ifdef HAVE_CONFIG_H | 
|---|
| 13 | #include <config.h> | 
|---|
| 14 | #endif | 
|---|
| 15 |  | 
|---|
| 16 | #include <map> | 
|---|
| 17 |  | 
|---|
| 18 | #include "CodePatterns/Observer/Zombie.hpp" | 
|---|
| 19 |  | 
|---|
| 20 | class GraveyardUnitTest; | 
|---|
| 21 | class Observable; | 
|---|
| 22 |  | 
|---|
| 23 | /** The Graveyard takes of Observables instances that are about to get | 
|---|
| 24 | * destroyed but where it is necessary that all Observers that are still | 
|---|
| 25 | * signOn()'ed signOff() before the instance actually vanishes. | 
|---|
| 26 | * | 
|---|
| 27 | * For this the Graveyard takes Observable and turns/wraps them into a | 
|---|
| 28 | * Zombie class (that is basically just an Attorney pattern so far) | 
|---|
| 29 | * informing the Observable of a present Graveyard. | 
|---|
| 30 | * | 
|---|
| 31 | * \section graveyard-usage Usage | 
|---|
| 32 | * | 
|---|
| 33 | *   The Graveyard is really easy to use. Have an instance that lives | 
|---|
| 34 | *   long enough and use | 
|---|
| 35 | *   \code | 
|---|
| 36 | *    Observable *_obs = new Observable("_obs"); | 
|---|
| 37 | *    Graveyard::turnZombies(_obs); | 
|---|
| 38 | *   \endcode | 
|---|
| 39 | *   in place pf | 
|---|
| 40 | *   \code | 
|---|
| 41 | *   delete _obs; | 
|---|
| 42 | *   \endcode | 
|---|
| 43 | *   The instance is fully destroyed as soon as all Observers are signOff()'d | 
|---|
| 44 | * | 
|---|
| 45 | */ | 
|---|
| 46 | class Graveyard | 
|---|
| 47 | { | 
|---|
| 48 | //!> grant unit test access to private parts | 
|---|
| 49 | friend class GraveyardUnitTest; | 
|---|
| 50 | public: | 
|---|
| 51 | Graveyard(); | 
|---|
| 52 | ~Graveyard(); | 
|---|
| 53 |  | 
|---|
| 54 | /** This turns an Observable into a Zombie and takes over the ptr. | 
|---|
| 55 | * | 
|---|
| 56 | * \param _observable Observable to take control of | 
|---|
| 57 | */ | 
|---|
| 58 | void turnZombie(Observable *&_observable); | 
|---|
| 59 |  | 
|---|
| 60 | private: | 
|---|
| 61 | friend class Observable; | 
|---|
| 62 | /** Function to be called by Observables if Observer's have signOff()ed. | 
|---|
| 63 | * | 
|---|
| 64 | * \param _observable calling Observable | 
|---|
| 65 | */ | 
|---|
| 66 | void ObserverLeft(const Observable *_observable); | 
|---|
| 67 |  | 
|---|
| 68 | private: | 
|---|
| 69 | //!> typedef for internal list of zombies | 
|---|
| 70 | typedef std::map<const Observable*,Zombie::ptr> graveyard_t; | 
|---|
| 71 | //!> the list of currently active zombies | 
|---|
| 72 | graveyard_t graveyard; | 
|---|
| 73 |  | 
|---|
| 74 | //!> static function to inform observer | 
|---|
| 75 | Observable::graveyard_informer_t graveyard_informer; | 
|---|
| 76 | }; | 
|---|
| 77 |  | 
|---|
| 78 | #endif /* GRAVEYARD_HPP_ */ | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.