#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 and to the same object. | |
ACE_Strong_Bound_Ptr (const ACE_Weak_Bound_Ptr< X, ACE_LOCK > &r) | |
Constructor binds and to the same object. | |
~ACE_Strong_Bound_Ptr (void) | |
Destructor. | |
void | operator= (const ACE_Strong_Bound_Ptr< X, ACE_LOCK > &r) |
Assignment operator that binds and to the same object. | |
void | operator= (const ACE_Weak_Bound_Ptr< X, ACE_LOCK > &r) |
Assignment operator that binds and to the same object. | |
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 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 > |
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 111 of file Bound_Ptr.h.
|
The ACE_Bound_Ptr_Counter type.
Definition at line 198 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 >::operator=(), and ACE_Strong_Bound_Ptr< X, ACE_LOCK >::reset(). |
|
Constructor that initializes an ACE_Strong_Bound_Ptr to point to the object <p> immediately. Definition at line 147 of file Bound_Ptr.inl. References ACE_Strong_Bound_Ptr< X, ACE_LOCK >::COUNTER.
|
|
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. References ACE_Strong_Bound_Ptr< X, ACE_LOCK >::COUNTER.
|
|
Copy constructor binds and to the same object.
Definition at line 161 of file Bound_Ptr.inl.
|
|
Constructor binds and to the same object.
Definition at line 169 of file Bound_Ptr.inl. References 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 } |
|
Destructor.
Definition at line 185 of file Bound_Ptr.inl. References ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ptr_.
00186 { 00187 if (COUNTER::detach_strong (this->counter_) == 0) 00188 delete this->ptr_; 00189 } |
|
Get the pointer value.
Definition at line 280 of file Bound_Ptr.inl. References ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ptr_.
00281 { 00282 return this->ptr_; 00283 } |
|
Allows us to check for NULL on all ACE_Strong_Bound_Ptr objects. Definition at line 286 of file Bound_Ptr.inl. References ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ptr_.
00287 { 00288 return this->ptr_ == 0; 00289 } |
|
Dereference 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 } |
|
Inequality operator, which is the opposite of equality.
Definition at line 262 of file Bound_Ptr.inl. References ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ptr_.
00263 { 00264 return this->ptr_ != p; 00265 } |
|
Inequality operator, which is the opposite of equality.
Definition at line 255 of file Bound_Ptr.inl.
00256 { 00257 // Use the weak pointer's operator!= since it will check for null. 00258 return r != *this; 00259 } |
|
Inequality operator, which is the opposite of equality.
Definition at line 249 of file Bound_Ptr.inl. References ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ptr_.
|
|
Redirection operator.
Definition at line 268 of file Bound_Ptr.inl. References ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ptr_.
00269 { 00270 return this->ptr_; 00271 } |
|
Assignment operator that binds and to the same object.
Definition at line 206 of file Bound_Ptr.inl. References ACE_Strong_Bound_Ptr< X, ACE_LOCK >::COUNTER, ACE_Weak_Bound_Ptr< X, ACE_LOCK >::counter_, ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ptr_, and ACE_Weak_Bound_Ptr< X, ACE_LOCK >::ptr_.
00207 { 00208 // This will work if &r == this, by first increasing the ref count 00209 00210 COUNTER *new_counter = rhs.counter_; 00211 X* new_ptr = rhs.ptr_; 00212 00213 // When creating a strong pointer from a weak one we can't assume that the 00214 // underlying object still exists. Therefore we must check for a return value 00215 // of -1, which indicates that the object has been destroyed. 00216 if (COUNTER::attach_strong (new_counter) == -1) 00217 { 00218 // Underlying object has already been deleted, so set this pointer to null. 00219 new_counter = COUNTER::create_strong (); 00220 new_ptr = 0; 00221 } 00222 00223 if (COUNTER::detach_strong (this->counter_) == 0) 00224 delete this->ptr_; 00225 this->counter_ = new_counter; 00226 this->ptr_ = new_ptr; 00227 } |
|
Assignment operator that binds and to the same object.
Definition at line 192 of file Bound_Ptr.inl. References ACE_Strong_Bound_Ptr< X, ACE_LOCK >::COUNTER, ACE_Strong_Bound_Ptr< X, ACE_LOCK >::counter_, and ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ptr_.
00193 { 00194 // This will work if &r == this, by first increasing the ref count 00195 00196 COUNTER *new_counter = rhs.counter_; 00197 X* new_ptr = rhs.ptr_; 00198 COUNTER::attach_strong (new_counter); 00199 if (COUNTER::detach_strong (this->counter_) == 0) 00200 delete this->ptr_; 00201 this->counter_ = new_counter; 00202 this->ptr_ = new_ptr; 00203 } |
|
Equality operator that returns Definition at line 243 of file Bound_Ptr.inl. References ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ptr_.
00244 { 00245 return this->ptr_ == p; 00246 } |
|
Definition at line 236 of file Bound_Ptr.inl.
00237 { 00238 // Use the weak pointer's operator== since it will check for null. 00239 return r == *this; 00240 } |
|
Definition at line 230 of file Bound_Ptr.inl. References ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ptr_.
|
|
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 303 of file Bound_Ptr.inl. References ACE_Strong_Bound_Ptr< X, ACE_LOCK >::COUNTER, ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ptr_, and ACE_Auto_Basic_Ptr< X >::release().
|
|
Resets the ACE_Strong_Bound_Ptr to refer to a different underlying object. Definition at line 292 of file Bound_Ptr.inl. References ACE_Strong_Bound_Ptr< X, ACE_LOCK >::COUNTER, and ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ptr_.
|
|
Definition at line 195 of file Bound_Ptr.h. |
|
Declare the dynamic allocation hooks.
Definition at line 192 of file Bound_Ptr.h. |
|
The reference counter.
Definition at line 201 of file Bound_Ptr.h. Referenced by ACE_Weak_Bound_Ptr< X, ACE_LOCK >::operator=(), and ACE_Strong_Bound_Ptr< X, ACE_LOCK >::operator=(). |
|