Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tao / Intrusive_Ref_Count_Handle_T.inl
blobef37073a8b24da6bfe006fb77b9921be790dbf8f
1 // -*- C++ -*-
2 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
4 template <typename T>
5 ACE_INLINE
6 TAO_Intrusive_Ref_Count_Handle<T>::TAO_Intrusive_Ref_Count_Handle ()
7   : ptr_(0)
12 template <typename T>
13 ACE_INLINE
14 TAO_Intrusive_Ref_Count_Handle<T>::TAO_Intrusive_Ref_Count_Handle (
15   T*   p,
16   bool take_ownership)
17   : ptr_(p)
19   if (!take_ownership)
20     {
21       this->claim ();
22     }
26 template <typename T>
27 ACE_INLINE
28 TAO_Intrusive_Ref_Count_Handle<T>::TAO_Intrusive_Ref_Count_Handle (
29   const TAO_Intrusive_Ref_Count_Handle<T>& b)
30   : ptr_(b.ptr_)
32   this->claim();
36 template <typename T>
37 ACE_INLINE
38 TAO_Intrusive_Ref_Count_Handle<T>::~TAO_Intrusive_Ref_Count_Handle()
40   this->drop();
44 template <typename T>
45 ACE_INLINE
46 TAO_Intrusive_Ref_Count_Handle<T>&
47 TAO_Intrusive_Ref_Count_Handle<T>::operator=(T* p)
49   TAO_Intrusive_Ref_Count_Handle<T> tmp (p);
50   return this->operator= (tmp);
54 template <typename T>
55 ACE_INLINE
56 TAO_Intrusive_Ref_Count_Handle<T>&
57 TAO_Intrusive_Ref_Count_Handle<T>::operator=
58                                  (const TAO_Intrusive_Ref_Count_Handle<T>& b)
60   // Strongly exception-safe assignment through the usual copy and
61   // swap technique.
63   TAO_Intrusive_Ref_Count_Handle<T> tmp (b);
65   T * old_ptr = this->ptr_;
66   this->ptr_ = tmp.ptr_;
67   tmp.ptr_ = old_ptr;
69   return *this;
73 template <typename T>
74 ACE_INLINE
76 TAO_Intrusive_Ref_Count_Handle<T>::operator->() const
78   return this->ptr_;
82 template <typename T>
83 ACE_INLINE
84 bool
85 TAO_Intrusive_Ref_Count_Handle<T>::is_nil() const
87   return this->ptr_ == 0;
91 template <typename T>
92 ACE_INLINE
94 TAO_Intrusive_Ref_Count_Handle<T>::in() const
96   return this->ptr_;
100 template <typename T>
101 ACE_INLINE
103 TAO_Intrusive_Ref_Count_Handle<T>::inout()
105   return this->ptr_;
109 template <typename T>
110 ACE_INLINE
112 TAO_Intrusive_Ref_Count_Handle<T>::out()
114   this->drop();
115   return this->ptr_;
119 template <typename T>
120 ACE_INLINE
122 TAO_Intrusive_Ref_Count_Handle<T>::_retn()
124   T* retval = this->ptr_;
125   this->ptr_ = 0;
126   return retval;
130 template <typename T>
131 ACE_INLINE
132 bool
133 TAO_Intrusive_Ref_Count_Handle<T>::operator== (const TAO_Intrusive_Ref_Count_Handle& h) const
135   return this->ptr_ == h.in();
139 template <typename T>
140 ACE_INLINE
141 void
142 TAO_Intrusive_Ref_Count_Handle<T>::claim()
144   if (this->ptr_ != 0)
145     {
146       this->ptr_->_add_ref();
147     }
151 template <typename T>
152 ACE_INLINE
153 void
154 TAO_Intrusive_Ref_Count_Handle<T>::drop()
156   if (this->ptr_ != 0)
157     {
158       this->ptr_->_remove_ref();
159       this->ptr_ = 0;
160     }
163 TAO_END_VERSIONED_NAMESPACE_DECL