Skip to content

Commit

Permalink
WIP: Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Nov 7, 2024
1 parent c08f4a1 commit a73c4c6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
2 changes: 1 addition & 1 deletion include/openPMD/ReadIterations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class LegacyIteratorAdaptor
* This is a feature-restricted subset for the functionality of
* `Series::snapshots()`, prefer using that. The compatibility layer is needed
* due to the different value_type for `Series::readIterations()`-based
* iteration (`IterationIndex` instead of `std::pair<uint64_t, Iteration>`).
* iteration (`IndexedIteration` instead of `std::pair<uint64_t, Iteration>`).
*
* Create instance via Series::readIterations().
* For use in a C++11-style foreach loop over iterations.
Expand Down
17 changes: 5 additions & 12 deletions include/openPMD/Series.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,8 @@ class Series : public Attributable
*
* Conversely, the Access::CREATE and Access::APPEND access modes both
* resolve to random-access by default, but can be specified to use
* Synchronous workflow if needed.
* Synchronous workflow if needed. A shorthand for Synchronous workflows can
* be found with Series::writeIterations().
*
* @param snapshot_workflow Specify the intended workflow
* in Access::CREATE and Access::APPEND. Leave unspecified in
Expand Down Expand Up @@ -736,17 +737,9 @@ class Series : public Attributable
/**
* @brief Entry point to the writing end of the streaming API.
*
* Creates and returns an instance of the WriteIterations class which is an
* intentionally restricted container of iterations that takes care of
* streaming semantics, e.g. ensuring that an iteration cannot be reopened
* once closed.
* For a less restrictive API in non-streaming situations,
* `Series::iterations` can be accessed directly.
* The created object is stored as member of the Series object, hence this
* method may be called as many times as a user wishes.
* There is only one shared iterator state per Series, even when calling
* this method twice.
* Look for the WriteIterations class for further documentation.
* Shorthand for `Series::snapshots()` for access types CREATE and APPEND
* called with parameter SnapshotWorkflow::Synchronous, i.e. for
* streaming-aware data producers.
*
* @return WriteIterations
*/
Expand Down
13 changes: 7 additions & 6 deletions src/Series.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3182,14 +3182,15 @@ void Series::parseBase()

WriteIterations Series::writeIterations()
{
auto &series = get();
if (series.m_deferred_initialization.has_value())
auto const access = IOHandler()->m_frontendAccess;
if (access != Access::CREATE && access != Access::APPEND)
{
runDeferredInitialization();
throw error::WrongAPIUsage(
"[Series::writeIterations()] May only be applied for access modes "
"CREATE or APPEND. Use Series::snapshots() for random-access-type "
"or for read-type workflows.");
}
auto begin = make_writing_stateful_iterator(*this, series);
return Snapshots(std::shared_ptr<StatefulSnapshotsContainer>(
new StatefulSnapshotsContainer(std::move(begin))));
return snapshots(SnapshotWorkflow::Synchronous);
}

void Series::close()
Expand Down

0 comments on commit a73c4c6

Please sign in to comment.