ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dfe::Dispatcher Class Reference

#include <acts/blob/master/thirdparty/dfelibs/dfe/dfe_dispatcher.hpp>

+ Collaboration diagram for dfe::Dispatcher:

Classes

struct  Command
 

Public Types

using Interface = std::function< Variable(const std::vector< Variable > &)>
 The native dispatcher function interface.
 

Public Member Functions

void add (std::string name, Interface &&func, std::vector< Variable::Type > &&arg_types, std::string help=std::string())
 
template<typename R , typename... Args>
void add (std::string name, std::function< R(Args...)> &&func, std::string help=std::string())
 
template<typename R , typename... Args>
void add (std::string name, R(*func)(Args...), std::string help=std::string())
 
template<typename T , typename R , typename... Args>
void add (std::string name, R(T::*member_func)(Args...), T *t, std::string help=std::string())
 
template<typename... Args>
Variable call (const std::string &name, Args &&...args)
 Call a command with arbitrary arguments.
 
Variable call_parsed (const std::string &name, const std::vector< std::string > &args)
 Call a command with arguments parsed from strings into the expected types.
 
Variable call_native (const std::string &name, const std::vector< Variable > &args)
 Call a command using the native argument encoding.
 
std::vector< std::string > commands () const
 Return a list of registered commands.
 
const std::string & help (const std::string &name) const
 Return the help text for the command.
 

Private Attributes

std::unordered_map
< std::string, Command
m_commands
 

Detailed Description

A simple command dispatcher.

You can register commands and call them by name.

Definition at line 106 of file dfe_dispatcher.hpp.

View newest version in sPHENIX GitHub at line 106 of file dfe_dispatcher.hpp

Member Typedef Documentation

The native dispatcher function interface.

Definition at line 109 of file dfe_dispatcher.hpp.

View newest version in sPHENIX GitHub at line 109 of file dfe_dispatcher.hpp

Member Function Documentation

void dfe::Dispatcher::add ( std::string  name,
Dispatcher::Interface &&  func,
std::vector< Variable::Type > &&  arg_types,
std::string  help = std::string() 
)
inline

Register a native dispatcher function.

Parameters
nameUnique function name
funcFunction object
arg_typesArguments types
helpOptional help text

Definition at line 332 of file dfe_dispatcher.hpp.

View newest version in sPHENIX GitHub at line 332 of file dfe_dispatcher.hpp

References func, and m_commands.

Referenced by add().

+ Here is the caller graph for this function:

template<typename R , typename... Args>
void dfe::Dispatcher::add ( std::string  name,
std::function< R(Args...)> &&  func,
std::string  help = std::string() 
)
inline

Register a function with arbitrary arguments.

The return type and the argument types must be compatible with Variable.

Definition at line 348 of file dfe_dispatcher.hpp.

View newest version in sPHENIX GitHub at line 348 of file dfe_dispatcher.hpp

References add(), and func.

+ Here is the call graph for this function:

template<typename R , typename... Args>
void dfe::Dispatcher::add ( std::string  name,
R(*)(Args...)  func,
std::string  help = std::string() 
)
inline

Definition at line 358 of file dfe_dispatcher.hpp.

View newest version in sPHENIX GitHub at line 358 of file dfe_dispatcher.hpp

References add(), func, and Acts::IntegrationTest::R.

+ Here is the call graph for this function:

template<typename T , typename R, typename... Args>
void dfe::Dispatcher::add ( std::string  name,
R(T::*)(Args...)  member_func,
T t,
std::string  help = std::string() 
)
inline

Definition at line 365 of file dfe_dispatcher.hpp.

View newest version in sPHENIX GitHub at line 365 of file dfe_dispatcher.hpp

References add(), Acts::IntegrationTest::R, and return().

+ Here is the call graph for this function:

template<typename... Args>
Variable dfe::Dispatcher::call ( const std::string &  name,
Args &&...  args 
)
inline

Call a command with arbitrary arguments.

Definition at line 410 of file dfe_dispatcher.hpp.

View newest version in sPHENIX GitHub at line 410 of file dfe_dispatcher.hpp

Variable dfe::Dispatcher::call_native ( const std::string &  name,
const std::vector< Variable > &  args 
)
inline

Call a command using the native argument encoding.

Definition at line 377 of file dfe_dispatcher.hpp.

View newest version in sPHENIX GitHub at line 377 of file dfe_dispatcher.hpp

Variable dfe::Dispatcher::call_parsed ( const std::string &  name,
const std::vector< std::string > &  args 
)
inline

Call a command with arguments parsed from strings into the expected types.

Definition at line 390 of file dfe_dispatcher.hpp.

View newest version in sPHENIX GitHub at line 390 of file dfe_dispatcher.hpp

std::vector< std::string > dfe::Dispatcher::commands ( ) const
inline

Return a list of registered commands.

Definition at line 416 of file dfe_dispatcher.hpp.

View newest version in sPHENIX GitHub at line 416 of file dfe_dispatcher.hpp

const std::string & dfe::Dispatcher::help ( const std::string &  name) const
inline

Return the help text for the command.

Definition at line 426 of file dfe_dispatcher.hpp.

View newest version in sPHENIX GitHub at line 426 of file dfe_dispatcher.hpp

Member Data Documentation

std::unordered_map<std::string, Command> dfe::Dispatcher::m_commands
private

Definition at line 156 of file dfe_dispatcher.hpp.

View newest version in sPHENIX GitHub at line 156 of file dfe_dispatcher.hpp

Referenced by add().


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