TF++, Miscellaneous classes and modules in C++:
tfxx::ConstHandle< X > Class Template Reference

template #tfxx::THandle<class TObj>#: More...

#include <handle.h>

Inheritance diagram for tfxx::ConstHandle< X >:

Public Types

typedef X Tmutableobject
 
typedef const X Tobject
 
typedef ConstHandle< TobjectTcontainer
 
typedef Tcontainer Tcoc
 
typedef Tcoc Tcontainer_of_const
 
typedef const TobjectTpointer
 
typedef const TobjectTreference
 

Public Member Functions

 ConstHandle (Treference p)
 constructor #tfxx::THandle<class X>::THandle#: More...
 
 ConstHandle (Tmutableobject *p)
 
 ConstHandle (const ConstHandle &h)
 constructor #tfxx::THandle<class X>::THandle#: More...
 
 ~ConstHandle ()
 desctructor #tfxx::THandle<class X>::~THandle# book-keeping destructor More...
 
Tpointer operator-> () const
 operator #tfxx::THandle<class X>::operator->()# More...
 
Treference operator* () const
 operator #tfxx::THandle<class X>::operator*()# More...
 
ConstHandleoperator= (const ConstHandle &h)
 operator #tfxx::THandle<class X>::operator=()# book-keeping asignment operator More...
 

Protected Member Functions

Tmutableobjectpointer () const
 expose the pointer to derived classes More...
 
Tmutableobjectreference () const
 expose the object to derived classes More...
 

Private Attributes

TmutableobjectMrep
 internal pointer to the handled object More...
 
int * Mpcount
 usage counter More...
 

Detailed Description

template<class X>
class tfxx::ConstHandle< X >

template #tfxx::THandle<class TObj>#:

THandle is a class template published by B. Stroustrup in Chapter 25.7 of "The C++ programming Language" (3rd edition). This is a slightly modified version.

Example: To create a handle #hs# to a string #s# and then output the string value you would code:

#THandle<string> hs(new string(s)); cout << *hs << endl;#

Thus the handle always represents a kind of pointer to your string. You may copy and pass this pointer as you like. And all these copies will allocated just memory for that pointer and any modification applied to the string will be accessible through every of these handles. However if the last handle is removed during program execution it will also remove the string representation from the memory. This is an convenient way to pass large objects without worrying about memory usage and management.

It is not possible to create an empty handle - that wouldn't make any sense. You always have to provide another handle to copy from or an element to be handled.

See also
tfxx::Handle
Author
Bjarne Stroustrup,
Thomas Forbriger
Version
V1.0 (#$Revision: 1.6 $
Date
2006-03-28 18:14:15

#) template providing a handle to an object of any type

Definition at line 82 of file handle.h.


The documentation for this class was generated from the following file: