source: src/Atom/AtomObserver.hpp@ 11cc05

Last change on this file since 11cc05 was 708277, checked in by Frederik Heber <heber@…>, 12 years ago

FIX: Using fixed Observer in CodePatterns 1.2.6.

  • we now require CodePatterns 1.2.6.
  • Notifications now use subjectKilled() when the Observable they are associated with is destroyed. This allows Observers that are just sign on to a single channel safely sign off.
  • also, derived Observable classes must not remove their Channels and Notifications by themselves. This is done by the Observable base class. Otherwise, subjectKilled() is not called.
  • changed AtomObserver: Is directly connected to the atom class, AtomInserted and AtomRemoved called in its cstor and dstor. The World has nothing to do with it. However, we have to make sure AtomObserver is purged after World.
  • Fixed also some faulty uses of ObserverLog and we always insert into NotificationChannels with static_cast to Observable for clarity.
  • Property mode set to 100644
File size: 1.2 KB
Line 
1/*
2 * AtomObserver.hpp
3 *
4 * Created on: Nov 30, 2011
5 * Author: heber
6 */
7
8#ifndef ATOMOBSERVER_HPP_
9#define ATOMOBSERVER_HPP_
10
11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16#include "CodePatterns/Observer/Relay.hpp"
17#include "CodePatterns/Singleton.hpp"
18
19class atom;
20
21/** The AtomObserver is a central instance to all changes occuring within atoms.
22 *
23 * The intent is that if a class wants to know about changes in just _any_ atom,
24 * he may register singly to this class and not to each and every atom. This also
25 * keeps him updated in case of removed or added atoms.
26 *
27 * \warning AtomObserver must get purged \b after World as we do not keep an
28 * an internal list of all atoms. Hence, each atom must get destroyed while
29 * the AtomObserver instance is still intact or segfault will occur.
30 *
31 */
32class AtomObserver : public Singleton<AtomObserver>, public Relay
33{
34 //!> grant Singleton access to cstor and dstor.
35 friend class Singleton<AtomObserver>;
36
37 //!> grant atom access
38 friend class atom;
39public:
40
41private:
42 void AtomInserted(atom *res);
43 void AtomRemoved(atom *res);
44
45 // private constructor and destructor due to singleton
46 AtomObserver();
47 virtual ~AtomObserver();
48};
49
50
51#endif /* ATOMOBSERVER_HPP_ */
Note: See TracBrowser for help on using the repository browser.