# Bakery::sharedptr< T_obj > Class Template Reference

A shared reference-counting smart-pointer. More...

`#include <sharedptr.h>`

List of all members.

## Public Types

typedef size_t | size_type

## Public Member Functions

| sharedptr ()
| Allocate a new instance.
| sharedptr (T_obj *pobj)
| Take ownership.
| sharedptr (const sharedptr &src)
| Share ownership.
sharedptr & | operator= (const sharedptr &src)
| Share ownership.
virtual | ~sharedptr ()
T_obj & | operator* ()
| Dereferencing.
const T_obj & | operator* () const
| Dereferencing.
T_obj * | operator-> () const
| Dereferencing.
| operator bool () const
| Test whether the RefPtr<> points to any underlying instance.
T_obj * | obj ()
| Get the underlying instance:.
const T_obj * | obj () const
| Get the underlying instance:.

## Protected Member Functions

void | ref ()
void | unref ()

## Protected Attributes

size_type * | m_pRefCount
T_obj * | m_pobj

## Detailed Description

### template<typename T_obj>
class Bakery::sharedptr< T_obj >

A shared reference-counting smart-pointer.

## Member Typedef Documentation

template<typename T_obj>

typedef size_t Bakery::sharedptr< T_obj >::size_type

## Constructor & Destructor Documentation

template<typename T_obj>

Bakery::sharedptr< T_obj >::sharedptr | ( |  | ) | `[inline]`

Allocate a new instance.

template<typename T_obj>

Bakery::sharedptr< T_obj >::sharedptr | ( | T_obj * | pobj | ) | `[inline, explicit]`

Take ownership.

References Bakery::sharedptr< T_obj >::ref().

template<typename T_obj>

Bakery::sharedptr< T_obj >::sharedptr | ( | const sharedptr< T_obj > & | src | ) | `[inline]`

Share ownership.

References Bakery::sharedptr< T_obj >::ref().

template<typename T_obj>

Bakery::sharedptr< T_obj >::~sharedptr | ( |  | ) | `[inline, virtual]`

References Bakery::sharedptr< T_obj >::unref().

## Member Function Documentation

template<typename T_obj>

sharedptr< T_obj > & Bakery::sharedptr< T_obj >::operator= | ( | const sharedptr< T_obj > & | src | ) | `[inline]`

Share ownership.

References Bakery::sharedptr< T_obj >::m_pobj, Bakery::sharedptr< T_obj >::m_pRefCount, Bakery::sharedptr< T_obj >::ref(), and Bakery::sharedptr< T_obj >::unref().

template<typename T_obj>

T_obj & Bakery::sharedptr< T_obj >::operator* | ( |  | ) | `[inline]`

Dereferencing.

References Bakery::sharedptr< T_obj >::m_pobj.

template<typename T_obj>

const T_obj & Bakery::sharedptr< T_obj >::operator* | ( |  | ) | const`[inline]`

Dereferencing.

References Bakery::sharedptr< T_obj >::m_pobj.

template<typename T_obj>

T_obj * Bakery::sharedptr< T_obj >::operator-> | ( |  | ) | const`[inline]`

Dereferencing.

Use the methods of the underlying instance like so:

     refptr->memberfun()

References Bakery::sharedptr< T_obj >::m_pobj.

template<class T_obj>

Bakery::sharedptr< T_obj >::operator bool | ( |  | ) | const`[inline]`

Test whether the RefPtr<> points to any underlying instance.

Mimics usage of ordinary pointers:

       if (ptr)
         do_something();

References Bakery::sharedptr< T_obj >::m_pobj.

template<typename T_obj>

T_obj * Bakery::sharedptr< T_obj >::obj | ( |  | ) | `[inline]`

Get the underlying instance:.

References Bakery::sharedptr< T_obj >::m_pobj.

template<typename T_obj>

const T_obj * Bakery::sharedptr< T_obj >::obj | ( |  | ) | const`[inline]`

Get the underlying instance:.

References Bakery::sharedptr< T_obj >::m_pobj.

template<class T_obj>

void Bakery::sharedptr< T_obj >::ref | ( |  | ) | `[inline, protected]`

References Bakery::sharedptr< T_obj >::m_pobj, and Bakery::sharedptr< T_obj >::m_pRefCount.

Referenced by Bakery::sharedptr< T_obj >::operator=(), and Bakery::sharedptr< T_obj >::sharedptr().

template<class T_obj>

void Bakery::sharedptr< T_obj >::unref | ( |  | ) | `[inline, protected]`

References Bakery::sharedptr< T_obj >::m_pobj, and Bakery::sharedptr< T_obj >::m_pRefCount.

Referenced by Bakery::sharedptr< T_obj >::operator=(), and Bakery::sharedptr< T_obj >::~sharedptr().

## Member Data Documentation

template<typename T_obj>

size_type* Bakery::sharedptr< T_obj >::m_pRefCount `[protected]`

Referenced by Bakery::sharedptr< T_obj >::operator=(), Bakery::sharedptr< T_obj >::ref(), and Bakery::sharedptr< T_obj >::unref().

template<typename T_obj>

T_obj* Bakery::sharedptr< T_obj >::m_pobj `[protected]`

Referenced by Bakery::sharedptr< T_obj >::obj(), Bakery::sharedptr< T_obj >::operator bool(), Bakery::sharedptr< T_obj >::operator*(), Bakery::sharedptr< T_obj >::operator->(), Bakery::sharedptr< T_obj >::operator=(), Bakery::sharedptr< T_obj >::ref(), and Bakery::sharedptr< T_obj >::unref().

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

- sharedptr.h