artdaq  v2_03_00
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
artdaq::cmd_ Class Referenceabstract

The "cmd_" class serves as the base class for all artdaq's XML-RPC commands. More...

+ Inheritance diagram for artdaq::cmd_:

Public Member Functions

 cmd_ (xmlrpc_commander &c, const std::string &signature, const std::string &description)
 cmd_ Constructor More...
 
void execute (const xmlrpc_c::paramList &paramList, xmlrpc_c::value *const retvalP) final
 Execute trhe command with the given parameters. More...
 

Protected Member Functions

virtual bool execute_ (const xmlrpc_c::paramList &, xmlrpc_c::value *const retvalP)=0
 "execute_" is a wrapper function around the call to the commandable object's function More...
 
template<typename T >
getParam (const xmlrpc_c::paramList &paramList, int index)
 Get a parameter from the parameter list. More...
 
template<typename T >
getParam (const xmlrpc_c::paramList &paramList, int index, T default_value)
 Get a parameter from the parameter list, returning a default value if not found at specified location. More...
 
template<>
uint64_t getParam (const xmlrpc_c::paramList &paramList, int index)
 Get a parameter from the parameter list. More...
 

Protected Attributes

xmlrpc_commander_c
 The xmlrpc_commander instance that the command will be sent to.
 

Detailed Description

The "cmd_" class serves as the base class for all artdaq's XML-RPC commands.

JCF, 9/5/14

The "cmd_" class serves as the base class for all artdaq's XML-RPC commands, all of which use the code in the "execute()" function; each specific command type deriving from cmd_ is implemented in the execute_() function which execute() calls (notice the underscore), and optionally sets the retvalP parameter

cmd_ contains a set of template functions, getParam<T>(), which are designed to prevent implementors of derived classes from having to worry about interfacing directly with xmlrpc_c's parameter-getting functionality

Definition at line 118 of file xmlrpc_commander.cc.

Constructor & Destructor Documentation

artdaq::cmd_::cmd_ ( xmlrpc_commander c,
const std::string &  signature,
const std::string &  description 
)
inline

cmd_ Constructor

Parameters
cxmlrpc_commander instance
signatureSignature of the command
descriptionDescription of the command

Definition at line 129 of file xmlrpc_commander.cc.

Member Function Documentation

void artdaq::cmd_::execute ( const xmlrpc_c::paramList &  paramList,
xmlrpc_c::value *const  retvalP 
)
final

Execute trhe command with the given parameters.

Parameters
paramListList of parameters for the command (i.e. a fhicl string for init transitions)
retvalPPointer to the return value (usually a string describing result of command)

Definition at line 285 of file xmlrpc_commander.cc.

virtual bool artdaq::cmd_::execute_ ( const xmlrpc_c::paramList &  ,
xmlrpc_c::value *const  retvalP 
)
protectedpure virtual

"execute_" is a wrapper function around the call to the commandable object's function

Parameters
retvalPPointer to the return value (usually a string describing result of command)
Returns
Whether the command succeeded
template<typename T >
T artdaq::cmd_::getParam ( const xmlrpc_c::paramList &  paramList,
int  index 
)
protected

Get a parameter from the parameter list.

Template Parameters
TType of the parameter
Parameters
paramListThe parameter list
indexIndex of the parameter in the parameter list
Returns
The requested parameter

Template specilization is used to provide valid overloads

Definition at line 196 of file xmlrpc_commander.cc.

template<typename T >
T artdaq::cmd_::getParam ( const xmlrpc_c::paramList &  paramList,
int  index,
default_value 
)
protected

Get a parameter from the parameter list, returning a default value if not found at specified location.

Template Parameters
TType of the parameter
Parameters
paramListThe parameter list
indexIndex of the parameter in the parameter list
default_valueDefault value to return if exception retrieving parameter
Returns
The requested parameter, or the default value if there was an exception retrieving the parameter

JCF, 9/5/14

Here, if getParam throws an exception due to a lack of an existing parameter, swallow the exception and return the default value passed to the function

Surprisingly, if an invalid index is supplied, although getParam throws an exception that exception is neither xmlrpc_c's girerr:error nor boost::bad_lexical_cast. Although it's less than ideal, we'll swallow almost all exceptions in the call to getParam, as an invalid index value simply means the user wishes to employ the default_value. I say "almost" because the only exception we don't swallow here is if an invalid parameter type "T" was supplied

Definition at line 267 of file xmlrpc_commander.cc.

template<>
uint64_t artdaq::cmd_::getParam ( const xmlrpc_c::paramList &  paramList,
int  index 
)
protected

Get a parameter from the parameter list.

Parameters
paramListThe parameter list
indexIndex of the parameter in the parameter list
Returns
The requested parameter

This specialized cmd_getParam for the uint64_t type

Definition at line 210 of file xmlrpc_commander.cc.


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