group: get filter from handlers

This commit is contained in:
Michele Caini
2023-03-15 10:32:59 +01:00
parent 945dc40937
commit e737ff7470
2 changed files with 19 additions and 15 deletions

View File

@@ -152,6 +152,11 @@ public:
return len;
}
template<typename Type>
Type filter_as() const noexcept {
return filter;
}
private:
std::tuple<Owned *..., Get *...> pools;
std::tuple<Exclude *...> filter;
@@ -204,6 +209,11 @@ public:
return elem;
}
template<typename Type>
Type filter_as() const noexcept {
return filter;
}
private:
std::tuple<Get *...> pools;
std::tuple<Exclude *...> filter;
@@ -280,12 +290,10 @@ public:
* @brief Constructs a group from a set of storage classes.
* @param ref A reference to a group handler.
* @param gpool The storage for the _observed_ types to iterate.
* @param epool The storage for the types used to filter the group.
*/
basic_group(handler &ref, Get &...gpool, Exclude &...epool) noexcept
basic_group(handler &ref, Get &...gpool) noexcept
: descriptor{&ref},
pools{&gpool...},
filter{&epool...} {}
pools{&gpool...} {}
/**
* @brief Returns the leading storage of a group.
@@ -317,7 +325,7 @@ public:
if constexpr(Index < offset) {
return *std::get<Index>(pools);
} else {
return *std::get<Index - offset>(filter);
return *std::get<Index - offset>(descriptor->template filter_as<std::tuple<Exclude *...>>());
}
}
@@ -621,7 +629,6 @@ public:
private:
handler *descriptor;
std::tuple<Get *...> pools;
std::tuple<Exclude *...> filter;
};
/**
@@ -688,12 +695,10 @@ public:
* @param ref A reference to a group handler.
* @param opool The storage for the _owned_ types to iterate.
* @param gpool The storage for the _observed_ types to iterate.
* @param epool The storage for the types used to filter the group.
*/
basic_group(handler &ref, Owned &...opool, Get &...gpool, Exclude &...epool) noexcept
basic_group(handler &ref, Owned &...opool, Get &...gpool) noexcept
: descriptor{&ref},
pools{&opool..., &gpool...},
filter{&epool...} {}
pools{&opool..., &gpool...} {}
/**
* @brief Returns the leading storage of a group.
@@ -725,7 +730,7 @@ public:
if constexpr(Index < offset) {
return *std::get<Index>(pools);
} else {
return *std::get<Index - offset>(filter);
return *std::get<Index - offset>(descriptor->template filter_as<std::tuple<Exclude *...>>());
}
}
@@ -999,7 +1004,6 @@ public:
private:
handler *descriptor;
std::tuple<Owned *..., Get *...> pools;
std::tuple<Exclude *...> filter;
};
} // namespace entt

View File

@@ -1258,7 +1258,7 @@ public:
}
}
return {*handler, assure<std::remove_const_t<Owned>>(), assure<std::remove_const_t<Other>>()..., assure<std::remove_const_t<Get>>()..., assure<std::remove_const_t<Exclude>>()...};
return {*handler, assure<std::remove_const_t<Owned>>(), assure<std::remove_const_t<Other>>()..., assure<std::remove_const_t<Get>>()...};
}
/**
@@ -1294,7 +1294,7 @@ public:
}
}
return {*handler, assure<std::remove_const_t<Get>>(), assure<std::remove_const_t<Other>>()..., assure<std::remove_const_t<Exclude>>()...};
return {*handler, assure<std::remove_const_t<Get>>(), assure<std::remove_const_t<Other>>()...};
}
/*! @copydoc group */
@@ -1306,7 +1306,7 @@ public:
if(auto it = groups.find(type_hash<handler_type>::value()); it == groups.cend()) {
return {};
} else {
return {*static_cast<handler_type *>(it->second.get()), assure<std::remove_const_t<Owned>>()..., assure<std::remove_const_t<Get>>()..., assure<std::remove_const_t<Exclude>>()...};
return {*static_cast<handler_type *>(it->second.get()), assure<std::remove_const_t<Owned>>()..., assure<std::remove_const_t<Get>>()...};
}
}