src/Entity/EntityTypes.hpp
src/Entity/EntityTypes.hpp
Core type definitions for the Entity identification system. More…
Namespaces
| Name |
|---|
| std Hash function specialization for EntityId to enable use in unordered containers. |
Classes
| Name | |
|---|---|
| struct | std::hash< EntityId > |
| struct | EntityDescriptor Descriptor for a discrete entity, sufficient to regenerate or reason about its origin. |
| struct | EntityTupleKey |
| struct | EntityTupleKeyHash |
| struct | DataEntry DataEntry. |
Types
| Name | |
|---|---|
| enum class std::uint8_t | EntityKind { PointEntity = 0, LineEntity = 1, EventEntity = 2, IntervalEntity = 3, MaskEntity = 4, TimeEntity = 5} Kinds of discrete entities that can be identified by an EntityId. |
Detailed Description
Core type definitions for the Entity identification system.
This header defines the fundamental types used throughout the Entity library:
- EntityId: Opaque identifier for discrete entities
- EntityKind: Classification of entity types
- EntityDescriptor: Full metadata for an entity
- EntityTupleKey: Composite key for entity registry lookups
- DataEntry: Template wrapper pairing data with EntityId
Types Documentation
enum EntityKind
| Enumerator | Value | Description |
|---|---|---|
| PointEntity | 0 | |
| LineEntity | 1 | |
| EventEntity | 2 | |
| IntervalEntity | 3 | |
| MaskEntity | 4 | |
| TimeEntity | 5 | A single time point within a specific TimeFrame (clock). |
Kinds of discrete entities that can be identified by an EntityId.
Source code
#ifndef ENTITYTYPES_HPP
#define ENTITYTYPES_HPP
#include "EntityId.hpp"// EntityId definition
#include <cstdint>
#include <string>
#include <utility>// std::forward
namespace std {
template<>
struct hash<EntityId> {
std::size_t operator()(EntityId const & e) const noexcept {
return std::hash<uint64_t>{}(e.id);
}
};
}// namespace std
enum class EntityKind : std::uint8_t {
PointEntity = 0,
LineEntity = 1,
EventEntity = 2,
IntervalEntity = 3,
MaskEntity = 4,
TimeEntity = 5
};
struct EntityDescriptor {
std::string data_key;
EntityKind kind;
std::int64_t time_value;
int local_index;
};
// Internal key used by EntityRegistry maps
struct EntityTupleKey {
std::string data_key;
EntityKind kind;
std::int64_t time_value;// store as primitive for hashing
int local_index;
bool operator==(EntityTupleKey const & other) const {
return kind == other.kind &&
local_index == other.local_index &&
time_value == other.time_value &&
data_key == other.data_key;
}
};
struct EntityTupleKeyHash {
std::size_t operator()(EntityTupleKey const & k) const noexcept {
std::size_t h1 = std::hash<std::string>{}(k.data_key);
std::size_t h2 = std::hash<std::uint8_t>{}(static_cast<std::uint8_t>(k.kind));
std::size_t h3 = std::hash<std::int64_t>{}(k.time_value);
std::size_t h4 = std::hash<int>{}(k.local_index);
// Combine hashes
std::size_t seed = h1;
seed ^= h2 + 0x9e3779b97f4a7c15ULL + (seed << 6) + (seed >> 2);
seed ^= h3 + 0x9e3779b97f4a7c15ULL + (seed << 6) + (seed >> 2);
seed ^= h4 + 0x9e3779b97f4a7c15ULL + (seed << 6) + (seed >> 2);
return seed;
}
};
template<typename TData>
struct DataEntry {
TData data;
EntityId entity_id;
template<typename... TDataArgs>
DataEntry(EntityId id, TDataArgs &&... args)
: data(std::forward<TDataArgs>(args)...),
entity_id(id) {}
};
#endif// ENTITYTYPES_HPPUpdated on 2026-11-13 at 20:25:43 +0000