![]() |
LINE Solver (C++)
Templated C++ port of the LINE queueing solver
|
SRVN output (the LQNS .in text grammar) for layered models, the C++ twin of lqnx2srvn / srvn_save in python/line_solver/io/srvn_io.py. More...
#include <cmath>#include <cstdio>#include <cstdlib>#include <fstream>#include <map>#include <memory>#include <set>#include <string>#include <utility>#include <vector>#include "line/lang/lqn/lqn_writer.h"#include "line/lang/lqn/srvn_reader.h"#include "line/util/error.h"#include "line/util/xml.h"Go to the source code of this file.
Classes | |
| struct | line::lqn::srvn_out::CallRow |
| struct | line::lqn::srvn_out::TaskRef |
| struct | line::lqn::srvn_out::Element |
Namespaces | |
| namespace | line |
| Conservation laws of a layered queueing network, enumerated from its structure. | |
| namespace | line::lqn |
| namespace | line::lqn::srvn_out |
Macros | |
| #define | LINE_SRVN_ACT_ATTRS |
Functions | |
| UnsupportedError | line::lqn::srvn_out::unsup (const std::string &msg) |
| InputError | line::lqn::srvn_out::xerr (const std::string &msg) |
| const std::string * | line::lqn::srvn_out::get (const Element *el, const std::string &key) |
| el.get(key), with Python's None as a null pointer. | |
| std::string | line::lqn::srvn_out::get (const Element *el, const std::string &key, const std::string &dflt) |
| el.get(key, dflt). | |
| std::string | line::lqn::srvn_out::show (const Element *el, const std::string &key) |
| 's' % el.get(key): None prints as "None". | |
| std::string | line::lqn::srvn_out::lower (std::string s) |
| std::string | line::lqn::srvn_out::upper (std::string s) |
| bool | line::lqn::srvn_out::starts_with (const std::string &s, const char *p) |
| void | line::lqn::srvn_out::utf8 (std::string &out, unsigned long cp) |
| std::string | line::lqn::srvn_out::normalize_attr (const std::string &v) |
| An attribute value as expat delivers it: literal tab, CR and LF become spaces (a CR LF pair one space), and &#n; / &#xh; are expanded afterwards. | |
| void | line::lqn::srvn_out::normalize_tree (Element *el) |
| bool | line::lqn::srvn_out::is_output_tag (const std::string &tag) |
| Output requests: read and dropped, as the reader drops H, R and observations. | |
| std::vector< const Element * > | line::lqn::srvn_out::kids (const Element *el) |
| Model children of el: results and output requests are skipped. | |
| const Element * | line::lqn::srvn_out::find (const Element *el, const std::string &tag) |
| el.find(tag): the first direct child with that tag, or null. | |
| std::vector< const Element * > | line::lqn::srvn_out::findall (const Element *el, const std::string &tag) |
| bool | line::lqn::srvn_out::in (const std::string &s, std::initializer_list< const char * > set) |
| void | line::lqn::srvn_out::check (const Element *el, std::initializer_list< const char * > allowed, std::initializer_list< const char * > kidtags={}) |
| bool | line::lqn::srvn_out::py_float (const std::string &text, double &x) |
| Python's float(text): surrounding whitespace, underscores between digits, inf/nan. | |
| const std::string * | line::lqn::srvn_out::num (const Element *el, const std::string &key, std::string &buf, const char *dflt=NULL) |
| _num: the attribute as format_number(float(text)), or dflt (null = None) when absent. | |
| std::string | line::lqn::srvn_out::numd (const Element *el, const std::string &key, const char *dflt) |
| _num with a default, which never returns None. | |
| bool | line::lqn::srvn_out::srvn_name_ok (const std::string &nm) |
| [A-Za-z_][A-Za-z0-9_]+$ under re.match, where $ also matches before a final newline. | |
| std::string | line::lqn::srvn_out::name (const Element *el, const std::string &key="name") |
| std::string | line::lqn::srvn_out::join (const std::vector< std::string > &v, const std::string &sep) |
| void | line::lqn::srvn_out::phase_lists (const std::map< int, const Element * > &acts, std::vector< std::pair< std::string, std::vector< std::string > > > &lines, std::vector< CallRow > &calls) |
| acts maps phase -> <activity>; the E-section lines of one entry's phases. | |
| const char * | line::lqn::srvn_out::proc_letter (const std::string &s) |
| const char * | line::lqn::srvn_out::task_letter (const std::string &s) |
| const char * | line::lqn::srvn_out::rwlock_letter (const std::string &s) |
| const char * | line::lqn::srvn_out::sem_letter (const std::string &s) |
| void | line::lqn::srvn_out::activity_section (const Element *t, const Element *ta, std::vector< std::string > &out) |
| One task's A section, appended to out. | |
| std::string | line::lqn::lqnx2srvn (const std::string &xml_text, const std::string &name=std::string()) |
| Translate an LQN XML document into SRVN text. | |
| template<class T> | |
| void | line::lqn::write_srvn (const LqnModel< T > &m, const std::string &path, bool use_abstract_names=false) |
| Write a layered model as SRVN text: write_lqnx, then lqnx2srvn, with LF line endings. | |
SRVN output (the LQNS .in text grammar) for layered models, the C++ twin of lqnx2srvn / srvn_save in python/line_solver/io/srvn_io.py.
The writer is the reader's inverse: an LQN XML document goes to SRVN text, so write_srvn is write_lqnx followed by lqnx2srvn, and the mapping of a model onto the LQN schema stays in one place. The output is deterministic and byte-identical across the four codebases (srvn/expected_srvn golden in line-test.git). What SRVN cannot say is refused by name (LINE:unsupported:Format) rather than dropped: an LQX program, SPEX parameters, a semaphore's initial state, the LINE dialect elements (cache, setup, call groups), and names that are not LQNS identifiers. Requests for output (results, histograms, mva-info) are skipped, as the reader skips them. Entry phases carry no activity names in SRVN, so a phase activity reads back as <entry>_<phase>.
The XML is read with xml::parse, then brought to what Python's ElementTree (expat) hands the reference: attribute whitespace normalized to spaces and numeric character references expanded. Malformed XML is LINE:input:Format; its message is this parser's, not expat's.
Definition in file srvn_writer.h.
| #define LINE_SRVN_ACT_ATTRS |
Definition at line 393 of file srvn_writer.h.
Referenced by line::lqn::srvn_out::activity_section(), and line::lqn::lqnx2srvn().