Go to the documentation of this file.    1 #ifndef EAGINE_ECS_COMPONENT_HPP 
    9 #define EAGINE_ECS_COMPONENT_HPP 
   11 #include "../config/basic.hpp" 
   12 #include "../flat_map.hpp" 
   13 #include "../identifier_t.hpp" 
   14 #include "../optional_ref.hpp" 
   15 #include <type_traits> 
   17 namespace eagine::ecs {
 
   23 template <
typename Derived, 
bool IsRelation>
 
   25     static constexpr 
auto component_uid() noexcept {
 
   26         return Derived::uid();
 
   29     static constexpr 
auto is_relation() noexcept {
 
   35 template <
typename Derived>
 
   36 using component = entity_data<Derived, false>;
 
   39 template <
typename Derived>
 
   40 using relation = entity_data<Derived, true>;
 
   44 class component_uid_map {
 
   46     flat_map<component_uid_t, T> _storage{};
 
   49     auto find(component_uid_t cid) noexcept -> optional_reference_wrapper<T> {
 
   50         const auto pos{_storage.find(cid)};
 
   51         if(pos != _storage.end()) {
 
   57     auto find(component_uid_t cid) 
const noexcept
 
   58       -> optional_reference_wrapper<const T> {
 
   59         const auto pos{_storage.find(cid)};
 
   60         if(pos != _storage.end()) {
 
   66     template <
typename... Args>
 
   67     auto emplace(component_uid_t cid, Args&&... args) -> 
bool {
 
   68         return _storage.emplace(cid, std::forward<Args>(args)...).second;
 
   71     auto erase(component_uid_t cid) {
 
   72         return _storage.erase(cid);
 
   75     auto operator[](component_uid_t cid) -> T& {
 
   82 #endif // EAGINE_ECS_COMPONENT_HPP 
 
static auto find(basic_span< T1, P1, S1 > where, basic_span< T2, P2, S2 > what) -> basic_span< T1, P1, S1 >
Finds the position of the last occurrence of what in a span.
Definition: span_algo.hpp:374
 
std::uint64_t identifier_t
The underlying integer type for eagine::identifier.
Definition: identifier_t.hpp:19
 
static constexpr nothing_t nothing
Constant of nothing_t type.
Definition: nothing.hpp:30