From 78529428b4c2effd0f4ba8720a82bc00c00b29e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Wed, 6 Apr 2022 15:34:19 +0200 Subject: [PATCH] Revert "Introduce Parsing state" This reverts commit f28f332467eb222c7ad990c2de2290d51320057a. --- include/openPMD/IO/AbstractIOHandler.hpp | 7 ----- include/openPMD/backend/Attributable.hpp | 4 +-- include/openPMD/backend/Container.hpp | 8 ++--- src/Iteration.cpp | 17 ++++++----- src/Series.cpp | 38 ++++++++++-------------- 5 files changed, 29 insertions(+), 45 deletions(-) diff --git a/include/openPMD/IO/AbstractIOHandler.hpp b/include/openPMD/IO/AbstractIOHandler.hpp index 93e367e4d5..cce88019ca 100644 --- a/include/openPMD/IO/AbstractIOHandler.hpp +++ b/include/openPMD/IO/AbstractIOHandler.hpp @@ -111,12 +111,6 @@ namespace internal * To be used for reading */ constexpr FlushParams defaultFlushParams{}; - - enum class SeriesStatus : unsigned char - { - Default, - Parsing - }; } // namespace internal /** Interface for communicating between logical and physically persistent data. @@ -163,7 +157,6 @@ class AbstractIOHandler std::string const directory; Access const m_backendAccess; Access const m_frontendAccess; - internal::SeriesStatus m_seriesStatus = internal::SeriesStatus::Default; std::queue m_work; }; // AbstractIOHandler diff --git a/include/openPMD/backend/Attributable.hpp b/include/openPMD/backend/Attributable.hpp index f4928fd17d..bba3eb409c 100644 --- a/include/openPMD/backend/Attributable.hpp +++ b/include/openPMD/backend/Attributable.hpp @@ -458,9 +458,7 @@ inline bool Attributable::setAttributeImpl( internal::attr_value_check(key, value, setAttributeMode); auto &attri = get(); - if (IOHandler() && - IOHandler()->m_seriesStatus == internal::SeriesStatus::Default && - Access::READ_ONLY == IOHandler()->m_frontendAccess) + if (IOHandler() && Access::READ_ONLY == IOHandler()->m_frontendAccess) { auxiliary::OutOfRangeMsg const out_of_range_msg( "Attribute", "can not be set (read-only)."); diff --git a/include/openPMD/backend/Container.hpp b/include/openPMD/backend/Container.hpp index 8db82c69f0..9dd163ecae 100644 --- a/include/openPMD/backend/Container.hpp +++ b/include/openPMD/backend/Container.hpp @@ -288,9 +288,7 @@ class Container : public Attributable return it->second; else { - if (IOHandler()->m_seriesStatus != - internal::SeriesStatus::Parsing && - Access::READ_ONLY == IOHandler()->m_frontendAccess) + if (Access::READ_ONLY == IOHandler()->m_frontendAccess) { auxiliary::OutOfRangeMsg const out_of_range_msg; throw std::out_of_range(out_of_range_msg(key)); @@ -323,9 +321,7 @@ class Container : public Attributable return it->second; else { - if (IOHandler()->m_seriesStatus != - internal::SeriesStatus::Parsing && - Access::READ_ONLY == IOHandler()->m_frontendAccess) + if (Access::READ_ONLY == IOHandler()->m_frontendAccess) { auxiliary::OutOfRangeMsg out_of_range_msg; throw std::out_of_range(out_of_range_msg(key)); diff --git a/src/Iteration.cpp b/src/Iteration.cpp index ccbd282ca6..0e5f5559fd 100644 --- a/src/Iteration.cpp +++ b/src/Iteration.cpp @@ -592,10 +592,12 @@ AdvanceStatus Iteration::beginStep(bool reread) { bool previous = series.iterations.written(); series.iterations.written() = false; - auto oldStatus = IOHandler()->m_seriesStatus; - IOHandler()->m_seriesStatus = internal::SeriesStatus::Parsing; + auto oldType = this->IOHandler()->m_frontendAccess; + auto newType = + const_cast(&this->IOHandler()->m_frontendAccess); + *newType = Access::READ_WRITE; series.readGorVBased(false); - IOHandler()->m_seriesStatus = oldStatus; + *newType = oldType; series.iterations.written() = previous; } @@ -705,8 +707,9 @@ void Iteration::runDeferredParseAccess() } auto const &deferred = it.m_deferredParseAccess.value(); - auto oldStatus = IOHandler()->m_seriesStatus; - IOHandler()->m_seriesStatus = internal::SeriesStatus::Parsing; + auto oldAccess = IOHandler()->m_frontendAccess; + auto newAccess = const_cast(&IOHandler()->m_frontendAccess); + *newAccess = Access::READ_WRITE; try { if (deferred.fileBased) @@ -722,12 +725,12 @@ void Iteration::runDeferredParseAccess() { // reset this thing it.m_deferredParseAccess = std::optional(); - IOHandler()->m_seriesStatus = oldStatus; + *newAccess = oldAccess; throw; } // reset this thing it.m_deferredParseAccess = std::optional(); - IOHandler()->m_seriesStatus = oldStatus; + *newAccess = oldAccess; } template float Iteration::time() const; diff --git a/src/Series.cpp b/src/Series.cpp index 63557ec4b7..df86d27518 100644 --- a/src/Series.cpp +++ b/src/Series.cpp @@ -506,34 +506,28 @@ Given file pattern: ')END" { /* Allow creation of values in Containers and setting of Attributes * Would throw for Access::READ_ONLY */ - IOHandler()->m_seriesStatus = internal::SeriesStatus::Parsing; + auto oldType = IOHandler()->m_frontendAccess; + auto newType = const_cast(&IOHandler()->m_frontendAccess); + *newType = Access::READ_WRITE; - try - { - if (input->iterationEncoding == IterationEncoding::fileBased) - readFileBased(); - else - readGorVBased(); + if (input->iterationEncoding == IterationEncoding::fileBased) + readFileBased(); + else + readGorVBased(); - if (series.iterations.empty()) - { - /* Access::READ_WRITE can be used to create a new Series - * allow setting attributes in that case */ - written() = false; + if (series.iterations.empty()) + { + /* Access::READ_WRITE can be used to create a new Series + * allow setting attributes in that case */ + written() = false; - initDefaults(input->iterationEncoding); - setIterationEncoding(input->iterationEncoding); + initDefaults(input->iterationEncoding); + setIterationEncoding(input->iterationEncoding); - written() = true; - } - } - catch (...) - { - IOHandler()->m_seriesStatus = internal::SeriesStatus::Default; - throw; + written() = true; } - IOHandler()->m_seriesStatus = internal::SeriesStatus::Default; + *newType = oldType; } else {