Ginan
|
Data Structures | |
struct | EnumDetails |
Helper object to output the use-cases and potential values for enum options. More... | |
struct | Indentor |
Helper object to allow push-pop style indentation in outputs. More... | |
struct | TempStreamDisabler |
Helper object to temporarily and automatically disable and reenable a stream when the object goes out of scope. More... | |
Functions | |
Architecture | Config__ () |
YAML based configuration. | |
Architecture | Globbing_And_Tags__ () |
Automatic expansion of configs. | |
Architecture | Aliases_And_Inheritance__ () |
Some configuration structures are possible to be configured specific for eg a receiver or signal or combination of both. | |
Architecture | Default_Values_And_Configurator__ () |
Each configuration parameter is defined with a default initialisation value which is most sensible for the majority of use-cases. | |
FileType | YAML__ () |
template<typename TYPE > | |
void | tryGetValFromVM (boost::program_options::variables_map &vm, const string &key, TYPE &output) |
Set value according to variable map entry if found. | |
void | conditionalPrefix (string prefix, string &path, bool condition=true) |
void | conditionalPrefix (const string &prefix, vector< string > &paths, bool condition=true) |
void | conditionalPrefix (const string &prefix, map< string, vector< string > > &paths, bool condition=true) |
bool | replaceString (string &str, string subStr, string replacement, bool warn) |
search for and replace section of string | |
void | replaceTags (string &str) |
Replace macros for times with configured values. | |
void | replaceTags (vector< string > &strs) |
void | replaceTags (map< string, vector< string > > &strs) |
bool | checkGlob (string str1, string str2) |
void | globber (vector< string > &files) |
void | globber (map< string, vector< string > > &files) |
void | dumpConfig (Trace &trace) |
string | stringify (string &value) |
template<typename TYPE > | |
string | stringify (TYPE value) |
template<typename TYPE > | |
string | stringify (vector< TYPE > vec) |
string | nonNumericStack (const string &stack, string &cutstr, bool colon=true) |
std::ostream & | operator<< (std::ostream &os, const Indentor &indentor) |
template<typename TYPE > | |
void | outputDefaultSiblings (int level, std::ostream &html, std::ostream &md, TYPE &it, Indentor &indentor, Indentor &htmlIndentor, Indentor &mdIndentor, const string &root="") |
Recursive function to output the default values of all siblings with a common root. | |
void | defaultConfigs () |
void | addAvailableOptions (const string &stack) |
NodeStack | stringsToYamlObject (NodeStack yamlBase, const vector< string > &yamlNodeDescriptor, const string &comment="", const string &defaultValue="", const string &type="") |
Get an object within a hierarchy of yaml structure using a vector of nodes. | |
template<typename TYPE > | |
bool | tryGetFromYaml (TYPE &output, NodeStack yamlBase, const vector< string > &yamlNodeDescriptor, const string &comment="") |
Set an output from yaml object if found. | |
template<typename TYPE > | |
bool | tryGetFromOpts (TYPE &output, boost::program_options::variables_map &commandOpts, const vector< string > &nodeDescriptor) |
Set an output from command line options if found. | |
template<typename TYPE > | |
bool | tryGetFromAny (TYPE &output, boost::program_options::variables_map &commandOpts, NodeStack &yamlBase, const vector< string > &nodeDescriptor, const string &comment="") |
Set an output from any config source if found. | |
template<typename ENUM > | |
void | addEnumDetails (string &stack) |
template<typename ENUM > | |
string | getEnumOpts (bool vec=false) |
Get a list of available enum values as readable string. | |
template<typename ENUM > | |
void | warnAboutEnum (const string &wrong, const string &option, ENUM enumValue) |
template<typename ENUM > | |
bool | tryGetEnumOpt (ENUM &out, NodeStack yamlBase, const vector< string > &yamlNodeDescriptor, const string &comment="") |
Set an enum from yaml, decoding strings to ints. | |
template<typename ENUM > | |
bool | tryGetEnumVec (vector< ENUM > &enumVector, NodeStack yamlBase, const vector< string > &yamlNodeDescriptor, const string &comment="") |
template<typename BASE , typename COMP > | |
void | setInited (BASE &base, COMP &comp, bool init=true) |
Use pointer arithmetic to keep track of variables that have been initialised. | |
void | tryGetKalmanFromYaml (KalmanModel &output, NodeStack &yaml, const string &key, const string &comment="", bool skippable=false) |
Set the variables associated with kalman filter states from yaml. | |
bool | tryGetMappedList (map< string, vector< string > > &mappedList, boost::program_options::variables_map &commandOpts, NodeStack &yaml, const string &key, const string &prefix, const string &comment="") |
void | tryGetStreamFromYaml (SsrBroadcast &outStreamData, NodeStack &yaml, const string &id) |
Set the variables associated with an output stream. | |
template<typename CONTAINER , typename ELEMENT > | |
bool | initIfNeeded (CONTAINER &thisContainer, const CONTAINER &thatContainer, ELEMENT &thisElement) |
Copy one parameter to another, if it has been initialised. | |
void | tryGetKalmanFromYaml (InertialKalmans &inertialOpts, NodeStack yamlBase, const vector< string > &descriptorVec) |
Set inertial force options from yaml. | |
void | tryGetKalmanFromYaml (EmpKalmans &empOpts, NodeStack yamlBase, const vector< string > &descriptorVec) |
Set empirical force options from yaml. | |
void | tryGetKalmanFromYaml (CommonKalmans &comOpts, NodeStack yamlBase, const vector< string > &descriptorVec) |
Set common options from yaml. | |
void | getKalmanFromYaml (SatelliteKalmans &satOpts, NodeStack yamlBase, const vector< string > &descriptorVec) |
Set satellite options from yaml. | |
void | getKalmanFromYaml (ReceiverKalmans &recOpts, NodeStack yamlBase, const vector< string > &descriptorVec) |
Set receiver options from yaml. | |
void | getOptionsFromYaml (OrbitOptions &orbOpts, NodeStack yamlBase, const vector< string > &descriptorVec) |
Set common options from yaml. | |
void | getOptionsFromYaml (CommonOptions &comOpts, NodeStack yamlBase, const vector< string > &descriptorVec) |
Set common options from yaml. | |
void | getOptionsFromYaml (SatelliteOptions &satOpts, NodeStack yamlBase, const vector< string > &descriptorVec) |
Set satellite options from yaml. | |
void | getOptionsFromYaml (ReceiverOptions &recOpts, NodeStack yamlBase, vector< string > &descriptorVec) |
Set receiver options from yaml. | |
template<typename ENUM > | |
void | tryGetScaledFromYaml (double &output, NodeStack node, const vector< string > &number_parameter, const vector< string > &scale_parameter, ENUM(&_from_string_nocase)(const char *), const string &comment="") |
Set and scale a variable according to yaml options. | |
void | recurseLowerCase (YAML::Node &node) |
bool | configure (int argc, char **argv) |
Prepare the configuration of the program. | |
Typedefs | |
typedef tuple< YAML::Node, string > | NodeStack |
typedef tuple<YAML::Node, string> NodeStack |
void addAvailableOptions | ( | const string & | stack | ) |
void addEnumDetails | ( | string & | stack | ) |
Architecture Aliases_And_Inheritance__ | ( | ) |
Some configuration structures are possible to be configured specific for eg a receiver or signal or combination of both.
Inheritance is performed by using the overloaded += operator on an object, with any configurations that have been initialised in the secondary object overwriting those values in the first.
bool checkGlob | ( | string | str1, |
string | str2 ) |
void conditionalPrefix | ( | const string & | prefix, |
map< string, vector< string > > & | paths, | ||
bool | condition = true ) |
void conditionalPrefix | ( | const string & | prefix, |
vector< string > & | paths, | ||
bool | condition = true ) |
void conditionalPrefix | ( | string | prefix, |
string & | path, | ||
bool | condition = true ) |
Architecture Config__ | ( | ) |
YAML based configuration.
The Pea uses one or more yaml files as its source of configuration. YAML files are simple heirarchical documents which are straightforward to edit in basic text editors.
The configuration parser performs many functions simultaneously, which may lead to issues if modifications are made without due care. In most cases, finding a similar configuration and duplicating all references to it will be the most straightforward method of creating new parameters.
The lines in this file can become very long, because they do perform so many functions at once, however they should be aligned such that columns of similar parameters form naturally on the screen. This is preferable to more standard formatting because of the vast amount of duplication that would be required otherwise. The block-select tool in the IDE will come in handy. There are cases where artificial scoping is used to allow dummy variables to be used such that rather than copying one variable name into multiple function calls, which is always a source of bugs, a single common parameter name may be used across many unrelated lines. thing
is one such variable name.
bool configure | ( | int | argc, |
char ** | argv ) |
Prepare the configuration of the program.
argc | Passthrough calling argument count |
argv | Passthrough calling argument list |
Architecture Default_Values_And_Configurator__ | ( | ) |
Each configuration parameter is defined with a default initialisation value which is most sensible for the majority of use-cases.
Parameters which are not assigned using the config will default to those values, allowing the size of yaml files to be minimised.
While parsing the code
void defaultConfigs | ( | ) |
void dumpConfig | ( | Trace & | trace | ) |
string getEnumOpts | ( | bool | vec = false | ) |
Get a list of available enum values as readable string.
void getKalmanFromYaml | ( | ReceiverKalmans & | recOpts, |
NodeStack | yamlBase, | ||
const vector< string > & | descriptorVec ) |
Set receiver options from yaml.
recOpts | Receiver options variable to output to |
yamlBase | Yaml node to search within |
descriptorVec | List of strings of keys of yaml hierarchy |
void getKalmanFromYaml | ( | SatelliteKalmans & | satOpts, |
NodeStack | yamlBase, | ||
const vector< string > & | descriptorVec ) |
Set satellite options from yaml.
satOpts | Satellite options variable to output to |
yamlBase | Yaml node to search within |
descriptorVec | List of strings of keys of yaml hierarchy |
void getOptionsFromYaml | ( | CommonOptions & | comOpts, |
NodeStack | yamlBase, | ||
const vector< string > & | descriptorVec ) |
Set common options from yaml.
comOpts | Satellite options variable to output to |
yamlBase | Yaml node to search within |
descriptorVec | List of strings of keys of yaml hierarchy |
void getOptionsFromYaml | ( | OrbitOptions & | orbOpts, |
NodeStack | yamlBase, | ||
const vector< string > & | descriptorVec ) |
Set common options from yaml.
orbOpts | Satellite options variable to output to |
yamlBase | Yaml node to search within |
descriptorVec | List of strings of keys of yaml hierarchy |
void getOptionsFromYaml | ( | ReceiverOptions & | recOpts, |
NodeStack | yamlBase, | ||
vector< string > & | descriptorVec ) |
Set receiver options from yaml.
recOpts | Receiver options variable to output to |
yamlBase | Yaml node to search within |
descriptorVec | List of strings of keys of yaml hierarchy |
void getOptionsFromYaml | ( | SatelliteOptions & | satOpts, |
NodeStack | yamlBase, | ||
const vector< string > & | descriptorVec ) |
Set satellite options from yaml.
satOpts | Satellite options variable to output to |
yamlBase | Yaml node to search within |
descriptorVec | List of strings of keys of yaml hierarchy |
void globber | ( | map< string, vector< string > > & | files | ) |
void globber | ( | vector< string > & | files | ) |
Architecture Globbing_And_Tags__ | ( | ) |
Automatic expansion of configs.
bool initIfNeeded | ( | CONTAINER & | thisContainer, |
const CONTAINER & | thatContainer, | ||
ELEMENT & | thisElement ) |
Copy one parameter to another, if it has been initialised.
Use pointer arithmetic to determine the offset of another parameter within its parent structure, assuming it has the same layout as this parameter in its parent.
string nonNumericStack | ( | const string & | stack, |
string & | cutstr, | ||
bool | colon = true ) |
std::ostream & operator<< | ( | std::ostream & | os, |
const Indentor & | indentor ) |
void outputDefaultSiblings | ( | int | level, |
std::ostream & | html, | ||
std::ostream & | md, | ||
TYPE & | it, | ||
Indentor & | indentor, | ||
Indentor & | htmlIndentor, | ||
Indentor & | mdIndentor, | ||
const string & | root = "" ) |
Recursive function to output the default values of all siblings with a common root.
level | Level of complexity for outputs |
html | Html file stream to output configurator to |
md | Markdown file stream to output configurator to |
it | Iterator over the default values map |
indentor | Helper to maintain and output indentation for default yaml output |
htmlIndentor | Helper to maintain and output indentation for internal html output |
mdIndentor | Helper to maintain and output indentation for markdown output |
root | Common root to determine extent of siblings relationship |
void recurseLowerCase | ( | YAML::Node & | node | ) |
bool replaceString | ( | string & | str, |
string | subStr, | ||
string | replacement, | ||
bool | warn ) |
search for and replace section of string
str | String to search within |
subStr | String to replace |
replacement | Replacement string |
warn | Optional wanring about undefined values |
void replaceTags | ( | map< string, vector< string > > & | strs | ) |
void replaceTags | ( | string & | str | ) |
Replace macros for times with configured values.
str | String to replace macros within |
void replaceTags | ( | vector< string > & | strs | ) |
void setInited | ( | BASE & | base, |
COMP & | comp, | ||
bool | init = true ) |
Use pointer arithmetic to keep track of variables that have been initialised.
string stringify | ( | string & | value | ) |
string stringify | ( | TYPE | value | ) |
string stringify | ( | vector< TYPE > | vec | ) |
NodeStack stringsToYamlObject | ( | NodeStack | yamlBase, |
const vector< string > & | yamlNodeDescriptor, | ||
const string & | comment = "", | ||
const string & | defaultValue = "", | ||
const string & | type = "" ) |
Get an object within a hierarchy of yaml structure using a vector of nodes.
This will also set default values and comments for the final object in the hierarchy as required. The descriptors may have numeric prefixes attached for ordering parameters in the default output, these are removed before searching for them in the hierarchy
yamlBase | Yaml node to search within |
yamlNodeDescriptor | List of strings of keys to trace hierarchy |
comment | Optional comment to append to default values output |
defaultValue | Optional default value |
type | Optional type of variable |
bool tryGetEnumOpt | ( | ENUM & | out, |
NodeStack | yamlBase, | ||
const vector< string > & | yamlNodeDescriptor, | ||
const string & | comment = "" ) |
Set an enum from yaml, decoding strings to ints.
out | Variable to output to |
yamlBase | Yaml node to search within |
yamlNodeDescriptor | List of strings of keys to trace hierarcy |
comment | Description to provide to user for automatic documentation |
bool tryGetEnumVec | ( | vector< ENUM > & | enumVector, |
NodeStack | yamlBase, | ||
const vector< string > & | yamlNodeDescriptor, | ||
const string & | comment = "" ) |
enumVector | Output vector for enum configurations |
yamlBase | Yaml node to search within |
yamlNodeDescriptor | List of strings of keys to trace hierarcy |
comment | Description to provide to user for automatic documentation |
bool tryGetFromAny | ( | TYPE & | output, |
boost::program_options::variables_map & | commandOpts, | ||
NodeStack & | yamlBase, | ||
const vector< string > & | nodeDescriptor, | ||
const string & | comment = "" ) |
Set an output from any config source if found.
output | Variable to output to |
commandOpts | Command line object to search within |
yamlBase | Yaml node to search within |
nodeDescriptor | List of strings of keys to trace hierarcy |
comment | Description to provide to user for automatic documentation |
bool tryGetFromOpts | ( | TYPE & | output, |
boost::program_options::variables_map & | commandOpts, | ||
const vector< string > & | nodeDescriptor ) |
Set an output from command line options if found.
output | Variable to output to |
commandOpts | Command line object to search within |
nodeDescriptor | List of strings of keys to trace hierarcy |
bool tryGetFromYaml | ( | TYPE & | output, |
NodeStack | yamlBase, | ||
const vector< string > & | yamlNodeDescriptor, | ||
const string & | comment = "" ) |
Set an output from yaml object if found.
output | Variable to output to |
yamlBase | Yaml node to search within |
yamlNodeDescriptor | List of strings of keys to trace hierarcy |
comment | Description to provide to user for automatic documentation |
void tryGetKalmanFromYaml | ( | CommonKalmans & | comOpts, |
NodeStack | yamlBase, | ||
const vector< string > & | descriptorVec ) |
Set common options from yaml.
comOpts | Receiver options variable to output to |
yamlBase | Yaml node to search within |
descriptorVec | List of strings of keys of yaml hierarchy |
void tryGetKalmanFromYaml | ( | EmpKalmans & | empOpts, |
NodeStack | yamlBase, | ||
const vector< string > & | descriptorVec ) |
Set empirical force options from yaml.
empOpts | Empirical options variable to output to |
yamlBase | Yaml node to search within |
descriptorVec | List of strings of keys of yaml hierarchy |
void tryGetKalmanFromYaml | ( | InertialKalmans & | inertialOpts, |
NodeStack | yamlBase, | ||
const vector< string > & | descriptorVec ) |
Set inertial force options from yaml.
inertialOpts | Inertail options variable to output to |
yamlBase | Yaml node to search within |
descriptorVec | List of strings of keys of yaml hierarchy |
void tryGetKalmanFromYaml | ( | KalmanModel & | output, |
NodeStack & | yaml, | ||
const string & | key, | ||
const string & | comment = "", | ||
bool | skippable = false ) |
Set the variables associated with kalman filter states from yaml.
output | Variable to output to |
yaml | Yaml node to search within |
key | Key of yaml object |
comment | Description to provide to user for automatic documentation |
skippable | Optionally skip this when yaml object not found in file |
bool tryGetMappedList | ( | map< string, vector< string > > & | mappedList, |
boost::program_options::variables_map & | commandOpts, | ||
NodeStack & | yaml, | ||
const string & | key, | ||
const string & | prefix, | ||
const string & | comment = "" ) |
commandOpts | Command line object to search within |
void tryGetScaledFromYaml | ( | double & | output, |
NodeStack | node, | ||
const vector< string > & | number_parameter, | ||
const vector< string > & | scale_parameter, | ||
ENUM(&)(const char *) | _from_string_nocase, | ||
const string & | comment = "" ) |
Set and scale a variable according to yaml options.
output | Variable to output to |
node | Yaml node to search within |
number_parameter | List of keys of the hierarchy to the value to be set |
scale_parameter | List of keys of the hierarchy to the scale to be applied |
_from_string_nocase | Function to decode scale enum strings |
comment | Description to use for documentation |
void tryGetStreamFromYaml | ( | SsrBroadcast & | outStreamData, |
NodeStack & | yaml, | ||
const string & | id ) |
Set the variables associated with an output stream.
outStreamData | Variable to output to |
yaml | Yaml node to search within |
id | Label associated with the stream |
void tryGetValFromVM | ( | boost::program_options::variables_map & | vm, |
const string & | key, | ||
TYPE & | output ) |
Set value according to variable map entry if found.
vm | Variable map to search in |
key | Variable name |
output | Destination to set |
void warnAboutEnum | ( | const string & | wrong, |
const string & | option, | ||
ENUM | enumValue ) |
FileType YAML__ | ( | ) |