s11n::fac Namespace Reference

The s11n::fac namespace contains s11n's "private" object factory manager. More...

Namespaces

namespace  Detail

Classes

struct  create_hook
 create_hook is a helper object factory for the factory_mgr API. More...
class  aliaser
 A helper class to alias one token to another. More...
class  factory_mgr
 The factory_mgr class is essentially a static classloader, capable of loading classes by using registered factories for a given set of keys (e.g., class names). More...

Functions

template<typename InterfaceT >
factory_mgr< InterfaceT,
std::string > & 
factory ()
 Returns factory_mgr<InterfaceT, std::string>::instance().
template<typename InterfaceT >
void register_factory (const std::string &classname, InterfaceT *(*factory_function)())
 Registers classname with InterfaceT using the given factory.
template<typename InterfaceT >
void register_factory (const std::string &classname)
 Registers classname with InterfaceT using a default factory: create_hook<InterfaceT,ImplT>::create().
template<typename InterfaceT , typename ImplT >
void register_subtype (const std::string &classname)
 Registers a factory creating ImplT objects with the InterfaceT classloader using a default factory.
template<typename InterfaceT >
void register_abstract (const std::string &classname)
 Registers a no-op factory for the given name and InterfaceT.
template<typename InterfaceT >
InterfaceT * create (const std::string &classname)
 Returns the same as factory<InterfaceT>().create( classname ).

Detailed Description

The s11n::fac namespace contains s11n's "private" object factory manager.

This code should not be considered to be part of the public APIs: use the s11n::cl API for your factory-related needs unless absolutely necessary. Unfortunately, classloading can be intrusive enough that this API might sometimes need to be leaked into client- or non-core library code. The example which immediately comes to mind is clients which want to get a list of all registered factories: this can only be done by querying the factory itself for them.

The factory manager layer acts as a registration point for factories for near-arbitrary classes. Classes compatible with this layer must currently meet the following requirements:


Function Documentation

template<typename InterfaceT >
InterfaceT* s11n::fac::create ( const std::string &  classname  )  [inline]
template<typename InterfaceT >
factory_mgr<InterfaceT, std::string>& s11n::fac::factory (  )  [inline]

Returns factory_mgr<InterfaceT, std::string>::instance().

All s11n-internal factory_mgr operations operate on one of these objects.

Definition at line 517 of file factory.hpp.

References s11nlite::instance().

template<typename InterfaceT >
void s11n::fac::register_abstract ( const std::string &  classname  )  [inline]

Registers a no-op factory for the given name and InterfaceT.

The factory will always return 0.

Definition at line 578 of file factory.hpp.

References register_factory().

template<typename InterfaceT >
void s11n::fac::register_factory ( const std::string &  classname  )  [inline]

Registers classname with InterfaceT using a default factory: create_hook<InterfaceT,ImplT>::create().

If ImplT is abstract then this function will fail unless create_hook is specialized to not create an object.

Definition at line 542 of file factory.hpp.

References register_factory().

template<typename InterfaceT >
void s11n::fac::register_factory ( const std::string &  classname,
InterfaceT *(*)()  factory_function 
) [inline]

Registers classname with InterfaceT using the given factory.

Definition at line 528 of file factory.hpp.

Referenced by register_abstract(), register_factory(), and register_subtype().

template<typename InterfaceT , typename ImplT >
void s11n::fac::register_subtype ( const std::string &  classname  )  [inline]

Registers a factory creating ImplT objects with the InterfaceT classloader using a default factory.

ImplT may not be abstract unless create_hook<InterfaceT,ImplT> is specialized such that it's create() function simply returns 0 (or otherwise does not call: new ImplT).

Definition at line 556 of file factory.hpp.

References register_factory().


Generated on Sat Mar 20 12:29:25 2010 for libs11n-1.2.10 by  doxygen 1.6.1