Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

base::Pointer< O > Class Template Reference

Pointer<of something> allows automatic reference counting and automatic deallocation when the reference drops to 0. More...

#include <Object.h>

List of all members.

Public Member Functions

 Pointer ()
 Default constructor: pointer to NULL.
 Pointer (const Pointer< O > &ptr)
 Copy constructor: add reference.
 Pointer (O *obj)
 Pointer constructor: add reference.
 ~Pointer ()
 Destructor: drop a reference.
O & operator * () const
 Dereference pointed object.
O * operator-> () const
 Different wrappers to pointed object, WITHOUT reference counting.
 operator O * () const
O * getPtr () const
bool null () const
bool operator! () const
Pointer< O > & operator= (const Pointer< O > &ptr)
 Copy operator:
  • add reference to new object
  • drop reference to current object
  • set new pointed object Note: add 1st and then drop in case it is an assignment a = a;.

template<class To>
 operator Pointer () const
 Cast operator.
void setMutable ()
 Make sure this pointer is mutable.
void ensure (size_t newSize)
 Make sure the object is big enough.

Protected Member Functions

void setPtr (O *obj)
 < This is for child classes with special needs.

Private Attributes

O * object
 pointed object, must be an Object


Detailed Description

template<class O>
class base::Pointer< O >

Pointer<of something> allows automatic reference counting and automatic deallocation when the reference drops to 0.

To use it, the referenced object must be an Object.


Constructor & Destructor Documentation

template<class O>
base::Pointer< O >::Pointer  )  [inline]
 

Default constructor: pointer to NULL.

template<class O>
base::Pointer< O >::Pointer const Pointer< O > &  ptr  )  [inline]
 

Copy constructor: add reference.

Parameters:
ptr,: pointer to copy.

template<class O>
base::Pointer< O >::Pointer O *  obj  )  [inline]
 

Pointer constructor: add reference.

Parameters:
obj,: pointed object

template<class O>
base::Pointer< O >::~Pointer  )  [inline]
 

Destructor: drop a reference.


Member Function Documentation

template<class O>
void base::Pointer< O >::ensure size_t  newSize  )  [inline]
 

Make sure the object is big enough.

The object type must have: size_t size() const; -> gives its current size. static O* create(size_t); -> create a new object with given size. O* copy(size_t) const; -> create & copy (to smaller or larger).

template<class O>
O* base::Pointer< O >::getPtr  )  const [inline]
 

template<class O>
bool base::Pointer< O >::null  )  const [inline]
 

Returns:
true if pointer == NULL

template<class O>
O& base::Pointer< O >::operator *  )  const [inline]
 

Dereference pointed object.

template<class O>
base::Pointer< O >::operator O *  )  const [inline]
 

template<class O>
template<class To>
base::Pointer< O >::operator Pointer  )  const [inline]
 

Cast operator.

class To is the cast type.

template<class O>
bool base::Pointer< O >::operator!  )  const [inline]
 

Returns:
true if pointer == NULL This is a convenience operator to get tests of the form if (!ptr) doThis();

template<class O>
O* base::Pointer< O >::operator->  )  const [inline]
 

Different wrappers to pointed object, WITHOUT reference counting.

template<class O>
Pointer<O>& base::Pointer< O >::operator= const Pointer< O > &  ptr  )  [inline]
 

Copy operator:

  • add reference to new object
  • drop reference to current object
  • set new pointed object Note: add 1st and then drop in case it is an assignment a = a;.

template<class O>
void base::Pointer< O >::setMutable  )  [inline]
 

Make sure this pointer is mutable.

The object class has to implement copy().

template<class O>
void base::Pointer< O >::setPtr O *  obj  )  [inline, protected]
 

< This is for child classes with special needs.


Member Data Documentation

template<class O>
O* base::Pointer< O >::object [private]
 

pointed object, must be an Object


The documentation for this class was generated from the following file:
Generated on Fri Jun 30 00:02:30 2006 for Module base by  doxygen 1.4.2