#include <Intrusive_Auto_Ptr.h>
Collaboration diagram for ACE_Intrusive_Auto_Ptr< X >:
Public Member Functions | |
operator unspecified_bool_type () const | |
Enables "if (sp) ...". | |
ACE_Intrusive_Auto_Ptr (X *p=0, bool addref=true) | |
ACE_Intrusive_Auto_Ptr (const ACE_Intrusive_Auto_Ptr< X > &r) | |
template<class U> | |
ACE_Intrusive_Auto_Ptr (const ACE_Intrusive_Auto_Ptr< U > &rhs) | |
virtual | ~ACE_Intrusive_Auto_Ptr (void) |
void | operator= (const ACE_Intrusive_Auto_Ptr< X > &r) |
X * | operator-> (void) const |
Redirection operator. | |
X & | operator * () const |
Accessor method. | |
X * | release (void) |
void | reset (X *p=0) |
X * | get (void) const |
Get the pointer value. | |
long | count (void) const |
Get the reference count value. | |
Public Attributes | |
ACE_ALLOC_HOOK_DECLARE | |
Declare the dynamic allocation hooks. | |
Protected Types | |
typedef void(*) | unspecified_bool_type (ACE_Intrusive_Auto_Ptr< X > ***) |
Static Protected Member Functions | |
static void | unspecified_bool (ACE_Intrusive_Auto_Ptr< X > ***) |
Used to define a proper boolean conversion for "if (sp) ...". | |
Protected Attributes | |
X * | rep_ |
Protect operations on the ACE_Intrusive_Auto_Ptr. |
Assigning or copying instances of an ACE_Intrusive_Auto_Ptr will automatically increment the reference count. When the last instance that references a ACE_Intrusive_Auto_Ptr instance is destroyed or overwritten, it will invoke delete on its underlying pointer.
The ACE_Intrusive_Auto_Ptr works by maintaining a reference to a separate representation object, ACE_Intrusive_Auto_Ptr_Rep. That separate representation object contains the reference count and the actual pointer value.
Definition at line 50 of file Intrusive_Auto_Ptr.h.
typedef void(*) ACE_Intrusive_Auto_Ptr< X >::unspecified_bool_type(ACE_Intrusive_Auto_Ptr< X > ***) [protected] |
Definition at line 56 of file Intrusive_Auto_Ptr.h.
ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE ACE_Intrusive_Auto_Ptr< X >::ACE_Intrusive_Auto_Ptr | ( | X * | p = 0 , |
|
bool | addref = true | |||
) |
Constructor that initializes an ACE_Intrusive_Auto_Ptr to the specified pointer value.
Definition at line 11 of file Intrusive_Auto_Ptr.inl.
References ACE_Intrusive_Auto_Ptr< X >::rep_.
ACE_INLINE ACE_Intrusive_Auto_Ptr< X >::ACE_Intrusive_Auto_Ptr | ( | const ACE_Intrusive_Auto_Ptr< X > & | r | ) |
Copy constructor binds the new ACE_Intrusive_Auto_Ptr to the representation object referenced by r. An ACE_Intrusive_Auto_Ptr_Rep is created if necessary.
Definition at line 19 of file Intrusive_Auto_Ptr.inl.
References ACE_Intrusive_Auto_Ptr< X >::rep_.
ACE_INLINE ACE_Intrusive_Auto_Ptr< X >::ACE_Intrusive_Auto_Ptr | ( | const ACE_Intrusive_Auto_Ptr< U > & | rhs | ) |
Definition at line 100 of file Intrusive_Auto_Ptr.inl.
References ACE_Intrusive_Auto_Ptr< X >::rep_.
00101 { 00102 // note implicit cast from U* to T* so illegal copy will generate a 00103 // compiler warning here 00104 this->rep_ = rhs.operator-> (); 00105 X::intrusive_add_ref(this->rep_); 00106 }
ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_Intrusive_Auto_Ptr< X >::~ACE_Intrusive_Auto_Ptr | ( | void | ) | [virtual] |
Destructor. Releases the reference to the underlying representation. If the release of that reference causes its reference count to reach 0, the representation object will also be destroyed.
Definition at line 15 of file Intrusive_Auto_Ptr.cpp.
References ACE_Intrusive_Auto_Ptr< X >::reset().
00016 { 00017 reset (0); 00018 }
long ACE_Intrusive_Auto_Ptr< X >::count | ( | void | ) | const |
Get the reference count value.
ACE_INLINE X * ACE_Intrusive_Auto_Ptr< X >::get | ( | void | ) | const |
Get the pointer value.
Definition at line 39 of file Intrusive_Auto_Ptr.inl.
References ACE_Intrusive_Auto_Ptr< X >::rep_.
Referenced by ACE_Threading_Helper< ACE_Null_Mutex >::get(), ACE_Service_Config::global(), operator!=(), operator==(), and ACE_Service_Config_Guard::~ACE_Service_Config_Guard().
00040 { 00041 // We return the ACE_Future_rep. 00042 return this->rep_; 00043 }
ACE_INLINE X & ACE_Intrusive_Auto_Ptr< X >::operator * | ( | ) | const |
Accessor method.
Definition at line 33 of file Intrusive_Auto_Ptr.inl.
References ACE_Intrusive_Auto_Ptr< X >::rep_.
00034 { 00035 return *this->rep_; 00036 }
ACE_Intrusive_Auto_Ptr< X >::operator unspecified_bool_type | ( | ) | const [inline] |
Enables "if (sp) ...".
Definition at line 61 of file Intrusive_Auto_Ptr.h.
00062 { 00063 return rep_ == 0 ? 0: unspecified_bool; 00064 }
ACE_INLINE X * ACE_Intrusive_Auto_Ptr< X >::operator-> | ( | void | ) | const |
Redirection operator.
Definition at line 27 of file Intrusive_Auto_Ptr.inl.
References ACE_Intrusive_Auto_Ptr< X >::rep_.
00028 { 00029 return this->rep_; 00030 }
ACE_INLINE void ACE_Intrusive_Auto_Ptr< X >::operator= | ( | const ACE_Intrusive_Auto_Ptr< X > & | r | ) |
Assignment operator that binds the current object and r to the same ACE_Intrusive_Auto_Ptr_Rep. An ACE_Intrusive_Auto_Ptr_Rep is created if necessary.
Definition at line 77 of file Intrusive_Auto_Ptr.inl.
References ACE_Intrusive_Auto_Ptr< X >::rep_.
00078 { 00079 // do nothing when aliasing 00080 if (this->rep_ == rhs.rep_) 00081 return; 00082 00083 // assign a zero 00084 if (rhs.rep_ == 0) 00085 { 00086 X::intrusive_remove_ref (rhs.rep_); 00087 this->rep_ = 0; 00088 return; 00089 } 00090 00091 // bind <this> to the same <ACE_Intrusive_Auto_Ptr_Rep> as <rhs>. 00092 X *old_rep = this->rep_; 00093 this->rep_ = rhs.rep_; 00094 X::intrusive_add_ref (this->rep_); 00095 X::intrusive_remove_ref (old_rep); 00096 }
ACE_INLINE X * ACE_Intrusive_Auto_Ptr< X >::release | ( | void | ) |
Releases the reference to the underlying representation object.
The | pointer value prior to releasing it. |
Definition at line 46 of file Intrusive_Auto_Ptr.inl.
References ACE_Intrusive_Auto_Ptr< X >::rep_.
00047 { 00048 X *p = this->rep_; 00049 if (this->rep_ != 0) 00050 X::intrusive_remove_ref (this->rep_); 00051 00052 this->rep_ = 0; 00053 return p; 00054 }
ACE_INLINE void ACE_Intrusive_Auto_Ptr< X >::reset | ( | X * | p = 0 |
) |
Releases the current pointer value and then sets a new pointer value specified by p.
Definition at line 57 of file Intrusive_Auto_Ptr.inl.
References ACE_Intrusive_Auto_Ptr< X >::rep_.
Referenced by ACE_Intrusive_Auto_Ptr< X >::~ACE_Intrusive_Auto_Ptr().
00058 { 00059 // Avoid deleting the underlying auto_ptr if assigning the same actual 00060 // pointer value. 00061 if (this->rep_ == p) 00062 return; 00063 00064 X *old_rep = this->rep_; 00065 this->rep_ = p; 00066 00067 if (this->rep_ != 0) 00068 X::intrusive_add_ref (this->rep_); 00069 00070 if (old_rep != 0) 00071 X::intrusive_remove_ref (old_rep); 00072 00073 return; 00074 }
static void ACE_Intrusive_Auto_Ptr< X >::unspecified_bool | ( | ACE_Intrusive_Auto_Ptr< X > *** | ) | [inline, static, protected] |
Used to define a proper boolean conversion for "if (sp) ...".
Definition at line 55 of file Intrusive_Auto_Ptr.h.
Referenced by ACE_Intrusive_Auto_Ptr< ACE_Service_Gestalt >::operator unspecified_bool_type().
ACE_Intrusive_Auto_Ptr< X >::ACE_ALLOC_HOOK_DECLARE |
X* ACE_Intrusive_Auto_Ptr< X >::rep_ [protected] |
Protect operations on the ACE_Intrusive_Auto_Ptr.
Definition at line 120 of file Intrusive_Auto_Ptr.h.
Referenced by ACE_Intrusive_Auto_Ptr< X >::ACE_Intrusive_Auto_Ptr(), ACE_Intrusive_Auto_Ptr< X >::get(), ACE_Intrusive_Auto_Ptr< X >::operator *(), ACE_Intrusive_Auto_Ptr< ACE_Service_Gestalt >::operator unspecified_bool_type(), ACE_Intrusive_Auto_Ptr< X >::operator->(), ACE_Intrusive_Auto_Ptr< X >::operator=(), ACE_Intrusive_Auto_Ptr< X >::release(), and ACE_Intrusive_Auto_Ptr< X >::reset().