Skip to content

Commit

Permalink
Revert "Introduce Parsing state"
Browse files Browse the repository at this point in the history
This reverts commit f28f332.
  • Loading branch information
franzpoeschel committed Apr 6, 2022
1 parent 059ac35 commit 7852942
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 45 deletions.
7 changes: 0 additions & 7 deletions include/openPMD/IO/AbstractIOHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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<IOTask> m_work;
}; // AbstractIOHandler

Expand Down
4 changes: 1 addition & 3 deletions include/openPMD/backend/Attributable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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).");
Expand Down
8 changes: 2 additions & 6 deletions include/openPMD/backend/Container.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down
17 changes: 10 additions & 7 deletions src/Iteration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Access *>(&this->IOHandler()->m_frontendAccess);
*newType = Access::READ_WRITE;
series.readGorVBased(false);
IOHandler()->m_seriesStatus = oldStatus;
*newType = oldType;
series.iterations.written() = previous;
}

Expand Down Expand Up @@ -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<Access *>(&IOHandler()->m_frontendAccess);
*newAccess = Access::READ_WRITE;
try
{
if (deferred.fileBased)
Expand All @@ -722,12 +725,12 @@ void Iteration::runDeferredParseAccess()
{
// reset this thing
it.m_deferredParseAccess = std::optional<DeferredParseAccess>();
IOHandler()->m_seriesStatus = oldStatus;
*newAccess = oldAccess;
throw;
}
// reset this thing
it.m_deferredParseAccess = std::optional<DeferredParseAccess>();
IOHandler()->m_seriesStatus = oldStatus;
*newAccess = oldAccess;
}

template float Iteration::time<float>() const;
Expand Down
38 changes: 16 additions & 22 deletions src/Series.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Access *>(&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
{
Expand Down

0 comments on commit 7852942

Please sign in to comment.