library of assembled shared sources

http://lass.cocamware.com

lass::util::IntrusiveCounter< T, CounterType, referenceCounter > Class Template Reference
[Smart Pointers]

implementation of CounterPolicy concept, using a counter in the managed object itself. More...

#include <smart_ptr_policies.h>


Public Types

typedef IntrusiveCounter< T,
CounterType, referenceCounter > 
TSelf
typedef CounterType TCount

Protected Member Functions

template<typename TStorage >
void init (TStorage &pointee)
template<typename TStorage >
void dispose (TStorage &pointee)
template<typename TStorage >
void increment (TStorage &pointee)
template<typename TStorage >
bool decrement (TStorage &pointee)
template<typename TStorage >
TCount count (TStorage &pointee) const
void swap (TSelf &)


Detailed Description

template<typename T, typename CounterType, CounterType T::* referenceCounter>
class lass::util::IntrusiveCounter< T, CounterType, referenceCounter >

implementation of CounterPolicy concept, using a counter in the managed object itself.

Author:
Bram de Greve [Bramz]
This comes from "C++ Templates, The Complete Guide" by David Vandevoorde and Nicolai M. Josuttis. See their MemberReferenceCount policy.

The DefaultCounter policy puts the reference counter outside the managed object. That's great in most cases, because that way, the managed type doesn't have to be designed to be used with our SharedPtr. However, in some cases it is more interesting to put the reference counter inside the managed object. You can use the IntrusiveCounter policy to use such a reference counter with our SharedPtr.

  struct Foo
  {
      std::string blablabla;
      int referenceCount;
  };

  typedef lass::util::SharedPtr
  <
      Foo,
      lass::util::ObjectStorage,
      lass::util::IntrusiveCounter
      <
          Foo,                        // the managed type (containing the counter)
          int,                        // type of the counter
          &Foo::referenceCount        // pointer to the counter
      >
  >
  TFooPtr;

  TFooPtr foo(new Foo);

Definition at line 418 of file smart_ptr_policies.h.


Member Typedef Documentation

template<typename T , typename CounterType , CounterType T::* referenceCounter>
typedef IntrusiveCounter<T, CounterType, referenceCounter> lass::util::IntrusiveCounter< T, CounterType, referenceCounter >::TSelf

Definition at line 422 of file smart_ptr_policies.h.

template<typename T , typename CounterType , CounterType T::* referenceCounter>
typedef CounterType lass::util::IntrusiveCounter< T, CounterType, referenceCounter >::TCount

Definition at line 423 of file smart_ptr_policies.h.


Member Function Documentation

template<typename T , typename CounterType , CounterType T::* referenceCounter>
template<typename TStorage >
void lass::util::IntrusiveCounter< T, CounterType, referenceCounter >::init ( TStorage &  pointee  )  [inline, protected]

Definition at line 427 of file smart_ptr_policies.h.

References LASS_ASSERT.

template<typename T , typename CounterType , CounterType T::* referenceCounter>
template<typename TStorage >
void lass::util::IntrusiveCounter< T, CounterType, referenceCounter >::dispose ( TStorage &  pointee  )  [inline, protected]

Definition at line 433 of file smart_ptr_policies.h.

References LASS_ASSERT.

template<typename T , typename CounterType , CounterType T::* referenceCounter>
template<typename TStorage >
void lass::util::IntrusiveCounter< T, CounterType, referenceCounter >::increment ( TStorage &  pointee  )  [inline, protected]

Definition at line 438 of file smart_ptr_policies.h.

References lass::util::atomicCompareAndSwap(), and LASS_ASSERT.

template<typename T , typename CounterType , CounterType T::* referenceCounter>
template<typename TStorage >
bool lass::util::IntrusiveCounter< T, CounterType, referenceCounter >::decrement ( TStorage &  pointee  )  [inline, protected]

Definition at line 451 of file smart_ptr_policies.h.

References lass::util::atomicCompareAndSwap(), and LASS_ASSERT.

template<typename T , typename CounterType , CounterType T::* referenceCounter>
template<typename TStorage >
TCount lass::util::IntrusiveCounter< T, CounterType, referenceCounter >::count ( TStorage &  pointee  )  const [inline, protected]

Definition at line 465 of file smart_ptr_policies.h.

References LASS_ASSERT.

template<typename T , typename CounterType , CounterType T::* referenceCounter>
void lass::util::IntrusiveCounter< T, CounterType, referenceCounter >::swap ( TSelf  )  [inline, protected]

Definition at line 471 of file smart_ptr_policies.h.


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

Generated on Mon Nov 10 14:22:17 2008 for Library of Assembled Shared Sources by doxygen 1.5.7.1
SourceForge.net Logo