source: src/documentation/patterns/observer.dox@ 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.8 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010 University of Bonn. All rights reserved.
5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
8/**
9 * \file observer.dox
10 *
11 * Created on: Dec 1, 2011
12 * Author: heber
13 */
14
15/** \page pattern-observer
16 *
17 * Basic structure for the observer pattern
18 *
19 * Observers register themselves with the observables to be notified when something changes.
20 * In the Observable code that changes, attributes should be started with OBSERVE;. This macro
21 * locks the observer mechanism while changes are done. At the end of the scope in which the
22 * macro was placed the lock is released. When the last lock is released all changes are
23 * propagated to the observers.
24 *
25 * Each observerable can have sub-observables. When one of these sub-observables changes and
26 * notifies its observers the observable that contains them will also notify its observers.
27 * This passing on of updates is blocked, when the main-observable is in the process of
28 * updating many of its internal sub-observables. This means the update is not passed, if
29 * it is produced while the main-observable itself is within any Observation block.
30 *
31 * \section pattern-observer-howtos Howto
32 *
33 * Below you find various howtos to guide you through how to use the various
34 * observer patterns.
35 *
36 * \section pattern-observer-howtos-observer Observers
37 *
38 * \todo write howto for using an Observer
39 *
40 * \section pattern-observer-howtos-observables Observables
41 *
42 * \todo write howto for using an Observable
43 *
44 * \section pattern-observer-howtos-relay Relays
45 *
46 * Lets us assume that you want to observe all instances of class "foo".
47 * In order to create a Relay you have to do the following:
48 * -# Create a new class "bar" that inherits the Relay pattern.
49 * \code
50 * #include "CodePatterns/Relay.hpp"
51 * class bar : public Relay {
52 * ...
53 * };
54 * \endcode
55 * -# In the constructor bar::bar() create a Channels object for your Relay and
56 * add a channel for each of foo's channels, use foo's enum for this:
57 * \code
58 * bar::bar() {
59 * Channels *OurChannel = new Channels();
60 * NotificationChannels.insert( std::make_pair(this, OurChannel) );
61 * OurChannel->addChannel(foo::Notification1);
62 * OurChannel->addChannel(foo::Notification2);
63 * ...
64 * }
65 * \endcode
66 * -# Someplace else you have add all Observers that need to check on all
67 * instances of "foo" to be signed on.
68 * \code
69 * bar barInstance;
70 * ... someObserverInstance;
71 * barInstance.signOn(someObserverInstance);
72 * \endcode
73 * -# ... or maybe just for a specific channel of foo.
74 * \code
75 * bar barInstance;
76 * ... someObserverInstance;
77 * barInstance.signOn(someObserverInstance, foo::Notification1);
78 * \endcode
79 *
80 *
81 * \date 2011-12-01
82 */
83
Note: See TracBrowser for help on using the repository browser.