Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Command Class Referenceabstract

Base class for commands: typically actions taking parameters but also plain variable assignments and parameterless actions. More...

#include <Command.h>

Inheritance diagram for Command:
Inheritance graph
[legend]
Collaboration diagram for Command:
Collaboration graph
[legend]

Public Member Functions

 Command (const Command &cmd)
 
virtual const std::string & getName () const =0
 
virtual const std::string & getDescription () const =0
 
virtual const ReferenceMapgetParameters () const =0
 
virtual void setParameters (const std::string &args) final
 
template<class T >
void setParameters (const SmartMap< T > &args)
 
template<class T >
void setParameter (const std::string &key, const T &value)
 Set a value to a single parameter. More...
 
CommandaddSection (drain::Flagger::ivalue_t i)
 
virtual void update ()
 Optional method for preparing command to execution. More...
 
bool hasParameters () const
 
virtual const std::string & getType () const
 Description of result, comparable to a return type of a function. ?
 
virtual void exec () const
 Run the command with current parameter values.
 
virtual void run (const std::string &params="")
 Convenience. Sets parameters and executes the command. More...
 
const std::string & getLastParameters () const
 After executing this command run a routine, if defined. More...
 
- Public Member Functions inherited from Contextual
 Contextual ()
 Sets internal contextPtr to NULL.
 
 Contextual (const Contextual &src)
 Copies base context (even null) of the source. Notice that the actual instance may be of derived class.
 
 Contextual (Context &ctx)
 Copies internal contextPtr.
 
template<class C >
void setContext ()
 Sets internal contextPtr to the static source.
 
void setExternalContext (Context &ctx)
 Sets internal contextPtr to outside target.
 
bool contextIsSet () const
 True, if contextPtr has been set.
 
template<class T = Context>
T & getContext () const
 If context has been set, returns it through a cast to base class Context. More...
 

Public Attributes

int section = 1
 

Static Public Attributes

static const SprinterLayout cmdArgLayout = {",", "?", "=", ""}
 

Protected Member Functions

virtual ReferenceMapgetParameters ()=0
 

Protected Attributes

std::string lastParameters
 
- Protected Attributes inherited from Contextual
ContextcontextPtr
 

Additional Inherited Members

- Static Public Member Functions inherited from Contextual
template<class T >
static Cloner< Context, T > & getCloner ()
 

Detailed Description

Base class for commands: typically actions taking parameters but also plain variable assignments and parameterless actions.

Member Function Documentation

◆ getLastParameters()

const std::string& getLastParameters ( ) const
inline

After executing this command run a routine, if defined.

Future option: single-code Dynamic functions: handle the command string

◆ run()

virtual void run ( const std::string &  params = "")
inlinevirtual

Convenience. Sets parameters and executes the command.

See also
exec() .

◆ setParameter()

void setParameter ( const std::string &  key,
const T &  value 
)
inline

Set a value to a single parameter.

This method also assigns "<key>=<value>" to lastParameters

◆ update()

virtual void update ( )
inlinevirtual

Optional method for preparing command to execution.

This function will be called prior to running exec()

Reimplemented in ProductCommand< OP >, DetectorCommand< OP >, and AnDReCommand< OP >.

Member Data Documentation

◆ section

int section = 1

Typically, zero section is for "hidden" commands not appearing in help dumps.


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