OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
openswmm::HotStartManager Class Reference

Static utility class for hot start file operations. More...

#include <HotStartManager.hpp>

Collaboration diagram for openswmm::HotStartManager:

Public Member Functions

 HotStartManager ()=delete
 

Static Public Member Functions

static HotStartFilesave (const SimulationContext &ctx, const std::string &path)
 Capture current engine state and write to a hot start file (V1 format).
 
static HotStartFilesave (const SimulationContext &ctx, const runoff::RunoffSolver *runoff, const groundwater::GWSolver *gw, const std::string &path)
 Capture current engine state including infiltration and GW (V2 format).
 
static HotStartFileopen (const std::string &path)
 Read and validate a hot start file.
 
static int apply (HotStartFile &hs, SimulationContext &ctx, std::function< void(const std::string &)> warn_cb={})
 Apply hot start records to a simulation context.
 
static int apply (HotStartFile &hs, SimulationContext &ctx, runoff::RunoffSolver *runoff, groundwater::GWSolver *gw, std::function< void(const std::string &)> warn_cb={})
 Apply hot start records including infiltration and GW state.
 
static bool flush (HotStartFile &hs)
 If the file is dirty, rewrite it to disk.
 
static const std::string & last_io_error () noexcept
 Description of the most recent I/O error (empty = none).
 

Detailed Description

Static utility class for hot start file operations.

All operations on the binary file are handled here. The HotStartFile struct is the data carrier; HotStartManager provides the I/O logic.

Constructor & Destructor Documentation

◆ HotStartManager()

openswmm::HotStartManager::HotStartManager ( )
delete

Member Function Documentation

◆ apply() [1/2]

int openswmm::HotStartManager::apply ( HotStartFile hs,
SimulationContext ctx,
runoff::RunoffSolver runoff,
groundwater::GWSolver gw,
std::function< void(const std::string &)>  warn_cb = {} 
)
static

Apply hot start records including infiltration and GW state.

Gap #54: extended apply that also restores infiltration model state and GW zone state when the file is V2 format.

Parameters
hsHot start file (from save() or open()).
ctxTarget simulation context (must be INITIALIZED).
runoffRunoffSolver to restore infiltration state into (may be nullptr).
gwGWSolver to restore GW zone state into (may be nullptr).
warn_cbOptional callback for per-missing-object warnings.
Returns
Number of missing-object warnings generated.
Here is the call graph for this function:

◆ apply() [2/2]

int openswmm::HotStartManager::apply ( HotStartFile hs,
SimulationContext ctx,
std::function< void(const std::string &)>  warn_cb = {} 
)
static

Apply hot start records to a simulation context.

For each record in the hot start file, the matching object (by string ID) in ctx is updated. Objects in the hot start that are absent from ctx generate warnings — they do not fail.

Parameters
hsHot start file (from save() or open()).
ctxTarget simulation context (must be INITIALIZED).
warn_cbOptional callback for per-missing-object warnings.
Returns
Number of missing-object warnings generated (0 = perfect match).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ flush()

bool openswmm::HotStartManager::flush ( HotStartFile hs)
static

If the file is dirty, rewrite it to disk.

Returns
true on success, false on I/O error.
Here is the caller graph for this function:

◆ last_io_error()

const std::string & openswmm::HotStartManager::last_io_error ( )
staticnoexcept

Description of the most recent I/O error (empty = none).

◆ open()

HotStartFile * openswmm::HotStartManager::open ( const std::string &  path)
static

Read and validate a hot start file.

Validates magic, version, and CRC32. Loads all records into memory.

Parameters
pathFile path.
Returns
Heap-allocated HotStartFile* on success, nullptr on error.
Here is the caller graph for this function:

◆ save() [1/2]

HotStartFile * openswmm::HotStartManager::save ( const SimulationContext ctx,
const runoff::RunoffSolver runoff,
const groundwater::GWSolver gw,
const std::string &  path 
)
static

Capture current engine state including infiltration and GW (V2 format).

Gap #54: extends V1 save with per-subcatchment infiltration model state (6-element flat array) and GW zone state (theta, lower_depth). Writes version=2 header.

Parameters
ctxSimulation context (must be RUNNING or ENDED).
runoffRunoffSolver providing infiltration state (may be nullptr).
gwGWSolver providing GW zone state (may be nullptr).
pathOutput file path.
Here is the call graph for this function:

◆ save() [2/2]

HotStartFile * openswmm::HotStartManager::save ( const SimulationContext ctx,
const std::string &  path 
)
static

Capture current engine state and write to a hot start file (V1 format).

Parameters
ctxSimulation context (must be RUNNING or ENDED).
pathOutput file path.
Returns
Heap-allocated HotStartFile* on success (caller owns), or nullptr on I/O error (error description in last_io_error).
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files: