RSC  0.17.1
rsc::patterns::Factory< Key, Interface > Class Template Reference

Objects of this class manage a family of named implementations of a particular interface. More...

#include <Factory.h>

Inheritance diagram for rsc::patterns::Factory< Key, Interface >:
Inheritance graph
Collaboration diagram for rsc::patterns::Factory< Key, Interface >:
Collaboration graph

Classes

class  ImplMapProxy
 This object presents the registered implementations in a form very similar to a STL container. More...
 

Public Types

typedef FactoryBase< Key > base
 
typedef base::KeyType KeyType
 
typedef Interface InterfaceType
 
typedef boost::function1< InterfaceType *, const runtime::Properties & > CreateFunction
 
typedef std::map< Key, CreateFunctionImplMap
 
typedef base::ImplMap ImplMapBase
 
typedef base::ImplMapProxy ImplMapBaseProxy
 
- Public Types inherited from rsc::patterns::FactoryBase< Key >
typedef Key KeyType
 
typedef boost::function1< void *, const runtime::Properties & > CreateFunction
 
typedef std::pair< const std::type_info *, void * > type_and_storage
 
typedef std::map< Key, CreateFunctionImplMap
 

Public Member Functions

 Factory ()
 
virtual ~Factory ()
 
const std::type_info & GetInterfaceType () const throw ()
 Return the type information of the interface type of the factory. More...
 
const ImplMapBaseProxyimplsBase () const throw ()
 Return a container-like object holding all registered implementations. More...
 
ImplMapProxyimpls () throw ()
 Return a container-like object holding all registered implementations. More...
 
const ImplMapProxyimpls () const throw ()
 Return a container-like object holding all registered implementations. More...
 
FactoryBase< Key >::type_and_storage createBase (const Key &key, const runtime::Properties &properties_=runtime::Properties())
 
Interface * createInst (const Key &key, const runtime::Properties &properties_=runtime::Properties())
 Create and return an instance of the implementation designated by key. More...
 

Protected Member Functions

virtual void register_ (const Key &key, const CreateFunction &create_function_)
 
virtual void unregister (const Key &key)
 

Protected Attributes

ImplMapBase impl_map_base_
 
ImplMapBaseProxy impl_map_base_proxy_
 
ImplMap impl_map_
 
ImplMapProxy impl_map_proxy_
 

Friends

class ImplMapProxy
 

Detailed Description

template<typename Key, typename Interface>
class rsc::patterns::Factory< Key, Interface >

Objects of this class manage a family of named implementations of a particular interface.

See also
FactoryBase
Author
Jan Moringen jmori.nosp@m.nge@.nosp@m.techf.nosp@m.ak.u.nosp@m.ni-bi.nosp@m.elef.nosp@m.eld.d.nosp@m.e

Definition at line 129 of file Factory.h.

Member Typedef Documentation

template<typename Key, typename Interface>
typedef FactoryBase<Key> rsc::patterns::Factory< Key, Interface >::base

Definition at line 131 of file Factory.h.

template<typename Key, typename Interface>
typedef boost::function1<InterfaceType*, const runtime::Properties&> rsc::patterns::Factory< Key, Interface >::CreateFunction

Definition at line 137 of file Factory.h.

template<typename Key, typename Interface>
typedef std::map<Key, CreateFunction> rsc::patterns::Factory< Key, Interface >::ImplMap

Definition at line 139 of file Factory.h.

template<typename Key, typename Interface>
typedef base::ImplMap rsc::patterns::Factory< Key, Interface >::ImplMapBase

Definition at line 141 of file Factory.h.

template<typename Key, typename Interface>
typedef base::ImplMapProxy rsc::patterns::Factory< Key, Interface >::ImplMapBaseProxy

Definition at line 142 of file Factory.h.

template<typename Key, typename Interface>
typedef Interface rsc::patterns::Factory< Key, Interface >::InterfaceType

Definition at line 134 of file Factory.h.

template<typename Key, typename Interface>
typedef base::KeyType rsc::patterns::Factory< Key, Interface >::KeyType

Definition at line 133 of file Factory.h.

Constructor & Destructor Documentation

template<typename Key , typename Interface >
rsc::patterns::Factory< Key, Interface >::Factory ( )

Definition at line 275 of file Factory.h.

template<typename Key , typename Interface >
rsc::patterns::Factory< Key, Interface >::~Factory ( )
virtual

Definition at line 280 of file Factory.h.

Member Function Documentation

template<typename Key , typename Interface >
FactoryBase< Key >::type_and_storage rsc::patterns::Factory< Key, Interface >::createBase ( const Key &  key,
const runtime::Properties properties_ = runtime::Properties() 
)
virtual
Exceptions
NoSuchImpl
ConstructError

Implements rsc::patterns::FactoryBase< Key >.

Definition at line 341 of file Factory.h.

References rsc::patterns::Factory< Key, Interface >::createInst(), and rsc::patterns::detail::make_pair().

Here is the call graph for this function:

template<typename Key , typename Interface >
Interface * rsc::patterns::Factory< Key, Interface >::createInst ( const Key &  key,
const runtime::Properties properties_ = runtime::Properties() 
)

Create and return an instance of the implementation designated by key.

properties_ is passed to the create function.

Parameters
keyThe name of a registered implementation.
properties_A set of properties. The interpretation is up the selected create function.
Returns
A pointer to a newly created instance of the implementation specified by key.
Exceptions
NoSuchImplIf key does not name a registered implementation.
ConstructErrorIf the selected create function produced an exception during execution.

Definition at line 350 of file Factory.h.

References rsc::patterns::Factory< Key, Interface >::impl_map_, rsc::runtime::typeName(), and rsc::runtime::typeString().

Referenced by rsc::patterns::Factory< Key, Interface >::createBase().

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename Key , typename Interface >
const std::type_info & rsc::patterns::Factory< Key, Interface >::GetInterfaceType ( ) const
throw (
)
virtual

Return the type information of the interface type of the factory.

Implements rsc::patterns::FactoryBase< Key >.

Definition at line 285 of file Factory.h.

template<typename Key , typename Interface >
Factory< Key, Interface >::ImplMapProxy & rsc::patterns::Factory< Key, Interface >::impls ( )
throw (
)

Return a container-like object holding all registered implementations.

Definition at line 297 of file Factory.h.

References rsc::patterns::Factory< Key, Interface >::impl_map_proxy_.

Referenced by rsc::patterns::operator<<().

Here is the caller graph for this function:

template<typename Key , typename Interface >
const Factory< Key, Interface >::ImplMapProxy & rsc::patterns::Factory< Key, Interface >::impls ( ) const
throw (
)

Return a container-like object holding all registered implementations.

Definition at line 303 of file Factory.h.

References rsc::patterns::Factory< Key, Interface >::impl_map_proxy_.

template<typename Key , typename Interface >
const Factory< Key, Interface >::ImplMapBaseProxy & rsc::patterns::Factory< Key, Interface >::implsBase ( ) const
throw (
)
virtual

Return a container-like object holding all registered implementations.

Returns
A constant reference to the implementation list proxy.

Implements rsc::patterns::FactoryBase< Key >.

Definition at line 291 of file Factory.h.

References rsc::patterns::Factory< Key, Interface >::impl_map_base_proxy_.

template<typename Key , typename Interface >
void rsc::patterns::Factory< Key, Interface >::register_ ( const Key &  key,
const CreateFunction create_function_ 
)
protectedvirtual
Exceptions
std::invalid_

Definition at line 308 of file Factory.h.

References rsc::patterns::Factory< Key, Interface >::impl_map_, rsc::patterns::Factory< Key, Interface >::impl_map_base_, and rsc::runtime::typeString().

Referenced by rsc::patterns::ObservableFactory< Key, Interface >::register_().

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename Key , typename Interface >
void rsc::patterns::Factory< Key, Interface >::unregister ( const Key &  key)
protectedvirtual
Exceptions
NoSuchImpl

Reimplemented in rsc::patterns::ObservableFactory< Key, Interface >.

Definition at line 322 of file Factory.h.

References rsc::patterns::Factory< Key, Interface >::impl_map_, rsc::patterns::Factory< Key, Interface >::impl_map_base_, and rsc::runtime::typeString().

Referenced by rsc::patterns::ObservableFactory< Key, Interface >::unregister().

Here is the call graph for this function:

Here is the caller graph for this function:

Friends And Related Function Documentation

template<typename Key, typename Interface>
friend class ImplMapProxy
friend

Definition at line 174 of file Factory.h.

Member Data Documentation

template<typename Key, typename Interface>
ImplMapBase rsc::patterns::Factory< Key, Interface >::impl_map_base_
protected
template<typename Key, typename Interface>
ImplMapBaseProxy rsc::patterns::Factory< Key, Interface >::impl_map_base_proxy_
protected

Definition at line 225 of file Factory.h.

Referenced by rsc::patterns::Factory< Key, Interface >::implsBase().

template<typename Key, typename Interface>
ImplMapProxy rsc::patterns::Factory< Key, Interface >::impl_map_proxy_
protected

Definition at line 228 of file Factory.h.

Referenced by rsc::patterns::Factory< Key, Interface >::impls().


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