Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

classload.hpp File Reference

#include <s11n.net/s11n/s11n_debuggering_macros.hpp>
#include <s11n.net/s11n/factory.hpp>
#include <s11n.net/s11n/exception.hpp>
#include <s11n.net/s11n/type_traits.hpp>
#include <s11n.net/s11n/s11n_config.hpp>
#include <s11n.net/s11n/classload.tpp>

Go to the source code of this file.

Namespaces

namespace  s11n
namespace  s11n::cl
namespace  s11n::cl::Detail

Defines

#define s11n_cl_S11N_CLASSLOAD_HPP_INCLUDED   1

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 T>
T * noop_factory ()
 Internal no-op 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).


Define Documentation

#define s11n_cl_S11N_CLASSLOAD_HPP_INCLUDED   1
 

Definition at line 2 of file classload.hpp.


Function Documentation

template<typename InterfaceBase>
InterfaceBase* classload const std::string  key  ) 
 

Returns object_factory<InterfaceBase>()(key).

template<typename InterfaceBase>
void 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).

Added in 1.1.0.

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

Definition at line 216 of file classload.hpp.

template<typename InterfaceBase>
void classloader_register const std::string &  classname,
InterfaceBase *(*)()  factory_func
 

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 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, or the registrations will go to the subtype's classloader, which isn't what you want to do.

Definition at line 196 of file classload.hpp.

template<typename InterfaceBase>
void 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 168 of file classload.hpp.

template<typename InterfaceBase, typename SubType>
void 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 154 of file classload.hpp.

template<typename T>
T* noop_factory  )  [inline]
 

Internal no-op factory.

Always returns 0.

Definition at line 178 of file classload.hpp.


Generated on Thu Sep 29 20:01:15 2005 for libs11n-1.1.3-dev by  doxygen 1.4.1