NGen
Loading...
Searching...
No Matches
ngen::serialization Namespace Reference

Namespaces

namespace  anonymous_namespace{file_backend.cpp}
 
namespace  detail
 One checkpoint record: a saved-state blob tagged with its feature id, simulation step counter, the simulated moment the state represents, and the wall-clock moment the operator triggered the save.
 

Classes

struct  BackendError
 Categorized error carried on every abstract-backend method's expected<> error arm. More...
 
class  FileBackend
 
class  RecordBackend
 Abstract storage interface for Records. More...
 

Typedefs

using IdPredicate = std::function<bool(const std::string& id)>
 Eligibility predicate over a SerializationRecord's id string.
 
using Record = detail::RecordT<std::vector<char>>
 A checkpoint record that owns its payload.
 
using RecordView = detail::RecordT<boost::span<const char>>
 A checkpoint record that views its payload (non-owning).
 

Enumerations

enum class  Durability {
  relaxed ,
  strict
}
 Save-time durability requirement. More...
 

Functions

IdPredicate exact_id (std::string target)
 Match: the id equals target exactly.
 
IdPredicate primary_prefix (std::string prefix)
 Match: the first :/.
 
IdPredicate contains_segment (std::string segment)
 Match: segment appears as any :/.
 
IdPredicate at_position (std::size_t n, std::string value)
 Match: the n'th (zero-indexed) :/.
 
IdPredicate starts_with (std::string prefix)
 Match: the id begins with the substring prefix.
 
IdPredicate all_of (std::vector< IdPredicate > preds)
 All sub-predicates must be true.
 
IdPredicate any_of (std::vector< IdPredicate > preds)
 Any sub-predicate true.
 
IdPredicate not_fn (IdPredicate p)
 Inverse of p.
 
int64_t parse_epoch_string (const std::string &s)
 Parse s as a whole-string signed integer interpreted as Unix epoch seconds (e.g.
 
int64_t parse_formatted_time (const std::string &s)
 Parse s as a formatted timestamp matching TIMESTAMP_STRPTIME_FORMAT.
 
int64_t parse_timestamp (const std::string &s)
 Parse s as seconds-since-Unix-epoch.
 

Variables

constexpr const char * TIMESTAMP_STRPTIME_FORMAT = "%Y-%m-%d %T"
 Tests in parse_timestamp_Test.cpp pin both TIMESTAMP_STRPTIME_FORMAT and UNPARSEABLE_TIMESTAMP_SENTINEL so producer/consumer drift surfaces as a test failure.
 
constexpr int64_t UNPARSEABLE_TIMESTAMP_SENTINEL = (std::numeric_limits<int64_t>::min)()
 Out-of-band value returned by parse_timestamp and its helpers when the input string cannot be resolved to a Unix epoch.
 
constexpr int LIBRARY_VERSION_MAJOR = 0
 
constexpr int LIBRARY_VERSION_MINOR = 1
 
constexpr int LIBRARY_VERSION_PATCH = 0
 
constexpr const char * LIBRARY_VERSION_STRING = "0.1.0"
 Human-readable "MAJOR.MINOR.PATCH" string.
 

Typedef Documentation

◆ IdPredicate

using ngen::serialization::IdPredicate = std::function<bool(const std::string& id)>

Eligibility predicate over a SerializationRecord's id string.

The library invokes this once per record during the index walk and treats the returned bool as authoritative.

◆ Record

using ngen::serialization::Record = detail::RecordT<std::vector<char>>

A checkpoint record that owns its payload.

payload is a std::vector<char> of opaque saved bytes — neither this value type nor any consumer interprets them; the producer chooses the byte format and the eventual consumer parses them.

See RecordView for the non-owning payload-view.

◆ RecordView

using ngen::serialization::RecordView = detail::RecordT<boost::span<const char>>

A checkpoint record that views its payload (non-owning).

Same metadata field set as Record, but payload is a boost::span<const char> rather than an owning vector. The caller keeps the payload bytes alive elsewhere for the lifetime of the view.

Enumeration Type Documentation

◆ Durability

Save-time durability requirement.

Backend-specific in meaning; the contract is that strict surfaces errors synchronously and blocks until durably stored, while relaxed is best-effort with deferred error surfacing.

Enumerator
relaxed 
strict 

Function Documentation

◆ all_of()

IdPredicate ngen::serialization::all_of ( std::vector< IdPredicate > preds)
inline

All sub-predicates must be true.

Short-circuits on the first false.

◆ any_of()

IdPredicate ngen::serialization::any_of ( std::vector< IdPredicate > preds)
inline

Any sub-predicate true.

Short-circuits on the first true.

◆ at_position()

IdPredicate ngen::serialization::at_position ( std::size_t n,
std::string value )
inline

Match: the n'th (zero-indexed) :/.

-delimited segment of the id equals value. Returns false if the id has fewer than n + 1 segments.

◆ contains_segment()

IdPredicate ngen::serialization::contains_segment ( std::string segment)
inline

Match: segment appears as any :/.

-delimited token in the id. Exact-token match — "key_1" does not match "key_10".

◆ exact_id()

IdPredicate ngen::serialization::exact_id ( std::string target)
inline

Match: the id equals target exactly.

The default common case for restore-by-known-id.

Referenced by models::bmi::protocols::NgenDeserializationProtocol::run().

◆ not_fn()

IdPredicate ngen::serialization::not_fn ( IdPredicate p)
inline

Inverse of p.

Named after std::not_fn from <functional>.

◆ parse_epoch_string()

int64_t ngen::serialization::parse_epoch_string ( const std::string & s)
inline

Parse s as a whole-string signed integer interpreted as Unix epoch seconds (e.g.

"1448931600", "-3786825600", " 42 "). Leading/trailing whitespace is stripped before conversion. Any other form is considered unparseable.

Returns UNPARSEABLE_TIMESTAMP_SENTINEL on any failure (partial match, empty, whitespace-only, non-numeric, integer overflow). Never throws.

References UNPARSEABLE_TIMESTAMP_SENTINEL.

Referenced by parse_timestamp().

◆ parse_formatted_time()

int64_t ngen::serialization::parse_formatted_time ( const std::string & s)
inline

Parse s as a formatted timestamp matching TIMESTAMP_STRPTIME_FORMAT.

Interpreted in UTC via timegm. White space is allowed and doesn't impact the match.

Returns UNPARSEABLE_TIMESTAMP_SENTINEL on any failure (empty, whitespace-only, partial match, trailing non-whitespace).

References TIMESTAMP_STRPTIME_FORMAT, and UNPARSEABLE_TIMESTAMP_SENTINEL.

Referenced by parse_timestamp().

◆ parse_timestamp()

int64_t ngen::serialization::parse_timestamp ( const std::string & s)
inline

Parse s as seconds-since-Unix-epoch.

Tries parse_epoch_string first, then attempts parse_formatted_time (TIMESTAMP_STRPTIME_FORMAT match). Returns UNPARSEABLE_TIMESTAMP_SENTINEL only when neither parser can resolve the input.

References parse_epoch_string(), parse_formatted_time(), and UNPARSEABLE_TIMESTAMP_SENTINEL.

◆ primary_prefix()

IdPredicate ngen::serialization::primary_prefix ( std::string prefix)
inline

Match: the first :/.

-delimited segment of the id equals prefix. Encodes the ngen v0.2 composition convention where "cat-1" matches both "cat-1:cfe" and "cat-1.0:cfe:multi".

Referenced by models::bmi::protocols::anonymous_namespace{deserialization.cpp}::make_scope().

◆ starts_with()

IdPredicate ngen::serialization::starts_with ( std::string prefix)
inline

Match: the id begins with the substring prefix.

Escape hatch for ids that are not segment-structured.

Variable Documentation

◆ LIBRARY_VERSION_MAJOR

int ngen::serialization::LIBRARY_VERSION_MAJOR = 0
inlineconstexpr

◆ LIBRARY_VERSION_MINOR

int ngen::serialization::LIBRARY_VERSION_MINOR = 1
inlineconstexpr

◆ LIBRARY_VERSION_PATCH

int ngen::serialization::LIBRARY_VERSION_PATCH = 0
inlineconstexpr

◆ LIBRARY_VERSION_STRING

const char* ngen::serialization::LIBRARY_VERSION_STRING = "0.1.0"
inlineconstexpr

Human-readable "MAJOR.MINOR.PATCH" string.

◆ TIMESTAMP_STRPTIME_FORMAT

const char* ngen::serialization::TIMESTAMP_STRPTIME_FORMAT = "%Y-%m-%d %T"
constexpr

Tests in parse_timestamp_Test.cpp pin both TIMESTAMP_STRPTIME_FORMAT and UNPARSEABLE_TIMESTAMP_SENTINEL so producer/consumer drift surfaces as a test failure.

strptime format used by parse_timestamp's formatted- string fallback.

Referenced by parse_formatted_time().

◆ UNPARSEABLE_TIMESTAMP_SENTINEL

int64_t ngen::serialization::UNPARSEABLE_TIMESTAMP_SENTINEL = (std::numeric_limits<int64_t>::min)()
constexpr

Out-of-band value returned by parse_timestamp and its helpers when the input string cannot be resolved to a Unix epoch.

INT64_MIN interpreted as Unix epoch is roughly 9.2e18 seconds before 1970 — far enough before any plausible simulated moment

Referenced by models::bmi::protocols::NgenDeserializationProtocol::initialize(), parse_epoch_string(), parse_formatted_time(), parse_timestamp(), and models::bmi::protocols::NgenSerializationProtocol::run().