ork::Factory< K, C > Class Template Reference
[core]

A factory to create and destroy shared objects. More...

#include <Factory.h>

Inheritance diagram for ork::Factory< K, C >:
ork::Object

List of all members.

Public Types

typedef C(* constructor )(K key)
 Function pointer to the factory objects constructor.

Public Member Functions

 Factory (constructor ctor)
 Creates a factory that creates objects from keys with the given constructor function.
get (K key)
 Returns the object corresponding to the given key.
void put (K key)
 Releases the object corresponding to the given key.

Detailed Description

template<typename K, typename C>
class ork::Factory< K, C >

A factory to create and destroy shared objects.

Each object is constructed from a key, and is destructed when it is no longer used. Clients of this factory must call get to get the object corresponding to a given key, and must call put when this object is no longer used. The object will be destroyed automatically when all clients have called put (if this object is managed via smart pointers).


Member Typedef Documentation

template<typename K, typename C>
typedef C(* ork::Factory< K, C >::constructor)(K key)

Function pointer to the factory objects constructor.


Constructor & Destructor Documentation

template<typename K , typename C >
ork::Factory< K, C >::Factory ( constructor  ctor  )  [inline]

Creates a factory that creates objects from keys with the given constructor function.

Parameters:
ctor a constructor function.

Member Function Documentation

template<typename K, typename C >
C ork::Factory< K, C >::get ( key  )  [inline]

Returns the object corresponding to the given key.

If this object does not exist yet it is created with the constructor function of this factory. Otherwise a reference counter is incremented to know when this object is no longer used.

template<typename K, typename C >
void ork::Factory< K, C >::put ( key  )  [inline]

Releases the object corresponding to the given key.

If the reference count of this object becomes 0, the object is automatically destroyed.


Generated on Mon Oct 18 09:36:07 2010 for ork by  doxygen 1.6.1