|
DART 6.12.2
|
sub_ptr is a pointer to a Subject. More...
#include <sub_ptr.hpp>
Public Member Functions | |
| sub_ptr () | |
| Default constructor. | |
| sub_ptr (T *_ptr) | |
| Alternative constructor. | |
| sub_ptr (const sub_ptr &other) | |
| User defined copy constructor. | |
| sub_ptr & | operator= (const sub_ptr &_sp) |
| Change the Subject of this sub_ptr. | |
| sub_ptr & | operator= (T *_ptr) |
| Change the Subject of this sub_ptr. | |
| operator T* () const | |
| Implicit conversion to pointer type. | |
| T & | operator* () const |
| Dereferencing operator. | |
| T * | operator-> () const |
| Dereferencing operation. | |
| T * | get () const |
| Get the Subject of this sub_ptr. | |
| void | set (T *_ptr) |
| Set the subject of this sub_ptr. | |
| bool | valid () |
| True if and only if this sub_ptr still points to a valid Subject. | |
Protected Member Functions | |
| void | handleDestructionNotification (const Subject *_subject) override |
| Called by receiveDestructionNotification(). | |
| void | receiveDestructionNotification (const Subject *_subject) |
| Called whenever a Subject is destroyed (or sends out a destruction notification). | |
| void | addSubject (const Subject *_subject) |
| Add a Subject for this Observer. | |
| void | removeSubject (const Subject *_subject) |
| Remove a Subject from this Observer. | |
| void | removeAllSubjects () |
| Remove all Subjects from this Observer. | |
Protected Attributes | |
| T * | mT |
| Store the pointer to the full object. | |
| Subject * | mSubjectBase |
| Store the pointer to the virtual Subject base. | |
| std::set< const Subject * > | mSubjects |
| List of current Subjects for this Observer. | |
sub_ptr is a pointer to a Subject.
It can be used as a pointer to any class that publicly inherits Subject. If the instance that it is pointing to is ever destroyed, the sub_ptr class will start pointing to a nullptr. You can check the return of sub_ptr::valid() to see if the pointer is still valid.
| dart::common::sub_ptr< T >::sub_ptr | ( | ) |
Default constructor.
| dart::common::sub_ptr< T >::sub_ptr | ( | T * | _ptr | ) |
Alternative constructor.
_ptr must be a valid pointer when passed to this constructor.
| dart::common::sub_ptr< T >::sub_ptr | ( | const sub_ptr< T > & | other | ) |
User defined copy constructor.
|
protectedinherited |
| T * dart::common::sub_ptr< T >::get | ( | ) | const |
|
overrideprotectedvirtual |
Called by receiveDestructionNotification().
Override this function to customize your class's response to destruction notifications.
Reimplemented from dart::common::Observer.
| dart::common::sub_ptr< T >::operator T* | ( | ) | const |
Implicit conversion to pointer type.
| T & dart::common::sub_ptr< T >::operator* | ( | ) | const |
Dereferencing operator.
| T * dart::common::sub_ptr< T >::operator-> | ( | ) | const |
Dereferencing operation.
| sub_ptr< T > & dart::common::sub_ptr< T >::operator= | ( | const sub_ptr< T > & | _sp | ) |
| sub_ptr< T > & dart::common::sub_ptr< T >::operator= | ( | T * | _ptr | ) |
|
protectedinherited |
Called whenever a Subject is destroyed (or sends out a destruction notification).
Override handleDestructionNotification() in order to customize your class's response to destruction notifications.
|
protectedinherited |
Remove all Subjects from this Observer.
|
protectedinherited |
| void dart::common::sub_ptr< T >::set | ( | T * | _ptr | ) |
Set the subject of this sub_ptr.
| bool dart::common::sub_ptr< T >::valid | ( | ) |
|
protected |
Store the pointer to the virtual Subject base.
|
protectedinherited |
List of current Subjects for this Observer.
|
protected |
Store the pointer to the full object.