File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -298,12 +298,7 @@ class Iteration
298298 [[deprecated(" This attribute is no longer set by the openPMD-api." )]] bool
299299 closedByWriter () const ;
300300
301- void visitHierarchy (HierarchyVisitor &v) override
302- {
303- v (*this );
304- meshes.visitHierarchy (v);
305- particles.visitHierarchy (v);
306- }
301+ void visitHierarchy (HierarchyVisitor &v) override ;
307302
308303 Meshes meshes{};
309304 Particles particles{};
Original file line number Diff line number Diff line change @@ -402,9 +402,27 @@ class Attributable
402402 */
403403 void touch ();
404404
405- virtual void visitHierarchy (HierarchyVisitor &);
405+ /* *
406+ * Visitor pattern for the openPMD object hierarchy in postfix traversal.
407+ *
408+ * @note As the HierarchyVisitor interface can be tedious to implement,
409+ * consider using visitHierarchyFromLambda for a more convenient
410+ * interface.
411+ *
412+ * @param visitor Operations to run for each object.
413+ */
414+ virtual void visitHierarchy (HierarchyVisitor &visitor);
406415
407- // definition inside include/openPMD/backend/HierarchyVisitorImpl.hpp
416+ /* *
417+ * Visitor pattern for the openPMD object hierarchy in postfix traversal,
418+ * lambda version.
419+ *
420+ * The lambda parameter will be called with a reference to each object in
421+ * the current object's enclosed hierarchy.
422+ *
423+ * @note Definition inside include/openPMD/backend/HierarchyVisitorImpl.hpp.
424+ * @param lambda Operations to run for each object.
425+ */
408426 template <typename Lambda>
409427 void visitHierarchyFromLambda (Lambda &&lambda);
410428
Original file line number Diff line number Diff line change @@ -266,11 +266,11 @@ class Container : virtual public Attributable
266266 template <typename ChildClass>
267267 void visitHierarchyImpl (HierarchyVisitor &v)
268268 {
269- v (*static_cast <ChildClass *>(this ));
270269 for (auto &p : *this )
271270 {
272271 p.second .visitHierarchy (v);
273272 }
273+ v (*static_cast <ChildClass *>(this ));
274274 }
275275
276276 // clang-format off
Original file line number Diff line number Diff line change @@ -254,6 +254,13 @@ bool Iteration::closedByWriter() const
254254 }
255255}
256256
257+ void Iteration::visitHierarchy (HierarchyVisitor &v)
258+ {
259+ meshes.visitHierarchy (v);
260+ particles.visitHierarchy (v);
261+ v (*this );
262+ }
263+
257264void Iteration::flushFileBased (
258265 std::string const &filename,
259266 IterationIndex_t i,
Original file line number Diff line number Diff line change @@ -3566,8 +3566,8 @@ void Series::close()
35663566
35673567void Series::visitHierarchy (HierarchyVisitor &v)
35683568{
3569- v (*this );
35703569 get ().iterations .visitHierarchy (v);
3570+ v (*this );
35713571}
35723572
35733573auto Series::currentSnapshot () -> std::optional<std::vector<IterationIndex_t>>
You can’t perform that action at this time.
0 commit comments