Ignore:
Timestamp:
Feb 26, 2010, 1:57:01 PM (16 years ago)
Author:
Tillmann Crueger <crueger@…>
Children:
78b9d9, d50264
Parents:
e65cc0 (diff), 45cc89 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'FreddiesRefactoring' into StructureRefactoring

Conflicts:

molecuilder/src/Patterns/Observer.cpp
molecuilder/src/World.cpp
molecuilder/src/boundary.cpp
molecuilder/src/molecule_dynamics.cpp
molecuilder/src/unittests/AnalysisCorrelationToPointUnitTest.cpp
molecuilder/src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
molecuilder/src/unittests/AnalysisPairCorrelationUnitTest.cpp
molecuilder/src/unittests/Makefile.am
molecuilder/src/unittests/bondgraphunittest.cpp
molecuilder/src/unittests/listofbondsunittest.cpp

Location:
molecuilder/src/Patterns
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/Patterns/Observer.cpp

    re65cc0 rdc5413  
    2424// See [Gamma et al, 1995] p. 297
    2525
    26 map<Observable*, int> Observable::depth;
    27 map<Observable*,multimap<int,Observer*>*> Observable::callTable;
    28 set<Observable*> Observable::busyObservables;
    29 
    30 // The two functions start_observer_internal and finish_observer_internal
    31 // have to be used together at all time. Never use these functions directly
    32 // START_OBSERVER and FINISH_OBSERVER also construct a bogus while(0) loop
    33 // thus producing compiler-errors whenever only one is used
    34 
     26map<Observable*, int> Observable::depth;  //!< Map of Observables to the depth of the DAG of Observers
     27map<Observable*,multimap<int,Observer*>*> Observable::callTable; //!< Table for each Observable of all its Observers
     28set<Observable*> Observable::busyObservables; //!< Set of Observables that are currently busy notifying their sign-on'ed Observers
     29
     30/** Attaching Sub-observables to Observables.
     31 * Increases entry in Observable::depth for this \a *publisher by one.
     32 *
     33 * The two functions \sa start_observer_internal() and \sa finish_observer_internal()
     34 * have to be used together at all time. Never use these functions directly
     35 * START_OBSERVER and FINISH_OBSERVER also construct a bogus while(0) loop
     36 * thus producing compiler-errors whenever only one is used.
     37 * \param *publisher reference of sub-observable
     38 */
    3539void Observable::start_observer_internal(Observable *publisher){
    3640  // increase the count for this observable by one
     
    4044}
    4145
     46/** Detaching Sub-observables from Observables.
     47 * Decreases entry in Observable::depth for this \a *publisher by one. If zero, we
     48 * start notifying all our Observers.
     49 *
     50 * The two functions start_observer_internal() and finish_observer_internal()
     51 * have to be used together at all time. Never use these functions directly
     52 * START_OBSERVER and FINISH_OBSERVER also construct a bogus while(0) loop
     53 * thus producing compiler-errors whenever only one is used.
     54 * \param *publisher reference of sub-observable
     55 */
    4256void Observable::finish_observer_internal(Observable *publisher){
    4357  // decrease the count for this observable
     
    5367}
    5468
     69/** Constructor for Observable Protector.
     70 * Basically, calls start_observer_internal(). Hence use this class instead of
     71 * calling the function directly.
     72 *
     73 * \param *protege Observable to be protected.
     74 */
    5575Observable::_Observable_protector::_Observable_protector(Observable *_protege) :
    5676  protege(_protege)
     
    5979}
    6080
     81/** Destructor for Observable Protector.
     82 * Basically, calls finish_observer_internal(). Hence use this class instead of
     83 * calling the function directly.
     84 *
     85 * \param *protege Observable to be protected.
     86 */
    6187Observable::_Observable_protector::~_Observable_protector()
    6288{
     
    6692/************* Notification mechanism for observables **************/
    6793
    68 
     94/** Notify all Observers of changes.
     95 * Puts \a *this into Observable::busyObservables, calls Observer::update() for all in callee_t
     96 * and removes from busy list.
     97 */
    6998void Observable::notifyAll() {
    7099  // we are busy notifying others right now
     
    87116}
    88117
    89 // this handles passing on updates from sub-Observables
     118/** Handles passing on updates from sub-Observables.
     119 * Mimicks basically the Observer::update() function.
     120 *
     121 * \param *publisher The \a *this we observe.
     122 */
    90123void Observable::update(Observable *publisher) {
    91124  // circle detection
     
    109142}
    110143
    111 // methods to sign-on and off
     144/** Sign on an Observer to this Observable.
     145 * Puts \a *target into Observable::callTable list.
     146 * \param *target Observer
     147 * \param priority number in [-20,20]
     148 */
    112149void Observable::signOn(Observer *target,int priority) {
    113150  assert(priority>=-20 && priority<=+20 && "Priority out of range [-20:+20]");
     
    130167}
    131168
     169/** Sign off an Observer from this Observable.
     170 * Removes \a *target from Observable::callTable list.
     171 * \param *target Observer
     172 */
    132173void Observable::signOff(Observer *target) {
    133174  assert(callTable.count(this) && "SignOff called for an Observable without Observers.");
    134175  callees_t *callees = callTable[this];
    135176  callees_t::iterator iter;
     177  callees_t::iterator deliter;
    136178  for(iter=callees->begin();iter!=callees->end();) {
    137179    if((*iter).second == target) {
     
    148190}
    149191
    150 // when an sub-observerable dies we usually don't need to do anything
     192/** Handles sub-observables that just got killed
     193 *  when an sub-observerable dies we usually don't need to do anything
     194 *  \param *publisher Sub-Observable.
     195 */
    151196void Observable::subjectKilled(Observable *publisher){
    152197}
    153198
     199/** Constructor for class Observable.
     200 */
    154201Observable::Observable()
    155202{}
    156203
    157 // when an observable is deleted, we let all our observers know
     204/** Destructor for class Observable.
     205 * When an observable is deleted, we let all our observers know. \sa Observable::subjectKilled().
     206 */
    158207Observable::~Observable()
    159208{
     
    170219}
    171220
     221/** Constructor for class Observer.
     222 */
    172223Observer::Observer()
    173224{}
    174225
     226/** Destructor for class Observer.
     227 */
    175228Observer::~Observer()
    176229{}
  • molecuilder/src/Patterns/Observer.hpp

    re65cc0 rdc5413  
    1616 *
    1717 * Observers register themselves with the observables to be notified when something changes.
    18  * In the Observable code that changes attributes should be started with OBSERVE;. This macro
     18 * In the Observable code that changes, attributes should be started with OBSERVE;. This macro
    1919 * locks the observer mechanism while changes are done. At the end of the scope in which the
    2020 * macro was placed the lock is released. When the last lock is released all changes are
Note: See TracChangeset for help on using the changeset viewer.