Skip to content

Commit 4aea6d0

Browse files
committed
Move dirtyRecursive to CustomHierarchy
1 parent 88bdd11 commit 4aea6d0

4 files changed

Lines changed: 51 additions & 37 deletions

File tree

include/openPMD/CustomHierarchy.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,16 @@ class CustomHierarchy : public Container<CustomHierarchy>
102102

103103
void linkHierarchy(Writable &w) override;
104104

105+
/*
106+
* @brief Check recursively whether this object is dirty.
107+
* It is dirty if any attribute or dataset is read from or written to
108+
* the backend.
109+
*
110+
* @return true If dirty.
111+
* @return false Otherwise.
112+
*/
113+
bool dirtyRecursive() const;
114+
105115
public:
106116
CustomHierarchy(CustomHierarchy const &other) = default;
107117
CustomHierarchy(CustomHierarchy &&other) = default;

include/openPMD/Iteration.hpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -388,16 +388,6 @@ class Iteration : public CustomHierarchy
388388
*/
389389
void setStepStatus(StepStatus);
390390

391-
/*
392-
* @brief Check recursively whether this Iteration is dirty.
393-
* It is dirty if any attribute or dataset is read from or written to
394-
* the backend.
395-
*
396-
* @return true If dirty.
397-
* @return false Otherwise.
398-
*/
399-
bool dirtyRecursive() const;
400-
401391
/**
402392
* @brief Access an iteration in read mode that has potentially not been
403393
* parsed yet.

src/CustomHierarchy.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,47 @@ void CustomHierarchy::linkHierarchy(Writable &w)
397397
particles.linkHierarchy(this->writable());
398398
}
399399

400+
bool CustomHierarchy::dirtyRecursive() const
401+
{
402+
if (dirty())
403+
{
404+
return true;
405+
}
406+
if (particles.dirty() || meshes.dirty())
407+
{
408+
return true;
409+
}
410+
for (auto const &pair : particles)
411+
{
412+
if (pair.second.dirtyRecursive())
413+
{
414+
return true;
415+
}
416+
}
417+
for (auto const &pair : meshes)
418+
{
419+
if (pair.second.dirtyRecursive())
420+
{
421+
return true;
422+
}
423+
}
424+
for (auto const &pair : *this)
425+
{
426+
if (pair.second.dirtyRecursive())
427+
{
428+
return true;
429+
}
430+
}
431+
for (auto const &pair : get().m_embeddedDatasets)
432+
{
433+
if (pair.second.dirtyRecursive())
434+
{
435+
return true;
436+
}
437+
}
438+
return false;
439+
}
440+
400441
Container<RecordComponent> CustomHierarchy::datasets()
401442
{
402443
Container<RecordComponent> res = get().m_embeddedDatasets;

src/Iteration.cpp

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -619,33 +619,6 @@ void Iteration::setStepStatus(StepStatus status)
619619
}
620620
}
621621

622-
bool Iteration::dirtyRecursive() const
623-
{
624-
if (dirty())
625-
{
626-
return true;
627-
}
628-
if (particles.dirty() || meshes.dirty())
629-
{
630-
return true;
631-
}
632-
for (auto const &pair : particles)
633-
{
634-
if (pair.second.dirtyRecursive())
635-
{
636-
return true;
637-
}
638-
}
639-
for (auto const &pair : meshes)
640-
{
641-
if (pair.second.dirtyRecursive())
642-
{
643-
return true;
644-
}
645-
}
646-
return false;
647-
}
648-
649622
void Iteration::runDeferredParseAccess()
650623
{
651624
if (access::read(IOHandler()->m_frontendAccess))

0 commit comments

Comments
 (0)