Open 3D Engine AzCore API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::IConsole Class Referenceabstract

#include <IConsole.h>

Inherited by AZ::Console.

Public Types

using FunctorVisitor = AZStd::function< void(ConsoleFunctorBase *)>
 
using ConsoleCommandRegisteredEvent = AZ::Event< ConsoleFunctorBase * >
 Returns the AZ::Event<> invoked whenever a console command is registered.
 

Public Member Functions

 AZ_RTTI (IConsole, "{20001930-119D-4A80-BD67-825B7E4AEB3D}")
 
virtual PerformCommandResult PerformCommand (const char *command, ConsoleSilentMode silentMode=ConsoleSilentMode::NotSilent, ConsoleInvokedFrom invokedFrom=ConsoleInvokedFrom::AzConsole, ConsoleFunctorFlags requiredSet=ConsoleFunctorFlags::Null, ConsoleFunctorFlags requiredClear=ConsoleFunctorFlags::ReadOnly)=0
 
virtual PerformCommandResult PerformCommand (const ConsoleCommandContainer &commandAndArgs, ConsoleSilentMode silentMode=ConsoleSilentMode::NotSilent, ConsoleInvokedFrom invokedFrom=ConsoleInvokedFrom::AzConsole, ConsoleFunctorFlags requiredSet=ConsoleFunctorFlags::Null, ConsoleFunctorFlags requiredClear=ConsoleFunctorFlags::ReadOnly)=0
 
virtual PerformCommandResult PerformCommand (AZStd::string_view command, const ConsoleCommandContainer &commandArgs, ConsoleSilentMode silentMode=ConsoleSilentMode::NotSilent, ConsoleInvokedFrom invokedFrom=ConsoleInvokedFrom::AzConsole, ConsoleFunctorFlags requiredSet=ConsoleFunctorFlags::Null, ConsoleFunctorFlags requiredClear=ConsoleFunctorFlags::ReadOnly)=0
 
virtual void ExecuteConfigFile (AZStd::string_view configFileName)=0
 
virtual void ExecuteCommandLine (const AZ::CommandLine &commandLine)=0
 
virtual bool ExecuteDeferredConsoleCommands ()=0
 
virtual void ClearDeferredConsoleCommands ()=0
 Clear out any deferred console commands queue.
 
virtual bool HasCommand (AZStd::string_view command, ConsoleFunctorFlags ignoreAnyFlags=ConsoleFunctorFlags::IsInvisible)=0
 
virtual ConsoleFunctorBaseFindCommand (AZStd::string_view command, ConsoleFunctorFlags ignoreAnyFlags=ConsoleFunctorFlags::IsInvisible)=0
 
virtual AZStd::string AutoCompleteCommand (AZStd::string_view command, AZStd::vector< AZStd::string > *matches=nullptr)=0
 
template<typename RETURN_TYPE >
GetValueResult GetCvarValue (AZStd::string_view command, RETURN_TYPE &outValue)
 
virtual void VisitRegisteredFunctors (const FunctorVisitor &visitor)=0
 
virtual void RegisterFunctor (ConsoleFunctorBase *functor)=0
 
virtual void UnregisterFunctor (ConsoleFunctorBase *functor)=0
 
virtual void LinkDeferredFunctors (ConsoleFunctorBase *&deferredHead)=0
 
ConsoleCommandRegisteredEventGetConsoleCommandRegisteredEvent ()
 
ConsoleCommandInvokedEventGetConsoleCommandInvokedEvent ()
 Returns the AZ::Event<> invoked whenever a console command is executed.
 
DispatchCommandNotFoundEventGetDispatchCommandNotFoundEvent ()
 Returns the AZ::Event<> invoked whenever a console command could not be found.
 
virtual void RegisterCommandInvokerWithSettingsRegistry (AZ::SettingsRegistryInterface &settingsRegistry)=0
 
 AZ_DISABLE_COPY_MOVE (IConsole)
 

Static Public Attributes

static constexpr AZStd::string_view ConsoleRuntimeCommandKey = "/Amazon/AzCore/Runtime/ConsoleCommands"
 
static constexpr AZStd::string_view ConsoleAutoexecCommandKey = "/O3DE/Autoexec/ConsoleCommands"
 

Protected Attributes

ConsoleCommandRegisteredEvent m_consoleCommandRegisteredEvent
 
ConsoleCommandInvokedEvent m_consoleCommandInvokedEvent
 
DispatchCommandNotFoundEvent m_dispatchCommandNotFoundEvent
 

Detailed Description

A simple console class for providing text based variable and process interaction.

Member Function Documentation

◆ AutoCompleteCommand()

virtual AZStd::string AZ::IConsole::AutoCompleteCommand ( AZStd::string_view  command,
AZStd::vector< AZStd::string > *  matches = nullptr 
)
pure virtual

Finds all commands where the input command is a prefix and returns the longest matching substring prefix the results have in common.

Parameters
commandThe prefix string to find all matching commands for.
matchesThe list of all commands that match the input prefix.
Returns
The longest matching substring prefix the results have in common.

Implemented in AZ::Console.

◆ ClearDeferredConsoleCommands()

virtual void AZ::IConsole::ClearDeferredConsoleCommands ( )
pure virtual

Clear out any deferred console commands queue.

Implemented in AZ::Console.

◆ ExecuteCommandLine()

virtual void AZ::IConsole::ExecuteCommandLine ( const AZ::CommandLine commandLine)
pure virtual

Invokes all of the commands as contained in a concatenated command-line string.

Parameters
commandLinethe concatenated command-line string to execute

Implemented in AZ::Console.

◆ ExecuteConfigFile()

virtual void AZ::IConsole::ExecuteConfigFile ( AZStd::string_view  configFileName)
pure virtual

Loads and executes the specified config file.

Parameters
configFileNamethe filename of the config file to load and execute

Implemented in AZ::Console.

◆ ExecuteDeferredConsoleCommands()

virtual bool AZ::IConsole::ExecuteDeferredConsoleCommands ( )
pure virtual

Attempts to invoke a "deferred console command", which is a console command that has failed to execute previously due to the command not being registered yet.

Returns
boolean true if any deferred console commands have executed, false otherwise

Implemented in AZ::Console.

◆ FindCommand()

virtual ConsoleFunctorBase * AZ::IConsole::FindCommand ( AZStd::string_view  command,
ConsoleFunctorFlags  ignoreAnyFlags = ConsoleFunctorFlags::IsInvisible 
)
pure virtual

FindCommand finds the console command with the specified console string.

Parameters
commandthe command that is being searched for
Returns
non-null pointer to the console command if found

Implemented in AZ::Console.

◆ GetCvarValue()

template<typename RETURN_TYPE >
GetValueResult AZ::IConsole::GetCvarValue ( AZStd::string_view  command,
RETURN_TYPE &  outValue 
)
inline

Retrieves the value of the requested cvar.

Parameters
commandthe name of the cvar to find and retrieve the current value of
outValuereference to the instance to write the current cvar value to
Returns
GetValueResult::Success if the operation succeeded, or an error result if the operation failed

◆ HasCommand()

virtual bool AZ::IConsole::HasCommand ( AZStd::string_view  command,
ConsoleFunctorFlags  ignoreAnyFlags = ConsoleFunctorFlags::IsInvisible 
)
pure virtual

HasCommand is used to determine if the console knows about a command.

Parameters
commandthe command we are checking for
Returns
boolean true on if the command is registered, false otherwise

Implemented in AZ::Console.

◆ LinkDeferredFunctors()

virtual void AZ::IConsole::LinkDeferredFunctors ( ConsoleFunctorBase *&  deferredHead)
pure virtual

Should be invoked for every module that gets loaded.

Parameters
pointerto the modules set of ConsoleFunctors to register

Implemented in AZ::Console.

◆ PerformCommand() [1/3]

virtual PerformCommandResult AZ::IConsole::PerformCommand ( AZStd::string_view  command,
const ConsoleCommandContainer commandArgs,
ConsoleSilentMode  silentMode = ConsoleSilentMode::NotSilent,
ConsoleInvokedFrom  invokedFrom = ConsoleInvokedFrom::AzConsole,
ConsoleFunctorFlags  requiredSet = ConsoleFunctorFlags::Null,
ConsoleFunctorFlags  requiredClear = ConsoleFunctorFlags::ReadOnly 
)
pure virtual

Invokes a single console command, optionally returning the command output.

Parameters
commandthe command to execute
commandArgsthe arguments to the command to execute
silentModeif true, logs will be suppressed during command execution
invokedFromthe source point that initiated console invocation
requiredSeta set of flags that must be set on the functor for it to execute
requiredCleara set of flags that must NOT be set on the functor for it to execute
Returns
PerformCommandResult Returns "AZ::Success" if the command was executed; otherwise "AZ::Failure". Note: A failure could result in a deferred execution (check error for details).

Implemented in AZ::Console.

◆ PerformCommand() [2/3]

virtual PerformCommandResult AZ::IConsole::PerformCommand ( const char *  command,
ConsoleSilentMode  silentMode = ConsoleSilentMode::NotSilent,
ConsoleInvokedFrom  invokedFrom = ConsoleInvokedFrom::AzConsole,
ConsoleFunctorFlags  requiredSet = ConsoleFunctorFlags::Null,
ConsoleFunctorFlags  requiredClear = ConsoleFunctorFlags::ReadOnly 
)
pure virtual

Invokes a single console command, optionally returning the command output.

Parameters
commandthe command string to parse and execute on
silentModeif true, logs will be suppressed during command execution
invokedFromthe source point that initiated console invocation
requiredSeta set of flags that must be set on the functor for it to execute
requiredCleara set of flags that must NOT be set on the functor for it to execute
Returns
PerformCommandResult Returns "AZ::Success" if the command was executed; otherwise "AZ::Failure". Note: A failure could result in a deferred execution (check error for details).

Implemented in AZ::Console.

◆ PerformCommand() [3/3]

virtual PerformCommandResult AZ::IConsole::PerformCommand ( const ConsoleCommandContainer commandAndArgs,
ConsoleSilentMode  silentMode = ConsoleSilentMode::NotSilent,
ConsoleInvokedFrom  invokedFrom = ConsoleInvokedFrom::AzConsole,
ConsoleFunctorFlags  requiredSet = ConsoleFunctorFlags::Null,
ConsoleFunctorFlags  requiredClear = ConsoleFunctorFlags::ReadOnly 
)
pure virtual

Invokes a single console command, optionally returning the command output.

Parameters
commandAndArgslist of command and command arguments to execute. The first argument is the command itself
silentModeif true, logs will be suppressed during command execution
invokedFromthe source point that initiated console invocation
requiredSeta set of flags that must be set on the functor for it to execute
requiredCleara set of flags that must NOT be set on the functor for it to execute
Returns
PerformCommandResult Returns "AZ::Success" if the command was executed; otherwise "AZ::Failure". Note: A failure could result in a deferred execution (check error for details).

Implemented in AZ::Console.

◆ RegisterCommandInvokerWithSettingsRegistry()

virtual void AZ::IConsole::RegisterCommandInvokerWithSettingsRegistry ( AZ::SettingsRegistryInterface settingsRegistry)
pure virtual

Register a notification event handler with the Settings Registry That is responsible for updating console commands whenever a key is found underneath the "/Amazon/AzCore/Runtime/ConsoleCommands" JSON entry

Parameters
SettingsRegistry reference to register notifier with

Implemented in AZ::Console.

◆ RegisterFunctor()

virtual void AZ::IConsole::RegisterFunctor ( ConsoleFunctorBase functor)
pure virtual

Registers a ConsoleFunctor with the console instance.

Parameters
functorpointer to the ConsoleFunctor to register

Implemented in AZ::Console.

◆ UnregisterFunctor()

virtual void AZ::IConsole::UnregisterFunctor ( ConsoleFunctorBase functor)
pure virtual

Unregisters a ConsoleFunctor with the console instance.

Parameters
functorpointer to the ConsoleFunctor to unregister

Implemented in AZ::Console.

◆ VisitRegisteredFunctors()

virtual void AZ::IConsole::VisitRegisteredFunctors ( const FunctorVisitor visitor)
pure virtual

Visits all registered console functors.

Parameters
visitorthe instance to visit all functors with

Implemented in AZ::Console.


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