- Main Page
- Namespaces
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# Mers::Utils::Containers::SharedPointer< t_Object > Class Template Reference

`#include <SharedPointer.h>`

List of all members.

## Public Types
typedef ::boost::shared_ptr< t_Object > | t_Implementation
| The implementation used for this object.
typedef t_Implementation::pointer | t_Pointer
| The type of a pointer to this object.
typedef t_Implementation::reference | t_Reference
| The type of a reference to this object.
## Public Member Functions
| SharedPointer ()
template<class to_Object>
| SharedPointer (to_Object *obj)
template<class to_Object, class t_Deleter>
| SharedPointer (to_Object *obj, t_Deleter deleter)
template<class to_Object>
| SharedPointer (SharedPointer< to_Object > const &other)
template<class to_Object>
| SharedPointer (SharedPointer< to_Object > const &other, DynamicCastTag)
template<class to_Object>
SharedPointer & | operator= (SharedPointer< to_Object > const &other)
void | reset ()
template<class to_Object>
void | set (to_Object *obj)
template<class to_Object, class t_Deleter>
void | set (to_Object *obj, t_Deleter deleter)
t_Reference | operator * () const
t_Pointer | operator-> () const
t_Pointer | get () const
| operator t_Pointer () const
| operator bool () const
bool | operator! () const
bool | unique () const
size_t | use_count () const
void | swap (SharedPointer< t_Object > &other)
template<class to_Object>
bool | operator== (SharedPointer< to_Object > const &other) const
template<class to_Object>
bool | operator!= (SharedPointer< to_Object > const &other) const
template<class to_Object>
bool | operator< (SharedPointer< to_Object > const &other) const
## Protected Attributes
t_Implementation | m_Pointer
## Friends
class | SharedPointer
| We are friends with ourself.
template<class E, class T>
std::basic_ostream< E, T > & | operator<< (std::basic_ostream< E, T > &os, SharedPointer< t_Object > const &pointer)

## Detailed Description

### template<class t_Object>
class Mers::Utils::Containers::SharedPointer< t_Object >

This is a generic pointer container class. It handles reference counting for an object and will automatically cleanup the object when all references have been eliminated.

Author:
  Paul Elliott

Definition at line 36 of file SharedPointer.h.

## Constructor & Destructor Documentation

template<class t_Object>

Mers::Utils::Containers::SharedPointer< t_Object >::SharedPointer | ( |  | ) | `[inline]`

Constructs a new shared pointer to an object of type t_Object. The pointer is initially NULL.

Definition at line 55 of file SharedPointer.h.

template<class t_Object>
template<class to_Object>

Mers::Utils::Containers::SharedPointer< t_Object >::SharedPointer | ( | to_Object * | obj | ) | `[inline, explicit]`

Constructs a new shared pointer to the specified object. This shared pointer assumes ownership of the object and will share it between all other shared pointers. The object will be deleted when all shared pointers have been released.

Parameters:

  | obj | The object for which this object assumes ownership.

Definition at line 67 of file SharedPointer.h.

template<class t_Object>
template<class to_Object, class t_Deleter>

Mers::Utils::Containers::SharedPointer< t_Object >::SharedPointer | ( | to_Object * | obj,
|  | t_Deleter | deleter |
| ) |  |  | `[inline]`

Constructs a new shared pointer to the specified object. This shared pointer assumes wonership of the object and will share it between all other shared pointers. When all the shared references to the object have been deleted, obj will be released by calling deleter(obj).

t_Deleter's copy constructor must not throw.

Parameters:

  | obj | The object for which this object assumes ownership.
  | deleter | The object type used to delete obj.

Definition at line 85 of file SharedPointer.h.

template<class t_Object>
template<class to_Object>

Mers::Utils::Containers::SharedPointer< t_Object >::SharedPointer | ( | SharedPointer< to_Object > const & | other | ) | `[inline]`

Constructs this object to point at the other objects target. This object takes an additional reference to the specified object.

Parameters:

  | other | The other shared object being used to construct this object.

Definition at line 100 of file SharedPointer.h.

template<class t_Object>
template<class to_Object>

Mers::Utils::Containers::SharedPointer< t_Object >::SharedPointer | ( | SharedPointer< to_Object > const & | other,
|  | DynamicCastTag |  |
| ) |  |  | `[inline]`

Constructs this object to point at the other objects target. This object takes an additional reference to the specified object.

Parameters:

  | other | The other shared object being used to construct this object.

Definition at line 113 of file SharedPointer.h.

## Member Function Documentation

template<class t_Object>
template<class to_Object>

SharedPointer& Mers::Utils::Containers::SharedPointer< t_Object >::operator= | ( | SharedPointer< to_Object > const & | other | ) | `[inline]`

The assignment operator for shared pointers to derrived classes. This object will no longer point to what it used to point to and will now point to the other object.

Parameters:

  | other | The other object to which this will now point.

Definition at line 126 of file SharedPointer.h.

References Mers::Utils::Containers::SharedPointer< t_Object >::m_Pointer.

template<class t_Object>

void Mers::Utils::Containers::SharedPointer< t_Object >::reset | ( | void |  | ) | `[inline]`

Makes this object no longer point to anything. A reference to the current object is removed.

Definition at line 136 of file SharedPointer.h.

References Mers::Utils::Containers::SharedPointer< t_Object >::m_Pointer.

template<class t_Object>
template<class to_Object>

void Mers::Utils::Containers::SharedPointer< t_Object >::set | ( | to_Object * | obj | ) | `[inline]`

Sets this object to point to the new object, assuming ownership of it, and removing a reference to the previous object.

Parameters:

  | obj | The new object that this object should point at.

Definition at line 147 of file SharedPointer.h.

References Mers::Utils::Containers::SharedPointer< t_Object >::m_Pointer.

template<class t_Object>
template<class to_Object, class t_Deleter>

void Mers::Utils::Containers::SharedPointer< t_Object >::set | ( | to_Object * | obj,
|  | t_Deleter | deleter |
| ) |  |  | `[inline]`

Sets this object to point to the new object and use a specific deleter. This object assumes ownership of obj and removes a refernce to the object it previously pointed at.

Parameters:

  | obj | The new object that this object should point at.
  | deleter | The object to use to delete obj when nothing references obj.

Definition at line 162 of file SharedPointer.h.

References Mers::Utils::Containers::SharedPointer< t_Object >::m_Pointer.

template<class t_Object>

t_Reference Mers::Utils::Containers::SharedPointer< t_Object >::operator * | ( |  | ) | const`[inline]`

Allow for the access of this pointer by dereferencing.

Returns:
  a reference to the object at which this object points.

Definition at line 171 of file SharedPointer.h.

References Mers::Utils::Containers::SharedPointer< t_Object >::m_Pointer.

template<class t_Object>

t_Pointer Mers::Utils::Containers::SharedPointer< t_Object >::operator-> | ( |  | ) | const`[inline]`

Allow for the access of this pointer by pointer access.

Returns:
  a pointer to the object at which this object points.

Definition at line 180 of file SharedPointer.h.

References Mers::Utils::Containers::SharedPointer< t_Object >::m_Pointer.

template<class t_Object>

t_Pointer Mers::Utils::Containers::SharedPointer< t_Object >::get | ( |  | ) | const`[inline]`

Allow for the access of this pointer through a function. Note that the pointer returned is just a copy so ownership is still maintained by the shared pointers.

Returns:
  a pointer to the object at which this object points.

Definition at line 191 of file SharedPointer.h.

References Mers::Utils::Containers::SharedPointer< t_Object >::m_Pointer.

Referenced by Mers::Executives::DeductiveController::DCInterface::start(), and Mers::Executives::DeductiveController::DCInterface::stop().

template<class t_Object>

Mers::Utils::Containers::SharedPointer< t_Object >::operator t_Pointer | ( |  | ) | const`[inline]`

Allows the implicit typecasting of this object to a t_Object *. This is equivalent to get().

Returns:
  a pointer to the object at which this object points.

Definition at line 201 of file SharedPointer.h.

References Mers::Utils::Containers::SharedPointer< t_Object >::m_Pointer.

template<class t_Object>

Mers::Utils::Containers::SharedPointer< t_Object >::operator bool | ( |  | ) | const`[inline]`

Allows the implicit typecasting of this object to a bool. This is equivalent to (get() != NULL).

Returns:
  True iff the pointer is not NULL.

Definition at line 211 of file SharedPointer.h.

References Mers::Utils::Containers::SharedPointer< t_Object >::m_Pointer.

template<class t_Object>

bool Mers::Utils::Containers::SharedPointer< t_Object >::operator! | ( |  | ) | const`[inline]`

Allows the implicit typecasting of this object to a bool. This is equivalent to (get() == NULL).

Returns:
  True iff the pointer is NULL.

Definition at line 221 of file SharedPointer.h.

References Mers::Utils::Containers::SharedPointer< t_Object >::m_Pointer.

template<class t_Object>

bool Mers::Utils::Containers::SharedPointer< t_Object >::unique | ( |  | ) | const`[inline]`

Returns true if this object is the only object that points at the current pointer. This is always false if the object in question is the NULL object.

Returns:
  true iff there exists only one SharedPointer (this one) that points at the current object and that object is not NULL.

Definition at line 233 of file SharedPointer.h.

References Mers::Utils::Containers::SharedPointer< t_Object >::m_Pointer.

template<class t_Object>

size_t Mers::Utils::Containers::SharedPointer< t_Object >::use_count | ( |  | ) | const`[inline]`

Returns the number of objects that have shared references to this same object. This number will always be at least one.

Definition at line 241 of file SharedPointer.h.

References Mers::Utils::Containers::SharedPointer< t_Object >::m_Pointer.

template<class t_Object>

void Mers::Utils::Containers::SharedPointer< t_Object >::swap | ( | SharedPointer< t_Object > & | other | ) | `[inline]`

Swaps the two object pointed at.

Parameters:

  | other | The other object whose pointer will be swapped with the pointer within this object.

Definition at line 251 of file SharedPointer.h.

References Mers::Utils::Containers::SharedPointer< t_Object >::m_Pointer.

Referenced by Mers::Utils::Containers::swap().

template<class t_Object>
template<class to_Object>

bool Mers::Utils::Containers::SharedPointer< t_Object >::operator== | ( | SharedPointer< to_Object > const & | other | ) | const`[inline]`

Returns true if both objects point at the same thing.

Definition at line 259 of file SharedPointer.h.

References Mers::Utils::Containers::SharedPointer< t_Object >::m_Pointer.

template<class t_Object>
template<class to_Object>

bool Mers::Utils::Containers::SharedPointer< t_Object >::operator!= | ( | SharedPointer< to_Object > const & | other | ) | const`[inline]`

Returns true if both objects point at something different.

Definition at line 267 of file SharedPointer.h.

References Mers::Utils::Containers::SharedPointer< t_Object >::m_Pointer.

template<class t_Object>
template<class to_Object>

bool Mers::Utils::Containers::SharedPointer< t_Object >::operator< | ( | SharedPointer< to_Object > const & | other | ) | const`[inline]`

Returns true if this object is sorted before the other object.

Definition at line 275 of file SharedPointer.h.

References Mers::Utils::Containers::SharedPointer< t_Object >::m_Pointer.

## Friends And Related Function Documentation

template<class t_Object>
template<class E, class T>

std::basic_ostream< E, T >& operator<< | ( | std::basic_ostream< E, T > & | os,
|  | SharedPointer< t_Object > const & | pointer |
| ) |  |  | `[friend]`

Prints this object (the pointer's address) to os.

Parameters:

  | os | The stream being printed.
  | pointer | The shared pointer being printed.

Definition at line 288 of file SharedPointer.h.

## Member Data Documentation

template<class t_Object>

t_Implementation Mers::Utils::Containers::SharedPointer< t_Object >::m_Pointer`[protected]`

The implementation we're using for shared pointers. This is the boost implementation.

Definition at line 297 of file SharedPointer.h.

Referenced by Mers::Utils::Containers::SharedPointer< t_Object >::get(), Mers::Utils::Containers::SharedPointer< t_Object >::operator *(), Mers::Utils::Containers::SharedPointer< t_Object >::operator bool(), Mers::Utils::Containers::SharedPointer< t_Object >::operator t_Pointer(), Mers::Utils::Containers::SharedPointer< t_Object >::operator!(), Mers::Utils::Containers::SharedPointer< t_Object >::operator!=(), Mers::Utils::Containers::SharedPointer< t_Object >::operator->(), Mers::Utils::Containers::SharedPointer< t_Object >::operator<(), Mers::Utils::Containers::SharedPointer< t_Object >::operator=(), Mers::Utils::Containers::SharedPointer< t_Object >::operator==(), Mers::Utils::Containers::SharedPointer< t_Object >::reset(), Mers::Utils::Containers::SharedPointer< t_Object >::set(), Mers::Utils::Containers::SharedPointer< t_Object >::swap(), Mers::Utils::Containers::SharedPointer< t_Object >::unique(), and Mers::Utils::Containers::SharedPointer< t_Object >::use_count().

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

- /Users/fpy/titan-1-5-MBARI/Mers/Utils/Containers/SharedPointer.h