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();
271 return installDeprecating<CMD,CMD_NEW>(name, alias);
279 template <
class ...TT>
282 std::set<std::string> cmdList;
283 linkRelatedCommandList(cmdList, cmds...);
286 template <
class ...TT>
288 void linkRelatedCommandList(std::set<std::string> & cmdList,
Command & cmd, TT & ... cmds){
289 std::string name = cmd.
getName();
291 cmdList.insert(name);
292 linkRelatedCommandList(cmdList, cmds...);
295 template <
class ...TT>
297 void linkRelatedCommandList(std::set<std::string> & cmdList,
const std::string & cmdName, TT & ... cmds){
298 cmdList.insert(cmdName);
299 linkRelatedCommandList(cmdList, cmds...);
303 template <
class ...TT>
305 void linkRelatedCommandList(std::set<std::string> & cmdList){
315 std::string name = cmd.
getName();
317 this->cmdBank.
get(name).linkRelated(section);
327#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:159
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:917
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 linkRelatedSection(Command &cmd, const CommandSection §ion)
Definition CommandInstaller.h:314
void linkRelatedCommands(TT &... cmds)
Definition CommandInstaller.h:281
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
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