#include <Intrusive_Ref_Count_Handle_T.h>
Collaboration diagram for TAO_Intrusive_Ref_Count_Handle< T >:
Public Member Functions | |
TAO_Intrusive_Ref_Count_Handle (void) | |
Default Constructor - enters the "nil" state. | |
TAO_Intrusive_Ref_Count_Handle (T *p, bool take_ownership=true) | |
TAO_Intrusive_Ref_Count_Handle (const TAO_Intrusive_Ref_Count_Handle &b) | |
Copy Constructor - claims a "copy" of rhs object's reference to T. | |
~TAO_Intrusive_Ref_Count_Handle (void) | |
Destructor. | |
TAO_Intrusive_Ref_Count_Handle & | operator= (T *p) |
TAO_Intrusive_Ref_Count_Handle & | operator= (const TAO_Intrusive_Ref_Count_Handle &b) |
T * | operator-> () const |
Const Accessor to underlying pointer (T*) using arrow (->) operator. | |
bool | is_nil (void) const |
T * | in (void) const |
Used to pass the underlying pointer as an "IN" argument to a method. | |
T *& | inout (void) |
Used to pass the underlying pointer as an "IN/OUT" argument to a method. | |
T *& | out (void) |
Used to pass the underlying pointer as an "OUT" argument to a method. | |
T * | _retn (void) |
Private Member Functions | |
void | claim (void) |
void | drop (void) |
Private Attributes | |
T * | ptr_ |
This class behaves just like a xxx_var type behaves. The only significant difference is that this class provides a "bool is_nil() const" method, and xxx_var types don't (they use the "bool CORBA::is_nil(xxx_ptr ptr)" method instead). For example,
typedef TAO_Intrusive_Ref_Count_Handle<PortableServer::ServantBase> MyServantBase_var;
The MyServantBase_var and the PortableServer::ServantBase_var are nearly idenitical. The only difference is that the MyServantBase_var has a "isNil()" method that indicates whether or not the smart pointer is in the 'nil' state or not.
This class can be used to "safely" deal with an instance of a servant. For example, we can use a single variable TAO_Intrusive_Ref_Count_Handle<Foo_i>
typedef TAO_Intrusive_Ref_Count_Handle<Foo_i> Foo_i_var; Foo_i_var servant_;
instead of using two variables
PortableServer::ServantBase_var servant_holder_; Foo_i* servant_;
to deal with the servant memory.
The Foo_i_var type does everything that the PortableServer::ServantBase_var type does. In addition, the Foo_i_var type can provide access to the servant as derived class via the arrow operator.
Definition at line 65 of file Intrusive_Ref_Count_Handle_T.h.
TAO_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE TAO_Intrusive_Ref_Count_Handle< T >::TAO_Intrusive_Ref_Count_Handle | ( | void | ) |
Default Constructor - enters the "nil" state.
Definition at line 9 of file Intrusive_Ref_Count_Handle_T.inl.
00010 : ptr_(0) 00011 { 00012 }
ACE_INLINE TAO_Intrusive_Ref_Count_Handle< T >::TAO_Intrusive_Ref_Count_Handle | ( | T * | p, | |
bool | take_ownership = true | |||
) |
Ctor - By default, takes ownership of passed-in "copy" of reference to T. But the second argument (bool) can be changed from the default value of 'true' to the non-default value of 'false'. The second argument dictates whether or not this handle object should take ownership of the passed-in pointer to the T object. By default, it takes ownership, leaving the reference counter of the T object unchanged. When it is instructed to not take ownership (false value for second arg), then the reference counter of the T object will be incremented so that this handle object has its own "copy".
Definition at line 17 of file Intrusive_Ref_Count_Handle_T.inl.
References TAO_Intrusive_Ref_Count_Handle< T >::claim().
TAO_Intrusive_Ref_Count_Handle< T >::TAO_Intrusive_Ref_Count_Handle | ( | const TAO_Intrusive_Ref_Count_Handle< T > & | b | ) |
Copy Constructor - claims a "copy" of rhs object's reference to T.
ACE_INLINE TAO_Intrusive_Ref_Count_Handle< T >::~TAO_Intrusive_Ref_Count_Handle | ( | void | ) |
Destructor.
Definition at line 41 of file Intrusive_Ref_Count_Handle_T.inl.
References TAO_Intrusive_Ref_Count_Handle< T >::drop().
00042 { 00043 this->drop(); 00044 }
ACE_INLINE T * TAO_Intrusive_Ref_Count_Handle< T >::_retn | ( | void | ) |
Used to take-away the underlying pointer from this smart pointer object. Caller becomes responsibe for the returned "copy" to the reference. Always leaves the smart pointer in the "nil" state upon return.
Definition at line 125 of file Intrusive_Ref_Count_Handle_T.inl.
References TAO_Intrusive_Ref_Count_Handle< T >::ptr_.
ACE_INLINE void TAO_Intrusive_Ref_Count_Handle< T >::claim | ( | void | ) | [private] |
Claim a "copy" of the reference-counted object by adding one to its reference counter. Do nothing if this smart pointer object is currently in the "nil" state.
Definition at line 136 of file Intrusive_Ref_Count_Handle_T.inl.
References TAO_Intrusive_Ref_Count_Handle< T >::ptr_.
Referenced by TAO_Intrusive_Ref_Count_Handle< T >::TAO_Intrusive_Ref_Count_Handle().
00137 { 00138 if (this->ptr_ != 0) 00139 { 00140 this->ptr_->_add_ref(); 00141 } 00142 }
ACE_INLINE void TAO_Intrusive_Ref_Count_Handle< T >::drop | ( | void | ) | [private] |
Drop our "copy" of the reference-counted object by removing one from its reference counter. Do nothing if this smart pointer object is currently in the "nil" state. Note that this method will always leave this smart pointer in the "nil" state upon its return.
Definition at line 148 of file Intrusive_Ref_Count_Handle_T.inl.
References TAO_Intrusive_Ref_Count_Handle< T >::ptr_.
Referenced by TAO_Intrusive_Ref_Count_Handle< T >::out(), and TAO_Intrusive_Ref_Count_Handle< T >::~TAO_Intrusive_Ref_Count_Handle().
00149 { 00150 if (this->ptr_ != 0) 00151 { 00152 this->ptr_->_remove_ref(); 00153 this->ptr_ = 0; 00154 } 00155 }
ACE_INLINE T * TAO_Intrusive_Ref_Count_Handle< T >::in | ( | void | ) | const |
Used to pass the underlying pointer as an "IN" argument to a method.
Definition at line 97 of file Intrusive_Ref_Count_Handle_T.inl.
References TAO_Intrusive_Ref_Count_Handle< T >::ptr_.
00098 { 00099 return this->ptr_; 00100 }
ACE_INLINE T *& TAO_Intrusive_Ref_Count_Handle< T >::inout | ( | void | ) |
Used to pass the underlying pointer as an "IN/OUT" argument to a method.
Definition at line 106 of file Intrusive_Ref_Count_Handle_T.inl.
References TAO_Intrusive_Ref_Count_Handle< T >::ptr_.
00107 { 00108 return this->ptr_; 00109 }
ACE_INLINE bool TAO_Intrusive_Ref_Count_Handle< T >::is_nil | ( | void | ) | const |
Returns true if underlying pointer is NULL (0). Returns false otherwise.
Definition at line 88 of file Intrusive_Ref_Count_Handle_T.inl.
References TAO_Intrusive_Ref_Count_Handle< T >::ptr_.
00089 { 00090 return this->ptr_ == 0; 00091 }
ACE_INLINE T * TAO_Intrusive_Ref_Count_Handle< T >::operator-> | ( | ) | const |
Const Accessor to underlying pointer (T*) using arrow (->) operator.
Definition at line 79 of file Intrusive_Ref_Count_Handle_T.inl.
References TAO_Intrusive_Ref_Count_Handle< T >::ptr_.
00080 { 00081 return this->ptr_; 00082 }
TAO_Intrusive_Ref_Count_Handle& TAO_Intrusive_Ref_Count_Handle< T >::operator= | ( | const TAO_Intrusive_Ref_Count_Handle< T > & | b | ) |
Assignment Operator with const TAO_Smart_Ptr<T>& argument. Claims a "copy" of rhs object's reference to T.
ACE_INLINE TAO_Intrusive_Ref_Count_Handle< T > & TAO_Intrusive_Ref_Count_Handle< T >::operator= | ( | T * | p | ) |
Assignment Operator with T* argument. Takes ownership of passed-in "copy" of reference to T.
Definition at line 50 of file Intrusive_Ref_Count_Handle_T.inl.
00051 { 00052 TAO_Intrusive_Ref_Count_Handle<T> tmp (p); 00053 return this->operator= (tmp); 00054 }
ACE_INLINE T *& TAO_Intrusive_Ref_Count_Handle< T >::out | ( | void | ) |
Used to pass the underlying pointer as an "OUT" argument to a method.
Definition at line 115 of file Intrusive_Ref_Count_Handle_T.inl.
References TAO_Intrusive_Ref_Count_Handle< T >::drop(), and TAO_Intrusive_Ref_Count_Handle< T >::ptr_.
T* TAO_Intrusive_Ref_Count_Handle< T >::ptr_ [private] |
The underlying pointer to the (intrusively) reference-counted object. Set to 0 when this smart pointer is in the "nil" state. Otherwise, this smart pointer always owns a (reference-counted) "copy" of the object pointed to by the ptr_ data member.
Definition at line 140 of file Intrusive_Ref_Count_Handle_T.h.
Referenced by TAO_Intrusive_Ref_Count_Handle< T >::_retn(), TAO_Intrusive_Ref_Count_Handle< T >::claim(), TAO_Intrusive_Ref_Count_Handle< T >::drop(), TAO_Intrusive_Ref_Count_Handle< T >::in(), TAO_Intrusive_Ref_Count_Handle< T >::inout(), TAO_Intrusive_Ref_Count_Handle< T >::is_nil(), TAO_Intrusive_Ref_Count_Handle< T >::operator->(), and TAO_Intrusive_Ref_Count_Handle< T >::out().