12 namespace ComponentModel
21 static void registerType();
37 static_assert(std::is_base_of<Component, T>::value,
"<T> not derived from Component");
40 return static_cast<T *
>(getComponent(typeId));
54 static_assert(std::is_base_of<Component, T>::value,
"<T> not derived from Component");
77 static_assert(std::is_base_of<Component, T>::value,
"<T> not derived from Component");
78 return static_cast<T *
>(getComponentPtr(type));
113 [[nodiscard]]
constexpr size_t getId() const noexcept {
return id; }
117 constexpr void setId(
const size_t id)
noexcept { this->
id = id; }
120 [[nodiscard]]
const std::string &
getName() const noexcept {
return name; }
131 constexpr void setUserData(
void* userData)
noexcept { this->userData = userData; }
134 [[deprecated]]
void setUserData(intptr_t userData) { this->userData =
reinterpret_cast<void*
>(userData); }
137 [[nodiscard]]
constexpr void*
getUserData() const noexcept {
return this->userData; }
147 size_t id =
static_cast<size_t>(-1);
150 void* userData =
nullptr;
Cogs::StringView getName< Cogs::ComponentModel::Entity >()
Definition: Entity.h:155
#define COGSFOUNDATION_API
Definition: FoundationBase.h:31
A collection of components, held by component handles.
Definition: ComponentCollection.h:19
Typed collection of components.
Definition: ComponentCollection.h:157
Base class for Component instances.
Definition: Component.h:143
Container for components, providing composition of dynamic entities.
Definition: Entity.h:18
T * getComponent() const
Get a pointer to the first component implementing the given type in the entity.
Definition: Entity.h:35
T * getComponent(const Reflection::Type &type) const
Get a pointer to the first component implementing the given type. Note T and type represented by type...
Definition: Entity.h:75
constexpr size_t getId() const noexcept
Get the unique identifier of this entity.
Definition: Entity.h:113
ComponentCollectionBase components
Handles to components attached to this entity.
Definition: Entity.h:141
constexpr void setId(const size_t id) noexcept
Definition: Entity.h:117
std::string name
Name of the entity.
Definition: Entity.h:144
void getComponents(ComponentCollection< T > &collection) const
Get all the components implementing the templated type.
Definition: Entity.h:52
const std::string & getName() const noexcept
Get the name of this entity.
Definition: Entity.h:120
const ComponentCollectionBase & getComponents() const
Get the collection of Component instances owned by this entity.
Definition: Entity.h:127
constexpr void * getUserData() const noexcept
Get user data.
Definition: Entity.h:137
constexpr void setUserData(void *userData) noexcept
Definition: Entity.h:131
void setUserData(intptr_t userData)
Deprecated use void*. Delete when Usage removed.
Definition: Entity.h:134
ComponentHandle getComponentHandle() const
Get a component handle to the first component implementing the given type.
Definition: Entity.h:90
Represents a discrete type definition, describing a native type class.
Definition: Type.h:89
Provides a weakly referenced view over the contents of a string.
Definition: StringView.h:24
uint16_t TypeId
Built in type used to uniquely identify a single type instance.
Definition: Name.h:48
Main Cogs namespace.
Definition: MortonCode.h:5
Handle to a Component instance.
Definition: Component.h:67
Represents an unique name.
Definition: Name.h:70