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::Console Class Referencefinal

#include <Console.h>

Inherits AZ::IConsole.

Public Member Functions

 AZ_RTTI (Console, "{CF6DCDE7-1A66-442C-BA87-01A432C13E7D}", IConsole)
 
 AZ_CLASS_ALLOCATOR (Console, AZ::OSAllocator)
 
 Console (AZ::SettingsRegistryInterface &settingsRegistry)
 
PerformCommandResult PerformCommand (const char *command, ConsoleSilentMode silentMode=ConsoleSilentMode::NotSilent, ConsoleInvokedFrom invokedFrom=ConsoleInvokedFrom::AzConsole, ConsoleFunctorFlags requiredSet=ConsoleFunctorFlags::Null, ConsoleFunctorFlags requiredClear=ConsoleFunctorFlags::ReadOnly) override
 
PerformCommandResult PerformCommand (const ConsoleCommandContainer &commandAndArgs, ConsoleSilentMode silentMode=ConsoleSilentMode::NotSilent, ConsoleInvokedFrom invokedFrom=ConsoleInvokedFrom::AzConsole, ConsoleFunctorFlags requiredSet=ConsoleFunctorFlags::Null, ConsoleFunctorFlags requiredClear=ConsoleFunctorFlags::ReadOnly) override
 
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) override
 
void ExecuteConfigFile (AZStd::string_view configFileName) override
 
void ExecuteCommandLine (const AZ::CommandLine &commandLine) override
 
bool ExecuteDeferredConsoleCommands () override
 
void ClearDeferredConsoleCommands () override
 Clear out any deferred console commands queue.
 
bool HasCommand (AZStd::string_view command, ConsoleFunctorFlags ignoreAnyFlags=ConsoleFunctorFlags::IsInvisible) override
 
ConsoleFunctorBaseFindCommand (AZStd::string_view command, ConsoleFunctorFlags ignoreAnyFlags=ConsoleFunctorFlags::IsInvisible) override
 
AZStd::string AutoCompleteCommand (AZStd::string_view command, AZStd::vector< AZStd::string > *matches=nullptr) override
 
void VisitRegisteredFunctors (const FunctorVisitor &visitor) override
 
void RegisterFunctor (ConsoleFunctorBase *functor) override
 
void UnregisterFunctor (ConsoleFunctorBase *functor) override
 
void LinkDeferredFunctors (ConsoleFunctorBase *&deferredHead) override
 
void RegisterCommandInvokerWithSettingsRegistry (AZ::SettingsRegistryInterface &settingsRegistry) override
 
- Public Member Functions inherited from AZ::IConsole
 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)
 

Friends

struct ConsoleCommandKeyNotificationHandler
 
class ConsoleFunctorBase
 

Additional Inherited Members

- Public Types inherited from AZ::IConsole
using FunctorVisitor = AZStd::function< void(ConsoleFunctorBase *)>
 
using ConsoleCommandRegisteredEvent = AZ::Event< ConsoleFunctorBase * >
 Returns the AZ::Event<> invoked whenever a console command is registered.
 
- Static Public Attributes inherited from AZ::IConsole
static constexpr AZStd::string_view ConsoleRuntimeCommandKey = "/Amazon/AzCore/Runtime/ConsoleCommands"
 
static constexpr AZStd::string_view ConsoleAutoexecCommandKey = "/O3DE/Autoexec/ConsoleCommands"
 
- Protected Attributes inherited from AZ::IConsole
ConsoleCommandRegisteredEvent m_consoleCommandRegisteredEvent
 
ConsoleCommandInvokedEvent m_consoleCommandInvokedEvent
 
DispatchCommandNotFoundEvent m_dispatchCommandNotFoundEvent
 

Detailed Description

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

Constructor & Destructor Documentation

◆ Console()

AZ::Console::Console ( AZ::SettingsRegistryInterface settingsRegistry)
explicit

Constructor overload which registers a notifier with the Settings Registry that will execute a console command whenever a key is set under the AZ::IConsole::ConsoleCommandRootKey JSON object

Member Function Documentation

◆ AutoCompleteCommand()

AZStd::string AZ::Console::AutoCompleteCommand ( AZStd::string_view  command,
AZStd::vector< AZStd::string > *  matches = nullptr 
)
overridevirtual

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.

Implements AZ::IConsole.

◆ ClearDeferredConsoleCommands()

void AZ::Console::ClearDeferredConsoleCommands ( )
overridevirtual

Clear out any deferred console commands queue.

Implements AZ::IConsole.

◆ ExecuteCommandLine()

void AZ::Console::ExecuteCommandLine ( const AZ::CommandLine commandLine)
overridevirtual

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

Parameters
commandLinethe concatenated command-line string to execute

Implements AZ::IConsole.

◆ ExecuteConfigFile()

void AZ::Console::ExecuteConfigFile ( AZStd::string_view  configFileName)
overridevirtual

Loads and executes the specified config file.

Parameters
configFileNamethe filename of the config file to load and execute

Implements AZ::IConsole.

◆ ExecuteDeferredConsoleCommands()

bool AZ::Console::ExecuteDeferredConsoleCommands ( )
overridevirtual

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

Implements AZ::IConsole.

◆ FindCommand()

ConsoleFunctorBase * AZ::Console::FindCommand ( AZStd::string_view  command,
ConsoleFunctorFlags  ignoreAnyFlags = ConsoleFunctorFlags::IsInvisible 
)
overridevirtual

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

Implements AZ::IConsole.

◆ HasCommand()

bool AZ::Console::HasCommand ( AZStd::string_view  command,
ConsoleFunctorFlags  ignoreAnyFlags = ConsoleFunctorFlags::IsInvisible 
)
overridevirtual

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

Implements AZ::IConsole.

◆ LinkDeferredFunctors()

void AZ::Console::LinkDeferredFunctors ( ConsoleFunctorBase *&  deferredHead)
overridevirtual

Should be invoked for every module that gets loaded.

Parameters
pointerto the modules set of ConsoleFunctors to register

Implements AZ::IConsole.

◆ PerformCommand() [1/3]

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

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).

Implements AZ::IConsole.

◆ PerformCommand() [2/3]

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

IConsole interface

Implements AZ::IConsole.

◆ PerformCommand() [3/3]

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

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).

Implements AZ::IConsole.

◆ RegisterCommandInvokerWithSettingsRegistry()

void AZ::Console::RegisterCommandInvokerWithSettingsRegistry ( AZ::SettingsRegistryInterface settingsRegistry)
overridevirtual

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

Implements AZ::IConsole.

◆ RegisterFunctor()

void AZ::Console::RegisterFunctor ( ConsoleFunctorBase functor)
overridevirtual

Registers a ConsoleFunctor with the console instance.

Parameters
functorpointer to the ConsoleFunctor to register

Implements AZ::IConsole.

◆ UnregisterFunctor()

void AZ::Console::UnregisterFunctor ( ConsoleFunctorBase functor)
overridevirtual

Unregisters a ConsoleFunctor with the console instance.

Parameters
functorpointer to the ConsoleFunctor to unregister

Implements AZ::IConsole.

◆ VisitRegisteredFunctors()

void AZ::Console::VisitRegisteredFunctors ( const FunctorVisitor visitor)
overridevirtual

Visits all registered console functors.

Parameters
visitorthe instance to visit all functors with

Implements AZ::IConsole.


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