source: src/CodePatterns/Observer/Observer.hpp@ b09709

Last change on this file since b09709 was 9b8fa4, checked in by Frederik Heber <heber@…>, 14 years ago

Huge update of file structure to place installation header files into right folder.

  • The problem ist that we desire use as include "CodePatterns/...". For this to work, especially with the new Observer subfolder structure, it has been necessary to place all header files away from their source files into a distinct folder called CodePatterns. This emulates the later, after make install present structure.
  • essentially all source and header files had to be changed to adapt the include.
  • all Makefile.am's had to be changed.
  • nobase_ ... was removed such that header files are installed flat and not creating their subfolder along the process.
  • We placed Observer into its own convenience library and own folder Observer away from Patterns.

Some other changes:

  • FIX: MemDebug.hpp inclusion has been removed in all stubs.
  • Property mode set to 100644
File size: 2.0 KB
RevLine 
[e2e035e]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
[9b8fa4]26#include "CodePatterns/Observer/defs.hpp"
[e2e035e]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;
[d85532]47 friend class Observable;
48 friend class Relay;
[e2e035e]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.