libpgplotxx.a (C++ interface to PGPLOT)
pgplot::HandleOfConst< X > Class Template Reference

Base class for handles. More...

#include <pghandle.h>

Inheritance diagram for pgplot::HandleOfConst< X >:

Public Types

Typedefs for class template HandleOfConst.
Note
typedef const X* Tpointer_to_const;
is not the same as
typedef X Tvalue
 
typedef X * Tpointer
 
typedef X & Treference
 
typedef const X * Tpointer_to_const
 
typedef const X & Treference_to_const
 
typedef HandleOfConst< TvalueTcontainer
 
typedef Tcontainer Tcontainer_of_const
 
typedef Tcontainer_of_const Tcoc
 

Public Member Functions

 ~HandleOfConst ()
 Destructor that takes care of reference count. More...
 
template<class Y >
Tcontaineroperator= (const HandleOfConst< Y > &h)
 Assignement operator that provide transparency for inheritance. More...
 
Constructors
 HandleOfConst ()
 Default constructor if class X provides one too. More...
 
 HandleOfConst (Treference_to_const x)
 Constructor to initialize the handle. More...
 
template<class Y >
 HandleOfConst (const HandleOfConst< Y > &h)
 Copy constructor that provides transparency for inheritance. More...
 
Read access operators
Tpointer_to_const operator-> () const
 Read access operator with pointer semantics. More...
 
Treference_to_const operator* () const
 Read access operator with pointer semantics. More...
 

Protected Member Functions

Write access operators must be protected
Tpointer pointer () const
 expose the pointer to derived classes More...
 
Treference reference () const
 expose the object to derived classes More...
 

Private Attributes

Tpointer Mpointer
 internal pointer to the handled object More...
 
int * Mpcount
 reference counter More...
 

Friends

template<class Y >
class HandleOfConst
 friend declaration to other Handle templates is essential for inheritance transparency. More...
 

Detailed Description

template<class X>
class pgplot::HandleOfConst< X >

Base class for handles.

The base class is necessary to promise constness for values that are passed around using handles. Consider a code that uses a handle to pass the contents of a class of type A as defined by

class A {
...
};
Handle<A> a;

A function sample can accept a handle providing access to the values of type A but promising not to changes these values if declared

void sample(const Handle<A>::Tcontainer_of_const& h);

or briefly

void sample(const Handle<A>::Tcoc& h);

Declaring the function

void sample(const Handle<A>& h);

is not sufficient, since this only promises constness of the handle but not of the values that can be accessed through the handle.

See also
Example code is available in pgtestxx.cc
Therein example code is available in functions testhandle() and testhandlefunction()

Definition at line 85 of file pghandle.h.


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