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::Command Class Referenceabstract

#include <Command.h>

Inherited by CommandSystem::CommandAddTransitionCondition, CommandSystem::CommandAdjustMotion, CommandSystem::CommandAdjustMotionEvent, CommandSystem::CommandAdjustMotionEventTrack, CommandSystem::CommandAdjustNodeGroup, CommandSystem::CommandAdjustTransitionCondition, CommandSystem::CommandAnimGraphAddStateAction, CommandSystem::CommandAnimGraphAddTransitionAction, CommandSystem::CommandAnimGraphAdjustNodeGroup, CommandSystem::CommandAnimGraphAdjustTransition, CommandSystem::CommandAnimGraphRemoveStateAction, CommandSystem::CommandAnimGraphRemoveTransitionAction, CommandSystem::CommandClearMotionEvents, CommandSystem::CommandCreateMotionEvent, CommandSystem::CommandCreateMotionEventTrack, CommandSystem::CommandRemoveTransitionCondition, EMStudio::SourceControlCommand, EMotionFX::CommandAddCollider, EMotionFX::CommandAddRagdollJoint, EMotionFX::CommandAddSimulatedJoints, EMotionFX::CommandAddSimulatedObject, EMotionFX::CommandAdjustCollider, EMotionFX::CommandAdjustJointLimit, EMotionFX::CommandAdjustRagdollJoint, EMotionFX::CommandAdjustSimulatedJoint, EMotionFX::CommandAdjustSimulatedObject, EMotionFX::CommandRemoveCollider, EMotionFX::CommandRemoveRagdollJoint, EMotionFX::CommandRemoveSimulatedJoints, and EMotionFX::CommandRemoveSimulatedObject.

Classes

class  Callback
 

Public Member Functions

 Command (AZStd::string commandName, Command *originalCommand)
 
virtual ~Command ()
 
virtual bool Execute (const CommandLine &parameters, AZStd::string &outResult)=0
 
virtual bool Undo (const CommandLine &parameters, AZStd::string &outResult)
 
virtual CommandCreate ()=0
 
virtual bool GetIsUndoable () const
 
virtual void InitSyntax ()
 
virtual bool SetCommandParameters (const CommandLine &parameters)
 
virtual const char * GetDescription () const
 
virtual const char * GetHistoryName () const
 
const char * GetName () const
 
const AZStd::string & GetNameString () const
 
MCORE_INLINE CommandSyntaxGetSyntax ()
 
size_t GetNumCallbacks () const
 
size_t CalcNumPreCommandCallbacks () const
 
size_t CalcNumPostCommandCallbacks () const
 
MCORE_INLINE Command::CallbackGetCallback (size_t index)
 
void AddCallback (Command::Callback *callback)
 
bool CheckIfHasCallback (Command::Callback *callback) const
 
void RemoveCallback (Command::Callback *callback, bool delFromMem=true)
 
void RemoveAllCallbacks ()
 
void SetOriginalCommand (Command *orgCommand)
 
MCORE_INLINE CommandGetOriginalCommand ()
 
template<class T >
void ExecuteParameter (AZStd::optional< T > &oldParameter, AZStd::optional< T > &parameter, T &value)
 

Static Public Member Functions

static void Reflect (AZ::ReflectContext *context)
 

Detailed Description

If a command changes the state of any data in an application, it should implement undo and redo methods. The command manager checks if a command is undoable when executing it and if that method returns true the command will be remained and saved in the command history. If it is not undoable, the command instance is destroyed right away.

Constructor & Destructor Documentation

◆ Command()

MCore::Command::Command ( AZStd::string  commandName,
Command originalCommand 
)

Default constructor.

Parameters
commandNameThe unique identifier for the command.
originalCommandThe original command, or nullptr when this is the original command.

◆ ~Command()

virtual MCore::Command::~Command ( )
virtual

Destructor.

Member Function Documentation

◆ AddCallback()

void MCore::Command::AddCallback ( Command::Callback callback)

Add (register) a command callback.

Parameters
callBackThe command callback to register to this command.

◆ CalcNumPostCommandCallbacks()

size_t MCore::Command::CalcNumPostCommandCallbacks ( ) const

Calculate the number of registered post-execute callbacks.

Returns
The number of registered post-execute callbacks.

◆ CalcNumPreCommandCallbacks()

size_t MCore::Command::CalcNumPreCommandCallbacks ( ) const

Calculate the number of registered pre-execute callbacks.

Returns
The number of registered pre-execute callbacks.

◆ CheckIfHasCallback()

bool MCore::Command::CheckIfHasCallback ( Command::Callback callback) const

Check if we already registered a given command callback.

Parameters
callbackThe callback object to check for.
Returns
Returns true when the specified callback has already been added to this command, otherwise false is returned.

◆ Create()

virtual Command* MCore::Command::Create ( )
pure virtual

This will be called by the CommandManager when the command is executed. The function will return an instance of the command implementation which will be stored in the command history. An instance of the called command is needed to be able to store information for the undo.

Returns
The instance of the command.

Implemented in EMotionFX::CommandAdjustSimulatedJoint, EMotionFX::CommandRemoveSimulatedJoints, EMotionFX::CommandAddSimulatedJoints, EMotionFX::CommandAdjustSimulatedObject, EMotionFX::CommandRemoveSimulatedObject, EMotionFX::CommandAddSimulatedObject, EMotionFX::CommandAdjustRagdollJoint, EMotionFX::CommandRemoveRagdollJoint, EMotionFX::CommandAddRagdollJoint, CommandSystem::CommandAdjustNodeGroup, CommandSystem::CommandAdjustMotionEvent, CommandSystem::CommandCreateMotionEvent, CommandSystem::CommandClearMotionEvents, CommandSystem::CommandAdjustMotionEventTrack, CommandSystem::CommandCreateMotionEventTrack, CommandSystem::CommandAdjustMotion, EMotionFX::CommandAdjustJointLimit, EMotionFX::CommandRemoveCollider, EMotionFX::CommandAdjustCollider, EMotionFX::CommandAddCollider, CommandSystem::CommandAnimGraphRemoveStateAction, CommandSystem::CommandAnimGraphAddStateAction, CommandSystem::CommandAnimGraphRemoveTransitionAction, CommandSystem::CommandAnimGraphAddTransitionAction, CommandSystem::CommandAnimGraphAdjustNodeGroup, CommandSystem::CommandAnimGraphAdjustTransition, CommandSystem::CommandAdjustTransitionCondition, CommandSystem::CommandRemoveTransitionCondition, and CommandSystem::CommandAddTransitionCondition.

◆ Execute()

virtual bool MCore::Command::Execute ( const CommandLine parameters,
AZStd::string &  outResult 
)
pure virtual

The do it method should call redo it to make the command happen. The redo it method should do the actual work. This is a pure virtual method, and must be overridden in derived commands.

Parameters
parametersA list of the passed command arguments.
outResultThe result/return value of the command.
Returns
True if the command execution succeeded, false if not.

Implemented in EMotionFX::CommandAdjustSimulatedJoint, EMotionFX::CommandRemoveSimulatedJoints, EMotionFX::CommandAddSimulatedJoints, EMotionFX::CommandAdjustSimulatedObject, EMotionFX::CommandRemoveSimulatedObject, EMotionFX::CommandAddSimulatedObject, EMotionFX::CommandAdjustRagdollJoint, EMotionFX::CommandRemoveRagdollJoint, EMotionFX::CommandAddRagdollJoint, CommandSystem::CommandAdjustNodeGroup, CommandSystem::CommandAdjustMotionEvent, CommandSystem::CommandCreateMotionEvent, CommandSystem::CommandClearMotionEvents, CommandSystem::CommandAdjustMotionEventTrack, CommandSystem::CommandCreateMotionEventTrack, CommandSystem::CommandAdjustMotion, EMotionFX::CommandAdjustJointLimit, EMotionFX::CommandRemoveCollider, EMotionFX::CommandAdjustCollider, EMotionFX::CommandAddCollider, CommandSystem::CommandAnimGraphRemoveStateAction, CommandSystem::CommandAnimGraphAddStateAction, CommandSystem::CommandAnimGraphRemoveTransitionAction, CommandSystem::CommandAnimGraphAddTransitionAction, CommandSystem::CommandAnimGraphAdjustNodeGroup, CommandSystem::CommandAdjustTransitionCondition, CommandSystem::CommandRemoveTransitionCondition, and CommandSystem::CommandAddTransitionCondition.

◆ GetCallback()

MCORE_INLINE Command::Callback* MCore::Command::GetCallback ( size_t  index)
inline

Get a given command callback.

Parameters
indexThe callback number, which must be in range of [0..GetNumCallbacks()-1].
Returns
A pointer to the command callback object.

◆ GetDescription()

virtual const char* MCore::Command::GetDescription ( ) const
inlinevirtual

◆ GetHistoryName()

virtual const char* MCore::Command::GetHistoryName ( ) const
inlinevirtual

Get the name of the command as it can be shown in the command history. This can be a nicer name than the actual command name. For example some "MyAPILoadActor" command could be shown in the command history to the user with a more friendly name like "Load Actor". The "Load Actor" string could be returned by this function. On default the command name is returned.

Returns
The user-friendly name of the command.

Reimplemented in EMotionFX::CommandAdjustSimulatedJoint, EMotionFX::CommandRemoveSimulatedJoints, EMotionFX::CommandAddSimulatedJoints, EMotionFX::CommandAdjustSimulatedObject, EMotionFX::CommandRemoveSimulatedObject, EMotionFX::CommandAddSimulatedObject, EMotionFX::CommandAdjustRagdollJoint, EMotionFX::CommandRemoveRagdollJoint, EMotionFX::CommandAddRagdollJoint, CommandSystem::CommandAdjustNodeGroup, CommandSystem::CommandAdjustMotionEvent, CommandSystem::CommandCreateMotionEvent, CommandSystem::CommandClearMotionEvents, CommandSystem::CommandAdjustMotionEventTrack, CommandSystem::CommandCreateMotionEventTrack, CommandSystem::CommandAdjustMotion, EMotionFX::CommandAdjustJointLimit, EMotionFX::CommandRemoveCollider, EMotionFX::CommandAdjustCollider, EMotionFX::CommandAddCollider, CommandSystem::CommandAnimGraphRemoveStateAction, CommandSystem::CommandAnimGraphAddStateAction, CommandSystem::CommandAnimGraphRemoveTransitionAction, CommandSystem::CommandAnimGraphAddTransitionAction, CommandSystem::CommandAnimGraphAdjustNodeGroup, CommandSystem::CommandAnimGraphAdjustTransition, CommandSystem::CommandAdjustTransitionCondition, CommandSystem::CommandRemoveTransitionCondition, and CommandSystem::CommandAddTransitionCondition.

◆ GetIsUndoable()

virtual bool MCore::Command::GetIsUndoable ( ) const
virtual

This method is used to specify whether or not the command is undoable. On default, when not overloaded, it always returns false. If you are writing a command that might be eligible for undo, you should override this method. The is undoable method will be called and used to indicate whether or not the command will be saved in the command history in the command manager.

Returns
True if the command is undoable and should be saved in the command history, false if not.

Reimplemented in EMotionFX::CommandAdjustSimulatedJoint, EMotionFX::CommandRemoveSimulatedJoints, EMotionFX::CommandAddSimulatedJoints, EMotionFX::CommandAdjustSimulatedObject, EMotionFX::CommandRemoveSimulatedObject, EMotionFX::CommandAddSimulatedObject, EMotionFX::CommandAdjustRagdollJoint, EMotionFX::CommandRemoveRagdollJoint, EMotionFX::CommandAddRagdollJoint, CommandSystem::CommandAdjustNodeGroup, CommandSystem::CommandAdjustMotionEvent, CommandSystem::CommandCreateMotionEvent, CommandSystem::CommandClearMotionEvents, CommandSystem::CommandAdjustMotionEventTrack, CommandSystem::CommandCreateMotionEventTrack, CommandSystem::CommandAdjustMotion, EMotionFX::CommandAdjustJointLimit, EMotionFX::CommandRemoveCollider, EMotionFX::CommandAdjustCollider, EMotionFX::CommandAddCollider, CommandSystem::CommandAnimGraphRemoveStateAction, CommandSystem::CommandAnimGraphAddStateAction, CommandSystem::CommandAnimGraphRemoveTransitionAction, CommandSystem::CommandAnimGraphAddTransitionAction, CommandSystem::CommandAnimGraphAdjustNodeGroup, CommandSystem::CommandAnimGraphAdjustTransition, CommandSystem::CommandAdjustTransitionCondition, CommandSystem::CommandRemoveTransitionCondition, and CommandSystem::CommandAddTransitionCondition.

◆ GetName()

const char* MCore::Command::GetName ( ) const

Get the command string that is associated with this command.

Returns
The unique command name used to identify the command.

◆ GetNameString()

const AZStd::string& MCore::Command::GetNameString ( ) const

Get the command string that is associated with this command.

Returns
The unique command name used to identify the command.

◆ GetNumCallbacks()

size_t MCore::Command::GetNumCallbacks ( ) const

Get the number of registered/added command callbacks.

Returns
The number of command callbacks that have been added.

◆ GetOriginalCommand()

MCORE_INLINE Command* MCore::Command::GetOriginalCommand ( )
inline

Get the original command where this command has been cloned from. The original command contains the syntax. In case this is the original command, it returns a pointer to itself.

Returns
A pointer to the original command.

◆ GetSyntax()

MCORE_INLINE CommandSyntax& MCore::Command::GetSyntax ( )
inline

Get the command syntax. The syntax describes the possible parameters that can be passed to this command. Also it can verify and show info about these parameters.

Returns
The syntax object.

◆ InitSyntax()

◆ RemoveAllCallbacks()

void MCore::Command::RemoveAllCallbacks ( )

Remove all the registered command callbacks.

◆ RemoveCallback()

void MCore::Command::RemoveCallback ( Command::Callback callback,
bool  delFromMem = true 
)

Remove a given callback.

Parameters
callBackThe callback to remove.
delFromMemSet to true when you want the callback to be automatically removed from memory as well (even if its not found and removed).

◆ Undo()

virtual bool MCore::Command::Undo ( const CommandLine parameters,
AZStd::string &  outResult 
)
inlinevirtual

This method should undo the work done be the redo it method. This is a pure virtual method, and must be overridden in derived commands.

Parameters
parametersA list of the passed command arguments.
outResultThe result/return value of the command.
Returns
True if the command undo succeeded, false if not.

Reimplemented in EMotionFX::CommandAdjustSimulatedJoint, EMotionFX::CommandRemoveSimulatedJoints, EMotionFX::CommandAddSimulatedJoints, EMotionFX::CommandAdjustSimulatedObject, EMotionFX::CommandRemoveSimulatedObject, EMotionFX::CommandAddSimulatedObject, EMotionFX::CommandAdjustRagdollJoint, EMotionFX::CommandRemoveRagdollJoint, EMotionFX::CommandAddRagdollJoint, CommandSystem::CommandAdjustNodeGroup, CommandSystem::CommandAdjustMotionEvent, CommandSystem::CommandCreateMotionEvent, CommandSystem::CommandClearMotionEvents, CommandSystem::CommandAdjustMotionEventTrack, CommandSystem::CommandCreateMotionEventTrack, CommandSystem::CommandAdjustMotion, EMotionFX::CommandAdjustJointLimit, EMotionFX::CommandRemoveCollider, EMotionFX::CommandAdjustCollider, EMotionFX::CommandAddCollider, CommandSystem::CommandAnimGraphRemoveStateAction, CommandSystem::CommandAnimGraphAddStateAction, CommandSystem::CommandAnimGraphRemoveTransitionAction, CommandSystem::CommandAnimGraphAddTransitionAction, CommandSystem::CommandAnimGraphAdjustNodeGroup, CommandSystem::CommandAnimGraphAdjustTransition, CommandSystem::CommandAdjustTransitionCondition, CommandSystem::CommandRemoveTransitionCondition, and CommandSystem::CommandAddTransitionCondition.


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