source: src/Patterns/Observer/Notification.hpp@ e2e035e

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

Refactored all Observer stuff into own subfolder and split up into distinct modules.

  • Observer/all.hpp is all that's needed.
  • Property mode set to 100644
File size: 1.1 KB
Line 
1/*
2 * Notification.hpp
3 *
4 * Created on: Dec 1, 2011
5 * Author: heber
6 */
7
8#ifndef NOTIFICATION_HPP_
9#define NOTIFICATION_HPP_
10
11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16#include <set>
17
18class Channels;
19class Observable;
20class Observer;
21
22/** Notifications are sort of news channels of an Observable.
23 * Via the NOTIFY() macro updates can be transmitted in a specific channel.
24 * Observers can subscribe to Notification in much the same way as they can to
25 * the Observable itself. Usually, Notifications are used along
26 * with the usual OBSERVE() macro to generate both the specific and
27 * the global message of change.
28 */
29class Notification {
30 friend class Observable;
31 friend class Channels;
32public:
33 Notification(size_t _channelno);
34 virtual ~Notification();
35
36 size_t getChannelNo() const { return channelno; }
37
38protected:
39
40 void addObserver(Observer *target);
41 void removeObserver(Observer *target);
42
43 void notifyAll(Observable * const publisher);
44private:
45 std::set<Observer*> targets;
46 const size_t channelno;
47};
48
49
50
51#endif /* NOTIFICATION_HPP_ */
Note: See TracBrowser for help on using the repository browser.