ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK > Class Template Reference

An ACE_Refcounted_Auto_Ptr_Rep object encapsulates a pointer to an object of type X. It uses a lock object of type ACE_LOCK to protect access to the reference count. More...

#include <Refcounted_Auto_Ptr.h>

Collaboration diagram for ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >:

Collaboration graph
[legend]
List of all members.

Private Member Functions

X * get (void) const
 Get the pointer value.
long count (void) const
 Get the reference count value.
 ACE_Refcounted_Auto_Ptr_Rep (X *p=0)
 ~ACE_Refcounted_Auto_Ptr_Rep (void)

Static Private Member Functions

static ACE_Refcounted_Auto_Ptr_Rep<
X, ACE_LOCK > * 
internal_create (X *p)
static ACE_Refcounted_Auto_Ptr_Rep<
X, ACE_LOCK > * 
create (X *p)
static ACE_Refcounted_Auto_Ptr_Rep<
X, ACE_LOCK > * 
attach (ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK > *&rep)
static void detach (ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK > *&rep)

Private Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.
ACE_Auto_Basic_Ptr< X > ptr_
 Pointer to the result.
ACE_Atomic_Op< ACE_LOCK, long > ref_count_
 Reference count.

Friends

class ACE_Refcounted_Auto_Ptr< X, ACE_LOCK >

Detailed Description

template<class X, class ACE_LOCK>
class ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >

An ACE_Refcounted_Auto_Ptr_Rep object encapsulates a pointer to an object of type X. It uses a lock object of type ACE_LOCK to protect access to the reference count.

For internal use only.

ACE_Refcounted_Auto_Ptr_Rep is used internally by the ACE_Refcounted_Auto_Ptr class and is only accessible through it.

Definition at line 135 of file Refcounted_Auto_Ptr.h.


Constructor & Destructor Documentation

template<class X, class ACE_LOCK>
ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::ACE_Refcounted_Auto_Ptr_Rep ( X *  p = 0  )  [inline, private]

Definition at line 74 of file Refcounted_Auto_Ptr.inl.

00075   : ptr_ (p),
00076     ref_count_ (0)
00077 {
00078 }

template<class X, class ACE_LOCK>
ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::~ACE_Refcounted_Auto_Ptr_Rep ( void   )  [inline, private]

Definition at line 81 of file Refcounted_Auto_Ptr.inl.

00082 {
00083 }


Member Function Documentation

template<class X, class ACE_LOCK>
ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK > * ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::attach ( ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK > *&  rep  )  [inline, static, private]

Increase the reference count on rep.

Return values:
@a rep if success, 0 if there's an error obtaining the lock on rep.

Definition at line 53 of file Refcounted_Auto_Ptr.inl.

References ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::ref_count_.

Referenced by ACE_Refcounted_Auto_Ptr< X, ACE_LOCK >::operator=().

00054 {
00055   if (rep == 0)
00056     return 0;
00057 
00058   ++rep->ref_count_;
00059 
00060   return rep;
00061 }

template<class X, class ACE_LOCK>
ACE_BEGIN_VERSIONED_NAMESPACE_DECL long ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::count ( void   )  const [inline, private]

Get the reference count value.

Definition at line 11 of file Refcounted_Auto_Ptr.inl.

References ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::ref_count_, and ACE_Atomic_Op< ACE_LOCK, TYPE >::value().

Referenced by ACE_Refcounted_Auto_Ptr< X, ACE_LOCK >::count().

00012 {
00013   return this->ref_count_.value();
00014 }

template<class X, class ACE_LOCK>
ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK > * ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::create ( X *  p  )  [inline, static, private]

Create a ACE_Refcounted_Auto_Ptr_Rep<X, ACE_LOCK> and initialize the reference count.

Definition at line 39 of file Refcounted_Auto_Ptr.inl.

References ACE_ASSERT, ACE_throw_bad_alloc, and ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::internal_create().

Referenced by ACE_Refcounted_Auto_Ptr< X, ACE_LOCK >::reset().

00040 {
00041   // Yes set ref count to zero.
00042   ACE_Refcounted_Auto_Ptr_Rep<X, ACE_LOCK> *temp = internal_create (p);
00043 #if defined (ACE_NEW_THROWS_EXCEPTIONS)
00044   if (temp == 0)
00045     ACE_throw_bad_alloc;
00046 #else
00047   ACE_ASSERT (temp != 0);
00048 #endif /* ACE_NEW_THROWS_EXCEPTIONS */
00049    return temp;
00050 }

template<class X, class ACE_LOCK>
void ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::detach ( ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK > *&  rep  )  [inline, static, private]

Decreases the reference count and and deletes rep if there are no more references to rep.

Precondition (rep != 0)

Definition at line 64 of file Refcounted_Auto_Ptr.inl.

References ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::ref_count_.

Referenced by ACE_Refcounted_Auto_Ptr< X, ACE_LOCK >::operator=(), ACE_Refcounted_Auto_Ptr< X, ACE_LOCK >::release(), ACE_Refcounted_Auto_Ptr< X, ACE_LOCK >::reset(), and ACE_Refcounted_Auto_Ptr< X, ACE_LOCK >::~ACE_Refcounted_Auto_Ptr().

00065 {
00066   if (rep == 0)
00067     return;
00068 
00069   if (rep->ref_count_-- == 0)
00070     delete rep;
00071 }

template<class X, class ACE_LOCK>
X * ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::get ( void   )  const [inline, private]

Get the pointer value.

Definition at line 86 of file Refcounted_Auto_Ptr.inl.

References ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::ptr_.

Referenced by ACE_Refcounted_Auto_Ptr< X, ACE_LOCK >::get(), ACE_Refcounted_Auto_Ptr< X, ACE_LOCK >::operator *(), ACE_Refcounted_Auto_Ptr< X, ACE_LOCK >::operator bool(), ACE_Refcounted_Auto_Ptr< X, ACE_LOCK >::operator!(), and ACE_Refcounted_Auto_Ptr< X, ACE_LOCK >::operator->().

00087 {
00088   return this->ptr_.get ();
00089 }

template<class X, class ACE_LOCK>
ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK > * ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::internal_create ( X *  p  )  [inline, static, private]

Allocate a new ACE_Refcounted_Auto_Ptr_Rep<X, ACE_LOCK> instance, returning NULL if it cannot be created.

Definition at line 29 of file Refcounted_Auto_Ptr.inl.

References ACE_NEW_RETURN.

Referenced by ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::create().

00030 {
00031   ACE_Refcounted_Auto_Ptr_Rep<X, ACE_LOCK> *temp = 0;
00032   ACE_NEW_RETURN (temp,
00033                   (ACE_Refcounted_Auto_Ptr_Rep<X, ACE_LOCK>) (p),
00034                   0);
00035   return temp;
00036 }


Friends And Related Function Documentation

template<class X, class ACE_LOCK>
friend class ACE_Refcounted_Auto_Ptr< X, ACE_LOCK > [friend]

Definition at line 138 of file Refcounted_Auto_Ptr.h.


Member Data Documentation

template<class X, class ACE_LOCK>
ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::ACE_ALLOC_HOOK_DECLARE [private]

Declare the dynamic allocation hooks.

Definition at line 147 of file Refcounted_Auto_Ptr.h.

template<class X, class ACE_LOCK>
ACE_Auto_Basic_Ptr<X> ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::ptr_ [private]

Pointer to the result.

Definition at line 174 of file Refcounted_Auto_Ptr.h.

Referenced by ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::get().

template<class X, class ACE_LOCK>
ACE_Atomic_Op<ACE_LOCK, long> ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::ref_count_ [mutable, private]

Reference count.

Definition at line 177 of file Refcounted_Auto_Ptr.h.

Referenced by ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::attach(), ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::count(), and ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::detach().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:35:30 2010 for ACE by  doxygen 1.4.7