Open 3D Engine AzFramework 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.
AzFramework::Components::ComponentAdapter< TController, TConfiguration > Class Template Reference

#include <ComponentAdapter.h>

Inherits AZ::Component.

Public Member Functions

 AZ_RTTI ((ComponentAdapter, "{644A9187-4FDB-42C1-9D59-DD75304B551A}", TController, TConfiguration), AZ::Component)
 
 ComponentAdapter (const TConfiguration &configuration)
 
void Init () override
 
void Activate () override
 
void Deactivate () override
 

Static Public Member Functions

static void GetProvidedServices (AZ::ComponentDescriptor::DependencyArrayType &services)
 
static void GetIncompatibleServices (AZ::ComponentDescriptor::DependencyArrayType &services)
 
static void GetRequiredServices (AZ::ComponentDescriptor::DependencyArrayType &services)
 
static void GetDependentServices (AZ::ComponentDescriptor::DependencyArrayType &services)
 

Protected Member Functions

bool ReadInConfig (const AZ::ComponentConfig *baseConfig) override
 
bool WriteOutConfig (AZ::ComponentConfig *outBaseConfig) const override
 

Static Protected Member Functions

static void Reflect (AZ::ReflectContext *context)
 

Protected Attributes

TController m_controller
 

Detailed Description

template<typename TController, typename TConfiguration = AZ::ComponentConfig>
class AzFramework::Components::ComponentAdapter< TController, TConfiguration >

ComponentAdapter is a utility base class that provides a consistent pattern for implementing components that operate in the launcher but may need to share code in different contexts like the editor.

ComponentAdapter achieves this by delegating to a controller class that implements common behavior instead of duplicating code between multiple components.

To use the ComponentAdapter, 2 classes are required for the template:

  • a class that implements the functions required for TController (see below)
  • a configuration struct/class which extends AZ::ComponentConfig

The concrete component extends the adapter and implements behavior which is unique to the component.

TController can handle any common functionality between the runtime and editor component and is where most of the code for the component will live

TConfiguration is where any data that needs to be serialized out should live.

TController must implement certain functions to conform to the template. These functions mirror those in AZ::Component and must be accesible to any adapter that follows this pattern:

static void Reflect(AZ::ReflectContext* context);
void Activate(EntityId entityId);
void Deactivate();
void SetConfiguration(const ComponentConfigurationType& config);
const ComponentConfigurationType& GetConfiguration() const;

In addition, certain functions will optionally be called if they are available:

static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& services);
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& services);
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& services);
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& services);
void Init();

It is recommended that TController handle the SerializeContext, but the editor components handle the EditContext. TController can friend itself to the editor component to make this work if required.


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