5#ifndef LINE_IO_LINEMODEL_H
6#define LINE_IO_LINEMODEL_H
56 const nlohmann::json& model = root.contains(
"model") ? root.at(
"model") : root;
57 if (!model.is_object() || !model.contains(
"type") || !model.at(
"type").is_string())
59 return model.at(
"type").get<std::string>();
71 throw InputError(
"linemodel_load: the document's model declares no 'type'; expected "
72 "Network, LayeredNetwork, Workflow or Environment");
83 std::ifstream in(path.c_str());
84 if (!in)
throw InputError(
"linemodel_load: cannot open " + path);
88 }
catch (
const nlohmann::json::parse_error& e) {
89 throw InputError(
"linemodel_load: malformed JSON in " + path +
": " + e.what());
UnsupportedError(const std::string &what)
A network plus its refreshed NetworkStruct.
A queueing network under construction.
const NetworkStruct< T > & get_struct()
The refreshed struct, MATLAB's model.getStruct().
A random environment: a port of matlab/src/lang/Environment.m, restricted to what SolverENV reads out...
Reader for the LINE model.json interchange of an ENVIRONMENT model into an env::Environment<T>.
The exception types the port throws.
model.json writers for a LayeredNetwork, a Workflow and an Environment: the layered2json,...
model.json with type: "LayeredNetwork" -> LqnStruct, via LqnBuilder.
.lqnx -> LqnStruct, a port of matlab/src/lang/layered/@LayeredNetwork/parseXML.m followed by ....
std::string linemodel_type(const nlohmann::json &root)
The envelope's model.type of a parsed document; empty when it declares none.
LineModel< T > linemodel_load(const std::string &path)
Port of linemodel_load(filename).
detail::json environment_to_json(const env::Environment< T > &e)
environment2json: the model object of an Environment document.
detail::json lqn_model_to_json(const lqn::LqnModel< T > &m)
layered2json: the model object of a LayeredNetwork document.
env::Environment< T > build_environment_from_json(const detail::json &root)
Build an env::Environment<T> from a parsed model.json envelope.
workflow::Workflow< T > build_workflow_from_json(const detail::json &root)
Build a workflow::Workflow<T> from a parsed model.json envelope.
qn::Network< T > build_network_from_json(const detail::json &root)
Build a qn::Network<T> from a parsed model.json envelope.
lqn::LqnModel< T > build_lqn_model_from_json(const detail::json &root)
Build the intermediate LqnModel<T> from a parsed model.json envelope carrying a LayeredNetwork.
detail::json linemodel_envelope(const detail::json &model)
The {format, version, model} envelope around a model object, with the wire's non-finites.
std::variant< qn::Network< T >, lqn::LqnModel< T >, workflow::Workflow< T >, env::Environment< T > > LineModel
What linemodel_load returns: MATLAB's Network, LayeredNetwork, Workflow or Environment.
void write_network_json(const qn::NetworkStruct< T > &sn, const std::string &path)
Write a model.json file, indented as the reference writers indent it.
detail::json workflow_to_json(const workflow::Workflow< T > &wf)
workflow2json: the model object of a Workflow document.
LineModel< T > linemodel_from_json(const nlohmann::json &root)
Port of linemodel_load(filename) on an already parsed document.
void write_linemodel_json(const detail::json &root, const std::string &path)
Write an envelope, indented as write_network_json indents it.
void linemodel_save(const qn::NetworkStruct< T > &sn, const std::string &path)
Port of linemodel_save(model, filename) for a refreshed Network struct.
Conservation laws of a layered queueing network, enumerated from its structure.
The Network constructor API: Queue, Delay, Source, Sink, Router, ClassSwitch, Cache,...
Reader for the LINE model.json interchange (a Network model) into a qn::Network<T> built through the ...
qn::NetworkStruct -> model.json, the inverse of network_reader.h.
The intermediate model, and the second stage that flattens it.
An activity workflow reduced to one phase-type law.
Reader for the LINE model.json interchange (a Workflow model) into a workflow::Workflow<T> built thro...