Loading...
Searching...
No Matches
Public Types | 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 Types

typedef int cmd_section_type
 

Public Member Functions

 Command (const Command &cmd)
 
virtual const std::string & getName () const =0
 Returns the class name of this command, like "CmdVerbose".
 
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 T &args)
 
template<class T >
void setParameter (const std::string &key, const T &value)
 Set a value to a single parameter.
 
bool hasParameters () const
 
virtual void run (const std::string &params="") final
 Description of result, comparable to a return type of a function. ?
 
virtual void update ()
 Optional method for preparing command to execution.
 
virtual void exec () const
 Run the command with current parameter values.
 
CommandaddSection (int i)
 
const std::string & getLastParameters () const
 
virtual void help (std::ostream &ostr=std::cout, bool DETAILED=false) const
 
virtual void getRelatedCommands (std::ostream &ostr=std::cout) const
 
- 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.
 

Public Attributes

cmd_section_type section = 1
 
std::set< std::string > relatedCommands
 Add related command(s), to appear in help after "See-also:" phrase.
 

Static Public Attributes

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

Protected Member Functions

CommandlinkRelatedCommands ()
 
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 Typedef Documentation

◆ cmd_section_type

typedef int cmd_section_type

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

Member Function Documentation

◆ exec()

virtual void exec ( ) const
inlinevirtual

Run the command with current parameter values.

Reimplemented in CmdVerbosity, CmdDebug, CmdLog, CmdStatus, CmdExpandVariables, CmdExecScript, HelpCmd, CmdFormat, CmdFormatFile< C >, CmdNotFound, CmdOpticalFlowBase, PolarSite, PolarPlot, PolarPlotFile, PolarAdd, PolarExtract, AnDReDefaultQuality, AnDReUniversal, CompositeAdd, CompositeAddWeighted, CartesianBBox, CartesianBBoxReset, CartesianBBoxTest, CartesianBBoxTile, CartesianExtract, CartesianSun, CartesianGrid, CartesianPlot, CartesianPlotFile, CartesianSpread, CartesianSize, CartesianTime, CartesianInit, CompositeMethod, CompositeDefaultQuality, CompositeTimeDecay, CompositeDecayTime, CmdSelectQuantity, CmdSelectObject, CmdSet, CmdConvert, CmdDumpMap, CmdHelpExample, CmdJSON, CmdEcho, CmdCheckType, CmdValidate, CmdVersion, OutputDataVerbosityOLD, CmdAppend, CmdStore, VerboseCmd, CmdExpandVariables2, CmdInputFilter, CmdPause, CmdTest2, CmdHdf5Test, CmdHistogram, CmdGeoTiff, CmdInputPrefix, CmdInputFile, CmdInputSelect, CmdPanelTest, CmdOutputConf, CmdOutputPrefix, CmdOutputRawImages, CmdOutputTree, RackImageOpCmd< OP >, CmdImagePhysical, CmdImageAlpha, CmdImageTransp, CmdImageFlatten, CmdPalette, CmdPaletteDefault, CmdPaletteConf, CmdInputPalette, CmdPaletteRefine, CmdImageQuality, CmdImageBox, CmdPlot, CmdImage, CmdSweep, CmdOutputQuantity, CmdTestSelect, CmdTestTree, CartesianProj, CmdErrorFlags, CmdStopOnError, AnDReCommand< OP >, CartesianCreate, CompositeCreateTile, CartesianCreateLookup, CartesianReset, CmdSelect, CmdCreateDefaultQuality, CmdDelete, CmdKeep, CmdMove, CmdRename, CmdCompleteODIM, CmdODIM, CmdSetODIM, CmdEncoding, CmdQuantityConf, CmdUpdateVariables, CmdLayout, CmdAlign, CmdFontSizes, CmdTitleHeights, CmdLinkImage, CmdGroupTitle, CmdImageTitle, CmdInclude, CmdPanelFoo, CmdStyle, CmdPanel, CmdFormat, CmdFormatOut, CmdOutputFile, CmdOutputPalette, Deprecator< C >, Deprecator< CmdOutputPalette >, and ProductCommand< OP >.

◆ getName()

virtual const std::string & getName ( ) const
pure virtual

Returns the class name of this command, like "CmdVerbose".

Typically not same as the command line command, for example "verbose" for command "--verbose",

Implemented in BeanCommand< B, B2 >, BeanCommand< B, B & >, BeanCommand< BeanLike >, BeanCommand< drain::image::ImageBox >, BeanCommand< drain::image::ImageSampler >, BeanCommand< FastOpticalFlow2Op >, and BeanCommand< OP >.

◆ run()

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

Description of result, comparable to a return type of a function. ?

Convenience. Sets parameters and executes the command.

See also
exec() .

◆ setParameter()

template<class T >
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

◆ setParameters()

void setParameters ( const std::string &  args)
finalvirtual

Somewhat ambiguous: how should empty argument be treated?

Somewhat ambiguous: how should empty argument be treated?

◆ update()

virtual void update ( )
inlinevirtual

Optional method for preparing command to execution.

This function will be called prior to running exec()

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

Member Data Documentation

◆ relatedCommands

std::set<std::string> relatedCommands
mutable

Add related command(s), to appear in help after "See-also:" phrase.

This "relation" is single directional, so typically linked commands should also link this command. Command catalogs like CommandBank should administer two-way linking.

See also
CommandBank

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