dart
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
dart::common::sub_ptr< T > Class Template Reference

sub_ptr is a pointer to a Subject. More...

#include <sub_ptr.hpp>

Inheritance diagram for dart::common::sub_ptr< T >:
Inheritance graph
[legend]
Collaboration diagram for dart::common::sub_ptr< T >:
Collaboration graph
[legend]

Public Member Functions

 sub_ptr ()
 Default constructor.
 
 sub_ptr (T *_ptr)
 Alternative constructor. More...
 
 sub_ptr (const sub_ptr &other)
 User defined copy constructor.
 
sub_ptroperator= (const sub_ptr &_sp)
 Change the Subject of this sub_ptr.
 
sub_ptroperator= (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.
 
- Public Member Functions inherited from dart::common::Observer
virtual ~Observer ()
 Destructor will notify all Subjects that it is destructing.
 

Protected Member Functions

void handleDestructionNotification (const Subject *_subject) override
 Called by receiveDestructionNotification(). More...
 
- Protected Member Functions inherited from dart::common::Observer
void receiveDestructionNotification (const Subject *_subject)
 Called whenever a Subject is destroyed (or sends out a destruction notification). More...
 
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.
 
SubjectmSubjectBase
 Store the pointer to the virtual Subject base.
 
- Protected Attributes inherited from dart::common::Observer
std::set< const Subject * > mSubjects
 List of current Subjects for this Observer.
 

Detailed Description

template<class T>
class dart::common::sub_ptr< T >

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.

Constructor & Destructor Documentation

◆ sub_ptr()

template<class T>
dart::common::sub_ptr< T >::sub_ptr ( T *  _ptr)

Alternative constructor.

_ptr must be a valid pointer when passed to this constructor.

Member Function Documentation

◆ handleDestructionNotification()

template<class T >
void dart::common::sub_ptr< T >::handleDestructionNotification ( const Subject _subject)
overrideprotectedvirtual

Called by receiveDestructionNotification().

Override this function to customize your class's response to destruction notifications.

Reimplemented from dart::common::Observer.


The documentation for this class was generated from the following file: