# Khaotic Engine Reborn: ecs::IdentityComponent Class Reference

Loading...
Searching...
No Matches
ecs::IdentityComponent Class Reference
Inheritance diagram for ecs::IdentityComponent:

## 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
Component & | operator= (const Component &)=delete
| Component (Component &&)=default
Component & | operator= (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.

: 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.

: 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.

: 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.

{ 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.

{ 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.

{ 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.

{}

## ObjectTypeToString()

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

inlinestatic

Convert an ObjectType to a string representation.

Parameters

  type | The ObjectType to convert.

Returns
  A string representation of the ObjectType.

Definition at line 74 of file identity_component.h.

{
switch (type) {
case ObjectType::Cube: return "Cube";
case ObjectType::Sphere: return "Sphere";
case ObjectType::Terrain: return "Terrain";
default: return "Unknown";
}
}

## SetId()

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

inline

Set the ID for the component.

Parameters

  id | The ID to set.

Definition at line 45 of file identity_component.h.

{ m_id = id; }

## SetName()

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

inline

Set the name of the object.

Parameters

  name | The name to set.

Definition at line 56 of file identity_component.h.

{ m_name = name; }

## SetType()

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

inline

Set the type of the object.

Parameters

  type | The type to set as an ObjectType enum.

Definition at line 67 of file identity_component.h.

{ m_type = type; }

## StringToObjectType()

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

inlinestatic

Convert a string representation to an ObjectType.

Parameters

  str | The 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.

{
if (str == "Cube") return ObjectType::Cube;
if (str == "Sphere") return ObjectType::Sphere;
if (str == "Terrain") return ObjectType::Terrain;
return ObjectType::Unknown;
}

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

- enginecustom/src/inc/system/ecs/components/identity_component.h