39#ifndef OPENSWMM_ENGINE_DEFAULT_OUTPUT_PLUGIN_HPP
40#define OPENSWMM_ENGINE_DEFAULT_OUTPUT_PLUGIN_HPP
85 int initialize(
const std::vector<std::string>& init_args,
129 bool checkpoint_fresh_ =
false;
130 std::string checkpoint_header_;
137 std::string checkpointBytes(
const SimulationContext& ctx,
double next_report_ms)
const;
147 std::shared_ptr<PreparedCheckpoint> prepareCheckpoint(
const SimulationContext& ctx,
148 double next_report_ms, std::string bytes);
176 void validateCheckpoint(
const SimulationContext& ctx,
double next_report_ms,
int periods,
177 const std::string& bytes)
const;
183 std::string readPrefix()
const;
195 const std::filesystem::path& base,
196 std::shared_ptr<io::OwnedCheckpointFile>& artifact)
const;
206 std::shared_ptr<PreparedCheckpoint> prepareFileCheckpoint(
const SimulationContext& ctx,
207 double next, std::string bytes);
218 void validateFileCheckpoint(FILE* file, uint64_t bytes,
const SimulationContext& ctx,
219 double next,
int periods)
const;
221 std::string out_path_;
223 std::string last_error_;
226 FILE* out_file_ =
nullptr;
231 int n_subcatch_vars_ = 0;
232 bool snow_process_ =
false;
233 int n_node_vars_ = 0;
234 int n_link_vars_ = 0;
235 int flow_units_code_ = 0;
236 long id_start_pos_ = 0;
237 long input_start_pos_ = 0;
238 long output_start_pos_ = 0;
246 double ucf_length_ = 1.0;
249 std::vector<char> subcatch_rpt_flag_;
250 std::vector<char> node_rpt_flag_;
251 std::vector<char> link_rpt_flag_;
253 static constexpr int MAGIC_NUMBER = 516114522;
254 static constexpr int VERSION = 60000;
255 static constexpr int MAX_SYS_RESULTS = 15;
266 void writeID(
const char*
id);
270 void writeInt4(
int value);
274 void writeReal4(
float value);
278 void writeReal8(
double value);
Versioned checkpoint file serialization and integrity checks.
Publication of outputs associated with restored checkpoint sessions.
Interface for output-writing plugins.
friend class SWMMEngine
Definition DefaultOutputPlugin.hpp:127
DefaultOutputPlugin(std::string out_path)
Store a binary output destination and start in LOADED state.
Definition DefaultOutputPlugin.cpp:56
int update(const SimulationSnapshot &snapshot) override
Append and flush one complete report-period record, then increment counters.
Definition DefaultOutputPlugin.cpp:158
const char * last_error_message() const noexcept override
Borrow the stored diagnostic text without clearing it.
Definition DefaultOutputPlugin.hpp:124
~DefaultOutputPlugin() override=default
Destroy member buffers without implicitly closing out_file_. Caller must finalize() before deletion o...
int initialize(const std::vector< std::string > &init_args, const IPluginComponentInfo *info) override
Reset write counters and mark INITIALIZED.
Definition DefaultOutputPlugin.cpp:59
PluginState state() const noexcept override
Read the last assigned lifecycle marker without synchronization.
Definition DefaultOutputPlugin.hpp:79
int prepare(const SimulationContext &ctx) override
Open/truncate the binary output and write its reporting layout/header.
Definition DefaultOutputPlugin.cpp:114
int finalize(const SimulationContext &ctx) override
Write a footer with current counters, close the output and mark FINALIZED.
Definition DefaultOutputPlugin.cpp:312
int validate(const SimulationContext &ctx) override
Mark VALIDATED without checking path or model arrays.
Definition DefaultOutputPlugin.cpp:67
Interface for output-writing plugins.
Definition IOutputPlugin.hpp:77
Describes a plugin component: metadata, capabilities, and factory methods.
Definition IPluginComponentInfo.hpp:201
PluginState
Plugin lifecycle states.
Definition PluginState.hpp:86
@ UNLOADED
Library not yet loaded (or was closed).
Definition PluginState.hpp:87
Definition ExchangeLaw.hpp:60
Definition DefaultOutputCheckpoint.cpp:53
Central, reentrant simulation context.
Definition SimulationContext.hpp:390
Complete simulation state snapshot at one output time step.
Definition SimulationSnapshot.hpp:123
Definition CheckpointOutputPublication.hpp:64