diff --git a/include/UECS/ArchetypeFilter.h b/include/UECS/ArchetypeFilter.h index 0e04bee..657d1d5 100644 --- a/include/UECS/ArchetypeFilter.h +++ b/include/UECS/ArchetypeFilter.h @@ -9,8 +9,8 @@ namespace Ubpa::UECS { // filter Archetype with all, any and none struct ArchetypeFilter { - std::set all; - std::set any; + CmptAccessTypeSet all; + CmptAccessTypeSet any; std::set none; size_t HashCode() const noexcept; diff --git a/include/UECS/CmptLocator.h b/include/UECS/CmptLocator.h index f938525..2fed2f3 100644 --- a/include/UECS/CmptLocator.h +++ b/include/UECS/CmptLocator.h @@ -23,13 +23,13 @@ namespace Ubpa::UECS { size_t HashCode() const noexcept { return hashCode; } - const std::set& CmptAccessTypes() const noexcept { return cmptTypes; } + const CmptAccessTypeSet& CmptAccessTypes() const noexcept { return cmptTypes; } bool operator==(const CmptLocator& rhs) const; private: size_t GenHashCode() const noexcept; - std::set cmptTypes; + CmptAccessTypeSet cmptTypes; size_t hashCode; }; diff --git a/include/UECS/CmptType.h b/include/UECS/CmptType.h index 471f274..04146fc 100644 --- a/include/UECS/CmptType.h +++ b/include/UECS/CmptType.h @@ -6,6 +6,8 @@ #include +#include + namespace Ubpa::UECS { // Component Type // use a hashcode to distinguish different type @@ -68,10 +70,26 @@ namespace Ubpa::UECS { constexpr bool operator>=(const CmptAccessType& rhs) const noexcept { return type >= rhs.type; } constexpr bool operator==(const CmptAccessType& rhs) const noexcept { return type == rhs.type; } constexpr bool operator!=(const CmptAccessType& rhs) const noexcept { return type != rhs.type; } + + constexpr bool operator< (const CmptType& rhs) const noexcept { return type < rhs; } + constexpr bool operator<=(const CmptType& rhs) const noexcept { return type <= rhs; } + constexpr bool operator> (const CmptType& rhs) const noexcept { return type > rhs; } + constexpr bool operator>=(const CmptType& rhs) const noexcept { return type >= rhs; } + constexpr bool operator==(const CmptType& rhs) const noexcept { return type == rhs; } + constexpr bool operator!=(const CmptType& rhs) const noexcept { return type != rhs; } + + friend constexpr bool operator< (const CmptType& lhs, const CmptAccessType& rhs) noexcept { return lhs < rhs.type; } + friend constexpr bool operator<=(const CmptType& lhs, const CmptAccessType& rhs) noexcept { return lhs <= rhs.type; } + friend constexpr bool operator> (const CmptType& lhs, const CmptAccessType& rhs) noexcept { return lhs > rhs.type; } + friend constexpr bool operator>=(const CmptType& lhs, const CmptAccessType& rhs) noexcept { return lhs >= rhs.type; } + friend constexpr bool operator==(const CmptType& lhs, const CmptAccessType& rhs) noexcept { return lhs == rhs.type; } + friend constexpr bool operator!=(const CmptType& lhs, const CmptAccessType& rhs) noexcept { return lhs != rhs.type; } private: CmptType type; AccessMode mode; }; + + using CmptAccessTypeSet = std::set>; } #include "detail/CmptType.inl" diff --git a/include/UECS/detail/EntityMngr.inl b/include/UECS/detail/EntityMngr.inl index dbed852..4b9a3ec 100644 --- a/include/UECS/detail/EntityMngr.inl +++ b/include/UECS/detail/EntityMngr.inl @@ -136,7 +136,7 @@ namespace Ubpa::UECS { template std::vector EntityMngr::GetCmptArray(const ArchetypeFilter& filter) const { constexpr auto type = CmptType::Of; - assert(filter.all.find(type) != filter.all.end()); + assert(filter.all.find(type) != filter.all.end()); // transparent less std::vector rst; diff --git a/src/core/Schedule.cpp b/src/core/Schedule.cpp index 3a2f786..48d6f1b 100644 --- a/src/core/Schedule.cpp +++ b/src/core/Schedule.cpp @@ -55,7 +55,7 @@ namespace Ubpa::UECS::detail { return *this; } - set needTypes; + set> needTypes; set noneTypes; set sysFuncs; };