#include <Bound_Ptr.h>
Collaboration diagram for ACE_Weak_Bound_Ptr< X, ACE_LOCK >:
Public Member Functions | |
ACE_Weak_Bound_Ptr (X *p=0) | |
ACE_Weak_Bound_Ptr (const ACE_Weak_Bound_Ptr< X, ACE_LOCK > &r) | |
Copy constructor binds this and r to the same object. | |
ACE_Weak_Bound_Ptr (const ACE_Strong_Bound_Ptr< X, ACE_LOCK > &r) | |
Constructor binds this and r to the same object. | |
~ACE_Weak_Bound_Ptr (void) | |
Destructor. | |
void | operator= (const ACE_Weak_Bound_Ptr< X, ACE_LOCK > &r) |
Assignment operator that binds this and r to the same object. | |
void | operator= (const ACE_Strong_Bound_Ptr< X, ACE_LOCK > &r) |
Assignment operator that binds this and r to the same object. | |
bool | operator== (const ACE_Weak_Bound_Ptr< X, ACE_LOCK > &r) const |
bool | operator== (const ACE_Strong_Bound_Ptr< X, ACE_LOCK > &r) const |
bool | operator== (X *p) const |
bool | operator!= (const ACE_Weak_Bound_Ptr< X, ACE_LOCK > &r) const |
Inequality operator, which is the opposite of equality. | |
bool | operator!= (const ACE_Strong_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. | |
ACE_Strong_Bound_Ptr< X, ACE_LOCK > | operator-> (void) const |
Redirection operator. | |
ACE_Strong_Bound_Ptr< X, ACE_LOCK > | strong (void) const |
X * | unsafe_get (void) const |
void | reset (X *p=0) |
long | add_ref (void) |
Increment the reference count on the underlying object. | |
long | remove_ref (void) |
int | null (void) const |
Allows us to check for NULL on all ACE_Weak_Bound_Ptr objects. | |
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_Strong_Bound_Ptr< X, ACE_LOCK > |
Unlike ACE_Strong_Bound_Ptr, assigning or copying instances of an ACE_Weak_Bound_Ptr will not automatically increment the reference count of the underlying object. What ACE_Weak_Bound_Ptr does is preserve the knowledge that the object is in fact reference counted, and thus provides an alternative to raw pointers where non-ownership associations must be maintained. When the last instance of an ACE_Strong_Bound_Ptr that references a particular object is destroyed or overwritten, the corresponding ACE_Weak_Bound_Ptr instances are set to NULL.
Definition at line 266 of file Bound_Ptr.h.
|
The ACE_Bound_Ptr_Counter type.
Definition at line 373 of file Bound_Ptr.h. |
|
Definition at line 368 of file Bound_Ptr.h. |
|
Constructor that initializes an ACE_Weak_Bound_Ptr to point to the object <p> immediately. Definition at line 320 of file Bound_Ptr.inl.
|
|
Copy constructor binds
Definition at line 327 of file Bound_Ptr.inl.
|
|
Constructor binds
Definition at line 335 of file Bound_Ptr.inl.
|
|
Destructor.
Definition at line 343 of file Bound_Ptr.inl.
00344 { 00345 COUNTER::detach_weak (this->counter_); 00346 } |
|
Increment the reference count on the underlying object. Returns the new reference count on the object. This function may be used to integrate the bound pointers into an external reference counting mechanism such as those used by COM or CORBA servants. Definition at line 477 of file Bound_Ptr.inl.
00478 {
00479 return COUNTER::attach_strong (counter_);
00480 }
|
|
Allows us to check for NULL on all ACE_Weak_Bound_Ptr objects.
Definition at line 457 of file Bound_Ptr.inl.
00458 { 00459 // A weak pointer must behave as though it is automatically set to null 00460 // if the underlying object has been deleted. 00461 if (COUNTER::object_was_deleted (this->counter_)) 00462 return 1; 00463 00464 return this->ptr_ == 0; 00465 } |
|
Inequality operator, which is the opposite of equality.
Definition at line 426 of file Bound_Ptr.inl.
00427 { 00428 // A weak pointer must behave as though it is automatically set to null 00429 // if the underlying object has been deleted. 00430 if (COUNTER::object_was_deleted (this->counter_)) 00431 return p != 0; 00432 00433 return this->ptr_ != p; 00434 } |
|
Inequality operator, which is the opposite of equality.
Definition at line 415 of file Bound_Ptr.inl. References ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ptr_.
|
|
Inequality operator, which is the opposite of equality.
Definition at line 404 of file Bound_Ptr.inl. References ACE_Weak_Bound_Ptr< X, ACE_LOCK >::ptr_.
|
|
Redirection operator. It returns a temporary strong pointer and makes use of the chaining properties of operator-> to ensure that the underlying object does not disappear while you are using it. If you are certain of the lifetimes of the object, and do not want to incur the locking overhead, then use the unsafe_get method instead. Definition at line 437 of file Bound_Ptr.inl.
00438 { 00439 return ACE_Strong_Bound_Ptr<X, ACE_LOCK> (*this); 00440 } |
|
Assignment operator that binds
Definition at line 360 of file Bound_Ptr.inl. References ACE_Strong_Bound_Ptr< X, ACE_LOCK >::counter_, and ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ptr_.
|
|
Assignment operator that binds
Definition at line 349 of file Bound_Ptr.inl. References ACE_Weak_Bound_Ptr< X, ACE_LOCK >::counter_, and ACE_Weak_Bound_Ptr< X, ACE_LOCK >::ptr_.
|
|
Equality operator that returns Definition at line 393 of file Bound_Ptr.inl.
00394 { 00395 // A weak pointer must behave as though it is automatically set to null 00396 // if the underlying object has been deleted. 00397 if (COUNTER::object_was_deleted (this->counter_)) 00398 return p == 0; 00399 00400 return this->ptr_ == p; 00401 } |
|
Definition at line 382 of file Bound_Ptr.inl. References ACE_Strong_Bound_Ptr< X, ACE_LOCK >::ptr_.
|
|
Definition at line 371 of file Bound_Ptr.inl. References ACE_Weak_Bound_Ptr< X, ACE_LOCK >::ptr_.
|
|
Returns the new reference count on the object. This function may be used to integrate the bound pointers into an external reference counting mechanism such as those used by COM or CORBA servants. Definition at line 483 of file Bound_Ptr.inl.
|
|
Resets the ACE_Weak_Bound_Ptr to refer to a different underlying object. Definition at line 468 of file Bound_Ptr.inl.
|
|
Obtain a strong pointer corresponding to this weak pointer. This function is useful to create a temporary strong pointer for conversion to a reference. Definition at line 443 of file Bound_Ptr.inl.
00444 { 00445 return ACE_Strong_Bound_Ptr<X, ACE_LOCK> (*this); 00446 } |
|
Get the pointer value. Warning: this does not affect the reference count of the underlying object, so it may disappear on you while you are using it if you are not careful. Definition at line 449 of file Bound_Ptr.inl.
00450 { 00451 // We do not check if the object has been deleted, since this operation 00452 // is defined to be unsafe! 00453 return this->ptr_; 00454 } |
|
Definition at line 370 of file Bound_Ptr.h. |
|
Declare the dynamic allocation hooks.
Definition at line 365 of file Bound_Ptr.h. |
|
The reference counter.
Definition at line 376 of file Bound_Ptr.h. Referenced by ACE_Weak_Bound_Ptr< X, ACE_LOCK >::operator=(), and ACE_Strong_Bound_Ptr< X, ACE_LOCK >::operator=(). |
|
The underlying object.
Definition at line 379 of file Bound_Ptr.h. Referenced by ACE_Weak_Bound_Ptr< X, ACE_LOCK >::operator!=(), ACE_Weak_Bound_Ptr< X, ACE_LOCK >::operator=(), ACE_Strong_Bound_Ptr< X, ACE_LOCK >::operator=(), and ACE_Weak_Bound_Ptr< X, ACE_LOCK >::operator==(). |