Public Member Functions | Private Attributes
mbl_cloneable_nzptr< BaseClass > Class Template Reference

Cunning non-zero pointer for objects that can be cloned. More...

#include <mbl_cloneable_ptr.h>

List of all members.

Public Member Functions

 ~mbl_cloneable_nzptr ()
 Destructor.
 mbl_cloneable_nzptr (const mbl_cloneable_nzptr< BaseClass > &cp)
 Copy constructor.
 mbl_cloneable_nzptr (const BaseClass &r)
 Construct from pointer, making a clone of r.
 mbl_cloneable_nzptr (BaseClass *p)
 Constructor from pointer, taking ownership of *p.
mbl_cloneable_nzptr< BaseClass > & operator= (const mbl_cloneable_nzptr< BaseClass > &cp)
 Copy operator.
mbl_cloneable_nzptr< BaseClass > & operator= (const BaseClass &r)
 Copy operator - takes clone of r.
mbl_cloneable_nzptr< BaseClass > & operator= (BaseClass *p)
 Copy operator - takes responsibility for *p.
bool isDefined () const
 Return true.
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 * replace (BaseClass *p)
 Return and give up ownership of wrapped pointer, while taking ownership a new pointer.
 operator BaseClass & ()
 Cast to allow object to look like thing pointed to.
 operator const BaseClass & () const
 Cast to allow object to look like thing pointed to.
BaseClass & operator* ()
 Dereferencing the pointer.
const BaseClass & operator* () const
 Dereferencing the pointer.
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_

Detailed Description

template<class BaseClass>
class mbl_cloneable_nzptr< BaseClass >

Cunning non-zero pointer for objects that can be cloned.

The pointer is guaranteed to always point to something. 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.

To take ownership of the contents of a vcl_auto_ptr<T> use

 vcl_auto_ptr<T> inst = get_from_some_factory_function();
 mbl_cloneable_nzptr<T> long_term_store(inst.release());

Definition at line 141 of file mbl_cloneable_ptr.h.


Constructor & Destructor Documentation

template<class BaseClass>
mbl_cloneable_nzptr< BaseClass >::~mbl_cloneable_nzptr ( ) [inline]

Destructor.

Definition at line 147 of file mbl_cloneable_ptr.h.

template<class BaseClass>
mbl_cloneable_nzptr< BaseClass >::mbl_cloneable_nzptr ( const mbl_cloneable_nzptr< BaseClass > &  cp) [inline]

Copy constructor.

There is no default constructor.

Definition at line 151 of file mbl_cloneable_ptr.h.

template<class BaseClass>
mbl_cloneable_nzptr< BaseClass >::mbl_cloneable_nzptr ( const BaseClass &  r) [inline]

Construct from pointer, making a clone of r.

There is no default constructor.

Definition at line 156 of file mbl_cloneable_ptr.h.

template<class BaseClass>
mbl_cloneable_nzptr< BaseClass >::mbl_cloneable_nzptr ( BaseClass *  p) [inline]

Constructor from pointer, taking ownership of *p.

There is no default constructor.

Definition at line 160 of file mbl_cloneable_ptr.h.


Member Function Documentation

template<class BaseClass>
void mbl_cloneable_nzptr< BaseClass >::b_read ( vsl_b_istream bfs) [inline]

Load from binary stream.

Definition at line 234 of file mbl_cloneable_ptr.h.

template<class BaseClass>
void mbl_cloneable_nzptr< BaseClass >::b_write ( vsl_b_ostream bfs) const [inline]

Save to binary stream.

Definition at line 228 of file mbl_cloneable_ptr.h.

template<class BaseClass>
bool mbl_cloneable_nzptr< BaseClass >::isDefined ( ) const [inline]

Return true.

Definition at line 197 of file mbl_cloneable_ptr.h.

template<class BaseClass>
mbl_cloneable_nzptr< BaseClass >::operator BaseClass & ( ) [inline]

Cast to allow object to look like thing pointed to.

Definition at line 216 of file mbl_cloneable_ptr.h.

template<class BaseClass>
mbl_cloneable_nzptr< BaseClass >::operator const BaseClass & ( ) const [inline]

Cast to allow object to look like thing pointed to.

Definition at line 219 of file mbl_cloneable_ptr.h.

template<class BaseClass>
BaseClass& mbl_cloneable_nzptr< BaseClass >::operator* ( ) [inline]

Dereferencing the pointer.

Definition at line 222 of file mbl_cloneable_ptr.h.

template<class BaseClass>
const BaseClass& mbl_cloneable_nzptr< BaseClass >::operator* ( ) const [inline]

Dereferencing the pointer.

Definition at line 225 of file mbl_cloneable_ptr.h.

template<class BaseClass>
const BaseClass* mbl_cloneable_nzptr< BaseClass >::operator-> ( ) const [inline]

Make object behave like pointer to BaseClass.

Definition at line 200 of file mbl_cloneable_ptr.h.

template<class BaseClass>
BaseClass* mbl_cloneable_nzptr< BaseClass >::operator-> ( ) [inline]

Make object behave like pointer to BaseClass.

Definition at line 203 of file mbl_cloneable_ptr.h.

template<class BaseClass>
mbl_cloneable_nzptr<BaseClass>& mbl_cloneable_nzptr< BaseClass >::operator= ( const mbl_cloneable_nzptr< BaseClass > &  cp) [inline]

Copy operator.

Definition at line 163 of file mbl_cloneable_ptr.h.

template<class BaseClass>
mbl_cloneable_nzptr<BaseClass>& mbl_cloneable_nzptr< BaseClass >::operator= ( const BaseClass &  r) [inline]

Copy operator - takes clone of r.

Definition at line 174 of file mbl_cloneable_ptr.h.

template<class BaseClass>
mbl_cloneable_nzptr<BaseClass>& mbl_cloneable_nzptr< 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 187 of file mbl_cloneable_ptr.h.

template<class BaseClass>
const BaseClass* mbl_cloneable_nzptr< BaseClass >::ptr ( ) const [inline]

Return actual pointer.

Definition at line 206 of file mbl_cloneable_ptr.h.

template<class BaseClass>
BaseClass* mbl_cloneable_nzptr< BaseClass >::ptr ( ) [inline]

Return actual pointer.

Definition at line 209 of file mbl_cloneable_ptr.h.

template<class BaseClass>
BaseClass* mbl_cloneable_nzptr< BaseClass >::replace ( BaseClass *  p) [inline]

Return and give up ownership of wrapped pointer, while taking ownership a new pointer.

Definition at line 212 of file mbl_cloneable_ptr.h.


Member Data Documentation

template<class BaseClass>
BaseClass* mbl_cloneable_nzptr< BaseClass >::ptr_ [private]

Definition at line 143 of file mbl_cloneable_ptr.h.


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