32#ifndef DRAIN_CMD_INSTALLER_H_
33#define DRAIN_CMD_INSTALLER_H_
41#include "drain/util/ReferenceMap.h"
46#include "CommandBank.h"
47#include "CommandSections.h"
64 CommandWrapper(const std::string & name, char alias = 0){
65 getCommandBank().add<C>(name,alias); //.section = S;
79template <
char PREFIX=0,
class SECTION=GeneralSection>
91 return drain::Static::get<SECTION>();
103 Command & cmd = cmdBank.add<CMD>(name,alias);
104 cmd.section |= getSection().index;
111 std::string name = CMD().
getName();
113 return install<CMD>(name, alias);
123 Command & cmd = cmdBank.addExternal(cmdExt, name,alias);
124 cmd.section |= getSection().index;
135 std::string name = cmdExt.
getName();
137 return install(cmdExt, name, alias);
163 cmd.section |= getSection().index;
171 std::string name = CMD().
getName();
173 return installShared<CMD>(name, alias);
227template <
char PREFIX=0,
class SECTION=GeneralSection>
248 template <
class CMD,
class CMD_NEW = CMD>
250 Command & cmd = this->cmdBank.template add<CMD>(name,alias);
251 cmd.section |= this->getSection().index;
253 cmd.section |= drain::Static::get<drain::DeprecatingSection>().index;
257 std::string nameNew = CMD_NEW().getName();
267 template <
class CMD,
class CMD_NEW = CMD>
269 std::string name = CMD().
getName();
272 return installDeprecating<CMD,CMD_NEW>(name, alias);
292 template <
class ...TT>
295 std::set<std::string> cmdList;
296 linkRelatedCommandList(cmdList, cmds...);
299 template <
class ...TT>
301 void linkRelatedCommandList(std::set<std::string> & cmdList,
Command & cmd, TT & ... cmds){
302 std::string name = cmd.
getName();
304 cmdList.insert(name);
305 linkRelatedCommandList(cmdList, cmds...);
308 template <
class ...TT>
310 void linkRelatedCommandList(std::set<std::string> & cmdList,
const std::string & cmdName, TT & ... cmds){
311 cmdList.insert(cmdName);
312 linkRelatedCommandList(cmdList, cmds...);
316 template <
class ...TT>
318 void linkRelatedCommandList(std::set<std::string> & cmdList){
319 this->cmdBank.linkRelatedCommandList(cmdList);
330#define DRAIN_CMD_INSTALL(prefix, cmd) drain::Command & cmd = install<prefix##cmd>
Container and execution tools for commands derived from Command.
Definition CommandBank.h:56
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
Creates an instance of command class C.
Definition CommandInstaller.h:80
Command & install(char alias=0)
Install external command.
Definition CommandInstaller.h:110
Command & install(CMD &cmdExt, char alias=0)
Install external command.
Definition CommandInstaller.h:134
static char getPrefix()
Return the character used as prefix for the commands in this section.
Definition CommandInstaller.h:96
static Command & installShared(const std::string &name, char alias=0)
Install to shared (global) CommandBank.
Definition CommandInstaller.h:161
static Command & installShared(char alias=0)
Install to shared (global) CommandBank.
Definition CommandInstaller.h:170
Command & install(CMD &cmdExt, const std::string &name, char alias=0)
Install external command.
Definition CommandInstaller.h:122
Command & install(const std::string &name, char alias=0)
Install command initialized and stored by command bank.
Definition CommandInstaller.h:102
Combines command installation and sectioning.
Definition CommandInstaller.h:228
Command & installDeprecating(const std::string &name, char alias=0)
Definition CommandInstaller.h:249
CommandModule(CommandBank &bank=getCommandBank())
Definition CommandInstaller.h:240
void linkRelatedCommands(TT &... cmds)
Definition CommandInstaller.h:294
Command & installDeprecating(char alias=0)
Definition CommandInstaller.h:268
Definition CommandSections.h:54
Base class for commands: typically actions taking parameters but also plain variable assignments and ...
Definition Command.h:55
std::set< std::string > relatedCommands
Add related command(s), to appear in help after "See-also:" phrase.
Definition Command.h:223
virtual const std::string & getName() const =0
Returns the class name of this command, like "CmdVerbose".
Definition DataSelector.cpp:1277
CommandBank & getCommandBank()
Global program command registry. Optional utility.
Definition CommandBank.cpp:51