JANA2
|
Public Member Functions | |
bool | Exists (std::string name) |
JParameter * | FindParameter (std::string) |
void | PrintParameters (bool all=false) |
template<typename T > | |
JParameter * | GetParameter (std::string name, T &val) |
template<typename T > | |
T | GetParameterValue (std::string name) |
template<typename T > | |
JParameter * | SetParameter (std::string name, T val) |
template<typename T > | |
JParameter * | SetDefaultParameter (std::string name, T &val, std::string description="") |
void | ReadConfigFile (std::string name) |
void | WriteConfigFile (std::string name) |
template<> | |
bool | parse (const std::string &value) |
template<> | |
std::vector< std::string > | parse (const std::string &value) |
Specialization for std::vector<std::string> | |
template<> | |
std::string | stringify (std::vector< std::string > value) |
Specialization for std::vector<std::string> | |
Public Member Functions inherited from JService | |
virtual | ~JService ()=default |
acquire_services is a callback which allows the user to configure a JService which relies on other JServices. More... | |
virtual void | acquire_services (JServiceLocator *sl) |
Protected Member Functions | |
template<typename T > | |
T | parse (const std::string &value) |
template<typename T > | |
std::string | stringify (T value) |
std::string | to_lower (std::string &name) |
Protected Attributes | |
std::map< std::string, JParameter * > | m_parameters |
JLogger | m_logger |
void JParameterManager::PrintParameters | ( | bool | all = false | ) |
Print configuration parameters to stdout. If "all" is false (default) then only parameters whose values are different than their default are printed. If "all" is true then all parameters are printed.
void JParameterManager::ReadConfigFile | ( | std::string | name | ) |
Read in the configuration file with name specified by "fname". The file should have the form:
key1 value1 key2 value2 ...
Where there is a space between the key and the value (thus, the "key" can contain no spaces). The value is taken as the rest of the line up to, but not including the newline itself.
A key may be specified with no value and the value will be set to "1".
A "#" charater will discard the remaining characters in a line up to the next newline. Therefore, lines starting with "#" are ignored completely.
Lines with no characters (except for the newline) are ignored.
JParameter * JParameterManager::SetDefaultParameter | ( | std::string | name, |
T & | val, | ||
std::string | description = "" |
||
) |
Retrieve a configuration parameter, creating it if necessary.
Upon entry, the value in "val" should be set to the desired default value. It will be overwritten if a value for the parameter already exists because it was given by the user either on the command line or in a configuration file. If the parameter does not already exist, it is created and its value set to that of "val". Upon exit, "val" will always contain the value that should be used for event processing.
If a parameter with the given name already exists, it will be checked to see if the parameter already has a default value assigned (this is kept separate from the actual value of the parameter used and is maintained purely for bookkeeping purposes). If it does not have a default value, then the value of "val" upon entry is saved as the default. If it does have a default, then the value of the default is compared to the value of "val" upon entry. If the two do not match, then a warning message is printed to indicate to the user that two different default values are being set for this parameter.
Parameters specified on the command line using the "-Pkey=value" syntax will not have a default value at the time the parameter is created.
This should be called after the JApplication object has been initialized so that parameters can be created from any command line options the user may specify.
Referenced by JPluginLoader::attach_plugin(), and JSignalHandler::register_handlers().
void JParameterManager::WriteConfigFile | ( | std::string | name | ) |
Write all of the configuration parameters out to an ASCII file in a format compatible with reading in via ReadConfigFile().