Sierra Toolkit  Version of the Day
sierra::Plugin::UserSubroutine< S > Class Template Reference

#include <UserPlugin.hpp>

Classes

class  Register
 Class template Register registers the user function function pointer with the function_name on object creation. More...
 

Public Types

typedef S Signature
 Subroutine call signature.
 

Static Public Member Functions

static UserSubroutineinstance ()
 Member function instance returns the instance of the registry, cast as a UserSubroutine registry.. More...
 
static void registerFunction (const std::string &function_name, Signature *function)
 Member function registerFunction registers the user function's name with the specified user function function pointer. More...
 
static Signatureexecute (const std::string &function_name)
 Member function execute returns the user function function associated with the specified signature and derived_name. More...
 
static SignaturegetFunction (const std::string &function_name)
 Member function execute returns the user function function pointer associated with the specified signature and derived_name. More...
 
static bool exists (const std::string &derived_name)
 Member function exists returns true if user function specified by derived_name exists. More...
 

Detailed Description

template<class S>
class sierra::Plugin::UserSubroutine< S >

Class template UserSubroutine is a template used for the association of user function to be registered and acquired via the UserSubroutine mechanism. The template traits enforces the signature matching of the user function and the its usage.

The registration requires a unique function name and is required to implement a traits class with a Signature typedef which specifies the signature of the user function and a static function named getUserSubroutineName() which returns a const std::string reference to the user function's 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 function name.

Definition at line 520 of file UserPlugin.hpp.

Member Function Documentation

◆ instance()

template<class S >
static UserSubroutine& sierra::Plugin::UserSubroutine< S >::instance ( )
inlinestatic

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

Returns
a UserSubroutine reference to the registry singleton.

Definition at line 537 of file UserPlugin.hpp.

◆ registerFunction()

template<class S >
static void sierra::Plugin::UserSubroutine< S >::registerFunction ( const std::string &  function_name,
Signature function 
)
inlinestatic

Member function registerFunction registers the user function's name with the specified user function function pointer.

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

Parameters
function_namea std::string const reference to the user function's name.
functiona Signature function pointer to the user function.

Definition at line 556 of file UserPlugin.hpp.

◆ execute()

template<class S >
static Signature* sierra::Plugin::UserSubroutine< S >::execute ( const std::string &  function_name)
inlinestatic

Member function execute returns the user function function associated with the specified signature and derived_name.

Parameters
function_namea std::string const reference to the user function's name.
Exceptions
astd::invalid_argument exception is thrown if there is no user function registered for the specified name.
Returns
a Signature user function.

Definition at line 573 of file UserPlugin.hpp.

◆ getFunction()

template<class S >
static Signature* sierra::Plugin::UserSubroutine< S >::getFunction ( const std::string &  function_name)
inlinestatic

Member function execute returns the user function function pointer associated with the specified signature and derived_name.

Parameters
function_namea std::string const reference to the user function's name.
Exceptions
astd::invalid_argument exception is thrown if there is no user function registered for the specified name.
Returns
a Signature user function pointer.

Definition at line 592 of file UserPlugin.hpp.

◆ exists()

template<class S >
static bool sierra::Plugin::UserSubroutine< S >::exists ( const std::string &  derived_name)
inlinestatic

Member function exists returns true if user function specified by derived_name exists.

Parameters
function_namea std::string const reference to the user function's name.
Returns
a bool of true if user function specified signature and function_name exists in BaseClass.

Definition at line 608 of file UserPlugin.hpp.


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