source: src/CodePatterns/Observer/Observer.hpp@ 084729c

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 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
Last change on this file since 084729c was 084729c, checked in by Frederik Heber <heber@…>, 8 years ago

Squashed 'ThirdParty/CodePatterns/' content from commit c1e1041

git-subtree-dir: ThirdParty/CodePatterns
git-subtree-split: c1e10418c454f98be2f43d93167642b0008428fc

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/*
2 * Observer.hpp
3 *
4 * Created on: Jan 19, 2010
5 * Author: crueger
6 */
7
8#ifndef OBSERVER_HPP_
9#define OBSERVER_HPP_
10
11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16#include <map>
17#include <set>
18#include <string>
19#include <sstream>
20
21// Deactivate any logging when we are not in debug mode
22#ifdef NDEBUG
23#undef LOG_OBSERVER
24#endif
25
26#include "CodePatterns/Observer/defs.hpp"
27
28class Channels;
29class Observable;
30
31/**
32 * An Observer is notified by all Observed objects, when anything changes.
33 *
34 * If a simple change is done to an Object the Obervable will call the update() method
35 * of all signed on observers, passing itself as a parameter for identification. The
36 * Observers should then react to the changes and update themselves accordingly.
37 *
38 * If an observed Object is destroyed it will call the subjectKilled() method
39 * of all signed on Observers, again passing itself as a parameter for identification.
40 * The Observers should handle the destruction of an observed Object gracefully, i.e.
41 * set themselves inactive, display something else, etc. There is no need
42 * to sign of from the dying object, since this will be handled by the Observable destructor.
43 */
44class Observer
45{
46 friend class Notification;
47 friend class Observable;
48 friend class Relay;
49 template<class> friend class ObservedIterator;
50
51 // indicates the constructor called from Observables
52 struct BaseConstructor{};
53
54public:
55 Observer(BaseConstructor);
56 Observer(std::string);
57 virtual ~Observer();
58
59protected:
60 /**
61 * This method is called upon changes of the Observable
62 */
63 virtual void update(Observable *publisher)=0;
64
65 /**
66 * This method is called when a special named change
67 * of the Observable occured
68 */
69 virtual void recieveNotification(Observable *publisher, Notification_ptr notification);
70
71 /**
72 * This method is called when the observed object is destroyed.
73 */
74 virtual void subjectKilled(Observable *publisher)=0;
75};
76
77#ifdef LOG_OBSERVER
78#include "ObserverLog.hpp"
79#endif
80
81
82#endif /* OBSERVER_HPP_ */
Note: See TracBrowser for help on using the repository browser.