managed_object< contents > Class Template Reference

Reference counts objects and destroys them automatically. More...

#include <managed_object.h>

List of all members.

Public Member Functions

 managed_object ()
 managed_object (contents *&_object)
 Pass a pointer of the object to be stored.
 managed_object (const managed_object &_rhs)
 Moves the contained object in _rhs into a new managed_object.
managed_objectoperator= (const managed_object &rhs)
 Moves the contents of _rhs into this object.
virtual ~managed_object ()
 Releases the object contained here.
bool operator== (const managed_object &_compare) const
managed_object< contents > * new_reference ()
 Return a new reference to the managed object class.
contents * access ()
 access the originally stored object
const contents * observe () const
 look at the originally stored object


Detailed Description

template<class contents>
class managed_object< contents >

Reference counts objects and destroys them automatically.

Provides an object management system that allows for references to an original stored object to be obtained, and the original object is not deleted until all references are gone.

Definition at line 31 of file managed_object.h.


Constructor & Destructor Documentation

template<class contents>
managed_object< contents >::managed_object (  ) 

Having a default constructor for a managed object does not make a lot of sense, since the whole point is you are managing another object. However, there are circumstances that make it useful.

Definition at line 58 of file managed_object.cpp.

template<class contents>
managed_object< contents >::managed_object ( contents *&  _object  ) 

Pass a pointer of the object to be stored.

The managed_object class takes control of the pointer and sets the reference null before returning. The original object is wrapped in the ObjectStorer class so that the number of references can be counted.

Definition at line 63 of file managed_object.cpp.

References NULL.

template<class contents>
managed_object< contents >::managed_object ( const managed_object< contents > &  _rhs  ) 

Moves the contained object in _rhs into a new managed_object.

Definition at line 68 of file managed_object.cpp.

template<class contents>
managed_object< contents >::~managed_object (  )  [virtual]

Releases the object contained here.

Doesn't delete the actual object, just tells the storer to decrement its reference count. When all references are gone the original object will be deleted.

Definition at line 83 of file managed_object.cpp.

References NULL.


Member Function Documentation

template<class contents>
managed_object< contents > & managed_object< contents >::operator= ( const managed_object< contents > &  rhs  ) 

Moves the contents of _rhs into this object.

Causes this object storer to have its reference count decremented, then the object storer pointer from the rhs is copied and its reference count is incremented.

Definition at line 73 of file managed_object.cpp.

References NULL, and managed_object< contents >::storer.

template<class contents>
bool managed_object< contents >::operator== ( const managed_object< contents > &  _compare  )  const

The equality operator for the managed_object invokes the equality operator on its stored pointer.

Definition at line 87 of file managed_object.cpp.

References NULL, and managed_object< contents >::storer.

template<class contents>
managed_object< contents > * managed_object< contents >::new_reference (  ) 

Return a new reference to the managed object class.

This uses the private constructor that simply copies the object storer pointer. We don't want to copy the actual stored object. The returned pointer must be deleted when it is finished being used. This can be achieved using the copy constructor also.

Definition at line 99 of file managed_object.cpp.

template<class contents>
contents * managed_object< contents >::access (  ) 

access the originally stored object

Definition at line 103 of file managed_object.cpp.

References NULL.

template<class contents>
const contents * managed_object< contents >::observe (  )  const

look at the originally stored object

Definition at line 107 of file managed_object.cpp.

References NULL.


The documentation for this class was generated from the following files:
Generated on Fri Nov 28 04:30:52 2008 for HOOPLE Libraries by  doxygen 1.5.1