Cunning pointer for objects that can be cloned. More...
#include <mbl_cloneable_ptr.h>
Public Member Functions | |
mbl_cloneable_ptr () | |
Default constructor (zeros pointer). | |
void | deleteObject () |
Delete object pointed to and set pointer to zero. | |
~mbl_cloneable_ptr () | |
Destructor. | |
mbl_cloneable_ptr (const mbl_cloneable_ptr< BaseClass > &p) | |
Copy constructor. | |
mbl_cloneable_ptr (const BaseClass &r) | |
Construct from pointer, making a clone of r. | |
mbl_cloneable_ptr (BaseClass *p) | |
Constructor from pointer, taking ownership of *p. | |
mbl_cloneable_ptr< BaseClass > & | operator= (const mbl_cloneable_ptr< BaseClass > &p) |
Copy operator. | |
mbl_cloneable_ptr< BaseClass > & | operator= (const BaseClass &p) |
Copy operator - takes clone of p. | |
mbl_cloneable_ptr< BaseClass > & | operator= (BaseClass *p) |
Copy operator - takes responsibility for *p. | |
bool | isDefined () const |
Return true if pointer defined. | |
const BaseClass * | operator-> () const |
Make object behave like pointer to BaseClass. | |
BaseClass * | operator-> () |
Make object behave like pointer to BaseClass. | |
const BaseClass * | ptr () const |
Return actual pointer. | |
BaseClass * | ptr () |
Return actual pointer. | |
BaseClass * | release () |
Return wrapped pointer and give up ownership. | |
operator BaseClass & () | |
Cast to allow object to look like thing pointed to. | |
BaseClass & | operator* () |
Dereferencing the pointer. | |
const BaseClass & | operator* () const |
Dereferencing the pointer. | |
operator const BaseClass & () const | |
Cast to allow object to look like thing pointed to. | |
void | b_write (vsl_b_ostream &bfs) const |
Save to binary stream. | |
void | b_read (vsl_b_istream &bfs) |
Load from binary stream. | |
Private Attributes | |
BaseClass * | ptr_ |
Cunning pointer for objects that can be cloned.
Used to record base class pointers to objects When copied, the object pointed to gets cloned. When written or read to/from binary streams, suitable polymorphic I/O is invoked.
vcl_auto_ptr<T> inst = get_from_some_factory_function(); mbl_cloneable_ptr<T> long_term_store; long_term_store = inst.release();
Definition at line 23 of file mbl_cloneable_ptr.h.
mbl_cloneable_ptr< BaseClass >::mbl_cloneable_ptr | ( | ) | [inline] |
Default constructor (zeros pointer).
Definition at line 28 of file mbl_cloneable_ptr.h.
mbl_cloneable_ptr< BaseClass >::~mbl_cloneable_ptr | ( | ) | [inline] |
Destructor.
Definition at line 34 of file mbl_cloneable_ptr.h.
mbl_cloneable_ptr< BaseClass >::mbl_cloneable_ptr | ( | const mbl_cloneable_ptr< BaseClass > & | p | ) | [inline] |
Copy constructor.
Definition at line 37 of file mbl_cloneable_ptr.h.
mbl_cloneable_ptr< BaseClass >::mbl_cloneable_ptr | ( | const BaseClass & | r | ) | [inline] |
Construct from pointer, making a clone of r.
Definition at line 40 of file mbl_cloneable_ptr.h.
mbl_cloneable_ptr< BaseClass >::mbl_cloneable_ptr | ( | BaseClass * | p | ) | [inline] |
Constructor from pointer, taking ownership of *p.
Definition at line 43 of file mbl_cloneable_ptr.h.
void mbl_cloneable_ptr< BaseClass >::b_read | ( | vsl_b_istream & | bfs | ) | [inline] |
Load from binary stream.
Definition at line 111 of file mbl_cloneable_ptr.h.
void mbl_cloneable_ptr< BaseClass >::b_write | ( | vsl_b_ostream & | bfs | ) | const [inline] |
Save to binary stream.
Definition at line 105 of file mbl_cloneable_ptr.h.
void mbl_cloneable_ptr< BaseClass >::deleteObject | ( | ) | [inline] |
Delete object pointed to and set pointer to zero.
Definition at line 31 of file mbl_cloneable_ptr.h.
bool mbl_cloneable_ptr< BaseClass >::isDefined | ( | ) | const [inline] |
Return true if pointer defined.
Definition at line 74 of file mbl_cloneable_ptr.h.
mbl_cloneable_ptr< BaseClass >::operator BaseClass & | ( | ) | [inline] |
Cast to allow object to look like thing pointed to.
Definition at line 93 of file mbl_cloneable_ptr.h.
mbl_cloneable_ptr< BaseClass >::operator const BaseClass & | ( | ) | const [inline] |
Cast to allow object to look like thing pointed to.
Definition at line 102 of file mbl_cloneable_ptr.h.
BaseClass& mbl_cloneable_ptr< BaseClass >::operator* | ( | ) | [inline] |
Dereferencing the pointer.
Definition at line 96 of file mbl_cloneable_ptr.h.
const BaseClass& mbl_cloneable_ptr< BaseClass >::operator* | ( | ) | const [inline] |
Dereferencing the pointer.
Definition at line 99 of file mbl_cloneable_ptr.h.
const BaseClass* mbl_cloneable_ptr< BaseClass >::operator-> | ( | ) | const [inline] |
Make object behave like pointer to BaseClass.
Definition at line 77 of file mbl_cloneable_ptr.h.
BaseClass* mbl_cloneable_ptr< BaseClass >::operator-> | ( | ) | [inline] |
Make object behave like pointer to BaseClass.
Definition at line 80 of file mbl_cloneable_ptr.h.
mbl_cloneable_ptr<BaseClass>& mbl_cloneable_ptr< BaseClass >::operator= | ( | const mbl_cloneable_ptr< BaseClass > & | p | ) | [inline] |
Copy operator.
Definition at line 46 of file mbl_cloneable_ptr.h.
mbl_cloneable_ptr<BaseClass>& mbl_cloneable_ptr< BaseClass >::operator= | ( | const BaseClass & | p | ) | [inline] |
Copy operator - takes clone of p.
Definition at line 54 of file mbl_cloneable_ptr.h.
mbl_cloneable_ptr<BaseClass>& mbl_cloneable_ptr< BaseClass >::operator= | ( | BaseClass * | p | ) | [inline] |
Copy operator - takes responsibility for *p.
Sets internal pointer to p, and takes responsibility for deleting *p
Definition at line 65 of file mbl_cloneable_ptr.h.
const BaseClass* mbl_cloneable_ptr< BaseClass >::ptr | ( | ) | const [inline] |
Return actual pointer.
Definition at line 83 of file mbl_cloneable_ptr.h.
BaseClass* mbl_cloneable_ptr< BaseClass >::ptr | ( | ) | [inline] |
Return actual pointer.
Definition at line 86 of file mbl_cloneable_ptr.h.
BaseClass* mbl_cloneable_ptr< BaseClass >::release | ( | ) | [inline] |
Return wrapped pointer and give up ownership.
Definition at line 89 of file mbl_cloneable_ptr.h.
BaseClass* mbl_cloneable_ptr< BaseClass >::ptr_ [private] |
Definition at line 25 of file mbl_cloneable_ptr.h.