Skip to content

Commit 5a359b7

Browse files
committed
Fix dirty handling
1 parent f4b14e5 commit 5a359b7

7 files changed

Lines changed: 32 additions & 25 deletions

File tree

include/openPMD/backend/Attributable.hpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,28 @@ OPENPMD_protected
553553
{
554554
return writable().dirtyRecursive;
555555
}
556+
void determineUnsetDirty(FlushLevel fl)
557+
{
558+
switch (fl)
559+
{
560+
case FlushLevel::UserFlush:
561+
setDirty(false);
562+
break;
563+
case FlushLevel::InternalFlush:
564+
// Used for parsing
565+
if (IOHandler()->m_seriesStatus == internal::SeriesStatus::Parsing)
566+
{
567+
throw error::Internal(
568+
"Parsing procedures should directly unset dirty.");
569+
}
570+
break;
571+
case FlushLevel::ImmediateFlush:
572+
case FlushLevel::SkeletonOnly:
573+
case FlushLevel::CreateOrOpenFiles:
574+
// noop
575+
break;
576+
}
577+
}
556578
void setDirty(bool dirty_in)
557579
{
558580
auto &w = writable();

src/Iteration.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ void Iteration::flush(internal::FlushParams const &flushParams)
393393
m.second.flush(m.first, flushParams);
394394
for (auto &species : particles)
395395
species.second.flush(species.first, flushParams);
396-
setDirty(false);
396+
determineUnsetDirty(flushParams.flushLevel);
397397
}
398398
else
399399
{
@@ -447,9 +447,9 @@ void Iteration::flush(internal::FlushParams const &flushParams)
447447
}
448448
if (flushParams.flushLevel != FlushLevel::SkeletonOnly)
449449
{
450-
setDirty(false);
451-
meshes.setDirty(false);
452-
particles.setDirty(false);
450+
determineUnsetDirty(flushParams.flushLevel);
451+
meshes.determineUnsetDirty(flushParams.flushLevel);
452+
particles.determineUnsetDirty(flushParams.flushLevel);
453453
}
454454
}
455455

src/ParticleSpecies.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,8 @@ void ParticleSpecies::flush(
188188
patch.second.flush(patch.first, flushParams);
189189
}
190190
}
191-
if (flushParams.flushLevel != FlushLevel::SkeletonOnly)
192-
{
193-
particlePatches.setDirty(false);
194-
setDirty(false);
195-
}
191+
determineUnsetDirty(flushParams.flushLevel);
192+
particlePatches.determineUnsetDirty(flushParams.flushLevel);
196193
}
197194
void ParticleSpecies::scientificDefaults_impl(bool /* write */, OpenpmdStandard)
198195
{

src/RecordComponent.cpp

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

612612
flushAttributes(flushParams);
613613
}
614-
if (flushParams.flushLevel != FlushLevel::SkeletonOnly)
615-
{
616-
setDirty(false);
617-
}
614+
determineUnsetDirty(flushParams.flushLevel);
618615
}
619616

620617
void RecordComponent::read()

src/backend/Attributable.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,7 @@ void Attributable::flushAttributes(internal::FlushParams const &flushParams)
328328
}
329329
}
330330
// Do this outside the if branch to also setDirty to dirtyRecursive
331-
if (flushParams.flushLevel != FlushLevel::SkeletonOnly)
332-
{
333-
setDirty(false);
334-
}
331+
determineUnsetDirty(flushParams.flushLevel);
335332
}
336333

337334
void Attributable::readAttributes(ReadMode mode)

src/backend/BaseRecord.cpp

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

795795
this->flush_impl(name, flushParams);
796-
if (flushParams.flushLevel != FlushLevel::SkeletonOnly)
797-
{
798-
this->setDirty(false);
799-
}
796+
this->determineUnsetDirty(flushParams.flushLevel);
800797
// flush_impl must take care to correctly set the dirty() flag so this
801798
// method doesn't do it
802799
}

src/backend/PatchRecord.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,7 @@ void PatchRecord::flush_impl(
6565
}
6666
else
6767
T_RecordComponent::flush(path, flushParams);
68-
if (flushParams.flushLevel != FlushLevel::SkeletonOnly)
69-
{
70-
setDirty(false);
71-
}
68+
determineUnsetDirty(flushParams.flushLevel);
7269
}
7370

7471
void PatchRecord::read()

0 commit comments

Comments
 (0)