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

The handle class. More...

#include <pghandle.h>

Inheritance diagram for pgplot::Handle< X >:
Collaboration diagram for pgplot::Handle< X >:

Public Types

Typedefs for class template Handle.
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< TvalueTbase
 
typedef Handle< TvalueTcontainer
 
typedef Tbase Tcontainer_of_const
 
typedef Tcontainer_of_const Tcoc
 

Public Member Functions

template<class Y >
Tcontaineroperator= (const Handle< Y > &h)
 Assignement operator providing transparency to inheritance. More...
 
Constructors

Action is provided by base class.

 Handle ()
 Default constructor. More...
 
 Handle (Treference_to_const x)
 Initializing constructor. More...
 
template<class Y >
 Handle (const Handle< Y > &h)
 Copy constructor providing transparency to inheritance. More...
 
Write access operators.
Tpointer operator-> () const
 Write access operator with pointer semantics. More...
 
Treference operator* () const
 Write 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...
 

Detailed Description

template<class X>
class pgplot::Handle< X >

The handle class.

This handle class provides transparency to class inheritance. Consider a base class A

class A {
...
};

and a derived class B

class B: public A {
public:
// constructor
B(const int& i, const int& j);
...
};

where the contstructor is just an example to illustrate code below. If you want to provide access to the same instance of B at more than one locations within your code, it is safe to use a Handle<B> that can be initialized in a straight forward way like

Handle<B> b(B(3,4));

The value b can be passed around safely, providing access to the contained value of type B with pointer semantics. No consider a function

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

that accepts a handle to the base class you can simply call this function by

sample(b);

and the contents of the object of type B will be available within function sample through virtual functions.

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

Definition at line 219 of file pghandle.h.


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