Deki 1.3.0
Modular C++ 2D engine for embedded displays and desktop
Loading...
Searching...
No Matches

Base class for components that need async setup during boot. More...

#include <SetupComponent.h>

Inherits DekiBehaviour.

Public Types

using SetupCallback = std::function<void(bool success)>
using EditorAutoFactory = SetupComponent* (*)()

Public Member Functions

 SetupComponent ()=default
virtual ~SetupComponent ()=default
virtual void Setup (SetupCallback onComplete)=0
 Begin async setup.
virtual const char * GetSetupName () const =0
 Get display name for logging.
Public Member Functions inherited from DekiBehaviour
 DekiBehaviour ()
virtual ~DekiBehaviour ()=default
ComponentType GetType () const override
ComponentType GetBaseType () const override
DekiBehaviourAsBehaviour () override
virtual void Awake ()
 Called once after AssetRefs and ObjectRefs are resolved.
virtual void Start ()
 Called once before first Update, after ALL Awake calls complete.
virtual void Update ()
 Called every frame (only if needs_update is true).
bool HasAwoken () const
bool HasStarted () const
void MarkAwoken ()
void MarkStarted ()
virtual bool NeedsUpdate () const
 Runtime opt-out for Update() calls.
void SetNeedsUpdate (bool needs)
 Enable or disable per-frame Update() calls.
Public Member Functions inherited from DekiComponent
 DekiComponent ()
virtual ~DekiComponent ()=default
 DekiComponent (const DekiComponent &)=delete
DekiComponentoperator= (const DekiComponent &)=delete
virtual bool DeclaresUpdate () const
 Does this class (or a reflected base) declare Update()?
DekiObjectGetOwner () const
void SetOwner (DekiObject *owner)
virtual void LoadAssets ()
 Load assets needed by this component.
virtual void UnloadAssets ()
 Unload/clear assets held by this component.
virtual void RuntimeUpdate (float deltaTime)
 Update this component (runtime only).
virtual void OnAssetRefResolved (const char *propertyName, void *asset, const char *guid)
 Called after an AssetRef property is resolved by LifecycleManager.
virtual bool NeedsAssetLoading () const
 Check if this component needs asset loading.
virtual bool NeedsRuntimeUpdate () const
 Check if this component needs runtime updates.
virtual bool Deserialize (SceneFormat::SceneMsgPackParser &parser, uint32_t mapSize)
 Deserialize component data from MessagePack.
virtual void ResolveObjectRefs (class Scene *scene)
 Resolve all ObjectRef properties in this component.
virtual void RemapObjectRefs (const std::unordered_map< uint32_t, uint32_t > &idRemap)
 Remap ObjectRef IDs after cloning/instantiation.
bool HasRefsResolved () const
void MarkRefsResolved ()
void ResetRefsResolved ()
virtual void OnPropertyChanged (const char *propertyName)
 Called when a property is modified via the editor.

Static Public Member Functions

static SETUP_COMPONENT_API void RegisterEditorAutoFactory (EditorAutoFactory factory)
static SETUP_COMPONENT_API void ClearEditorAutoFactories ()
static SETUP_COMPONENT_API void RunEditorAutoSetups ()

Additional Inherited Members

Static Public Attributes inherited from DekiBehaviour
static constexpr ComponentType StaticType = DekiHashString("DekiBehaviour")
Static Public Attributes inherited from DekiComponent
static constexpr ComponentType StaticType = 0
Protected Attributes inherited from DekiComponent
DekiObjectm_Owner
bool m_RefsResolved

Detailed Description

Base class for components that need async setup during boot.

Similar pattern to RendererComponent - inherit from this to participate in the boot sequence. BootSequenceComponent uses ObjectRef<SetupComponent> to reference setup components.

Usage: class MyHardwareComponent : public SetupComponent { DEKI_COMPONENT(MyHardwareComponent, SetupComponent, "System", "your-guid-here", "DEKI_FEATURE_MY_HARDWARE")

void Setup(SetupCallback onComplete) override { bool success = InitializeHardware(); onComplete(success); }

const char* GetSetupName() const override { return "My Hardware"; } };

Member Typedef Documentation

◆ SetupCallback

using SetupComponent::SetupCallback = std::function<void(bool success)>

◆ EditorAutoFactory

Constructor & Destructor Documentation

◆ SetupComponent()

SetupComponent::SetupComponent ( )
default

◆ ~SetupComponent()

virtual SetupComponent::~SetupComponent ( )
virtualdefault

Member Function Documentation

◆ Setup()

virtual void SetupComponent::Setup ( SetupCallback onComplete)
pure virtual

Begin async setup.

Call callback when done.

Implementations should perform their initialization and then call the callback with true on success, false on failure.

Parameters
onCompleteCallback to invoke when setup finishes

◆ GetSetupName()

virtual const char * SetupComponent::GetSetupName ( ) const
pure virtual

Get display name for logging.

Returns
Human-readable name for this setup component

◆ RegisterEditorAutoFactory()

SETUP_COMPONENT_API void SetupComponent::RegisterEditorAutoFactory ( EditorAutoFactory factory)
static

◆ ClearEditorAutoFactories()

SETUP_COMPONENT_API void SetupComponent::ClearEditorAutoFactories ( )
static

◆ RunEditorAutoSetups()

SETUP_COMPONENT_API void SetupComponent::RunEditorAutoSetups ( )
static

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