Stochastic Loading Module
Public Member Functions | Static Public Member Functions | List of all members
Dispatcher< Treturntype, Targs > Class Template Reference

#include <function_dispatcher.h>

Public Member Functions

void register_function (const std::string &key, std::function< Treturntype(Targs...)> new_function)
 
Treturntype dispatch (const std::string &key, Targs...args)
 
bool check (const std::string &key) const
 
std::vector< std::string > list () const
 

Static Public Member Functions

static Dispatcherinstance ()
 

Detailed Description

template<typename Treturntype, typename... Targs>
class Dispatcher< Treturntype, Targs >

Singleton function dispatcher

Template Parameters
TreturntypeFunction return type
TargsFunction arguments

Definition at line 16 of file function_dispatcher.h.

Member Function Documentation

template<typename Treturntype, typename... Targs>
bool Dispatcher< Treturntype, Targs >::check ( const std::string &  key) const
inline

Check if a function is registered

Parameters
[in]keyKey to be checked in registry
Returns
status Return if key is in registry or not

Definition at line 60 of file function_dispatcher.h.

template<typename Treturntype, typename... Targs>
Treturntype Dispatcher< Treturntype, Targs >::dispatch ( const std::string &  key,
Targs...  args 
)
inline

Dispatch function with input arguments

Parameters
keyKey to function in dispatcher
argsInputs to function
Returns
Return result of evaluating function with input args

Definition at line 47 of file function_dispatcher.h.

template<typename Treturntype, typename... Targs>
static Dispatcher* Dispatcher< Treturntype, Targs >::instance ( )
inlinestatic

Get the single instance of the dispatcher

Definition at line 21 of file function_dispatcher.h.

template<typename Treturntype, typename... Targs>
std::vector<std::string> Dispatcher< Treturntype, Targs >::list ( ) const
inline

List registered functions

Returns
dispather_items Return list of items in the registry

Definition at line 71 of file function_dispatcher.h.

template<typename Treturntype, typename... Targs>
void Dispatcher< Treturntype, Targs >::register_function ( const std::string &  key,
std::function< Treturntype(Targs...)>  new_function 
)
inline

Register a function with the dispatcher

Parameters
[in]keyRegister key
[in]new_functionNew function to register with the dispatcher

Definition at line 31 of file function_dispatcher.h.


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