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

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

Added unit test on Relay.

  • added new stubs to ObserverStub implementing Relay.
  • Relay is friend of Notification.
  • 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 Observable;
19class Observer;
20class Relay;
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 //!> grant Observable access to notifyAll()
31 friend class Observable;
32 //!> grant Relay access to notifyAll()
33 friend class Relay;
34public:
35 Notification(size_t _channelno);
36 virtual ~Notification();
37
38 size_t getChannelNo() const { return channelno; }
39
40protected:
41
42 void addObserver(Observer *target);
43 void removeObserver(Observer *target);
44
45 void notifyAll(Observable * const publisher);
46private:
47 std::set<Observer*> targets;
48 const size_t channelno;
49};
50
51
52
53#endif /* NOTIFICATION_HPP_ */
Note: See TracBrowser for help on using the repository browser.