Rogue Wave Views Foundation Package API Reference Guide |
Rogue Wave Views Documentation Home |
Non-intrusive Reference Counter smart pointer. More...
#include <ilviews/util/refcount.h>
Inherited by IlvInitializedRefCountPtr< LOCKABLE >.
Public Member Functions | |
ILVEXPLICIT | IlvRefCountPtr (LOCKABLE *ptr=0) |
The default constructor. More... | |
IlvRefCountPtr (const IlvRefCountPtr &src) | |
The copy constructor. More... | |
~IlvRefCountPtr () | |
The destructor. More... | |
LOCKABLE * | get () const |
This function returns a pointer to the object pointed to by this instance. More... | |
LOCKABLE & | operator* () const |
The dereference operator. More... | |
LOCKABLE * | operator-> () const |
The structure pointer dereference operator. More... | |
IlvRefCountPtr & | operator= (const IlvRefCountPtr &src) |
The assignment operator from another IlvRefCountPtr . More... | |
IlvRefCountPtr & | operator= (LOCKABLE *ptr) |
The assignment operator from a pointer to an object. More... | |
Non-intrusive Reference Counter smart pointer.
Library: xviews or winviews or mviews (mutually exclusive)
This template class is adapted from the class shared_ptr
of Boost
. A counter keeps the number of references to this object. As soon as the counter is decreased to 0
, the object is deleted. Of course the only way to reference this object must be by means of an IlvRefCountPtr
, otherwise dangling pointers could exist.
ILVEXPLICIT IlvRefCountPtr< LOCKABLE >::IlvRefCountPtr | ( | LOCKABLE * | ptr = 0 | ) |
The default constructor.
This constructor should be called only once for an object. Other instances must be built by the copy constructor.
ptr | A pointer to an object of type LOCKABLE given as parameter of the template. |
IlvRefCountPtr< LOCKABLE >::IlvRefCountPtr | ( | const IlvRefCountPtr< LOCKABLE > & | src | ) |
The copy constructor.
This constructor is called to create a new instance that will share the same object as src. The counter is incremented.
src | A const reference to an IlvRefCountPtr of the same type LOCKABLE given as parameter of the template. |
IlvRefCountPtr::IlvRefCountPtr(LOCKABLE* ptr = 0)
. IlvRefCountPtr< LOCKABLE >::~IlvRefCountPtr | ( | ) |
The destructor.
The destructor first decrements the counter. If the count reaches 0
, the object pointed to by this instance is deleted.
LOCKABLE* IlvRefCountPtr< LOCKABLE >::get | ( | ) | const |
This function returns a pointer to the object pointed to by this instance.
LOCKABLE& IlvRefCountPtr< LOCKABLE >::operator* | ( | ) | const |
The dereference operator.
This operator returns a reference to the object pointed to by this instance. It lets this class behave as if it were a pointer.
LOCKABLE* IlvRefCountPtr< LOCKABLE >::operator-> | ( | ) | const |
The structure pointer dereference operator.
This operator returns a pointer to the object pointed to by this instance. It lets this class behave as if it was a pointer.
IlvRefCountPtr& IlvRefCountPtr< LOCKABLE >::operator= | ( | const IlvRefCountPtr< LOCKABLE > & | src | ) |
The assignment operator from another IlvRefCountPtr
.
This operator stores the pointer to the object and the counter of src. The counter is incremented. If a previous object was already pointed to, then its counter is decremented, and the object is deleted in case the counter reaches 0
.
src | A const reference to this IlvRefCountPtr . |
IlvRefCountPtr& IlvRefCountPtr< LOCKABLE >::operator= | ( | LOCKABLE * | ptr | ) |
The assignment operator from a pointer to an object.
This operator stores a pointer to the object with a counter set to 1
. If a previous object was already pointed to, then its counter is decremented, and the object is deleted in case the counter reaches 0
.
WARNINGAn object already associated with an instance of IlvRefCountPtr
must never be assigned to another instance of IlvRefCountPtr
with this operator. It must be done through the other form of the operator=.
ptr | A pointer to a LOCKABLE object to be pointed to. |
© Copyright 2018, Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.