source: src/documentation/constructs/observers_observables.dox@ c8302f3

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since c8302f3 was 760c4c, checked in by Frederik Heber <heber@…>, 13 years ago

Cleaned observer structure in atom.

  • Added new channel BondsRemoved and used in bonds removal functions.
  • FIX: Removed PropertyChanged for setNr and alikes, Nr is molecule's responsibility. Made note of this in documentation.
  • Property mode set to 100644
File size: 4.6 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 observers_observables.dox
10 *
11 * Created on: Oct 12, 2011
12 * Author: heber
13 */
14
15/** \page observers Observers and Observables
16 *
17 * The Observer/Observerable mechanism is crucial to let different and
18 * independent components know about changes among one another. E.g. when an
19 * the element of an atom changes, the GUI (\ref graphical) needs to know
20 * about this change to plot the atom with a different color or shape.
21 *
22 * The Observer/Observerable mechanism is basically just a call-back: A
23 * class announces itself as Observable with having a specific interface
24 * of functions. Observer may signOn() to this class and have a specific
25 * function (update()) be called whenever a change occurs in the Observable
26 * class.
27 *
28 * Note that additionally an Observable may have various \a channels and
29 * Observers may signOn() to just such a channel to get a very specific
30 * update. E.g. a LinkedCell class needs to know when the position of an
31 * atom changes but it does not need to know about changes of element or
32 * velocity, ... These updates are called \a Notifications.
33 *
34 * As an example:
35 * \code
36 * World::getInstance().signOn(this, World::getInstance().getChannel(World::AtomInserted));
37 * \endcode
38 * Here, in the constructor of GLWorldView the class signs on to atoms
39 * being inserted into the World such that it can add these onto the display
40 * as well. Notifications are received via recieveNotifications(), e.g.
41 * which you have to implement for an Observer class
42 * \code
43 * switch (notification->getChannelNo()) {
44 * case World::AtomInserted:
45 * {
46 * const atom *_atom = World::getInstance().lastChanged<atom>();
47 * emit atomInserted(_atom);
48 * break;
49 * }
50 * \endcode
51 * Here, we just switch over all events that we process and care about (note
52 * that we only get called for those for which we have subscribed) and proceed.
53 *
54 * \note There is a complete logging mechanism available for this. However,
55 * it has to be compiled via a specific switch (\ref install). So, when
56 * you need to know why your function isn't notified, that's the way to
57 * find out.
58 *
59 * Be wary of where the update occurs: while the World tells you about new
60 * or destroyed atoms, only the atom itself tells you when its position has
61 * changed!
62 *
63 * \section observers-where Who observes what?
64 *
65 * Where to look for a specific update is very important. Hence, we list here
66 * all (major) Observables and what exactly they report in their channels:
67 * -# \ref World: Gives updates on insertion or removal of atoms and molecules.
68 * It does not tell whether the inner state of either has changed.
69 * -# \ref atom: Gives updates on changes to inner state of an atom, i.e.
70 * -# bonds
71 * -# element
72 * -# position
73 * It does not tell when e.g. it is associated to another molecule and
74 * like-wise not if its AtomInfo::Nr changes, as this is given by the
75 * molecule also.
76 * -# \ref AtomObserver: Gives updates on changes occuring in any atom. It
77 * acts as a relay that observes all atoms at once and gives notice when
78 * a single one has changed. It does not tell when a new has arrived or
79 * one has been removed.
80 * -# \ref molecule: Gives updates on changes occuring in its internal state,
81 * e.g. atoms being inserted or removed. It does not tell when atoms themself
82 * change.
83 * -# \ref Box: Gives updates on changes of its box matrix or boundary
84 * conditions.
85 *
86 * It should be adhered to these Does and Don'ts strictly. Each of these entities
87 * can only report about stuff it knows about. The World controls insertion and
88 * removal, hence its updates are concerned with these only!
89 *
90 *
91 * \section observers-world Observers and the World
92 *
93 * The World, containing the arrays of all atoms and molecules, is a bit
94 * special with these observers. E.g. when you request a non-const array
95 * of atoms you receive an ObservedIterator. That is one where automatically
96 * it is assumed that you changed something and hence update() is called
97 * after you stepped over one of its elements.
98 *
99 * Thus, use const-iterators and arrays whenever possible, first to avoid
100 * this overhead, but second to avoid making pain-in-the-ass, hard-to-find
101 * mistakes.
102 *
103 * Also, the world stores specific information about what changed in the
104 * template function World::lastChanged() where it might contain reference
105 * to an atom that is about to be destroyed or just added.
106 *
107 *
108 * \date 2011-10-31
109 *
110 */
Note: See TracBrowser for help on using the repository browser.