Skip to content

Commit 8e09666

Browse files
committed
Fix dirty handling
1 parent b57a8bc commit 8e09666

7 files changed

Lines changed: 31 additions & 24 deletions

File tree

include/openPMD/backend/Attributable.hpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,27 @@ OPENPMD_protected
549549
{
550550
return writable().dirtyRecursive;
551551
}
552+
void determineUnsetDirty(FlushLevel fl)
553+
{
554+
switch (fl)
555+
{
556+
case FlushLevel::UserFlush:
557+
setDirty(false);
558+
break;
559+
case FlushLevel::InternalFlush:
560+
// Used for parsing
561+
if (IOHandler()->m_seriesStatus == internal::SeriesStatus::Parsing)
562+
{
563+
throw error::Internal(
564+
"Parsing procedures should directly unset dirty.");
565+
}
566+
break;
567+
case FlushLevel::SkeletonOnly:
568+
case FlushLevel::CreateOrOpenFiles:
569+
// noop
570+
break;
571+
}
572+
}
552573
void setDirty(bool dirty_in)
553574
{
554575
auto &w = writable();

src/Iteration.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ void Iteration::flush(internal::FlushParams const &flushParams)
351351
m.second.flush(m.first, flushParams);
352352
for (auto &species : particles)
353353
species.second.flush(species.first, flushParams);
354-
setDirty(false);
354+
determineUnsetDirty(flushParams.flushLevel);
355355
}
356356
else
357357
{
@@ -405,9 +405,9 @@ void Iteration::flush(internal::FlushParams const &flushParams)
405405
}
406406
if (flushParams.flushLevel != FlushLevel::SkeletonOnly)
407407
{
408-
setDirty(false);
409-
meshes.setDirty(false);
410-
particles.setDirty(false);
408+
determineUnsetDirty(flushParams.flushLevel);
409+
meshes.determineUnsetDirty(flushParams.flushLevel);
410+
particles.determineUnsetDirty(flushParams.flushLevel);
411411
}
412412
}
413413

src/ParticleSpecies.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,7 @@ void ParticleSpecies::flush(
208208
particlePatches.setDirty(false);
209209
}
210210
}
211-
if (flushParams.flushLevel != FlushLevel::SkeletonOnly)
212-
{
213-
setDirty(false);
214-
}
211+
determineUnsetDirty(flushParams.flushLevel);
212+
particlePatches.determineUnsetDirty(flushParams.flushLevel);
215213
}
216214
} // namespace openPMD

src/RecordComponent.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -549,10 +549,7 @@ void RecordComponent::flush(
549549

550550
flushAttributes(flushParams);
551551
}
552-
if (flushParams.flushLevel != FlushLevel::SkeletonOnly)
553-
{
554-
setDirty(false);
555-
}
552+
determineUnsetDirty(flushParams.flushLevel);
556553
}
557554

558555
void RecordComponent::read(bool require_unit_si)

src/backend/Attributable.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,7 @@ void Attributable::flushAttributes(internal::FlushParams const &flushParams)
299299
}
300300
}
301301
// Do this outside the if branch to also setDirty to dirtyRecursive
302-
if (flushParams.flushLevel != FlushLevel::SkeletonOnly)
303-
{
304-
setDirty(false);
305-
}
302+
determineUnsetDirty(flushParams.flushLevel);
306303
}
307304

308305
void Attributable::readAttributes(ReadMode mode)

src/backend/BaseRecord.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -840,10 +840,7 @@ inline void BaseRecord<T_elem>::flush(
840840
}
841841

842842
this->flush_impl(name, flushParams);
843-
if (flushParams.flushLevel != FlushLevel::SkeletonOnly)
844-
{
845-
this->setDirty(false);
846-
}
843+
this->determineUnsetDirty(flushParams.flushLevel);
847844
// flush_impl must take care to correctly set the dirty() flag so this
848845
// method doesn't do it
849846
}

src/backend/PatchRecord.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,7 @@ void PatchRecord::flush_impl(
5656
}
5757
else
5858
T_RecordComponent::flush(path, flushParams);
59-
if (flushParams.flushLevel != FlushLevel::SkeletonOnly)
60-
{
61-
setDirty(false);
62-
}
59+
determineUnsetDirty(flushParams.flushLevel);
6360
}
6461

6562
void PatchRecord::read()

0 commit comments

Comments
 (0)