Sierra Toolkit Version of the Day
sierra::Plugin::UserPlugin< Creator, S > Class Template Reference

#include <UserPlugin.hpp>

List of all members.

Classes

class  Register
 Class template Register registers the createInstance() function with the derived_name on object creation. More...

Public Types

typedef S Signature
 Creator signature.

Static Public Member Functions

static UserPlugininstance ()
 Member function instance returns the instance of the registry, cast as a UserPlugin registry..
static void registerCreator (const std::string &derived_name, Signature function)
 Member function registerCreator registers the base class name and specified derived class name with the specified creator function.
static Signature create (const std::string &derived_name)
 Member function create returns the createInstance() function associated with the specified base class and derived_name.
static Signature create (int derived_id)
 Member function create returns the createInstance() function associated with the specified base class and derived_name.
static bool exists (const std::string &derived_name)
 Member function exists returns true if class of the type specified by derived_name exists in BaseClass.
static std::vector< std::string > getDerivedNames ()

Detailed Description

template<class Creator, typename S = Creator *(*)()>
class sierra::Plugin::UserPlugin< Creator, S >

Template class UserPlugin is a template used for the association of base and derived classed to be registered and created via the UserPlugin mechanism. The template traits enforces the signature matching of the base class constructor, derived class constructor, derived class creator static function and the usage of the creator static function.

The registration requires a unique base class name for each base class type. And, since typeid is not reliable for that implementation, each base class is required to implement a traits class with a Base typedef which specifies the base class, a Signature typedef which specifies the signature of the create function and a static function named getUserPluginCreatorName() which returns a const std::string reference to the base classes name. This name must be unique across users of the registry. There is no way to enforce this programatically, so it is recommended that a application prefix be attached to the base class name.

Definition at line 331 of file UserPlugin.hpp.


Member Function Documentation

template<class Creator , typename S = Creator *(*)()>
static UserPlugin& sierra::Plugin::UserPlugin< Creator, S >::instance ( ) [inline, static]

Member function instance returns the instance of the registry, cast as a UserPlugin registry..

Returns:
a UserPlugin reference to the registry singleton.

Definition at line 349 of file UserPlugin.hpp.

template<class Creator , typename S = Creator *(*)()>
static void sierra::Plugin::UserPlugin< Creator, S >::registerCreator ( const std::string &  derived_name,
Signature  function 
) [inline, static]

Member function registerCreator registers the base class name and specified derived class name with the specified creator function.

The base class name is determined by the BaseTraits template argument's getUserPluginCreatorName() static member function. The signature is defined by the BaseTraits template argument's Signature typedef.

Parameters:
derived_namea std::string const reference to the derived class name.
functiona signature function pointer to the creator function.

Definition at line 368 of file UserPlugin.hpp.

template<class Creator , typename S = Creator *(*)()>
static Signature sierra::Plugin::UserPlugin< Creator, S >::create ( const std::string &  derived_name) [inline, static]

Member function create returns the createInstance() function associated with the specified base class and derived_name.

Parameters:
derived_namea std::string const reference to the derived classes name.
Exceptions:
astd::invalid_argument exception is thrown if there is no instance creation function registered for the specified name of the base class.
Returns:
a Signature function pointer to the instance create function.

Definition at line 386 of file UserPlugin.hpp.

template<class Creator , typename S = Creator *(*)()>
static Signature sierra::Plugin::UserPlugin< Creator, S >::create ( int  derived_id) [inline, static]

Member function create returns the createInstance() function associated with the specified base class and derived_name.

Parameters:
derived_namea std::string const reference to the derived classes name.
Exceptions:
astd::invalid_argument exception is thrown if there is no instance creation function registered for the specified name of the base class.
Returns:
a Signature function pointer to the instance create function.

Definition at line 406 of file UserPlugin.hpp.

template<class Creator , typename S = Creator *(*)()>
static bool sierra::Plugin::UserPlugin< Creator, S >::exists ( const std::string &  derived_name) [inline, static]

Member function exists returns true if class of the type specified by derived_name exists in BaseClass.

Parameters:
derived_namea std::string const reference to the derived classes name.
Returns:
a bool of true if class of the type specified by derived_name exists in BaseClass.

Definition at line 419 of file UserPlugin.hpp.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines