Orxonox
0.0.5 Codename: Arcturus
|
The ConsoleCommand class stores all information about a console command which can be executed by CommandExecutor. More...
#include </home/jenkins/workspace/orxonox_doxygen_trunk/src/libraries/core/command/ConsoleCommand.h>
Classes | |
struct | Command |
Helper class that is used to put the current state of the ConsoleCommand on a stack. More... | |
struct | CommandName |
Defines the name of a command, consisting of an optional group ("" means no group) and the name itself. More... | |
struct | ConsoleCommandManipulator |
Helper class that is used to manipulate console commands. More... | |
Public Member Functions | |
ConsoleCommand (const std::string &name, const ExecutorPtr &executor, bool bInitialized=true) | |
Constructor: Initializes all values and registers the command (without a group). More... | |
ConsoleCommand (const std::string &group, const std::string &name, const ExecutorPtr &executor, bool bInitialized=true) | |
Constructor: Initializes all values and registers the command (with a group). More... | |
~ConsoleCommand () | |
Destructor: Unregisters the command. More... | |
ConsoleCommand & | accessLevel (AccessLevel level) |
Changes the access level of the command. More... | |
ConsoleCommand & | activate () |
Activates the command. More... | |
ConsoleCommand & | addGroup (const std::string &group) |
Registers the command in a different group but with the same name. More... | |
ConsoleCommand & | addGroup (const std::string &group, const std::string &name) |
Registers an alias of the command in a different group with a different name. More... | |
ConsoleCommand & | addShortcut () |
Registers the command with the same name, but without group, as shortcut. More... | |
ConsoleCommand & | addShortcut (const std::string &name) |
Registers the command with an alias as shortcut. More... | |
ConsoleCommand & | argumentCompleter (unsigned int index, ArgumentCompleter *completer) |
Changes the argument completer for the given argument. More... | |
ConsoleCommand & | changeKeybindMode (KeybindMode::Value mode) |
Changes the keybind mode. More... | |
ConsoleCommand & | deactivate () |
Deactivates the command. More... | |
ConsoleCommand & | defaultValue (unsigned int index, const MultiType &arg) |
Changes the default value of the argument with given index of the current executor. More... | |
ConsoleCommand & | defaultValues (const MultiType &arg1) |
Changes the default values of the current executor. More... | |
ConsoleCommand & | defaultValues (const MultiType &arg1, const MultiType &arg2) |
Changes the default values of the current executor. More... | |
ConsoleCommand & | defaultValues (const MultiType &arg1, const MultiType &arg2, const MultiType &arg3) |
Changes the default values of the current executor. More... | |
ConsoleCommand & | defaultValues (const MultiType &arg1, const MultiType &arg2, const MultiType &arg3, const MultiType &arg4) |
Changes the default values of the current executor. More... | |
ConsoleCommand & | defaultValues (const MultiType &arg1, const MultiType &arg2, const MultiType &arg3, const MultiType &arg4, const MultiType &arg5) |
Changes the default values of the current executor. More... | |
ConsoleCommand & | description (const std::string &description) |
Sets the description of this command. More... | |
ConsoleCommand & | descriptionParam (unsigned int index, const std::string &description) |
Sets the description for an argument with given index. More... | |
ConsoleCommand & | descriptionReturnvalue (const std::string &description) |
Sets the description for the return-value. More... | |
AccessLevel | getAccessLevel () const |
Returns the access level of the command. More... | |
ArgumentCompleter * | getArgumentCompleter (unsigned int index) const |
Returns the argument completer for the argument with given index. More... | |
const FunctorPtr & | getBaseFunctor () const |
Returns the functor that defines the required header for this command (but isn't necessarily executed). More... | |
const std::string & | getDescription () const |
Returns the description of this command. More... | |
const std::string & | getDescriptionParam (unsigned int index) const |
Returns the description for the argument with given index. More... | |
const std::string & | getDescriptionReturnvalue (int index) const |
Returns the description for the return-value. More... | |
const ExecutorPtr & | getExecutor () const |
Returns the current executor which can be used to execute the command. More... | |
int | getInputConfiguredParam () const |
Returns the input configured param. More... | |
KeybindMode::Value | getKeybindMode () const |
Returns the keybind mode. More... | |
ConsoleCommandManipulator | getManipulator () |
Returns a manipulator for this command. More... | |
const std::string & | getName () const |
Returns the name that was first used for this command. More... | |
const std::vector< CommandName > & | getNames () |
bool | hasAccess () const |
Returns true if the current state of the game matches the required access level. More... | |
ConsoleCommand & | hide () |
Hides the command (can still be executed, but is not visible in the list of available commands). More... | |
ConsoleCommand & | inputConfiguredParam (int index) |
Changes the input configured param to the given index. More... | |
bool | isActive () const |
Returns true if the command can be executed right now. More... | |
bool | isHidden () const |
Returns true if the command is currently hidden. More... | |
ConsoleCommand & | keybindMode (KeybindMode::Value mode) |
Sets the keybind mode. Note: use changeKeybindMode if you intend to change the mode. More... | |
ConsoleCommand & | setActive (bool bActive) |
Changes the activity of the command. More... | |
ConsoleCommand & | setAsInputCommand () |
Defines the command to be an input command. More... | |
ConsoleCommand & | setHidden (bool bHidden) |
Changes the visibility of the command. More... | |
ConsoleCommand & | show () |
Makes the command visible. More... | |
Private Member Functions | |
void * | getObject () const |
Returns the current object pointer that is used to execute member-functions. More... | |
bool | headersMatch (const FunctorPtr &functor) |
Returns true if the headers of the given functor match the declaration of this command. More... | |
bool | headersMatch (const ExecutorPtr &executor) |
Returns true if the headers of the given executor match the declaration of this command. More... | |
void | init (const std::string &group, const std::string &name, const ExecutorPtr &executor, bool bInitialized) |
void | popFunction () |
Removes the current function from the stack and restores the old state. More... | |
void | popObject () |
Removes the current object from the stack an restores the old object. More... | |
void | pushFunction (const ExecutorPtr &executor, bool bForce=false) |
Pushes a new executor to the command-stack. More... | |
void | pushFunction (const FunctorPtr &functor, bool bForce=false) |
Pushes a new functor to the command-stack. More... | |
void | pushFunction () |
Pushes a copy of the current executor and functor on the stack. More... | |
void | pushObject (void *object) |
Push a new object to the object-stack. More... | |
void | resetFunction () |
Sets the functor to nullptr (which also deactivates the command). More... | |
bool | setFunction (const ExecutorPtr &executor, bool bForce=false) |
Changes the executor. More... | |
bool | setFunction (const FunctorPtr &functor, bool bForce=false) |
Changes the functor of the current executor. More... | |
bool | setObject (void *object) |
Changes the current object that is used to execute member-functions. More... | |
Private Attributes | |
AccessLevel | accessLevel_ |
The access level (the state of the game in which you can access the command) More... | |
ArgumentCompleter * | argumentCompleter_ [MAX_FUNCTOR_ARGUMENTS] |
ArgumentCompleter for each argument. More... | |
bool | bActive_ |
True if the command should be active (it can still be inactive, for example if the function is missing) More... | |
FunctorPtr | baseFunctor_ |
The functor that defines the header of the command-function. More... | |
std::string | baseName_ |
The name that was first assigned to the command. More... | |
bool | bHidden_ |
True if the command is hidden (it is still executable, but not visible in the list of available commands) More... | |
std::stack< Command > | commandStack_ |
A stack of commands, used to push and pop different functions. More... | |
LanguageEntryLabel | description_ |
The description of the command. More... | |
LanguageEntryLabel | descriptionParam_ [MAX_FUNCTOR_ARGUMENTS] |
A description for each argument. More... | |
LanguageEntryLabel | descriptionReturnvalue_ |
A description of the return-value. More... | |
ExecutorPtr | executor_ |
The Executor that is used to execute the command. More... | |
int | inputConfiguredParam_ |
The input configured param. More... | |
KeybindMode::Value | keybindMode_ |
The keybind mode. More... | |
std::vector< CommandName > | names_ |
All names and aliases of this command. More... | |
std::vector< void * > | objectStack_ |
A stack of objects, used to push and pop different objects for a function. More... | |
Friends | |
struct | ConsoleCommandManipulator |
The ConsoleCommand class stores all information about a console command which can be executed by CommandExecutor.
Console commands can be entered by the user into the shell, called in scripts, or used for key-bindings. They are simple text strings that can be executed by CommandExecutor. CommandExecutor will search for a ConsoleCommand with the given group and name and will execute it's Executor (which again calls the Functor and this finally calls the command-function).
orxonox::ConsoleCommand::ConsoleCommand | ( | const std::string & | name, |
const ExecutorPtr & | executor, | ||
bool | bInitialized = true |
||
) |
Constructor: Initializes all values and registers the command (without a group).
name | The name of the command |
executor | The executor of the command |
bInitialized | If true, the executor is used for both, the definition of the function-header AND to executute the command. If false, the command is inactive and needs to be assigned a function before it can be used. |
orxonox::ConsoleCommand::ConsoleCommand | ( | const std::string & | group, |
const std::string & | name, | ||
const ExecutorPtr & | executor, | ||
bool | bInitialized = true |
||
) |
Constructor: Initializes all values and registers the command (with a group).
group | The group of the command |
name | The name of the command |
executor | The executor of the command |
bInitialized | If true, the executor is used for both, the definition of the function-header AND to executute the command. If false, the command is inactive and needs to be assigned a function before it can be used. |
orxonox::ConsoleCommand::~ConsoleCommand | ( | ) |
Destructor: Unregisters the command.
|
inline |
Changes the access level of the command.
|
inline |
Activates the command.
ConsoleCommand & orxonox::ConsoleCommand::addGroup | ( | const std::string & | group | ) |
Registers the command in a different group but with the same name.
ConsoleCommand & orxonox::ConsoleCommand::addGroup | ( | const std::string & | group, |
const std::string & | name | ||
) |
Registers an alias of the command in a different group with a different name.
ConsoleCommand & orxonox::ConsoleCommand::addShortcut | ( | ) |
Registers the command with the same name, but without group, as shortcut.
ConsoleCommand & orxonox::ConsoleCommand::addShortcut | ( | const std::string & | name | ) |
Registers the command with an alias as shortcut.
ConsoleCommand & orxonox::ConsoleCommand::argumentCompleter | ( | unsigned int | index, |
ArgumentCompleter * | completer | ||
) |
Changes the argument completer for the given argument.
index | The index of the argument (the first argument has index 0) |
completer | The new argument completer |
ConsoleCommand & orxonox::ConsoleCommand::changeKeybindMode | ( | KeybindMode::Value | mode | ) |
Changes the keybind mode.
|
inline |
Deactivates the command.
ConsoleCommand & orxonox::ConsoleCommand::defaultValue | ( | unsigned int | index, |
const MultiType & | arg | ||
) |
Changes the default value of the argument with given index of the current executor.
index | The index of the argument (the first argument has index 0) |
arg | The new default value |
ConsoleCommand & orxonox::ConsoleCommand::defaultValues | ( | const MultiType & | arg1 | ) |
Changes the default values of the current executor.
ConsoleCommand & orxonox::ConsoleCommand::defaultValues | ( | const MultiType & | arg1, |
const MultiType & | arg2 | ||
) |
Changes the default values of the current executor.
ConsoleCommand & orxonox::ConsoleCommand::defaultValues | ( | const MultiType & | arg1, |
const MultiType & | arg2, | ||
const MultiType & | arg3 | ||
) |
Changes the default values of the current executor.
ConsoleCommand & orxonox::ConsoleCommand::defaultValues | ( | const MultiType & | arg1, |
const MultiType & | arg2, | ||
const MultiType & | arg3, | ||
const MultiType & | arg4 | ||
) |
Changes the default values of the current executor.
ConsoleCommand & orxonox::ConsoleCommand::defaultValues | ( | const MultiType & | arg1, |
const MultiType & | arg2, | ||
const MultiType & | arg3, | ||
const MultiType & | arg4, | ||
const MultiType & | arg5 | ||
) |
Changes the default values of the current executor.
ConsoleCommand & orxonox::ConsoleCommand::description | ( | const std::string & | description | ) |
Sets the description of this command.
ConsoleCommand & orxonox::ConsoleCommand::descriptionParam | ( | unsigned int | index, |
const std::string & | description | ||
) |
Sets the description for an argument with given index.
ConsoleCommand & orxonox::ConsoleCommand::descriptionReturnvalue | ( | const std::string & | description | ) |
Sets the description for the return-value.
|
inline |
Returns the access level of the command.
ArgumentCompleter * orxonox::ConsoleCommand::getArgumentCompleter | ( | unsigned int | index | ) | const |
Returns the argument completer for the argument with given index.
|
inline |
Returns the functor that defines the required header for this command (but isn't necessarily executed).
const std::string & orxonox::ConsoleCommand::getDescription | ( | ) | const |
Returns the description of this command.
const std::string & orxonox::ConsoleCommand::getDescriptionParam | ( | unsigned int | index | ) | const |
Returns the description for the argument with given index.
const std::string & orxonox::ConsoleCommand::getDescriptionReturnvalue | ( | int | index | ) | const |
Returns the description for the return-value.
const ExecutorPtr & orxonox::ConsoleCommand::getExecutor | ( | ) | const |
Returns the current executor which can be used to execute the command.
|
inline |
Returns the input configured param.
|
inline |
Returns the keybind mode.
|
inline |
Returns a manipulator for this command.
|
inline |
Returns the name that was first used for this command.
|
inline |
|
private |
Returns the current object pointer that is used to execute member-functions.
bool orxonox::ConsoleCommand::hasAccess | ( | ) | const |
Returns true if the current state of the game matches the required access level.
|
private |
Returns true if the headers of the given functor match the declaration of this command.
|
private |
Returns true if the headers of the given executor match the declaration of this command.
|
inline |
Hides the command (can still be executed, but is not visible in the list of available commands).
|
private |
|
inline |
Changes the input configured param to the given index.
bool orxonox::ConsoleCommand::isActive | ( | void | ) | const |
Returns true if the command can be executed right now.
This returns only true, if the following conditions are met:
|
inline |
Returns true if the command is currently hidden.
|
inline |
Sets the keybind mode. Note: use changeKeybindMode if you intend to change the mode.
|
private |
Removes the current function from the stack and restores the old state.
|
private |
Removes the current object from the stack an restores the old object.
|
private |
Pushes a new executor to the command-stack.
executor | The new executor |
bForce | If true, the executor is always assigned, even if the headers don't match |
|
private |
Pushes a new functor to the command-stack.
functor | The new functor |
bForce | If true, the functor is always assigned, even if the headers don't match |
|
private |
Pushes a copy of the current executor and functor on the stack.
Push a new object to the object-stack.
|
private |
Sets the functor to nullptr (which also deactivates the command).
|
inline |
Changes the activity of the command.
|
inline |
Defines the command to be an input command.
|
private |
Changes the executor.
executor | The new executor |
bForce | If true, the executor is always assigned, even if the headers don't match |
|
private |
Changes the functor of the current executor.
functor | The new functor |
bForce | If true, the functor is always assigned, even if the headers don't match |
|
inline |
Changes the visibility of the command.
|
private |
Changes the current object that is used to execute member-functions.
|
inline |
Makes the command visible.
|
friend |
|
private |
The access level (the state of the game in which you can access the command)
|
private |
ArgumentCompleter for each argument.
|
private |
True if the command should be active (it can still be inactive, for example if the function is missing)
|
private |
The functor that defines the header of the command-function.
|
private |
The name that was first assigned to the command.
|
private |
True if the command is hidden (it is still executable, but not visible in the list of available commands)
|
private |
A stack of commands, used to push and pop different functions.
|
private |
The description of the command.
|
private |
A description for each argument.
|
private |
A description of the return-value.
|
private |
The Executor that is used to execute the command.
|
private |
The input configured param.
|
private |
The keybind mode.
|
private |
All names and aliases of this command.
|
private |
A stack of objects, used to push and pop different objects for a function.