Skip to content

Commit 150f172

Browse files
committed
Treat "meshes"/"particles" as normal subgroups
Introduction of iteration["meshes"].asContainerOf<Mesh>() as a more explicit variant for iteration.meshes.
1 parent c2aae33 commit 150f172

File tree

3 files changed

+380
-185
lines changed

3 files changed

+380
-185
lines changed

include/openPMD/CustomHierarchy.hpp

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@ namespace internal
4444
std::optional<std::string> meshesPath;
4545
std::optional<std::string> particlesPath;
4646

47+
inline std::string requestMeshesPath()
48+
{
49+
meshesPath = meshesPath.value_or("meshes");
50+
return *meshesPath;
51+
}
52+
inline std::string requestParticlesPath()
53+
{
54+
particlesPath = particlesPath.value_or("particles");
55+
return *particlesPath;
56+
}
57+
4758
explicit MeshesParticlesPath() = default;
4859
MeshesParticlesPath(
4960
std::optional<std::string> meshesPath,
@@ -67,6 +78,8 @@ namespace internal
6778
void syncAttributables();
6879

6980
Container<RecordComponent> m_embeddedDatasets;
81+
Container<Mesh> m_embeddedMeshes;
82+
Container<ParticleSpecies> m_embeddedParticles;
7083
};
7184
} // namespace internal
7285

@@ -91,8 +104,12 @@ class CustomHierarchy : public Container<CustomHierarchy>
91104
return *m_customHierarchyData;
92105
}
93106

94-
void readMeshes(std::string const &meshesPath);
95-
void readParticles(std::string const &particlesPath);
107+
using EraseStaleMeshes = internal::EraseStaleEntries<Container<Mesh>>;
108+
using EraseStaleParticles =
109+
internal::EraseStaleEntries<Container<ParticleSpecies>>;
110+
void readNonscalarMesh(EraseStaleMeshes &map, std::string const &name);
111+
void readScalarMesh(EraseStaleMeshes &map, std::string const &name);
112+
void readParticleSpecies(EraseStaleParticles &map, std::string const &name);
96113

97114
protected:
98115
CustomHierarchy();
@@ -139,10 +156,17 @@ class CustomHierarchy : public Container<CustomHierarchy>
139156
CustomHierarchy &operator=(CustomHierarchy const &) = default;
140157
CustomHierarchy &operator=(CustomHierarchy &&) = default;
141158

159+
mapped_type &operator[](key_type &&key);
160+
mapped_type &operator[](key_type const &key);
161+
142162
template <typename ContainedType>
143163
auto asContainerOf() -> Container<ContainedType> &;
144164

145165
Container<Mesh> meshes{};
146166
Container<ParticleSpecies> particles{};
167+
168+
private:
169+
template <typename KeyType>
170+
mapped_type &bracketOperatorImpl(KeyType &&);
147171
};
148172
} // namespace openPMD

0 commit comments

Comments
 (0)