Opm::Factory< Base > Class Template Reference

#include <Factory.hpp>

Public Types

typedef std::shared_ptr< Base > ProductPtr
 The type of pointer returned by createObject(). More...
 

Static Public Member Functions

static ProductPtr createObject (const std::string &type)
 
static ProductPtr cloneObject (const std::string &type, const ProductPtr original)
 
template<class Derived >
static void addCreator (const std::string &type)
 

Detailed Description

template<class Base>
class Opm::Factory< Base >

This is an object factory for creating objects of some type requested by the user, with a shared base class. The user need only interact with the factory through the static template member addCreator() and the static member function createObject().

Member Typedef Documentation

template<class Base >
typedef std::shared_ptr<Base> Opm::Factory< Base >::ProductPtr

The type of pointer returned by createObject().

Member Function Documentation

template<class Base >
template<class Derived >
static void Opm::Factory< Base >::addCreator ( const std::string &  type)
inlinestatic

Add a creator to the Factory. After the call, the user may obtain new objects of the Derived type by calling createObject() with the given type string as an argument.

Template Parameters
Derivedthe class we want to add a creator for, must inherit the class template parameter Base.
Parameters
typethe type string with which we want the Factory to associate the class Derived.
template<class Base >
static ProductPtr Opm::Factory< Base >::cloneObject ( const std::string &  type,
const ProductPtr  original 
)
inlinestatic

Clones an new object of the class associated with the given type string, and returns a pointer to it.

Parameters
typethe type string of the class that the user wants to have constructed.
original(smart) pointer to object to be cloned.
Returns
(smart) pointer to the created object.
template<class Base >
static ProductPtr Opm::Factory< Base >::createObject ( const std::string &  type)
inlinestatic

Creates a new object of the class associated with the given type string, and returns a pointer to it.

Parameters
typethe type string of the class that the user wants to have constructed.
Returns
(smart) pointer to the created object.

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