OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
EngineSourceResultStream.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2
11
12#pragma once
15#include <functional>
16#include <memory>
17
18namespace openswmm {
19class SWMMEngine;
20}
21namespace openswmm::twoD {
28public:
37 struct Frame {
41 std::map<std::string, SourceResultTable> tables;
42 };
43 struct Cursor {
44 std::string identity;
45 uint64_t bytes = 0, frames = 0, fingerprint = 0;
52 bool operator==(const Cursor&) const = default;
53 };
54
72 const Cursor& cursor() const { return cursor_; }
81 const Frame& latest() const { return latest_; }
90 const std::string& path() const { return path_; }
96 bool detailed() const { return detailed_; }
105 bool hasPendingCapture() const { return pending_capture_; }
119 const std::string& lastError() const { return error_; }
120 // Largest encoded frame, not cumulative result size. Excludes physical/output images.
127 std::size_t largestFrameBytes() const { return largest_frame_; }
143 static std::string visit(const std::string&, const Cursor&,
144 const std::function<void(const Frame&)>&);
145
146private:
149 struct PreparedRestore;
165 std::string initialize(const openswmm::SWMMEngine& e, const std::string& path, bool detailed);
186 std::string capture(const openswmm::SWMMEngine& e, Kind kind, double start,
187 uint64_t anchor = 0);
188 std::string captureSourceInterval(const CommonSourceStage&);
189 void preflight() const;
190 std::string checkpointContract(uint64_t physical_fingerprint,
191 uint64_t whole_checkpoint_fingerprint) const;
192 std::unique_ptr<PreparedRestore> prepareRestore(const std::string& contract,
193 uint64_t whole_checkpoint_fingerprint) const;
194 void adopt(PreparedRestore&) noexcept;
195 static uint64_t fingerprint(const std::string&);
196 static std::string encodeCursor(const Cursor&);
197 static Cursor decodeCursor(std::string);
198 void append(Frame);
199 const openswmm::SWMMEngine* engine_ = nullptr;
200 std::string path_, metadata_, fresh_header_;
201 Cursor cursor_;
202 Frame latest_;
203 uint64_t device_ = 0, inode_ = 0, source_intervals_ = 0;
204 double engine_end_ = 0, source_end_ = 0;
205 bool detailed_ = false, pending_capture_ = false;
206 Kind pending_kind_ = Kind::Initial;
207 double pending_start_ = 0;
208 std::string error_;
209 std::size_t largest_frame_ = 0;
210 mutable uint64_t preparation_sequence_ = 0;
211};
221}
Publication of outputs associated with restored checkpoint sessions.
Columnar source diagnostics and saved identifier tables.
Definition CommonSourceStage.hpp:44
bool hasPendingCapture() const
Read whether an engine-level capture remains pending after its physical anchor was obtained.
Definition EngineSourceResultStream.hpp:105
friend class ExplicitInertialSolver
Definition EngineSourceResultStream.hpp:148
const Frame & latest() const
Borrow the recorder's most recently committed frame.
Definition EngineSourceResultStream.hpp:81
const std::string & path() const
Borrow the recorder's attached companion filesystem path.
Definition EngineSourceResultStream.hpp:90
const Cursor & cursor() const
Borrow the recorder's committed prefix identity, byte/frame counts and rolling fingerprint.
Definition EngineSourceResultStream.hpp:72
EngineSourceResultStream & operator=(const EngineSourceResultStream &)=delete
EngineSourceResultStream(const EngineSourceResultStream &)=delete
const std::string & lastError() const
Borrow the recorder's last stored capture error text.
Definition EngineSourceResultStream.hpp:119
bool detailed() const
Test whether fine source intervals are included on their independent time axis.
Definition EngineSourceResultStream.hpp:96
std::size_t largestFrameBytes() const
Read the largest committed encoded frame payload size seen by this recorder.
Definition EngineSourceResultStream.hpp:127
static std::string visit(const std::string &, const Cursor &, const std::function< void(const Frame &)> &)
Visits a verified saved prefix one frame at a time, without retaining it.
Definition EngineSourceResultStream.cpp:573
EngineSourceResultStream()=default
Construct an unattached recorder with empty path/cursor and zero accepted clocks.
Kind
Definition EngineSourceResultStream.hpp:29
@ PrescriptionUpdate
Definition EngineSourceResultStream.hpp:34
@ SourceInterval
Definition EngineSourceResultStream.hpp:31
@ Initial
Definition EngineSourceResultStream.hpp:30
@ EngineStep
Definition EngineSourceResultStream.hpp:32
@ CouplingBarrier
Definition EngineSourceResultStream.hpp:33
@ Checkpoint
Definition EngineSourceResultStream.hpp:35
friend class openswmm::SWMMEngine
Definition EngineSourceResultStream.hpp:147
Definition ExchangeLaw.hpp:60
Definition ExchangeLaw.hpp:60
Definition CheckpointOutputPublication.hpp:64
Definition EngineSourceResultStream.hpp:43
uint64_t bytes
Definition EngineSourceResultStream.hpp:45
std::string identity
Definition EngineSourceResultStream.hpp:44
uint64_t fingerprint
Definition EngineSourceResultStream.hpp:45
uint64_t frames
Definition EngineSourceResultStream.hpp:45
bool operator==(const Cursor &) const =default
Compare all saved-prefix cursor fields exactly.
Definition EngineSourceResultStream.hpp:37
double engine_end
Definition EngineSourceResultStream.hpp:40
double source_start
Definition EngineSourceResultStream.hpp:40
uint64_t boundary_fingerprint
Definition EngineSourceResultStream.hpp:39
Kind kind
Definition EngineSourceResultStream.hpp:38
double engine_start
Definition EngineSourceResultStream.hpp:40
double source_end
Definition EngineSourceResultStream.hpp:40
uint64_t source_intervals
Definition EngineSourceResultStream.hpp:39
uint64_t sequence
Definition EngineSourceResultStream.hpp:39
std::map< std::string, SourceResultTable > tables
Definition EngineSourceResultStream.hpp:41
Definition EngineSourceResultStream.hpp:212
uint64_t device
Definition EngineSourceResultStream.hpp:217
io::CheckpointOutputPublication::Output publication
Definition EngineSourceResultStream.hpp:214
Frame latest
Definition EngineSourceResultStream.hpp:216
bool owns_staging
Definition EngineSourceResultStream.hpp:219
uint64_t inode
Definition EngineSourceResultStream.hpp:217
~PreparedRestore()
Best-effort remove this plan's exclusively owned unadopted staging file.
Definition EngineSourceResultStream.cpp:863
Cursor cursor
Definition EngineSourceResultStream.hpp:215
std::size_t largest_frame
Definition EngineSourceResultStream.hpp:218