#include <ComponentApplication.h>
Inherits ComponentApplicationBus::Handler, and TickRequestBus::Handler.
Classes | |
struct | Descriptor |
struct | StartupParameters |
Public Member Functions | |
AZ_RTTI (ComponentApplication, "{1F3B070F-89F7-4C3D-B5A3-8832D5BC81D7}") | |
AZ_CLASS_ALLOCATOR (ComponentApplication, SystemAllocator) | |
ComponentApplication (int argC, char **argV) | |
virtual Entity * | Create (const Descriptor &descriptor, const StartupParameters &startupParameters=StartupParameters()) |
virtual void | Destroy () |
void | RegisterComponentDescriptor (const ComponentDescriptor *descriptor) final |
void | UnregisterComponentDescriptor (const ComponentDescriptor *descriptor) final |
void | RegisterEntityAddedEventHandler (EntityAddedEvent::Handler &handler) final |
void | RegisterEntityRemovedEventHandler (EntityRemovedEvent::Handler &handler) final |
void | RegisterEntityActivatedEventHandler (EntityActivatedEvent::Handler &handler) final |
void | RegisterEntityDeactivatedEventHandler (EntityDeactivatedEvent::Handler &handler) final |
void | SignalEntityActivated (Entity *entity) final |
void | SignalEntityDeactivated (Entity *entity) final |
bool | AddEntity (Entity *entity) override |
bool | RemoveEntity (Entity *entity) override |
bool | DeleteEntity (const EntityId &id) override |
Entity * | FindEntity (const EntityId &id) override |
AZStd::string | GetEntityName (const EntityId &id) override |
bool | SetEntityName (const EntityId &id, const AZStd::string_view name) override |
void | EnumerateEntities (const ComponentApplicationRequests::EntityCallback &callback) override |
ComponentApplication * | GetApplication () override |
SerializeContext * | GetSerializeContext () override |
Returns the serialize context that has been registered with the app, if there is one. | |
BehaviorContext * | GetBehaviorContext () override |
Returns the behavior context that has been registered with the app, if there is one. | |
JsonRegistrationContext * | GetJsonRegistrationContext () override |
Returns the json registration context that has been registered with the app, if there is one. | |
const char * | GetEngineRoot () const override |
Returns the path to the engine. | |
const char * | GetExecutableFolder () const override |
Returns the path to the folder the executable is in. | |
float | GetTickDeltaTime () override |
TickRequestBus. | |
ScriptTimePoint | GetTimeAtCurrentTick () override |
Descriptor & | GetDescriptor () |
virtual void | Tick () |
virtual void | TickSystem () |
virtual ComponentTypeList | GetRequiredSystemComponents () const |
void | ResolveModulePath (AZ::OSString &modulePath) override |
void | QueryApplicationType (AZ::ApplicationTypeQuery &appType) const override |
AZ::CommandLine * | GetAzCommandLine () override |
int * | GetArgC () |
char *** | GetArgV () |
void | LoadModules () |
void | LoadStaticModules () |
Loads only static modules which are populated via the CreateStaticModules member function. | |
void | LoadDynamicModules () |
Protected Types | |
using | TickTimepoint = AZStd::chrono::steady_clock::time_point |
using | RecordMetricsCallback = AZStd::function< bool(AZStd::chrono::steady_clock::time_point)> |
Protected Member Functions | |
void | InitializeSettingsRegistry () |
void | InitializeEventLoggerFactory () |
void | InitializeLifecyleEvents (SettingsRegistryInterface &settingsRegistry) |
void | InitializeConsole (SettingsRegistryInterface &settingsRegistry) |
void | RegisterCoreEventLogger () |
virtual void | CreateReflectionManager () |
void | DestroyReflectionManager () |
virtual void | PreModuleLoad () |
Perform any additional initialization needed before loading modules. | |
virtual void | CreateStaticModules (AZStd::vector< AZ::Module * > &outModules) |
void | CreateCommon () |
Common logic shared between the multiple Create(...) functions. | |
void | ConfigureSystemAllocatorTracking () |
Create the system allocator to track allocations. | |
virtual void | MergeSettingsToRegistry (SettingsRegistryInterface ®istry) |
void | MergeSharedSettings (SettingsRegistryInterface ®istry, const AZ::SettingsRegistryInterface::Specializations &specializations, AZStd::vector< char > &scratchBuffer) |
void | MergeUserSettings (SettingsRegistryInterface ®istry, const AZ::SettingsRegistryInterface::Specializations &specializations, AZStd::vector< char > &scratchBuffer) |
virtual void | SetSettingsRegistrySpecializations (SettingsRegistryInterface::Specializations &specializations) |
void | ReportBadEngineRoot () |
virtual void | RegisterCoreComponents () |
virtual void | Reflect (ReflectContext *context) |
bool | ShouldAddSystemComponent (AZ::ComponentDescriptor *descriptor) |
Check if a System Component should be created. | |
void | AddRequiredSystemComponents (AZ::Entity *systemEntity) |
Adds system components requested by modules and the application to the system entity. | |
Static Protected Member Functions | |
template<typename Iterator > | |
static void | NormalizePath (Iterator begin, Iterator end, bool doLowercase=true) |
Protected Attributes | |
AZStd::unique_ptr< ModuleManager > | m_moduleManager |
AZStd::unique_ptr< NameDictionary > | m_nameDictionary |
AZStd::unique_ptr< SettingsRegistryInterface > | m_settingsRegistry |
AZStd::unique_ptr< SettingsRegistryOriginTracker > | m_settingsRegistryOriginTracker |
AZStd::unique_ptr< AZ::IConsole > | m_console |
EntityAddedEvent | m_entityAddedEvent |
EntityRemovedEvent | m_entityRemovedEvent |
EntityAddedEvent | m_entityActivatedEvent |
EntityRemovedEvent | m_entityDeactivatedEvent |
Descriptor | m_descriptor |
bool | m_isStarted { false } |
IAllocator * | m_osAllocator { nullptr } |
EntitySetType | m_entities |
AZ::SettingsRegistryInterface::NotifyEventHandler | m_projectPathChangedHandler |
AZ::SettingsRegistryInterface::NotifyEventHandler | m_projectNameChangedHandler |
AZ::SettingsRegistryInterface::NotifyEventHandler | m_commandLineUpdatedHandler |
AZStd::unique_ptr< AZ::TimeSystem > | m_timeSystem |
AZ::SettingsRegistryConsoleUtils::ConsoleFunctorHandle | m_settingsRegistryConsoleFunctors |
AZ::SettingsRegistryConsoleUtils::ConsoleFunctorHandle | m_settingsRegistryOriginTrackerConsoleFunctors |
Debug::BudgetTracker | m_budgetTracker |
char | m_commandLineBuffer [AZ_MAX_PATH_LEN] |
char * | m_commandLineBufferAddress { m_commandLineBuffer } |
StartupParameters | m_startupParameters |
char ** | m_argV { nullptr } |
int | m_argC { 0 } |
AZ::CommandLine | m_commandLine |
AZStd::unique_ptr< AZ::Entity > | m_systemEntity |
Track the system entity to ensure we free it on shutdown. | |
AZStd::unique_ptr< AZ::Metrics::IEventLoggerFactory > | m_eventLoggerFactory |
TickTimepoint | m_lastTickTime {} |
RecordMetricsCallback | m_recordMetricsOnTickCallback |
A main class that can be used directly or as a base to start a component based application. It will provide all the proper bootstrap and entity bookkeeping functionality.
IMPORTANT: If you use this as a base class you must follow one rule. You can't add data that will allocate memory on construction. This is because the memory managers are NOT yet ready. They will be initialized during the Create call.
|
protected |
Callback function for determining whether a call to record metrics in the Tick() member function functionshould take place
currentMonotonicTime | - The monotonic tick time of the application since launch |
|
virtual |
Create function which accepts a variant which allows passing in either a ComponentApplication::Descriptor or a c-string path to an object stream descriptor file. The object stream descriptor path is deprecated and will removed when the gems are loaded from the settings registry If descriptor type = const char*: Loads the application configuration and systemEntity from 'applicationDescriptorFile' (path relative to AppRoot). It is expected that the first node in the file will be the descriptor, for memory manager creation. If descriptor type = Descriptor: Create system allocator and system entity. No components are added to the system node. You will need to setup all system components manually.
int * AZ::ComponentApplication::GetArgC | ( | ) |
Retrieve the argc passed into the application class on startup, if any was passed in. Note that this could return nullptr if the application was not initialized with any such parameter. This is important to have because different operating systems have different level of access to the command line args and on some operating systems (MacOS) its fairly difficult to reliably retrieve them without resorting to NS libraries and making some assumptions. Instead, we allow you to pass your args in from the main(...) function. Another thing to notice here is that these are non-const pointers to the argc and argv values instead of int, char**, these are int*, char***. This is because some application layers (such as Qt) actually require that the ArgC and ArgV are modifiable, as they actually patch them to add/remove command line parameters during initialization. but also to highlight the fact that they are pointers to static memory that must remain relevant throughout the existence of the Application object. For best results, simply pass in &argc and &argv from your void main(argc, argv) in here - that memory is permanently tied to your process and is going to be available at all times during run.
char *** AZ::ComponentApplication::GetArgV | ( | ) |
Retrieve the argv parameter passed into the application class on startup. see the note on ArgC Note that this could return nullptr if the application was not initialized with any such parameter.
|
override |
Returns Parsed CommandLine structure which supports query command line options and positional parameters
|
inlinevirtual |
Application-overridable way to state required system components. These components will be added to the system entity if they were not already provided by the application descriptor.
void AZ::ComponentApplication::LoadDynamicModules | ( | ) |
Performs loading of dynamic modules made up of the list of modules in the cmake_dependencies.*.setreg loaded into the AZ::SettingsRegistry plus the list of modules stored in the Descriptor::m_modules array
void AZ::ComponentApplication::LoadModules | ( | ) |
Perform loading of modules by appending the modules in the Descriptor to the list of modules in cmake_dependencies.*.setreg file for the active project
|
inlineprotectedvirtual |
This is the function that will be called instantly after the memory manager is created. This is where we should register all core component factories that will participate in the loading of the bootstrap file or all factories in general. When you create your own application this is where you should FIRST call ComponentApplication::RegisterCoreComponents and then register the application specific core components.
|
override |
ResolveModulePath is called whenever LoadDynamicModule wants to resolve a module in order to actually load it. You can override this if you need to load modules from a different path or hijack module loading in some other way. If you do, ensure that you use platform-specific conventions to do so, as this is called by multiple platforms. The default implantation prepends the path to the executable to the module path, but you can override this behavior (Call the base class if you want this behavior to persist in overrides)
|
protectedvirtual |
Sets the specializations that will be used when loading the Settings Registry. Extend this in derived application classes to specialize settings for those applications.
|
virtual |
Ticks all components using the AZ::TickBus during simulation time. May not tick if the application is not active (i.e. not in focus)
|
virtual |
Ticks all using the AZ::SystemTickBus at all times. Should always tick even if the application is not active.