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"
61template <
char PREFIX=0,
class SECTION=GeneralSection>
73 return drain::Static::get<SECTION>();
85 Command & cmd = cmdBank.add<CMD>(name,alias);
86 cmd.section |= getSection().index;
93 std::string name = CMD().
getName();
95 return install<CMD>(name, alias);
105 Command & cmd = cmdBank.addExternal(cmdExt, name,alias);
106 cmd.section |= getSection().index;
117 std::string name = cmdExt.
getName();
119 return install(cmdExt, name, alias);
128 cmd.section |= getSection().index;
136 std::string name = CMD().
getName();
138 return installShared<CMD>(name, alias);
152template <
char PREFIX=0,
class SECTION=GeneralSection>
174 template <
class CMD,
class CMD_NEW = CMD>
176 Command & cmd = this->cmdBank.template add<CMD>(name,alias);
177 cmd.section |= this->getSection().index;
179 cmd.section |= drain::Static::get<drain::DeprecatingSection>().index;
183 std::string nameNew = CMD_NEW().getName();
195 template <
class CMD,
class CMD_NEW = CMD>
197 std::string name = CMD().
getName();
199 return installDeprecating<CMD,CMD_NEW>(name, alias);
207 template <
class ...TT>
210 std::set<std::string> cmdList;
211 linkRelatedCommandList(cmdList, cmds...);
214 template <
class ...TT>
216 void linkRelatedCommandList(std::set<std::string> & cmdList,
Command & cmd, TT & ... cmds){
217 std::string name = cmd.
getName();
219 cmdList.insert(name);
220 linkRelatedCommandList(cmdList, cmds...);
223 template <
class ...TT>
225 void linkRelatedCommandList(std::set<std::string> & cmdList,
const std::string & cmdName, TT & ... cmds){
226 cmdList.insert(cmdName);
227 linkRelatedCommandList(cmdList, cmds...);
231 template <
class ...TT>
233 void linkRelatedCommandList(std::set<std::string> & cmdList){
243 std::string name = cmd.
getName();
245 this->cmdBank.
get(name).linkRelated(section);
255#define DRAIN_CMD_INSTALL(prefix, cmd) drain::Command & cmd = install<prefix##cmd>
const T & get(const K &key) const
Returns the base instance.
Definition Bank.h:160
Container and execution tools for commands derived from Command.
Definition CommandBank.h:56
void linkRelatedCommandList(const std::set< std::string > &cmdList)
Adds command keys, intelinking all the commands in the list.
Definition CommandBank.cpp:887
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, deriving command name from the class name and prefixing if de...
Definition CommandInstaller.h:62
Command & install(char alias=0)
Install external command.
Definition CommandInstaller.h:92
Command & install(CMD &cmdExt, char alias=0)
Install external command.
Definition CommandInstaller.h:116
static char getPrefix()
Return the character used as prefix for the commands in this section.
Definition CommandInstaller.h:78
static Command & installShared(const std::string &name, char alias=0)
Install to shared (global) CommandBank.
Definition CommandInstaller.h:126
static Command & installShared(char alias=0)
Install to shared (global) CommandBank.
Definition CommandInstaller.h:135
Command & install(CMD &cmdExt, const std::string &name, char alias=0)
Install external command.
Definition CommandInstaller.h:104
Command & install(const std::string &name, char alias=0)
Install command initialized and stored by command bank.
Definition CommandInstaller.h:84
Combines command installation and sectioning.
Definition CommandInstaller.h:153
Command & installDeprecating(const std::string &name, char alias=0)
Mark deprecating commands by installing them with this.
Definition CommandInstaller.h:175
CommandModule(CommandBank &bank=getCommandBank())
Definition CommandInstaller.h:165
void linkRelatedSection(Command &cmd, const CommandSection §ion)
Definition CommandInstaller.h:242
void linkRelatedCommands(TT &... cmds)
Definition CommandInstaller.h:209
Command & installDeprecating(char alias=0)
Mark deprecating commands by installing them with this.
Definition CommandInstaller.h:196
Definition CommandSections.h:54
Base class for commands: typically actions taking parameters but also plain variable assignments and ...
Definition Command.h:55
void linkRelated(const std::string &cmdKey) const
Add related command(s), to appear in help after "See-also:" phrase.
Definition Command.h:221
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