-
Notifications
You must be signed in to change notification settings - Fork 3
Configuration
In the na62-farm-lib project there is a class called Options. This is used to define program parameters for na62-farm, na62-trigger-test and na62-trigger-algorithms in the following way:
For each project a class called MyOptions inheriting from Options is created. In the static method load
all possible options are defined with a corresponding string. This string can be used in run time to retrieve the value of the parameter.
To add a new option you have to do two things:
- Define the string
YOUR_OPTION
identifying the option. This string must also be used to set the option value when running the program as in./na62-farm --YourOption=someValue
- Add the option to the
desc
object in theload
method. The syntax is like following:
(YOUR_OPTION, po::value<OptionType>()->default_value(defaultValue), "Description availablie when calling --help")
(YOUR_OPTION2, po::value<OptionType>()->required(), "Program will not run when this option is not defined")
Please leave a blank line between every option as the autoformater destroys the structure otherwise
For every data type there is one getter function implemented in Options
. If you have defined an option identified by OPTION_SOME_NAME
with type int
you can retrieve it's value like following:
Options::GetInt(OPTION_SOME_NAME);
Please note that Options is implemented to offer a simple way to easily add parameters and retrieve new program parameters. However retrieving values is not very efficient and you should do that only during initialization time. So please store your parameter values in your own buffer similar to following code:
void MyClass::initialize(){
MyClass::myParameter = Options::GetInt(OPTION_My_OPTION);
}