Khaotic Engine Reborn
Loading...
Searching...
No Matches
ecs::IdentityComponent Class Reference
Inheritance diagram for ecs::IdentityComponent:
ecs::Component

Public Member Functions

 IdentityComponent ()
 
 IdentityComponent (int id)
 
 IdentityComponent (int id, const std::string &name)
 
void Initialize () override
 
int GetId () const
 
void SetId (int id)
 
const std::string & GetName () const
 
void SetName (const std::string &name)
 
ObjectType GetType () const
 
void SetType (ObjectType type)
 
- Public Member Functions inherited from ecs::Component
 Component (const Component &)=delete
 
Componentoperator= (const Component &)=delete
 
 Component (Component &&)=default
 
Componentoperator= (Component &&)=default
 
virtual void Update (float deltaTime)
 

Static Public Member Functions

static std::string ObjectTypeToString (ObjectType type)
 
static ObjectType StringToObjectType (const std::string &str)
 

Detailed Description

Definition at line 18 of file identity_component.h.

Constructor & Destructor Documentation

◆ IdentityComponent() [1/3]

ecs::IdentityComponent::IdentityComponent ( )
inline

Builder for the IdentityComponent class.

Definition at line 23 of file identity_component.h.

23: m_id(0), m_type(ObjectType::Unknown) {}

◆ IdentityComponent() [2/3]

ecs::IdentityComponent::IdentityComponent ( int id)
inlineexplicit

Definition at line 24 of file identity_component.h.

24: m_id(id), m_type(ObjectType::Unknown) {}

◆ IdentityComponent() [3/3]

ecs::IdentityComponent::IdentityComponent ( int id,
const std::string & name )
inline

Definition at line 25 of file identity_component.h.

25: m_id(id), m_name(name), m_type(ObjectType::Unknown) {}

Member Function Documentation

◆ GetId()

int ecs::IdentityComponent::GetId ( ) const
inline

Get the ID stored by the component.

Returns
The ID as an int.

Definition at line 40 of file identity_component.h.

40{ return m_id; }

◆ GetName()

const std::string & ecs::IdentityComponent::GetName ( ) const
inline

Get the name of the object.

Returns
The name as a string.

Definition at line 51 of file identity_component.h.

51{ return m_name; }

◆ GetType()

ObjectType ecs::IdentityComponent::GetType ( ) const
inline

Get the type of the object.

Returns
The type as an ObjectType enum.

Definition at line 62 of file identity_component.h.

62{ return m_type; }

◆ Initialize()

void ecs::IdentityComponent::Initialize ( )
inlineoverridevirtual

Initialize the component. This method is called when the component is added to an entity. It can be used to set up initial values or perform any necessary setup.

Reimplemented from ecs::Component.

Definition at line 33 of file identity_component.h.

33{}

◆ ObjectTypeToString()

static std::string ecs::IdentityComponent::ObjectTypeToString ( ObjectType type)
inlinestatic

Convert an ObjectType to a string representation.

Parameters
typeThe ObjectType to convert.
Returns
A string representation of the ObjectType.

Definition at line 74 of file identity_component.h.

74 {
75 switch (type) {
76 case ObjectType::Cube: return "Cube";
77 case ObjectType::Sphere: return "Sphere";
78 case ObjectType::Terrain: return "Terrain";
79 default: return "Unknown";
80 }
81 }

◆ SetId()

void ecs::IdentityComponent::SetId ( int id)
inline

Set the ID for the component.

Parameters
idThe ID to set.

Definition at line 45 of file identity_component.h.

45{ m_id = id; }

◆ SetName()

void ecs::IdentityComponent::SetName ( const std::string & name)
inline

Set the name of the object.

Parameters
nameThe name to set.

Definition at line 56 of file identity_component.h.

56{ m_name = name; }

◆ SetType()

void ecs::IdentityComponent::SetType ( ObjectType type)
inline

Set the type of the object.

Parameters
typeThe type to set as an ObjectType enum.

Definition at line 67 of file identity_component.h.

67{ m_type = type; }

◆ StringToObjectType()

static ObjectType ecs::IdentityComponent::StringToObjectType ( const std::string & str)
inlinestatic

Convert a string representation to an ObjectType.

Parameters
strThe string to convert.
Returns
The corresponding ObjectType, or Unknown if the string does not match any type.

Definition at line 88 of file identity_component.h.

88 {
89 if (str == "Cube") return ObjectType::Cube;
90 if (str == "Sphere") return ObjectType::Sphere;
91 if (str == "Terrain") return ObjectType::Terrain;
92 return ObjectType::Unknown;
93 }

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