35 #ifndef COMMAND_BANK_H_
36 #define COMMAND_BANK_H_
40 #include "drain/util/Bank.h"
41 #include "drain/util/Flags.h"
58 typedef data_t command_t;
81 template <
class D,
char PREFIX=0>
82 D & addExternal(
const D & entry,
char alias = 0){
83 std::string key(entry.getName());
91 D & addExternal(
char PREFIX,
const D & entry,
char alias=0){
92 std::string key(entry.getName());
97 template <
class D,
char PREFIX=0>
99 D & addExternal(
const D & entry,
const std::string & key,
char alias = 0){
118 void readFile(
const std::string & filename,
Program & prog)
const;
138 bool scriptify(
const std::string & arg,
const std::string & argNext,
Script & script)
const;
153 void tokenize(
const std::string & cmdLine, std::list<std::string> & args)
const;
162 append(script, ctx, prog);
167 void remove(
Program & prog)
const;
170 void run(
const std::string & cmd,
const std::string & params,
Context & ctx);
181 void help(std::ostream & ostr = std::cout);
184 void help(Flagger::ivalue_t sectionFilter, std::ostream & ostr = std::cout);
187 void help(
const std::string & key, std::ostream & ostr = std::cout);
190 void info(
const std::string & key,
const command_t & cmd, std::ostream & ostr = std::cout,
bool detailed=
true)
const ;
196 const std::string &
resolveFull(
const key_t & key)
const;
199 void exportStatus(std::map<std::string, T> & statusMap)
const;
207 void setScriptTriggerFlag(drain::Flagger::ivalue_t sectionFlag){
280 void CommandBank::exportStatus(std::map<std::string, T> & statusMap)
const {
281 for (map_t::const_iterator it = this->begin(); it!=this->end(); ++it){
282 statusMap[it->first] = it->second->getSource().getParameters().getValues();
A Bank with additional support for brief, single char keys.
Definition: Bank.h:314
Container and execution tools for commands derived from Command.
Definition: CommandBank.h:54
void scriptify(int argc, const char **argv, Script &script) const
Convert program arguments a script. Like in main(), actual command arguments start from 1.
Definition: CommandBank.cpp:180
void append(const Script &script, Program &prog) const
Converts command strings to executable command objects, appending them to a program.
Definition: CommandBank.cpp:140
void setNotFoundHandlerCmdKey(const std::string &s)
Set command to be executed when a command - argument with leading hyphen(s) - is not found.
Definition: CommandBank.h:232
std::string notFoundHandlerCmdKey
If defined, the command - key not getName() - to which all unresolved commands are directed.
Definition: CommandBank.h:222
std::string execFileCmd
Command for reading and executing commands from a file in the current (running) context.
Definition: CommandBank.h:268
static std::set< std::string > & trimWords()
Words that are moved from class name prior to composing a command name.
Definition: CommandBank.cpp:57
void flushRoutine(Script &script, Context &ctx, Program &prog)
Append routine to program, and clear routine.
Definition: CommandBank.h:161
const std::string & resolveFull(const key_t &key) const
Given an alias or a long key, possibly prefixed by hyphens, return the long key if a command exists.
Definition: CommandBank.cpp:1040
void run(const std::string &cmd, const std::string ¶ms, Context &ctx)
Run a single command.
Definition: CommandBank.cpp:484
std::string defaultCmdKey
Command that is used, if a plain argument is given.
Definition: CommandBank.h:209
void help(std::ostream &ostr=std::cout)
Basic help dump, displays help commands to proceed.
Definition: CommandBank.cpp:850
std::string scriptCmd
Command for storing a routine.
Definition: CommandBank.h:234
void info(const std::string &key, const command_t &cmd, std::ostream &ostr=std::cout, bool detailed=true) const
Checked key and respective command.
Definition: CommandBank.cpp:937
void readFileTXT(const std::string &filename, Script &script) const
Include commands from file, inserting them before iterator.
Definition: CommandBank.cpp:441
void setScriptFileCmd(const std::string &s)
Set command for reading and executing commands from a file in the current (running) context.
Definition: CommandBank.h:263
drain::Flagger::ivalue_t scriptTriggerFlag
Member and methods for special commands.
Definition: CommandBank.h:203
static void deriveCmdName(std::string &name, char prefix=0)
Given a command class name like MyFileReadCommand, derives a respective command line option ("myFileR...
Definition: CommandBank.cpp:62
void setScriptCmd(const std::string &s)
Set command for storing a routine.
Definition: CommandBank.h:244
void setDefaultCmdKey(const std::string &s)
Set command - key, not getName() - that is used if a plain argument is given.
Definition: CommandBank.h:220
Sequence consisting of Command:s retrieved from a CommandBank.
Definition: Program.h:101
A tool for expanding variables embedded in a std::string to literals.
Definition: StringMapper.h:275
Definition: DataSelector.cpp:1277
CommandBank & getCommandBank()
Global program command registry. Optional utility.
Definition: CommandBank.cpp:51