#include <Bound_Ptr.h>
Collaboration diagram for ACE_Strong_Bound_Ptr< X, ACE_LOCK >:
Public Member Functions | |
ACE_Strong_Bound_Ptr (X *p=0) | |
ACE_Strong_Bound_Ptr (auto_ptr< X > p) | |
ACE_Strong_Bound_Ptr (const ACE_Strong_Bound_Ptr< X, ACE_LOCK > &r) | |
Copy constructor binds this and r to the same object. | |
ACE_Strong_Bound_Ptr (const ACE_Weak_Bound_Ptr< X, ACE_LOCK > &r) | |
Constructor binds this and r to the same object. | |
template<class Y> | |
ACE_Strong_Bound_Ptr (const ACE_Strong_Bound_Ptr< Y, ACE_LOCK > &r) | |
~ACE_Strong_Bound_Ptr (void) | |
Destructor. | |
void | operator= (const ACE_Strong_Bound_Ptr< X, ACE_LOCK > &r) |
Assignment operator that binds this and r to the same object. | |
void | operator= (const ACE_Weak_Bound_Ptr< X, ACE_LOCK > &r) |
Assignment operator that binds this and r to the same object. | |
template<class Y> | |
ACE_Weak_Bound_Ptr< X, ACE_LOCK > & | operator= (const ACE_Strong_Bound_Ptr< Y, ACE_LOCK > &r) |
bool | operator== (const ACE_Strong_Bound_Ptr< X, ACE_LOCK > &r) const |
bool | operator== (const ACE_Weak_Bound_Ptr< X, ACE_LOCK > &r) const |
bool | operator== (X *p) const |
bool | operator!= (const ACE_Strong_Bound_Ptr< X, ACE_LOCK > &r) const |
Inequality operator, which is the opposite of equality. | |
bool | operator!= (const ACE_Weak_Bound_Ptr< X, ACE_LOCK > &r) const |
Inequality operator, which is the opposite of equality. | |
bool | operator!= (X *p) const |
Inequality operator, which is the opposite of equality. | |
X * | operator-> (void) const |
Redirection operator. | |
X & | operator * (void) const |
Dereference operator. | |
X * | get (void) const |
Get the pointer value. | |
void | reset (X *p=0) |
void | reset (auto_ptr< X > p) |
int | null (void) const |
Public Attributes | |
ACE_ALLOC_HOOK_DECLARE | |
Declare the dynamic allocation hooks. | |
Private Types | |
typedef X | X_t |
typedef ACE_Bound_Ptr_Counter< ACE_LOCK > | COUNTER |
The ACE_Bound_Ptr_Counter type. | |
Private Attributes | |
COUNTER * | counter_ |
The reference counter. | |
X * | ptr_ |
The underlying object. | |
Friends | |
class | ACE_Weak_Bound_Ptr< X, ACE_LOCK > |
class | ACE_Strong_Bound_Ptr |
Assigning or copying instances of an ACE_Strong_Bound_Ptr will automatically increment the reference count of the underlying object. When the last instance of an ACE_Strong_Bound_Ptr that references a particular object is destroyed or overwritten, it will invoke delete on its underlying pointer.
Definition at line 112 of file Bound_Ptr.h.
typedef ACE_Bound_Ptr_Counter<ACE_LOCK> ACE_Strong_Bound_Ptr< X, ACE_LOCK >::COUNTER [private] |
typedef X ACE_Strong_Bound_Ptr< X, ACE_LOCK >::X_t [private] |
Definition at line 232 of file Bound_Ptr.h.
ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ACE_Strong_Bound_Ptr | ( | X * | p = 0 |
) | [inline, explicit] |
Constructor that initializes an ACE_Strong_Bound_Ptr to point to the object <p> immediately.
Definition at line 147 of file Bound_Ptr.inl.
00148 : counter_ (COUNTER::create_strong ()), 00149 ptr_ (p) 00150 { 00151 }
ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ACE_Strong_Bound_Ptr | ( | auto_ptr< X > | p | ) | [inline, explicit] |
Constructor that initializes an ACE_Strong_Bound_Ptr by stealing ownership of an object from an auto_ptr.
Definition at line 154 of file Bound_Ptr.inl.
00155 : counter_ (COUNTER::create_strong ()), 00156 ptr_ (p.release()) 00157 { 00158 }
ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ACE_Strong_Bound_Ptr | ( | const ACE_Strong_Bound_Ptr< X, ACE_LOCK > & | r | ) | [inline] |
Copy constructor binds this
and r to the same object.
Definition at line 161 of file Bound_Ptr.inl.
References ACE_Bound_Ptr_Counter< ACE_LOCK >::attach_strong().
00162 : counter_ (r.counter_), 00163 ptr_ (r.ptr_) 00164 { 00165 COUNTER::attach_strong (this->counter_); 00166 }
ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ACE_Strong_Bound_Ptr | ( | const ACE_Weak_Bound_Ptr< X, ACE_LOCK > & | r | ) | [inline] |
Constructor binds this
and r to the same object.
Definition at line 169 of file Bound_Ptr.inl.
References ACE_Bound_Ptr_Counter< ACE_LOCK >::attach_strong(), ACE_Strong_Bound_Ptr< X, ACE_LOCK >::counter_, ACE_Bound_Ptr_Counter< ACE_LOCK >::create_strong(), and ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ptr_.
00170 : counter_ (r.counter_), 00171 ptr_ (r.ptr_) 00172 { 00173 // When creating a strong pointer from a weak one we can't assume that the 00174 // underlying object still exists. Therefore we must check for a return value 00175 // of -1, which indicates that the object has been destroyed. 00176 if (COUNTER::attach_strong (this->counter_) == -1) 00177 { 00178 // Underlying object has already been deleted, so set this pointer to null. 00179 this->counter_ = COUNTER::create_strong (); 00180 this->ptr_ = 0; 00181 } 00182 }
ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ACE_Strong_Bound_Ptr | ( | const ACE_Strong_Bound_Ptr< Y, ACE_LOCK > & | r | ) | [inline] |
Copy constructor binds this
and r to the same object if Y* can be implicitly converted to X*.
Definition at line 132 of file Bound_Ptr.h.
References ACE_Bound_Ptr_Counter< ACE_LOCK >::attach_strong().
00133 : counter_ (r.counter_), 00134 ptr_ (dynamic_cast<X_t*>(r.ptr_)) 00135 { 00136 // This ctor is temporarily defined here to increase our chances 00137 // of being accepted by broken compilers. 00138 // 00139 COUNTER::attach_strong (this->counter_); 00140 }
ACE_Strong_Bound_Ptr< X, ACE_LOCK >::~ACE_Strong_Bound_Ptr | ( | void | ) | [inline] |
Destructor.
Definition at line 185 of file Bound_Ptr.inl.
References ACE_Bound_Ptr_Counter< ACE_LOCK >::detach_strong(), and ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ptr_.
00186 { 00187 if (COUNTER::detach_strong (this->counter_) == 0) 00188 delete this->ptr_; 00189 }
X * ACE_Strong_Bound_Ptr< X, ACE_LOCK >::get | ( | void | ) | const [inline] |
Get the pointer value.
Definition at line 286 of file Bound_Ptr.inl.
References ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ptr_.
00287 { 00288 return this->ptr_; 00289 }
int ACE_Strong_Bound_Ptr< X, ACE_LOCK >::null | ( | void | ) | const [inline] |
Allows us to check for NULL on all ACE_Strong_Bound_Ptr objects.
Definition at line 292 of file Bound_Ptr.inl.
References ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ptr_.
00293 { 00294 return this->ptr_ == 0; 00295 }
X & ACE_Strong_Bound_Ptr< X, ACE_LOCK >::operator * | ( | void | ) | const [inline] |
Dereference operator.
Definition at line 280 of file Bound_Ptr.inl.
References ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ptr_.
00281 { 00282 return *this->ptr_; 00283 }
bool ACE_Strong_Bound_Ptr< X, ACE_LOCK >::operator!= | ( | X * | p | ) | const [inline] |
Inequality operator, which is the opposite of equality.
Definition at line 268 of file Bound_Ptr.inl.
References ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ptr_.
00269 { 00270 return this->ptr_ != p; 00271 }
bool ACE_Strong_Bound_Ptr< X, ACE_LOCK >::operator!= | ( | const ACE_Weak_Bound_Ptr< X, ACE_LOCK > & | r | ) | const [inline] |
Inequality operator, which is the opposite of equality.
Definition at line 261 of file Bound_Ptr.inl.
00262 { 00263 // Use the weak pointer's operator!= since it will check for null. 00264 return r != *this; 00265 }
bool ACE_Strong_Bound_Ptr< X, ACE_LOCK >::operator!= | ( | const ACE_Strong_Bound_Ptr< X, ACE_LOCK > & | r | ) | const [inline] |
Inequality operator, which is the opposite of equality.
Definition at line 255 of file Bound_Ptr.inl.
References ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ptr_.
X * ACE_Strong_Bound_Ptr< X, ACE_LOCK >::operator-> | ( | void | ) | const [inline] |
Redirection operator.
Definition at line 274 of file Bound_Ptr.inl.
References ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ptr_.
00275 { 00276 return this->ptr_; 00277 }
ACE_Weak_Bound_Ptr<X, ACE_LOCK>& ACE_Strong_Bound_Ptr< X, ACE_LOCK >::operator= | ( | const ACE_Strong_Bound_Ptr< Y, ACE_LOCK > & | r | ) | [inline] |
Assignment operator that binds this
and r to the same object if Y* can be implicitly converted to X*.
Definition at line 155 of file Bound_Ptr.h.
References ACE_Bound_Ptr_Counter< ACE_LOCK >::attach_strong(), ACE_Strong_Bound_Ptr< X, ACE_LOCK >::counter_, ACE_Bound_Ptr_Counter< ACE_LOCK >::detach_strong(), and ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ptr_.
00156 { 00157 // This operator is temporarily defined here to increase our chances 00158 // of being accepted by broken compilers. 00159 // 00160 00161 // This will work if &r == this, by first increasing the ref count 00162 00163 COUNTER *new_counter = r.counter_; 00164 X* new_ptr = dynamic_cast<X_t*> (r.ptr_); 00165 COUNTER::attach_strong (new_counter); 00166 if (COUNTER::detach_strong (this->counter_) == 0) 00167 delete this->ptr_; 00168 this->counter_ = new_counter; 00169 this->ptr_ = new_ptr; 00170 00171 return *this; 00172 }
void ACE_Strong_Bound_Ptr< X, ACE_LOCK >::operator= | ( | const ACE_Weak_Bound_Ptr< X, ACE_LOCK > & | r | ) | [inline] |
Assignment operator that binds this
and r to the same object.
Definition at line 209 of file Bound_Ptr.inl.
References ACE_Bound_Ptr_Counter< ACE_LOCK >::attach_strong(), ACE_Strong_Bound_Ptr< X, ACE_LOCK >::counter_, ACE_Weak_Bound_Ptr< X, ACE_LOCK >::counter_, ACE_Bound_Ptr_Counter< ACE_LOCK >::create_strong(), ACE_Bound_Ptr_Counter< ACE_LOCK >::detach_strong(), ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ptr_, and ACE_Weak_Bound_Ptr< X, ACE_LOCK >::ptr_.
00210 { 00211 // This will work if &r == this, by first increasing the ref count, but 00212 // why go through all that? 00213 if (&rhs == this) 00214 return; 00215 00216 COUNTER *new_counter = rhs.counter_; 00217 X_t *new_ptr = rhs.ptr_; 00218 00219 // When creating a strong pointer from a weak one we can't assume that the 00220 // underlying object still exists. Therefore we must check for a return value 00221 // of -1, which indicates that the object has been destroyed. 00222 if (COUNTER::attach_strong (new_counter) == -1) 00223 { 00224 // Underlying object has already been deleted, so set this pointer to null. 00225 new_counter = COUNTER::create_strong (); 00226 new_ptr = 0; 00227 } 00228 00229 if (COUNTER::detach_strong (this->counter_) == 0) 00230 delete this->ptr_; 00231 this->counter_ = new_counter; 00232 this->ptr_ = new_ptr; 00233 }
void ACE_Strong_Bound_Ptr< X, ACE_LOCK >::operator= | ( | const ACE_Strong_Bound_Ptr< X, ACE_LOCK > & | r | ) | [inline] |
Assignment operator that binds this
and r to the same object.
Definition at line 192 of file Bound_Ptr.inl.
References ACE_Bound_Ptr_Counter< ACE_LOCK >::attach_strong(), ACE_Strong_Bound_Ptr< X, ACE_LOCK >::counter_, ACE_Bound_Ptr_Counter< ACE_LOCK >::detach_strong(), and ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ptr_.
00193 { 00194 // This will work if &r == this, by first increasing the ref count, but 00195 // why go through all that? 00196 if (&rhs == this) 00197 return; 00198 00199 COUNTER *new_counter = rhs.counter_; 00200 X_t *new_ptr = rhs.ptr_; 00201 COUNTER::attach_strong (new_counter); 00202 if (COUNTER::detach_strong (this->counter_) == 0) 00203 delete this->ptr_; 00204 this->counter_ = new_counter; 00205 this->ptr_ = new_ptr; 00206 }
bool ACE_Strong_Bound_Ptr< X, ACE_LOCK >::operator== | ( | X * | p | ) | const [inline] |
Equality operator that returns true
if the ACE_Strong_Bound_Ptr and the raw pointer point to the same underlying object.
Definition at line 249 of file Bound_Ptr.inl.
References ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ptr_.
00250 { 00251 return this->ptr_ == p; 00252 }
bool ACE_Strong_Bound_Ptr< X, ACE_LOCK >::operator== | ( | const ACE_Weak_Bound_Ptr< X, ACE_LOCK > & | r | ) | const [inline] |
true
if both objects have just been instantiated and not used yet. Definition at line 242 of file Bound_Ptr.inl.
00243 { 00244 // Use the weak pointer's operator== since it will check for null. 00245 return r == *this; 00246 }
bool ACE_Strong_Bound_Ptr< X, ACE_LOCK >::operator== | ( | const ACE_Strong_Bound_Ptr< X, ACE_LOCK > & | r | ) | const [inline] |
true
if both objects have just been instantiated and not used yet. Definition at line 236 of file Bound_Ptr.inl.
References ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ptr_.
void ACE_Strong_Bound_Ptr< X, ACE_LOCK >::reset | ( | auto_ptr< X > | p | ) | [inline] |
Resets the ACE_Strong_Bound_Ptr to refer to a different underlying object, ownership of which is stolen from the auto_ptr.
Definition at line 309 of file Bound_Ptr.inl.
References ACE_Strong_Bound_Ptr< X, ACE_LOCK >::counter_, ACE_Bound_Ptr_Counter< ACE_LOCK >::create_strong(), ACE_Bound_Ptr_Counter< ACE_LOCK >::detach_strong(), ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ptr_, and ACE_Auto_Basic_Ptr< X >::release().
00310 { 00311 COUNTER *old_counter = this->counter_; 00312 X_t *old_ptr = this->ptr_; 00313 this->counter_ = COUNTER::create_strong (); 00314 this->ptr_ = p.release (); 00315 if (COUNTER::detach_strong (old_counter) == 0) 00316 delete old_ptr; 00317 }
void ACE_Strong_Bound_Ptr< X, ACE_LOCK >::reset | ( | X * | p = 0 |
) | [inline] |
Resets the ACE_Strong_Bound_Ptr to refer to a different underlying object.
Definition at line 298 of file Bound_Ptr.inl.
References ACE_Strong_Bound_Ptr< X, ACE_LOCK >::counter_, ACE_Bound_Ptr_Counter< ACE_LOCK >::create_strong(), ACE_Bound_Ptr_Counter< ACE_LOCK >::detach_strong(), and ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ptr_.
00299 { 00300 COUNTER *old_counter = this->counter_; 00301 X_t *old_ptr = this->ptr_; 00302 this->counter_ = COUNTER::create_strong (); 00303 this->ptr_ = p; 00304 if (COUNTER::detach_strong (old_counter) == 0) 00305 delete old_ptr; 00306 }
friend class ACE_Strong_Bound_Ptr [friend] |
Definition at line 237 of file Bound_Ptr.h.
friend class ACE_Weak_Bound_Ptr< X, ACE_LOCK > [friend] |
Definition at line 234 of file Bound_Ptr.h.
ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ACE_ALLOC_HOOK_DECLARE |
COUNTER* ACE_Strong_Bound_Ptr< X, ACE_LOCK >::counter_ [private] |
The reference counter.
Definition at line 243 of file Bound_Ptr.h.
Referenced by ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ACE_Strong_Bound_Ptr(), ACE_Weak_Bound_Ptr< X, ACE_LOCK >::operator=(), ACE_Strong_Bound_Ptr< X, ACE_LOCK >::operator=(), and ACE_Strong_Bound_Ptr< X, ACE_LOCK >::reset().
X* ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ptr_ [private] |
The underlying object.
Definition at line 246 of file Bound_Ptr.h.
Referenced by ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ACE_Strong_Bound_Ptr(), ACE_Strong_Bound_Ptr< X, ACE_LOCK >::get(), ACE_Strong_Bound_Ptr< X, ACE_LOCK >::null(), ACE_Strong_Bound_Ptr< X, ACE_LOCK >::operator *(), ACE_Weak_Bound_Ptr< X, ACE_LOCK >::operator!=(), ACE_Strong_Bound_Ptr< X, ACE_LOCK >::operator!=(), ACE_Strong_Bound_Ptr< X, ACE_LOCK >::operator->(), ACE_Weak_Bound_Ptr< X, ACE_LOCK >::operator=(), ACE_Strong_Bound_Ptr< X, ACE_LOCK >::operator=(), ACE_Weak_Bound_Ptr< X, ACE_LOCK >::operator==(), ACE_Strong_Bound_Ptr< X, ACE_LOCK >::operator==(), ACE_Strong_Bound_Ptr< X, ACE_LOCK >::reset(), and ACE_Strong_Bound_Ptr< X, ACE_LOCK >::~ACE_Strong_Bound_Ptr().