29#include <boost/current_function.hpp>
30#include <boost/program_options.hpp>
44using boost::program_options::bool_switch;
45using boost::program_options::value;
72 auto add = config_options.add_options();
77 add(
"int-option", value<int>()->default_value(
int{111}),
"An example int option");
78 add(
"int-option-with-default-and-default-in-conf", value<int>()->default_value(
int{222}),
"An example int option");
79 add(
"int-option-with-default-no-default-in-conf", value<int>()->default_value(
int{444}),
"An example int option");
80 add(
"int-option-no-default-not-defined-in-conf", value<int>(),
"An example int option");
81 add(
"int-option-with-no-defaults-anywhere", value<int>(),
"An example int option");
82 add(
"string-option", value<string>()->default_value(
string{}),
"An example string option");
83 add(
"boolean-option", value<bool>()->default_value(
false),
"An example boolean option");
84 add(
"flag,f", bool_switch(&flag),
"An option to set to true");
85 add(
"string-option-no-default", value<string>(),
"A string option without default value");
86 add(
"long-long-option", value<int64_t>()->default_value(
int64_t{}),
"An example long long option");
87 add(
"double-option", value<double>()->default_value(
double{}),
"An example double option");
89 "An example vector option");
90 add(
"threshold,t", value<double>()->default_value(
double{0.5}),
"An example double option");
92 return config_options;
111 log.info(
"Entering mainMethod()");
126 if (args[
"string-option-no-default"].empty()) {
127 log.info() <<
"No value are available for string-option-no-default";
139 string string_example{args[
"string-option"].as<
string>()};
140 log.info() <<
"String option value: " << string_example;
142 log.info() <<
"The int-option value is " << args[
"int-option"].as<
int>();
143 log.info() <<
"The threshold value is " << args[
"threshold"].as<
double>();
146 double input_variable = 3.4756;
151 ClassExample example_class_object = ClassExample::factoryMethod(source_id, ra);
157 double method_result = example_class_object.fundamentalTypeMethod(input_variable);
158 log.info() <<
"Some result: " << method_result;
161 double division_result{};
164 log.info(
"# Calling a method throwing an exception ");
167 division_result = example_class_object.divideNumbers(first, second);
171 log.info() << e.what();
173 log.info(
"# In this silly example we continue with a fake fix ");
175 division_result = example_class_object.divideNumbers(first, 0.000001);
177 log.info() <<
"Second result is: " << division_result;
186 example_class_object.passingUniquePointer(
std::move(vector_unique_ptr));
193 example_class_object.passingObjectInGeneral(object_example);
208 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
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
Simple example of an Elements program outside of the Elements namespace.
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.
ExitCode
Strongly typed exit numbers.
#define MAIN_FOR(ELEMENTS_PROGRAM_NAME)
ELEMENTS_API void printProject()
ELEMENTS_API int functionExample(const int j)
ELEMENTS_API const ModuleInfo & getThisExecutableInfo()
static std::string name()
static std::string versionString()
static std::string versionString()
static std::string name()