Open 3D Engine EMotionFX Gem API Reference  24.09
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
MCore::CommandGroup Class Reference

#include <CommandGroup.h>

Public Member Functions

 CommandGroup ()
 
 CommandGroup (const AZStd::string &groupName, size_t numCommandsToReserve=3)
 
 ~CommandGroup ()
 
void AddCommandString (const char *commandString)
 
void AddCommand (MCore::Command *command)
 
void AddCommandString (const AZStd::string &commandString)
 
const char * GetCommandString (size_t index) const
 
const AZStd::string & GetCommandStringAsString (size_t index) const
 
CommandGetCommand (size_t index)
 
const CommandLineGetParameters (size_t index) const
 
const char * GetGroupName () const
 
const AZStd::string & GetGroupNameString () const
 
void SetGroupName (const char *groupName)
 
void SetGroupName (const AZStd::string &groupName)
 
void SetCommandString (size_t index, const char *commandString)
 
void SetParameters (size_t index, const CommandLine &params)
 
void SetCommand (size_t index, Command *command)
 
void SetContinueAfterError (bool continueAfter)
 
void SetAddToHistoryAfterError (bool addAfterError)
 
void SetReturnFalseAfterError (bool returnAfterError)
 
bool GetContinueAfterError () const
 
bool GetAddToHistoryAfterError () const
 
bool GetReturnFalseAfterError () const
 
size_t GetNumCommands () const
 
bool IsEmpty () const
 
void RemoveAllCommands (bool delFromMem=false)
 
void Clear (bool delFromMem=false)
 
CommandGroupClone () const
 
void ReserveCommands (size_t numToReserve)
 

Detailed Description

The command group class, which executes a set of commands internally, while showing just one item inside the command history. Undoing a command group would undo all commands inside the group.

Constructor & Destructor Documentation

◆ CommandGroup() [1/2]

MCore::CommandGroup::CommandGroup ( )

Default constructor. You can set the name of the group with SetGroupName() manually.

◆ CommandGroup() [2/2]

MCore::CommandGroup::CommandGroup ( const AZStd::string &  groupName,
size_t  numCommandsToReserve = 3 
)

The constructor.

Parameters
groupNameThe name of the command group, which is the name that will appear inside the command history.
numCommandsToReservePre-allocate memory for a given amount of commands. This can be used to prevent memory reallocations.

◆ ~CommandGroup()

MCore::CommandGroup::~CommandGroup ( )

The destructor. Please note that this does NOT delete the actual Command objects after the group has been executed. They are deleted by the command manager automatically.

Member Function Documentation

◆ AddCommandString() [1/2]

void MCore::CommandGroup::AddCommandString ( const AZStd::string &  commandString)

Add a command string to the group. This will be added to the back of the list of commands to be executed when executing this group.

Parameters
commandStringThe full command string, like you would execute using CommandManager::ExecuteCommand(...).

◆ AddCommandString() [2/2]

void MCore::CommandGroup::AddCommandString ( const char *  commandString)

Add a command string to the group. This will be added to the back of the list of commands to be executed when executing this group.

Parameters
commandStringThe full command string, like you would execute using CommandManager::ExecuteCommand(...).

◆ Clone()

CommandGroup* MCore::CommandGroup::Clone ( ) const

Clone this command group.

Returns
The clone of this command group.

◆ GetAddToHistoryAfterError()

bool MCore::CommandGroup::GetAddToHistoryAfterError ( ) const

Check whether this command group will be added to the history, even when one of the internal commands fails to execute. The default is true.

Returns
Returns false when the group will not be added to the history when one of the internal commands fails to execute, otherwise true is returned.

◆ GetCommand()

Command* MCore::CommandGroup::GetCommand ( size_t  index)

Get a given command. The return value can be nullptr in case the group hasn't yet been executed or when the execution of this command failed.

Parameters
indexThe command number to get the pointer to. This must be in range of [0..GetNumCommands()-1].
Returns
A pointer to the command, which can be nullptr.

◆ GetCommandString()

const char* MCore::CommandGroup::GetCommandString ( size_t  index) const

Get the command execution string for a given command inside the group.

Parameters
indexThe command number to get the string for. This must be in range of [0..GetNumCommands()-1].
Returns
The command string for the specified command.

◆ GetCommandStringAsString()

const AZStd::string& MCore::CommandGroup::GetCommandStringAsString ( size_t  index) const

Get the command execution string for a given command inside the group.

Parameters
indexThe command number to get the string for. This must be in range of [0..GetNumCommands()-1].
Returns
The command string for the specified command.

◆ GetContinueAfterError()

bool MCore::CommandGroup::GetContinueAfterError ( ) const

Check if we want to continue when one of the internal commands fails. If not, it will stop executing further commands. The default is true.

Returns
Returns false when the internal command execution will stop at the first error, otherwise true is returned.

◆ GetGroupName()

const char* MCore::CommandGroup::GetGroupName ( ) const

Get the name of the group. This is the name that will appear inside the command history also.

Returns
The name of the group.

◆ GetGroupNameString()

const AZStd::string& MCore::CommandGroup::GetGroupNameString ( ) const

Get the group name in form of a string object. This is the name that will appear inside the command history also.

Returns
The name of the group.

◆ GetNumCommands()

size_t MCore::CommandGroup::GetNumCommands ( ) const

Get the number of commands inside this group. Using AddCommandString will increase the number returned by this method.

Returns
The number of commands inside this group.

◆ GetParameters()

const CommandLine& MCore::CommandGroup::GetParameters ( size_t  index) const

Get the parameter commandline object for the given command. This is only set after executing the command. Otherwise the parameter list will be empty.

Parameters
indexThe command number ot get the parameter list for. This must be in range of [0..GetNumCommands()-1].
Returns
The CommandLine object which represents the parameter list used during execution of the command.

◆ GetReturnFalseAfterError()

bool MCore::CommandGroup::GetReturnFalseAfterError ( ) const

Check whether the group returns false after calling CommandManager::ExecuteCommandGroup(). The default value is false.

Returns
Returns true if the group return false in case an error occurred.

◆ RemoveAllCommands()

void MCore::CommandGroup::RemoveAllCommands ( bool  delFromMem = false)

Remove all commands from the group.

Parameters
delFromMemSet to true if you wish to delete the Command objects from memory as well. Normally you shouldn't do this as the command manager handles this.

◆ ReserveCommands()

void MCore::CommandGroup::ReserveCommands ( size_t  numToReserve)

Reserve space for a given amount of commands, to prevent reallocs.

Parameters
[in]numToReserveThe number of command strings to reserve memory for. This will prevent reallocs when adding new commands.

◆ SetAddToHistoryAfterError()

void MCore::CommandGroup::SetAddToHistoryAfterError ( bool  addAfterError)

Set whether to add the group to the command history if one of the commands failed to execute or not. The default value is true.

Parameters
addAfterErrorSet to true if you wish the group to be added to the command history, even if an error occurred.

◆ SetCommand()

void MCore::CommandGroup::SetCommand ( size_t  index,
Command command 
)

Set the command pointer for a given command number. Normally you will not be using this function as this is automatically set by the command manager.

Parameters
indexThe command number to set the command pointer for. This must be in range of [0..GetNumCommands()-1].
commandThe command to use.

◆ SetCommandString()

void MCore::CommandGroup::SetCommandString ( size_t  index,
const char *  commandString 
)

Set the command line string for a given command.

Parameters
indexThe command number to change the command string for. This must be in range of [0..GetNumCommands()-1].
commandStringThe command string to use. This is the string you would pass to CommandManager::ExecuteCommand(...).

◆ SetContinueAfterError()

void MCore::CommandGroup::SetContinueAfterError ( bool  continueAfter)

Set if we want to continue when one of the internal commands fails. If not, it will stop executing further commands. The default value is true.

Parameters
continueAfterSet to true to continue even after an error, or false to stop when one of the commands fails to execute.

◆ SetGroupName() [1/2]

void MCore::CommandGroup::SetGroupName ( const AZStd::string &  groupName)

Set the name of the group, which is the name as it will appear inside the command history.

Parameters
groupNameThe name of the group.

◆ SetGroupName() [2/2]

void MCore::CommandGroup::SetGroupName ( const char *  groupName)

Set the name of the group, which is the name as it will appear inside the command history.

Parameters
groupNameThe name of the group.

◆ SetParameters()

void MCore::CommandGroup::SetParameters ( size_t  index,
const CommandLine params 
)

Set the parameter list for a given command. Normally you will not be using this function as this is automatically set by the command manager.

Parameters
indexThe command number to change the parameter list for. This must be in range of [0..GetNumCommands()-1]. Please note that this isn't needed to be set normally. With normal usage you would only specify the command string and nothing more.
paramsThe parameter list.

◆ SetReturnFalseAfterError()

void MCore::CommandGroup::SetReturnFalseAfterError ( bool  returnAfterError)

Set whether the group returns false after calling CommandManager::ExecuteCommandGroup(). The default value is false.

Parameters
returnAfterErrorSet to true if you wish the group to fail and return false in case an error occurred.

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