/* * Notification.hpp * * Created on: Dec 1, 2011 * Author: heber */ #ifndef NOTIFICATION_HPP_ #define NOTIFICATION_HPP_ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include class Channels; class Observable; class Observer; /** Notifications are sort of news channels of an Observable. * Via the NOTIFY() macro updates can be transmitted in a specific channel. * Observers can subscribe to Notification in much the same way as they can to * the Observable itself. Usually, Notifications are used along * with the usual OBSERVE() macro to generate both the specific and * the global message of change. */ class Notification { friend class Observable; friend class Channels; public: Notification(size_t _channelno); virtual ~Notification(); size_t getChannelNo() const { return channelno; } protected: void addObserver(Observer *target); void removeObserver(Observer *target); void notifyAll(Observable * const publisher); private: std::set targets; const size_t channelno; }; #endif /* NOTIFICATION_HPP_ */