diff --git a/include/openPMD/backend/Attributable.hpp b/include/openPMD/backend/Attributable.hpp index 1fc62463d3..3b9cbb283e 100644 --- a/include/openPMD/backend/Attributable.hpp +++ b/include/openPMD/backend/Attributable.hpp @@ -173,6 +173,12 @@ namespace internal * Attributable::setDirtyRecursive(). */ bool dirtyRecursive = true; + + /** + * If frontend_parent is not null, then this is a key such that: + * &(*frontend_parent)[key] == this + */ + std::string ownKeyWithinParent; }; template diff --git a/include/openPMD/backend/Container.hpp b/include/openPMD/backend/Container.hpp index 1b2175d318..4e683fc57d 100644 --- a/include/openPMD/backend/Container.hpp +++ b/include/openPMD/backend/Container.hpp @@ -301,11 +301,11 @@ class Container : virtual public Attributable auto &ret = container().insert({key, std::move(t)}).first->second; if constexpr (std::is_same_v) { - ret.writable().ownKeyWithinParent = key; + ret.m_attri->ownKeyWithinParent = key; } else { - ret.writable().ownKeyWithinParent = std::to_string(key); + ret.m_attri->ownKeyWithinParent = std::to_string(key); } traits::GenerationPolicy gen; gen(ret, this); @@ -342,11 +342,11 @@ class Container : virtual public Attributable auto &ret = container().insert({key, std::move(t)}).first->second; if constexpr (std::is_same_v) { - ret.writable().ownKeyWithinParent = std::move(key); + ret.m_attri->ownKeyWithinParent = std::move(key); } else { - ret.writable().ownKeyWithinParent = + ret.m_attri->ownKeyWithinParent = std::to_string(std::move(key)); } traits::GenerationPolicy gen; diff --git a/include/openPMD/backend/Writable.hpp b/include/openPMD/backend/Writable.hpp index 01cdc545dd..bef03a5e7a 100644 --- a/include/openPMD/backend/Writable.hpp +++ b/include/openPMD/backend/Writable.hpp @@ -163,11 +163,6 @@ OPENPMD_private internal::AttributableData *attributable = nullptr; Writable *parent = nullptr; - /** - * If parent is not null, then this is a key such that: - * &(*parent)[key] == this - */ - std::string ownKeyWithinParent; /** * @brief Whether a Writable has been written to the backend. * diff --git a/src/Iteration.cpp b/src/Iteration.cpp index 53abad548b..25b6170b69 100644 --- a/src/Iteration.cpp +++ b/src/Iteration.cpp @@ -51,8 +51,8 @@ Iteration::Iteration() : Attributable(NoInit()) setTime(static_cast(0)); setDt(static_cast(1)); setTimeUnitSI(1); - meshes.writable().ownKeyWithinParent = "meshes"; - particles.writable().ownKeyWithinParent = "particles"; + meshes.m_attri->ownKeyWithinParent = "meshes"; + particles.m_attri->ownKeyWithinParent = "particles"; } template diff --git a/src/ParticleSpecies.cpp b/src/ParticleSpecies.cpp index 4006cc82ba..fcd97e71a3 100644 --- a/src/ParticleSpecies.cpp +++ b/src/ParticleSpecies.cpp @@ -30,7 +30,7 @@ namespace openPMD { ParticleSpecies::ParticleSpecies() { - particlePatches.writable().ownKeyWithinParent = "particlePatches"; + particlePatches.m_attri->ownKeyWithinParent = "particlePatches"; } void ParticleSpecies::read() diff --git a/src/Series.cpp b/src/Series.cpp index a99c7f92ff..4348c7bb59 100644 --- a/src/Series.cpp +++ b/src/Series.cpp @@ -1111,7 +1111,7 @@ void Series::initSeries( } series.iterations.linkHierarchy(*this); - series.iterations.writable().ownKeyWithinParent = "iterations"; + series.iterations.m_attri->ownKeyWithinParent = "iterations"; series.m_rankTable.m_attributable.linkHierarchy(*this); series.m_name = input->name; @@ -3449,18 +3449,19 @@ namespace debug }; make_indent(); auto const &w = attr.writable(); - std::cout << w.ownKeyWithinParent << '\t' << attr.m_attri.get() - << " -> " << &attr.writable() << '\n'; + std::cout << attr.m_attri->ownKeyWithinParent << '\t' + << attr.m_attri.get() << " -> " << &attr.writable() + << '\n'; make_indent(); std::cout << "Self:\t" << attr.m_attri->dirtySelf << "\tRec: " << attr.m_attri->dirtyRecursive << '\n'; std::cout << '\n'; graph << "{rank = same; "; graph << "_" << attr.m_attri.get() << "[color=green, label = \"A " - << attr.m_attri.get() << " '" << w.ownKeyWithinParent - << "'\"]; "; + << attr.m_attri.get() << " '" + << attr.m_attri->ownKeyWithinParent << "'\"]; "; graph << "_" << &w << "[color=blue, label = \"W " << &w << " '" - << w.ownKeyWithinParent << "'\"]; "; + << attr.m_attri->ownKeyWithinParent << "'\"]; "; graph << "}\n"; graph << "_" << &w << " -> _" << attr.m_attri.get() << "[dir=none];\n"; diff --git a/src/backend/Attributable.cpp b/src/backend/Attributable.cpp index 608eeccc07..a4ae4d3ea0 100644 --- a/src/backend/Attributable.cpp +++ b/src/backend/Attributable.cpp @@ -232,19 +232,19 @@ std::string Attributable::MyPath::openPMDPath() const auto Attributable::myPath() const -> MyPath { MyPath res; - Writable const *findSeries = &writable(); - while (findSeries->parent) + internal::AttributableData *findSeries = m_attri.get(); + while (findSeries->frontend_parent) { // we don't need to push_back the ownKeyWithinParent of the Series class // so it's alright that this loop doesn't ask the key of the last found // Writable res.group.push_back(findSeries->ownKeyWithinParent); - findSeries = findSeries->parent; + findSeries = findSeries->frontend_parent; } std::reverse(res.group.begin(), res.group.end()); - auto &seriesData = auxiliary::deref_dynamic_cast( - findSeries->attributable); + auto &seriesData = + auxiliary::deref_dynamic_cast(findSeries); Series series; series.setData(std::shared_ptr{ &seriesData, [](auto const *) {}});