VisuTwin Canvas
C++ 3D Engine — Metal Backend
Loading...
Searching...
No Matches
visutwin::canvas::Component Class Referenceabstract

Base class for ECS components that attach functionality to entities. More...

#include <framework/components/component.h>

Inheritance diagram for visutwin::canvas::Component:
[legend]

Public Member Functions

virtual void cloneFrom (const Component *source)
 Component (IComponentSystem *system, Entity *entity)
virtual bool enabled () const
Entityentity () const
virtual void initializeComponentData ()=0
virtual void onDisable ()
virtual void onEnable ()
virtual void onPostStateChange ()
virtual void setEnabled (bool value)
IComponentSystemsystem () const
virtual ~Component ()=default
Public Member Functions inherited from visutwin::canvas::EventHandler
template<typename... Args>
EventHandlerfire (const std::string &name, Args &&... args)
bool hasEvent (const std::string &name) const
void initEventHandler ()
template<typename Callback>
requires (!std::is_same_v<std::decay_t<Callback>, HandleEventCallback>)
EventHandleroff (const std::string &name, Callback &&callback, void *scope=nullptr)
EventHandleroff (const std::string &name="", const HandleEventCallback &callback=HandleEventCallback(), void *scope=nullptr)
EventHandleroffByHandle (EventHandle *handle)
template<typename Callback>
requires (!std::is_same_v<std::decay_t<Callback>, HandleEventCallback>)
EventHandleon (const std::string &name, Callback &&callback, void *scope=nullptr)
EventHandleon (const std::string &name, HandleEventCallback callback, void *scope=nullptr)
template<typename Callback>
requires (!std::is_same_v<std::decay_t<Callback>, HandleEventCallback>)
EventHandleonce (const std::string &name, Callback &&callback, void *scope=nullptr)
EventHandleonce (const std::string &name, HandleEventCallback callback, void *scope=nullptr)
virtual ~EventHandler ()=default

Protected Member Functions

virtual void onSetEnabled (bool oldValue, bool newValue)
Protected Member Functions inherited from visutwin::canvas::EventHandler
EventHandleaddCallback (const std::string &name, HandleEventCallback callback, void *scope=nullptr, bool once=false)

Protected Attributes

bool _enabled = true
Entity_entity

Detailed Description

Base class for ECS components that attach functionality to entities.

Components are created and managed by their owning ComponentSystem<T>. Each component has lifecycle hooks (onEnable, onDisable, onPostStateChange) and can be cloned when an Entity is duplicated. Component lookup on Entity is O(1) via a type-ID map.

Definition at line 39 of file component.h.

Constructor & Destructor Documentation

◆ Component()

◆ ~Component()

virtual visutwin::canvas::Component::~Component ( )
virtualdefault

Member Function Documentation

◆ cloneFrom()

virtual void visutwin::canvas::Component::cloneFrom ( const Component * source)
inlinevirtual

Copy component data from a source component during Entity::clone(). — each system copies its properties. Subclasses override to copy their specific properties.

Reimplemented in visutwin::canvas::LightComponent, and visutwin::canvas::RenderComponent.

Definition at line 69 of file component.h.

References Component().

◆ enabled()

◆ entity()

◆ initializeComponentData()

◆ onDisable()

virtual void visutwin::canvas::Component::onDisable ( )
inlinevirtual

Definition at line 59 of file component.h.

Referenced by onSetEnabled().

◆ onEnable()

virtual void visutwin::canvas::Component::onEnable ( )
inlinevirtual

◆ onPostStateChange()

virtual void visutwin::canvas::Component::onPostStateChange ( )
inlinevirtual

Definition at line 62 of file component.h.

◆ onSetEnabled()

void visutwin::canvas::Component::onSetEnabled ( bool oldValue,
bool newValue )
protectedvirtual

Definition at line 28 of file component.cpp.

References _entity, onDisable(), and onEnable().

Referenced by setEnabled().

◆ setEnabled()

void visutwin::canvas::Component::setEnabled ( bool value)
virtual

◆ system()

Member Data Documentation

◆ _enabled

◆ _entity


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