29 #include <boost/current_function.hpp>
30 #include <boost/program_options.hpp>
44 using boost::program_options::bool_switch;
45 using 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);
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()");
ExitCode
Strongly typed exit numbers.
double fundamentalTypeMethod(const double input_variable) const
Simple method example.
OptionsDescription defineSpecificProgramOptions() override
Allows to define the (command line and configuration file) options specific to this program...
static std::string name()
Defines tools to describe the current project.
ELEMENTS_API const ModuleInfo & getThisExecutableInfo()
static std::string versionString()
void myLocalLogTestFunc()
test function to demonstrate the logger
ELEMENTS_API int functionExample(const int j)
Abstract class for all Elements programs.
constexpr double e
The base of the natural logarithm .
header to get the module info statically
#define MAIN_FOR(ELEMENTS_PROGRAM_NAME)
static std::string name()
const std::string name() const
ELEMENTS_API void printProject()
static std::string versionString()
ExitCode mainMethod(map< string, VariableValue > &args) override
The "main" method.
void passingUniquePointer(std::unique_ptr< std::vector< double >> vector_unique_ptr) const
Example method with a unique pointer argument.
Defines tools to describe the current Elmeents module.
Elements base exception class.
options_description OptionsDescription
void passingObjectInGeneral(const std::vector< double > &input_object) const
Example method taking an object in input.
Simple example of an Elements program.
double divideNumbers(const double first, const double second) const
Divide two double variables.
const char * what() const noexceptoverride
static Logging getLogger(const std::string &name="")
static ClassExample factoryMethod(const std::int64_t source_id, const double ra)
Example factory method.