Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
Ndk::BaseComponent Class Referenceabstract

NDK class that represents the common base of all components. More...

Inherited by Ndk::Component< CameraComponent >, Ndk::Component< CollisionComponent2D >, Ndk::Component< CollisionComponent3D >, Ndk::Component< GraphicsComponent >, Ndk::Component< LightComponent >, Ndk::Component< ListenerComponent >, Ndk::Component< NodeComponent >, Ndk::Component< ParticleEmitterComponent >, Ndk::Component< ParticleGroupComponent >, Ndk::Component< PhysicsComponent2D >, Ndk::Component< PhysicsComponent3D >, Ndk::Component< VelocityComponent >, and Ndk::Component< ComponentType >.

Public Types

using Factory = std::function< BaseComponent *()>
 

Public Member Functions

 BaseComponent (ComponentIndex componentIndex)
 Constructs a BaseComponent object with an index. More...
 
 BaseComponent (BaseComponent &&)=default
 
virtual std::unique_ptr< BaseComponentClone () const =0
 
const EntityHandleGetEntity () const
 Gets the entity owning this component. More...
 
ComponentIndex GetIndex () const
 Gets the index of the component. More...
 
BaseComponentoperator= (const BaseComponent &)=delete
 
BaseComponentoperator= (BaseComponent &&)=default
 

Static Public Member Functions

static ComponentIndex GetMaxComponentIndex ()
 Gets the maximal index of the components. More...
 

Protected Member Functions

 BaseComponent (const BaseComponent &)=default
 

Static Protected Member Functions

static ComponentIndex RegisterComponent (ComponentId id, Factory factoryFunc)
 Registers a component. More...
 

Protected Attributes

ComponentIndex m_componentIndex
 
EntityHandle m_entity
 

Friends

class Sdk
 

Detailed Description

NDK class that represents the common base of all components.

Remarks
This class is meant to be purely abstract, for type erasure

Constructor & Destructor Documentation

◆ BaseComponent()

Ndk::BaseComponent::BaseComponent ( ComponentIndex  index)
inline

Constructs a BaseComponent object with an index.

Parameters
indexIndex of the component

Member Function Documentation

◆ GetEntity()

const EntityHandle & Ndk::BaseComponent::GetEntity ( ) const
inline

Gets the entity owning this component.

Returns
A handle to the entity owning this component, may be invalid if no entity owns it.

◆ GetIndex()

ComponentIndex Ndk::BaseComponent::GetIndex ( ) const
inline

Gets the index of the component.

Returns
Index of the component

◆ GetMaxComponentIndex()

ComponentIndex Ndk::BaseComponent::GetMaxComponentIndex ( )
inlinestatic

Gets the maximal index of the components.

Returns
Index of the maximal component

◆ RegisterComponent()

ComponentIndex Ndk::BaseComponent::RegisterComponent ( ComponentId  id,
Factory  factoryFunc 
)
inlinestaticprotected

Registers a component.

Returns
Index of the registered component
Parameters
idIndex of the component
factoryFactory to create the component
Remarks
Produces a NazaraAssert if the identifier is already in use

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