OSFI-C++
3.10.0
OpenSF Integration Library
|
#include <ParamReader.h>
Public Member Functions | |
ParamReader (const string &xmlFile, const string &xsdFile) | |
ParamReader (const std::string &xmlFile) | |
ParamReader (const ParamReader &other) | |
ParamReader (ParamReader &&other)=default | |
bool | validateAgainst (const std::string &xsdFile) const |
bool | validateAgainstInternalSchema () const |
virtual | ~ParamReader () |
Parameter | getParameter (const string ¶mName) const |
vector< Parameter > | getParameters (const string &groupName) const |
t_params_map | getParameters () const |
bool | existParameter (const string ¶mName) const |
void | setParameter (const string ¶mName, string value) |
void | print () const |
Parameter & | getParameterRef (const string &path) |
const Parameter & | getParameterRef (const string &path) const |
This class parses the XML configuration files provided by the openSF HMI formatted with the following elements:
name
. This is the parameter identifier. Names cannot contain spaces.description
. Short definition or meaning for the parameter, optional.type
. Possible values for this attribute are in osfi::confm::ElementType. Alternatively, if values "ARRAY" or "MATRIX" appear, the data type is in the elementType
atttribute.units
, min
, max
. Optional metadata for the parameter.dims
. Size of the dimensions, used to represent vectors and matrices. The first number refers to columns and the second one to rows when describing a matrix. This attribute is also optional: for scalar variables, dims can be avoided.See the E2E-ICD reference for more details.
ParamReader::ParamReader | ( | const string & | xmlFile, |
const string & | xsdFile | ||
) |
Default class constructor. Creates an instance of the ParamReader class, parses a given configuration XML file and stores every valid parameter.
Validating agains an XSD schema is optional.
xmlFile | - Configuration XML file |
xsdFile | - Configuration XSD schema |
exception | if error while parsing |
ParamReader::ParamReader | ( | const std::string & | xmlFile | ) |
Reads OSFI-formatted parameters from the given file.
xmlFile | Configuration XML file |
std::exception | If an error arises during parsing. |
ParamReader::ParamReader | ( | const ParamReader & | other | ) |
Copy constructor, duplicates the map and document objects
|
virtual |
Class destructor.
bool ParamReader::existParameter | ( | const string & | paramName | ) | const |
Checks the existence of a parameter within a configuration file.
paramName | Parameter name (full path and name) |
Parameter ParamReader::getParameter | ( | const string & | paramName | ) | const |
Retrieves the parameter object corresponding with the given full path in the configuration file. If no such parameter exists, returns a "dummy" parameter. See also getParameterRef().
paramName | Parameter full path |
Parameter& ParamReader::getParameterRef | ( | const string & | path | ) |
Returns a reference to a parameter in the set of read data. This method differs from getParameter() in that it does not copy the data, so the lifetime of the referee is limited to that of this instance. The returned reference is never otherwise invalidated.
std::invalid_argument | If the path does not correspond to a parameter. |
const Parameter& ParamReader::getParameterRef | ( | const string & | path | ) | const |
Returns a reference to a parameter in the set of read data. This method differs from getParameter() in that it does not copy the data, so the lifetime of the referee is limited to that of this instance. The returned reference is never otherwise invalidated.
std::invalid_argument | If the path does not correspond to a parameter. |
t_params_map ParamReader::getParameters | ( | ) | const |
vector<Parameter> ParamReader::getParameters | ( | const string & | groupName | ) | const |
Retrieves a copy of all parameters under a certain group, directly or indirectly. If there are no parameters that have the argument as a parent group, returns an empty vector.
groupName | full path of the parent group |
void ParamReader::print | ( | ) | const |
Prints a textual representation of the list of Parameters to the OSFI log.
void ParamReader::setParameter | ( | const string & | paramName, |
string | value | ||
) |
Changes the stored value of a certain parameter. Shows an error if cannot find parameter.
paramName | - full name of the parameter |
value | - new value |
exception | if value is invalid |
bool ParamReader::validateAgainst | ( | const std::string & | xsdFile | ) | const |
Validate the XML document read against the given schema.
invalid_argument | If the schema cannot be read. |
bool ParamReader::validateAgainstInternalSchema | ( | ) | const |
Validate the XML document read against the schema referenced in the document itself.