29#include <boost/current_function.hpp>
30#include <boost/program_options.hpp>
44using boost::program_options::bool_switch;
45using boost::program_options::value;
62 logger.info(
"Test of Message");
65 logger2.info(
"Test2 of Message");
68 logger3.info(
"Test3 of Message");
94 auto add = config_options.add_options();
99 add(
"int-option", value<int>()->default_value(
int{111}),
"An example int option");
100 add(
"int-option-with-default-and-default-in-conf", value<int>()->default_value(
int{222}),
"An example int option");
101 add(
"int-option-with-default-no-default-in-conf", value<int>()->default_value(
int{444}),
"An example int option");
102 add(
"int-option-no-default-not-defined-in-conf", value<int>(),
"An example int option");
103 add(
"int-option-with-no-defaults-anywhere", value<int>(),
"An example int option");
104 add(
"string-option", value<string>()->default_value(
string{}),
"An example string option");
105 add(
"boolean-option", value<bool>()->default_value(
false),
"An example boolean option");
106 add(
"flag,f", bool_switch(&flag),
"An option to set to true");
107 add(
"string-option-no-default", value<string>(),
"A string option without default value");
108 add(
"long-long-option", value<int64_t>()->default_value(
int64_t{}),
"An example long long option");
109 add(
"double-option", value<double>()->default_value(
double{}),
"An example double option");
111 "An example vector option");
112 add(
"threshold,t", value<double>()->default_value(
double{0.5}),
"An example double option");
114 return config_options;
131 log.info(
"Entering mainMethod()");
146 if (args[
"string-option-no-default"].empty()) {
147 log.info() <<
"No value are available for string-option-no-default";
159 string string_example{args[
"string-option"].as<
string>()};
160 log.info() <<
"String option value: " << string_example;
162 log.info() <<
"The int-option value is " << args[
"int-option"].as<
int>();
163 log.info() <<
"The threshold value is " << args[
"threshold"].as<
double>();
166 double input_variable = 3.4756;
178 log.info() <<
"Some result: " << method_result;
181 double division_result{};
184 log.info(
"# Calling a method throwing an exception ");
187 division_result = example_class_object.
divideNumbers(first, second);
191 log.info() << e.what();
193 log.info(
"# In this silly example we continue with a fake fix ");
195 division_result = example_class_object.
divideNumbers(first, 0.000001);
197 log.info() <<
"Second result is: " << division_result;
230 log.info(
"Exiting mainMethod()");
Defines tools to describe the current Elmeents module.
Defines tools to describe the current project.
header to get the module info statically
double divideNumbers(const double first, const double second) const
Divide two double variables.
void passingUniquePointer(std::unique_ptr< std::vector< double > > vector_unique_ptr) const
Example method with a unique pointer argument.
static ClassExample factoryMethod(const std::int64_t source_id, const double ra)
Example factory method.
void passingObjectInGeneral(const std::vector< double > &input_object) const
Example method taking an object in input.
double fundamentalTypeMethod(const double input_variable) const
Simple method example.
Simple example of an Elements program.
OptionsDescription defineSpecificProgramOptions() override
Allows to define the (command line and configuration file) options specific to this program.
ExitCode mainMethod(map< string, VariableValue > &args) override
The "main" method.
Elements base exception class.
static Logging getLogger(const std::string &name="")
Abstract class for all Elements programs.
options_description OptionsDescription
const std::string name() const
ExitCode
Strongly typed exit numbers.
#define MAIN_FOR(ELEMENTS_PROGRAM_NAME)
ELEMENTS_API void printProject()
ELEMENTS_API int functionExample(const int j)
void myLocalLogTestFunc()
test function to demonstrate the logger
ELEMENTS_API const ModuleInfo & getThisExecutableInfo()
static std::string name()
static std::string versionString()
static std::string versionString()
static std::string name()