#include <Subject.h>

Public Member Functions | |
| virtual bool | attach (const std::string &signal, const Slot &slot)=0 |
| virtual bool | detach (const std::string &signal, const Slot &slot)=0 |
| virtual bool | signalsEnabled () const =0 |
Static Public Member Functions | |
| static const std::string & | signalDeleted () |
| static const std::string & | signalModified () |
Protected Member Functions | |
| virtual | ~Subject () |
Generalized interface for objects that can notify observers when changes have been made. It provides a uniform means for letting other objects register an interest in the contents of this object's contents.
Each Subject has signals that it will emit under certain circumstances. When a signal is emitted, all slots attached to that signal on the Subject will be called. For example:
pSubject->attach(SIGNAL_NAME(Subject, Modified), Slot(pObj, &Obj::mySlot));
Whenever a signal other than Subject::Modified or Subject::Deleted is emitted, Subject::Modified will also be emitted. This means that all slots attached to Subject::signalModified on a Subject of type MyClass will be called when that MyClass object emits SIGNAL_NAME(MyClass, MySignal).
Signals for a particular instance of a Subject can be supressed by using either the SignalBlocker or SignalEnabler classes.
The notification of slots is done in two passes. First, all slots attached to the specific signal are notified in FIFO order (First In == first attached, and First Out == first notified). Then, assuming the specific signal is not Subject::Deleted or Subject::Modified, all slots attached to Subject::Modified are notified in FIFO order.
Definition at line 96 of file Subject.h.
| virtual Subject::~Subject | ( | ) | [protected, virtual] |
| static const std::string& Subject::signalDeleted | ( | ) | [static] |
Emitted when a Subject is deleted.
This will always be emitted, it CANNOT be blocked using SignalBlocker or SignalEnabler.
| static const std::string& Subject::signalModified | ( | ) | [static] |
| virtual bool Subject::attach | ( | const std::string & | signal, | |
| const Slot & | slot | |||
| ) | [pure virtual] |
Allow another object to register an interest in specific changes on this Subject.
| signal | The name of the signal to attach to. If signal is empty, the Slot will be called on all signals from this Subject. | |
| slot | An object that contains the object and method to call when the specified signal is notified. This can be a Slot, SafeSlot or AutoSlot. |
| virtual bool Subject::detach | ( | const std::string & | signal, | |
| const Slot & | slot | |||
| ) | [pure virtual] |
Allow a Slot to be deregistered from a signal on this Subject.
| signal | The name of the signal the Slot is attached to. If signal is empty, the specified Slot will be detached from all signals on this Subject. | |
| slot | The Slot to detach from the specified signal. If the Slot is empty, all slots will be detached from the specified signal. If the slot was originally attached as a SafeSlot or AutoSlot, it needs to be detached as same type. |
| virtual bool Subject::signalsEnabled | ( | ) | const [pure virtual] |
Indicates whether the Subject's notification mechanism is enabled or not.
If signals are disabled, then only SIGNAL_NAME(Subject, Deleted) will be emitted when requested, all other signals will be suppressed.
To disable signals, either the SignalBlocker or SignalEnabler classes must be used.