s11n::cl Namespace Reference

The s11n::cl namespace encapsulates the public classloader-related API for libs11n. More...

Namespaces

namespace  Detail

Classes

struct  object_factory
 A default object factory functor for use with the s11n::s11n_traits type. More...

Functions

template<typename InterfaceBase >
InterfaceBase * classload (const std::string key)
 Returns object_factory<InterfaceBase>(key).
template<typename InterfaceBase >
void classloader_register (const std::string &classname, InterfaceBase *(*factory_func)())
 Registers a factory with InterfaceBase's classloader.
template<typename InterfaceBase , typename SubType >
void classloader_register_subtype (const std::string &classname)
 Registers a default factory which returns a SubType object.
template<typename InterfaceBase >
void classloader_register_base (const std::string &classname)
 Registers InterfaceBase with its own classloader using a default factory.
template<typename InterfaceBase >
void classloader_register_abstract (const std::string &classname)
 Registers InterfaceBase as an abstract type.
template<typename InterfaceBase >
void classloader_alias (const std::string &_alias, const std::string &classname)
 Aliases the given classname with the underlying factory layer, such that classload<InterfaceBase>(_alias) will return the same as classload<InterfaceBase>(classname).

Detailed Description

The s11n::cl namespace encapsulates the public classloader-related API for libs11n.

Note that the registration functions in this namespace register with the s11n::fac family of classes. Clients wishing to use their own factories should:

This layer is used for classloading anything which s11n needs to dynamically load, including:

It supports loading types via DLLs if the optional s11n::plugin layer is enabled.

Changes from 1.0.x to 1.1.x:

Changed in 1.2.2:


Function Documentation

template<typename InterfaceBase >
InterfaceBase* s11n::cl::classload ( const std::string  key  )  [inline]

Returns object_factory<InterfaceBase>(key).

template<typename InterfaceBase >
void s11n::cl::classloader_alias ( const std::string &  _alias,
const std::string &  classname 
) [inline]

Aliases the given classname with the underlying factory layer, such that classload<InterfaceBase>(_alias) will return the same as classload<InterfaceBase>(classname).

A tip for remembering the order of the arguments: it follows the same order as when assigning an alias via a Unix shell: alias thealias="the original string"

Added in 1.1.0.

Maintenance reminder: this function relies directly on the s11n::fac API, which isn't "really" public. This functionality is commonly useful when hand-registering types, thus we have a public-API wrapper around this fac-layer-specific feature.

Definition at line 184 of file classload.hpp.

template<typename InterfaceBase >
void s11n::cl::classloader_register ( const std::string &  classname,
InterfaceBase *(*)()  factory_func 
) [inline]

Registers a factory with InterfaceBase's classloader.

Trivia: 'register' is a reserved word in C++, inherited from C, so this function has an unduly long name. register() was the first choice.

template<typename InterfaceBase >
void s11n::cl::classloader_register_abstract ( const std::string &  classname  )  [inline]

Registers InterfaceBase as an abstract type.

That is, it assigns it a factory which always returns 0.

If types you register with classloader_register() (and friends) have an abstract InterfaceBase then that InterfaceBase should be registered via this function (or equivalent).

Note that this is also suitable for registering abstract subtypes of an abstract type, but InterfaceBase MUST be the type passed here (not the subtype's type), or the registrations will go to the subtype's classloader, which normally isn't what you want to do.

Definition at line 160 of file classload.hpp.

template<typename InterfaceBase >
void s11n::cl::classloader_register_base ( const std::string &  classname  )  [inline]

Registers InterfaceBase with its own classloader using a default factory.

InterfaceBase must be creatable with 'new', or the default factory implementation must be specialized to accomodate the abstract class.

Definition at line 130 of file classload.hpp.

template<typename InterfaceBase , typename SubType >
void s11n::cl::classloader_register_subtype ( const std::string &  classname  )  [inline]

Registers a default factory which returns a SubType object.

SubType must be a public subtype of InterfaceBase, or must be InterfaceBase, and must not be abstract.

Definition at line 116 of file classload.hpp.


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