diff --git a/include/openPMD/CustomHierarchy.hpp b/include/openPMD/CustomHierarchy.hpp index ee585ed6b3..dc23a97e64 100644 --- a/include/openPMD/CustomHierarchy.hpp +++ b/include/openPMD/CustomHierarchy.hpp @@ -85,7 +85,8 @@ namespace internal void syncAttributables(); - Container customHierarchies() +#if 0 + inline Container customHierarchiesWrapped() { Container res; res.setData( @@ -93,7 +94,8 @@ namespace internal [](auto const *) {}}); return res; } - Container embeddedDatasets() +#endif + inline Container embeddedDatasetsWrapped() { Container res; res.setData( @@ -101,7 +103,7 @@ namespace internal [](auto const *) {}}); return res; } - Container embeddedMeshes() + inline Container embeddedMeshesWrapped() { Container res; res.setData( @@ -110,7 +112,7 @@ namespace internal return res; } - Container embeddedParticles() + inline Container embeddedParticlesWrapped() { Container res; res.setData( @@ -118,6 +120,32 @@ namespace internal [](auto const *) {}}); return res; } + +#if 0 + inline Container::InternalContainer & + customHierarchiesInternal() + { + return static_cast *>(this) + ->m_container; + } +#endif + inline Container::InternalContainer & + embeddedDatasetsInternal() + { + return static_cast *>(this) + ->m_container; + } + inline Container::InternalContainer &embeddedMeshesInternal() + { + return static_cast *>(this)->m_container; + } + + inline Container::InternalContainer & + embeddedParticlesInternal() + { + return static_cast *>(this) + ->m_container; + } }; } // namespace internal @@ -218,16 +246,6 @@ class CustomHierarchy : public ConversibleContainer */ void linkHierarchy(Writable &w) override; - /* - * @brief Check recursively whether this object is dirty. - * It is dirty if any attribute or dataset is read from or written to - * the backend. - * - * @return true If dirty. - * @return false Otherwise. - */ - bool dirtyRecursive() const; - public: CustomHierarchy(CustomHierarchy const &other) = default; CustomHierarchy(CustomHierarchy &&other) = default; diff --git a/src/CustomHierarchy.cpp b/src/CustomHierarchy.cpp index 4398121a64..1dc0fb1788 100644 --- a/src/CustomHierarchy.cpp +++ b/src/CustomHierarchy.cpp @@ -402,8 +402,8 @@ void CustomHierarchy::read( std::deque constantComponentsPushback; auto &data = get(); - EraseStaleMeshes meshesMap(data.embeddedMeshes()); - EraseStaleParticles particlesMap(data.embeddedParticles()); + EraseStaleMeshes meshesMap(data.embeddedMeshesWrapped()); + EraseStaleParticles particlesMap(data.embeddedParticlesWrapped()); for (auto const &path : *pList.paths) { switch (mpp.determineType(currentPath)) @@ -487,7 +487,8 @@ void CustomHierarchy::read( // Group is a bit of an internal misnomer here, it just means that // it matches neither meshes nor particles path case internal::ContainedType::Group: { - auto &rc = data.embeddedDatasets()[path]; + auto embeddedDatasets = data.embeddedDatasetsWrapped(); + auto &rc = embeddedDatasets[path]; Parameter dOpen; dOpen.name = path; IOHandler()->enqueue(IOTask(&rc, dOpen)); @@ -505,7 +506,7 @@ void CustomHierarchy::read( << "' at path '" << myPath().openPMDPath() << "' and will skip it due to read error:\n" << err.what() << std::endl; - data.embeddedDatasets().container().erase(path); + embeddedDatasets.erase(path); } break; } @@ -528,7 +529,8 @@ void CustomHierarchy::read( for (auto const &path : constantComponentsPushback) { - auto &rc = data.embeddedDatasets()[path]; + auto embeddedDatasets = data.embeddedDatasetsWrapped(); + auto &rc = embeddedDatasets[path]; try { Parameter pOpen; @@ -543,7 +545,7 @@ void CustomHierarchy::read( << myPath().openPMDPath() << "/" << path << "' and will skip it due to read error:\n" << err.what() << std::endl; - data.embeddedDatasets().container().erase(path); + embeddedDatasets.erase(path); } } setDirty(false); @@ -580,7 +582,7 @@ void CustomHierarchy::flush_internal( subpath.flush_internal(flushParams, mpp, currentPath); currentPath.pop_back(); } - for (auto &[name, mesh] : data.embeddedMeshes()) + for (auto &[name, mesh] : data.embeddedMeshesInternal()) { if (!mpp.isMeshContainer(currentPath)) { @@ -604,7 +606,7 @@ void CustomHierarchy::flush_internal( } mesh.flush(name, flushParams); } - for (auto &[name, particleSpecies] : data.embeddedParticles()) + for (auto &[name, particleSpecies] : data.embeddedParticlesInternal()) { if (!mpp.isParticleContainer(currentPath)) { @@ -630,7 +632,7 @@ void CustomHierarchy::flush_internal( } particleSpecies.flush(name, flushParams); } - for (auto &[name, dataset] : get().embeddedDatasets()) + for (auto &[name, dataset] : get().embeddedDatasetsInternal()) { dataset.flush(name, flushParams, /* set_defaults = */ false); } @@ -653,27 +655,6 @@ void CustomHierarchy::linkHierarchy(Writable &w) { Attributable::linkHierarchy(w); } - -bool CustomHierarchy::dirtyRecursive() const -{ - if (dirty()) - { - return true; - } - auto check = [](auto const &container) { - for (auto const &pair : container) - { - if (pair.second.dirtyRecursive()) - { - return true; - } - } - return false; - }; - auto &data = const_cast(get()); // @todo do this better - return check(data.embeddedMeshes()) || check(data.embeddedParticles()) || - check(data.embeddedDatasets()) || check(data.customHierarchies()); -} } // namespace openPMD #undef OPENPMD_LEGAL_IDENTIFIER_CHARS