namespace Akenti template class ref_ptr

This class implements a simple reference counting scheme that simplifies memory management

Inheritance:


Public Methods

ref_ptr (T *pointee = NULL)
Constructs a reference-count pointer
ref_ptr (const ref_ptr& rhs)
Constructs a shallow copy of this object
ref_ptr & operator= (const ref_ptr& rhs)
Assignment operator
~ref_ptr ()
Destructor
T* operator-> () const
Accesses the wrapped pointer
operator void* () const
Overloads the void * pointer for conditional testsing
T* get () const
Returns the wrapped pointer

Documentation

This class implements a simple reference counting scheme that simplifies memory management. The ref_ptr object contains a reference to another object, (the wraped pointer) and a count of how many places this ref_ptr is stored. One should avoid using the wrapped pointer directly. More important, one should never, and I mean never, hold a live reference to wrapped pointer since that will invalidate the reference count in the ref pointer. We do allow null pointers to be wrapped. But the accesor methods throw exceptions when this pointer is null. ref_ptr is defined using class templates, so that you can create a ref_ptr to any class. Most of the Akenti classes that represent data objects are implented as a set of classes. There is a class that should be used for external manipulation of the object and is implemented as a ref_ptr. There is a class that holds the data members implements the methods.By convention the implementation class names end in Impl.
Usage:
class AImpl{
f();
g();
}

ref_ptr aptr( new AImpl);
aptr->f();
aptr->g();
ref_ptr(T *pointee = NULL)
Constructs a reference-count pointer. The ref_cnt starts at 1.
Parameters:
pointee - pointer to be wrapped

ref_ptr(const ref_ptr& rhs)
Constructs a shallow copy of this object. Increments the ref_cnt of rhs by 1.
Parameters:
rhs - the object to be copied

ref_ptr & operator=(const ref_ptr& rhs)
Assignment operator. The ref_cnt of the target pointer is decremented. the ref_cnt of the rhs is incremented.

~ref_ptr()
Destructor. Decrements the ref_cnt and when the ref_cnt is 0, deletes the object that the wrapper pointer references.

T* operator->() const
Accesses the wrapped pointer. This is preferred over the get method. So the objects that are wrapped by ref_ptr such as certificates should be referenced using the ref_ptr e.g. Certificate->getType() rather CertificateImpl.getType()
Throws:
Error if the wrapped object is null
See Also:
get()

operator void*() const
Overloads the void * pointer for conditional testsing
Returns:
pointee

T* get() const
Returns the wrapped pointer.
Throws:
Error if the wrapped object is null
Returns:
pointee


Direct child classes:
URLHandlerFactory
URLHandler
URLConnection
Signature
SSLContext
RevokedCertificate
PublicKey
Provider
PrivateKey
OutputStream
MessageDigest
KeyFactory
InputStream
CertificateRevocationList
CertificateRequestGenerator
CertificateRequest
CertificateGenerator
CertificateFactory
Certificate
Base64
AkentiCRL
Author:
Srilekha Mudumbai Abdelilah Essiari
Version:
1.1 00/05/01

alphabetic index hierarchy of classes


this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de