Skip to content

Commit

Permalink
Fix this..
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Dec 18, 2024
1 parent 492d9af commit c77a51e
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 23 deletions.
6 changes: 6 additions & 0 deletions include/openPMD/backend/Attributable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename, typename>
Expand Down
8 changes: 4 additions & 4 deletions include/openPMD/backend/Container.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<T_key, std::string>)
{
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<T> gen;
gen(ret, this);
Expand Down Expand Up @@ -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<T_key, std::string>)
{
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<T> gen;
Expand Down
5 changes: 0 additions & 5 deletions include/openPMD/backend/Writable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
4 changes: 2 additions & 2 deletions src/Iteration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ Iteration::Iteration() : Attributable(NoInit())
setTime(static_cast<double>(0));
setDt(static_cast<double>(1));
setTimeUnitSI(1);
meshes.writable().ownKeyWithinParent = "meshes";
particles.writable().ownKeyWithinParent = "particles";
meshes.m_attri->ownKeyWithinParent = "meshes";
particles.m_attri->ownKeyWithinParent = "particles";
}

template <typename T>
Expand Down
2 changes: 1 addition & 1 deletion src/ParticleSpecies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace openPMD
{
ParticleSpecies::ParticleSpecies()
{
particlePatches.writable().ownKeyWithinParent = "particlePatches";
particlePatches.m_attri->ownKeyWithinParent = "particlePatches";
}

void ParticleSpecies::read()
Expand Down
13 changes: 7 additions & 6 deletions src/Series.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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";
Expand Down
10 changes: 5 additions & 5 deletions src/backend/Attributable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<internal::SeriesData>(
findSeries->attributable);
auto &seriesData =
auxiliary::deref_dynamic_cast<internal::SeriesData>(findSeries);
Series series;
series.setData(std::shared_ptr<internal::SeriesData>{
&seriesData, [](auto const *) {}});
Expand Down

0 comments on commit c77a51e

Please sign in to comment.