snapshot: share ::orphans implementation (to deprecate in future though)

This commit is contained in:
Michele Caini
2023-06-07 09:17:25 +02:00
parent e366ffbd30
commit f91226ef47

View File

@@ -16,6 +16,31 @@
namespace entt {
/**
* @cond TURN_OFF_DOXYGEN
* Internal details not to be documented.
*/
namespace internal {
template<typename Registry>
void orphans(Registry &registry) {
auto view = registry.template view<typename Registry::entity_type>();
for(auto entt: view) {
if(registry.orphan(entt)) {
view.storage()->erase(entt);
}
}
}
} // namespace internal
/**
* Internal details not to be documented.
* @endcond
*/
/**
* @brief Utility class to create snapshots from a registry.
*
@@ -282,14 +307,7 @@ public:
* @return A valid loader to continue restoring data.
*/
basic_snapshot_loader &orphans() {
auto &storage = reg->template storage<entity_type>();
for(auto entt: storage) {
if(reg->orphan(entt)) {
storage.erase(entt);
}
}
internal::orphans(*reg);
return *this;
}
@@ -566,14 +584,7 @@ public:
* @return A non-const reference to this loader.
*/
basic_continuous_loader &orphans() {
auto &storage = reg->template storage<entity_type>();
for(auto entt: storage) {
if(reg->orphan(entt)) {
storage.erase(entt);
}
}
internal::orphans(*reg);
return *this;
}