Ginan
Loading...
Searching...
No Matches
acsConfig.cpp File Reference

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 Documentation

◆ NodeStack

typedef tuple<YAML::Node, string> NodeStack

Function Documentation

◆ addAvailableOptions()

void addAvailableOptions ( const string & stack)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ addEnumDetails()

template<typename ENUM >
void addEnumDetails ( string & stack)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Aliases_And_Inheritance__()

Architecture Aliases_And_Inheritance__ ( )

Some configuration structures are possible to be configured specific for eg a receiver or signal or combination of both.

  • Rather than creating multitudes of 'initialised' variables to correspond with config parameters, a map and pointer algebra is used to keep track of such things. Typically, the base container, the member variable, and a boolean to signify initialisation are included in a parsing line.

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.

Here is the caller graph for this function:

◆ checkGlob()

bool checkGlob ( string str1,
string str2 )
Here is the caller graph for this function:

◆ conditionalPrefix() [1/3]

void conditionalPrefix ( const string & prefix,
map< string, vector< string > > & paths,
bool condition = true )
Here is the call graph for this function:

◆ conditionalPrefix() [2/3]

void conditionalPrefix ( const string & prefix,
vector< string > & paths,
bool condition = true )
Here is the call graph for this function:

◆ conditionalPrefix() [3/3]

void conditionalPrefix ( string prefix,
string & path,
bool condition = true )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Config__()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ configure()

bool configure ( int argc,
char ** argv )

Prepare the configuration of the program.

Parameters
argcPassthrough calling argument count
argvPassthrough calling argument list
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Default_Values_And_Configurator__()

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

Here is the caller graph for this function:

◆ defaultConfigs()

void defaultConfigs ( )
Here is the caller graph for this function:

◆ dumpConfig()

void dumpConfig ( Trace & trace)
Here is the caller graph for this function:

◆ getEnumOpts()

template<typename ENUM >
string getEnumOpts ( bool vec = false)

Get a list of available enum values as readable string.

Here is the caller graph for this function:

◆ getKalmanFromYaml() [1/2]

void getKalmanFromYaml ( ReceiverKalmans & recOpts,
NodeStack yamlBase,
const vector< string > & descriptorVec )

Set receiver options from yaml.

Parameters
recOptsReceiver options variable to output to
yamlBaseYaml node to search within
descriptorVecList of strings of keys of yaml hierarchy
Here is the call graph for this function:

◆ getKalmanFromYaml() [2/2]

void getKalmanFromYaml ( SatelliteKalmans & satOpts,
NodeStack yamlBase,
const vector< string > & descriptorVec )

Set satellite options from yaml.

Parameters
satOptsSatellite options variable to output to
yamlBaseYaml node to search within
descriptorVecList of strings of keys of yaml hierarchy
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getOptionsFromYaml() [1/4]

void getOptionsFromYaml ( CommonOptions & comOpts,
NodeStack yamlBase,
const vector< string > & descriptorVec )

Set common options from yaml.

Parameters
comOptsSatellite options variable to output to
yamlBaseYaml node to search within
descriptorVecList of strings of keys of yaml hierarchy
Here is the call graph for this function:

◆ getOptionsFromYaml() [2/4]

void getOptionsFromYaml ( OrbitOptions & orbOpts,
NodeStack yamlBase,
const vector< string > & descriptorVec )

Set common options from yaml.

Parameters
orbOptsSatellite options variable to output to
yamlBaseYaml node to search within
descriptorVecList of strings of keys of yaml hierarchy
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getOptionsFromYaml() [3/4]

void getOptionsFromYaml ( ReceiverOptions & recOpts,
NodeStack yamlBase,
vector< string > & descriptorVec )

Set receiver options from yaml.

Parameters
recOptsReceiver options variable to output to
yamlBaseYaml node to search within
descriptorVecList of strings of keys of yaml hierarchy
Here is the call graph for this function:

◆ getOptionsFromYaml() [4/4]

void getOptionsFromYaml ( SatelliteOptions & satOpts,
NodeStack yamlBase,
const vector< string > & descriptorVec )

Set satellite options from yaml.

Parameters
satOptsSatellite options variable to output to
yamlBaseYaml node to search within
descriptorVecList of strings of keys of yaml hierarchy
Here is the call graph for this function:

◆ globber() [1/2]

void globber ( map< string, vector< string > > & files)
Here is the call graph for this function:

◆ globber() [2/2]

void globber ( vector< string > & files)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Globbing_And_Tags__()

Architecture Globbing_And_Tags__ ( )

Automatic expansion of configs.

Here is the caller graph for this function:

◆ initIfNeeded()

template<typename CONTAINER , typename ELEMENT >
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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nonNumericStack()

string nonNumericStack ( const string & stack,
string & cutstr,
bool colon = true )
Here is the caller graph for this function:

◆ operator<<()

std::ostream & operator<< ( std::ostream & os,
const Indentor & indentor )

◆ outputDefaultSiblings()

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.

Parameters
levelLevel of complexity for outputs
htmlHtml file stream to output configurator to
mdMarkdown file stream to output configurator to
itIterator over the default values map
indentorHelper to maintain and output indentation for default yaml output
htmlIndentorHelper to maintain and output indentation for internal html output
mdIndentorHelper to maintain and output indentation for markdown output
rootCommon root to determine extent of siblings relationship
Here is the call graph for this function:
Here is the caller graph for this function:

◆ recurseLowerCase()

void recurseLowerCase ( YAML::Node & node)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ replaceString()

bool replaceString ( string & str,
string subStr,
string replacement,
bool warn )

search for and replace section of string

Parameters
strString to search within
subStrString to replace
replacementReplacement string
warnOptional wanring about undefined values
Here is the caller graph for this function:

◆ replaceTags() [1/3]

void replaceTags ( map< string, vector< string > > & strs)
Here is the call graph for this function:

◆ replaceTags() [2/3]

void replaceTags ( string & str)

Replace macros for times with configured values.

Parameters
strString to replace macros within
Here is the call graph for this function:
Here is the caller graph for this function:

◆ replaceTags() [3/3]

void replaceTags ( vector< string > & strs)
Here is the call graph for this function:

◆ setInited()

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.

Here is the caller graph for this function:

◆ stringify() [1/3]

string stringify ( string & value)
Here is the caller graph for this function:

◆ stringify() [2/3]

template<typename TYPE >
string stringify ( TYPE value)

◆ stringify() [3/3]

template<typename TYPE >
string stringify ( vector< TYPE > vec)
Here is the call graph for this function:

◆ stringsToYamlObject()

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

Parameters
yamlBaseYaml node to search within
yamlNodeDescriptorList of strings of keys to trace hierarchy
commentOptional comment to append to default values output
defaultValueOptional default value
typeOptional type of variable
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tryGetEnumOpt()

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.

Parameters
outVariable to output to
yamlBaseYaml node to search within
yamlNodeDescriptorList of strings of keys to trace hierarcy
commentDescription to provide to user for automatic documentation
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tryGetEnumVec()

template<typename ENUM >
bool tryGetEnumVec ( vector< ENUM > & enumVector,
NodeStack yamlBase,
const vector< string > & yamlNodeDescriptor,
const string & comment = "" )
Parameters
enumVectorOutput vector for enum configurations
yamlBaseYaml node to search within
yamlNodeDescriptorList of strings of keys to trace hierarcy
commentDescription to provide to user for automatic documentation
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tryGetFromAny()

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.

Parameters
outputVariable to output to
commandOptsCommand line object to search within
yamlBaseYaml node to search within
nodeDescriptorList of strings of keys to trace hierarcy
commentDescription to provide to user for automatic documentation
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tryGetFromOpts()

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.

Parameters
outputVariable to output to
commandOptsCommand line object to search within
nodeDescriptorList of strings of keys to trace hierarcy
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tryGetFromYaml()

template<typename TYPE >
bool tryGetFromYaml ( TYPE & output,
NodeStack yamlBase,
const vector< string > & yamlNodeDescriptor,
const string & comment = "" )

Set an output from yaml object if found.

Parameters
outputVariable to output to
yamlBaseYaml node to search within
yamlNodeDescriptorList of strings of keys to trace hierarcy
commentDescription to provide to user for automatic documentation
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tryGetKalmanFromYaml() [1/4]

void tryGetKalmanFromYaml ( CommonKalmans & comOpts,
NodeStack yamlBase,
const vector< string > & descriptorVec )

Set common options from yaml.

Parameters
comOptsReceiver options variable to output to
yamlBaseYaml node to search within
descriptorVecList of strings of keys of yaml hierarchy
Here is the call graph for this function:

◆ tryGetKalmanFromYaml() [2/4]

void tryGetKalmanFromYaml ( EmpKalmans & empOpts,
NodeStack yamlBase,
const vector< string > & descriptorVec )

Set empirical force options from yaml.

Parameters
empOptsEmpirical options variable to output to
yamlBaseYaml node to search within
descriptorVecList of strings of keys of yaml hierarchy
Here is the call graph for this function:

◆ tryGetKalmanFromYaml() [3/4]

void tryGetKalmanFromYaml ( InertialKalmans & inertialOpts,
NodeStack yamlBase,
const vector< string > & descriptorVec )

Set inertial force options from yaml.

Parameters
inertialOptsInertail options variable to output to
yamlBaseYaml node to search within
descriptorVecList of strings of keys of yaml hierarchy
Here is the call graph for this function:

◆ tryGetKalmanFromYaml() [4/4]

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.

Parameters
outputVariable to output to
yamlYaml node to search within
keyKey of yaml object
commentDescription to provide to user for automatic documentation
skippableOptionally skip this when yaml object not found in file
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tryGetMappedList()

bool tryGetMappedList ( map< string, vector< string > > & mappedList,
boost::program_options::variables_map & commandOpts,
NodeStack & yaml,
const string & key,
const string & prefix,
const string & comment = "" )
Parameters
commandOptsCommand line object to search within
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tryGetScaledFromYaml()

template<typename ENUM >
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.

Parameters
outputVariable to output to
nodeYaml node to search within
number_parameterList of keys of the hierarchy to the value to be set
scale_parameterList of keys of the hierarchy to the scale to be applied
_from_string_nocaseFunction to decode scale enum strings
commentDescription to use for documentation
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tryGetStreamFromYaml()

void tryGetStreamFromYaml ( SsrBroadcast & outStreamData,
NodeStack & yaml,
const string & id )

Set the variables associated with an output stream.

Parameters
outStreamDataVariable to output to
yamlYaml node to search within
idLabel associated with the stream
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tryGetValFromVM()

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.

Parameters
vmVariable map to search in
keyVariable name
outputDestination to set

◆ warnAboutEnum()

template<typename ENUM >
void warnAboutEnum ( const string & wrong,
const string & option,
ENUM enumValue )
Here is the caller graph for this function:

◆ YAML__()

FileType YAML__ ( )
Here is the caller graph for this function: