libpqxx  v4.0-1
C++ library for PostgreSQL
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pqxx::internal::callgate< HOME > Class Template Reference

Base class for call gates. More...

#include <callgate.hxx>

Collaboration diagram for pqxx::internal::callgate< HOME >:

Protected Types

typedef HOME & reference
 A reference to the host class. Helps keep constructors easy. More...
 
typedef callgate< HOME > super
 This class, to keep constructors easy. More...
 

Protected Member Functions

 callgate (reference x)
 
reference home () const throw ()
 The home object. The gate class has full "private" access. More...
 

Private Attributes

reference m_home
 

Detailed Description

template<typename HOME>
class pqxx::internal::callgate< HOME >

Base class for call gates.

A call gate defines a limited, private interface on the host class that specified client classes can access.

The metaphor works as follows: the gate stands in front of a "home," which is really a class, and only lets specific friends in.

To implement a call gate that gives client C access to host H,

  • derive a gate class from callgate<H>;
  • make the gate class a friend of H;
  • make C a friend of the gate class; and
  • implement "stuff C can do with H" as private members in the gate class.

This special kind of "gated" friendship gives C private access to H, but only through an expressly limited interface. The gate class can access its host object as home().

Keep gate classes entirely stateless. They should be ultra-lightweight wrappers for their host classes, and be optimized away as much as possible by the compiler. Once you start adding state, you're on a slippery slope away from the pure, clean, limited interface pattern that gate classes are meant to implement.

Ideally, all member functions of the gate class should be one-liners passing calls straight on to the host class. It can be useful however to break this rule temporarily during inter-class refactoring.

Member Typedef Documentation

template<typename HOME>
typedef HOME& pqxx::internal::callgate< HOME >::reference
protected

A reference to the host class. Helps keep constructors easy.

template<typename HOME>
typedef callgate<HOME> pqxx::internal::callgate< HOME >::super
protected

This class, to keep constructors easy.

Constructor & Destructor Documentation

template<typename HOME>
pqxx::internal::callgate< HOME >::callgate ( reference  x)
inlineprotected

Member Function Documentation

template<typename HOME>
reference pqxx::internal::callgate< HOME >::home ( ) const throw ()
inlineprotected

The home object. The gate class has full "private" access.

Member Data Documentation

template<typename HOME>
reference pqxx::internal::callgate< HOME >::m_home
private

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