#include <AttachmentPtr.h>

Public Member Functions | |
| AttachmentPtr () | |
| AttachmentPtr (T *pSubject) | |
| AttachmentPtr (const std::string &signalName, const Slot &slot) | |
| AttachmentPtr (T *pSubject, const std::string &signalName, const Slot &slot) | |
| virtual | ~AttachmentPtr () |
| void | addSignal (const std::string &signalName, const Slot &slot) |
| void | reset (T *pSubject=NULL) |
This class handles a number of issues relating to the management of Subject attachment lifetimes:
This class is intended to be used as a member variable, in place of a raw pointer to the observed Subject. If subclasses are to be allowed to attach to the Subject, the variable should be made protected.
Note that this class will not cause any kind of callback in the case that its Subject has been deleted. It will simply NULLify the pointer. If you require any special handling for when the Subject has been deleted, You should separately attach to SIGNAL_NAME(Subject, Deleted) with AttachmentPtr::addSignal().
When used in conjunction with a SafeSlot, the attachments will additionally be automatically detached when the SafeSlot's invalidator object is destroyed.
Definition at line 43 of file AttachmentPtr.h.
| AttachmentPtr< T >::AttachmentPtr | ( | ) |
| AttachmentPtr< T >::AttachmentPtr | ( | T * | pSubject | ) |
Construct with a subject to observe.
| pSubject | The subject to observe. |
Definition at line 61 of file AttachmentPtr.h.
| AttachmentPtr< T >::AttachmentPtr | ( | const std::string & | signalName, | |
| const Slot & | slot | |||
| ) |
Construct with a single signal/slot connection registered, no Subject observed.
| signalName | The signal to register interest in. | |
| slot | The slot to call when the signal is emitted. |
Definition at line 75 of file AttachmentPtr.h.
| AttachmentPtr< T >::AttachmentPtr | ( | T * | pSubject, | |
| const std::string & | signalName, | |||
| const Slot & | slot | |||
| ) |
Construct with a subject to observe, and a single signal/slot connection registered.
| pSubject | The subject to observe. | |
| signalName | The signal to register interest in. | |
| slot | The slot to call when the signal is emitted. |
Definition at line 91 of file AttachmentPtr.h.
| virtual AttachmentPtr< T >::~AttachmentPtr | ( | ) | [virtual] |
Destructor.
This will take care of detaching from any signals.
Definition at line 102 of file AttachmentPtr.h.
| void AttachmentPtr< T >::addSignal | ( | const std::string & | signalName, | |
| const Slot & | slot | |||
| ) |
Add a new signal to be observed.
The attachment will be made immediately if there is currently a valid Subject. The attachment will automatically be made whenever the observed Subject is changed.
| signalName | The signal to register interest in. | |
| slot | The slot to call when the signal is emitted. |
Definition at line 119 of file AttachmentPtr.h.
| void AttachmentPtr< T >::reset | ( | T * | pSubject = NULL |
) |
Change what Subject to observe.
This will automatically detach from the old Subject, and attach to the new one.
| pSubject | The subject to begin observing. |
Reimplemented from SafePtr< T >.
Definition at line 135 of file AttachmentPtr.h.