|
- #pragma once
-
- #include <ecs/core/utils/bitset.h>
-
- namespace ecs {
- namespace core {
- namespace utils {
-
- template<typename T_settings>
- template<typename T_component_tag>
- constexpr decltype(auto) bitset<T_settings>
- ::component_id(T_component_tag&& ct) noexcept
- {
- return mp::list::index_of(all_components(), std::forward<T_component_tag>(ct));
- }
-
- template<typename T_settings>
- template<typename T_system_signature>
- constexpr decltype(auto) bitset<T_settings>
- ::from_system_signature(T_system_signature&& ssig) noexcept
- {
- bitset ret;
- hana::for_each(hana::concat(ssig.read(), ssig.write()), [&ret](auto ct){
- ret.set_component(ct, true);
- });
- return ret;
- }
-
- template<typename T_settings>
- inline decltype(auto) bitset<T_settings>
- ::to_string() const
- {
- return _bitset.to_string();
- }
-
- template<typename T_settings>
- inline void bitset<T_settings>
- ::clear() noexcept
- {
- _bitset.reset();
- }
-
- template<typename T_settings>
- template<typename T_other>
- inline bool bitset<T_settings>
- ::contains(const T_other& other) const noexcept
- {
- return (_bitset & other._bitset) == other._bitset;
- }
-
- template<typename T_settings>
- template<typename T_component_tag>
- inline bool bitset<T_settings>
- ::has_component(T_component_tag ct) const
- {
- return _bitset.test(component_id(ct));
- }
-
- template<typename T_settings>
- template<typename T_component_tag>
- inline void bitset<T_settings>
- ::set_component(T_component_tag ct, bool value)
- {
- _bitset.set(component_id(ct), value);
- }
-
- } } }
|