LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
sn_validate_contract.h File Reference

Check a NetworkStruct against its contract (sn_contract.h): the C++ twin of MATLAB's sn_validate. More...

#include <cmath>
#include <cstdlib>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include "line/api/sn/sn_contract.h"
#include "line/api/sn/sn_field_view.h"
#include "line/util/error.h"
#include "line/util/line_console.h"
Include dependency graph for sn_validate_contract.h:

Go to the source code of this file.

Namespaces

namespace  line
 Conservation laws of a layered queueing network, enumerated from its structure.
namespace  line::api

Functions

bool line::api::sn_validate_requested ()
 True when get_struct should validate: debug verbosity, or LINE_VALIDATE_SN=1.
std::vector< std::string > line::api::sn_validate_contract (const SnFieldViews &views, bool error=false)
 The contract violations of a field view; with error true, throws InternalError with id LINE:internal:Contract when there are any.
template<class T>
std::vector< std::string > line::api::sn_validate_contract (const qn::NetworkStruct< T > &sn, bool error=false)
 The contract violations of a struct; see sn_validate_contract(const SnFieldViews&, bool).

Detailed Description

Check a NetworkStruct against its contract (sn_contract.h): the C++ twin of MATLAB's sn_validate.

(sn_validate itself is taken in this port by the JAR's SnValidate value checks, see sn_validate.h.)

Four kinds of violation are reported, one string each: a required field is missing, a field is not in the contract at all, a value has a kind the contract does not admit, and a non-empty value has a shape none of the field's shapes admits.

The check runs on the FIELD VIEW of the struct (sn_contract_view), so a test can drop or inject a field as the MATLAB test does with rmfield. C++ has no reflection, so whether every DATA MEMBER of NetworkStruct is declared in the contract is checked when the view is generated, by doc/generate-sn-contract.py --check; at run time an unknown field is one in the view the contract does not list. qn::Network::get_struct runs it once per rebuild at VerboseLevel::DEBUG or with LINE_VALIDATE_SN=1, and warns.

Definition in file sn_validate_contract.h.