Elements
6.2
A C++ base framework for the Euclid Software.
|
Go to the documentation of this file.
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");
97 config_options.add_options()(
"int-option", value<int>()->default_value(
int{111}),
"An example int option")(
98 "int-option-with-default-and-default-in-conf", value<int>()->default_value(
int{222}),
"An example int option")(
99 "int-option-with-default-no-default-in-conf", value<int>()->default_value(
int{444}),
100 "An example int option")(
"int-option-no-default-not-defined-in-conf", value<int>(),
"An example int option")(
101 "int-option-with-no-defaults-anywhere", value<int>(),
102 "An example int option")(
"string-option", value<string>()->default_value(
string{}),
"An example string option")(
103 "boolean-option", value<bool>()->default_value(
false),
"An example boolean option")(
104 "flag,f", bool_switch(&flag),
"An option to set to true")(
"string-option-no-default", value<string>(),
105 "A string option without default value")(
106 "long-long-option", value<int64_t>()->default_value(
int64_t{}),
"An example long long option")(
107 "double-option", value<double>()->default_value(
double{}),
"An example double option")(
108 "int-vector-option", value<vector<int>>()->multitoken()->default_value(
vector<int>{},
"Empty"),
109 "An example vector option")(
"threshold,t", value<double>()->default_value(
double{0.5}),
110 "An example double option");
112 return config_options;
129 log.info(
"Entering mainMethod()");
144 if (args[
"string-option-no-default"].empty()) {
145 log.info() <<
"No value are available for string-option-no-default";
157 string string_example{args[
"string-option"].as<
string>()};
158 log.info() <<
"String option value: " << string_example;
160 log.info() <<
"The int-option value is " << args[
"int-option"].as<
int>();
161 log.info() <<
"The threshold value is " << args[
"threshold"].as<
double>();
164 double input_variable = 3.4756;
176 log.info() <<
"Some result: " << method_result;
179 double division_result{};
182 log.info(
"# Calling a method throwing an exception ");
189 log.info() <<
e.what();
191 log.info(
"# In this silly example we continue with a fake fix ");
193 division_result = example_class_object.
divideNumbers(first, 0.000001);
195 log.info() <<
"Second result is: " << division_result;
228 log.info(
"Exiting mainMethod()");
void myLocalLogTestFunc()
test function to demonstrate the logger
const std::string name() const
static ClassExample factoryMethod(const std::int64_t source_id, const double ra)
Example factory method.
Defines tools to describe the current project.
Defines tools to describe the current Elmeents module.
options_description OptionsDescription
static std::string versionString()
ELEMENTS_API int functionExample(const int j)
ExitCode
Strongly typed exit numbers.
Simple example of an Elements program.
static std::string name()
OptionsDescription defineSpecificProgramOptions() override
Allows to define the (command line and configuration file) options specific to this program.
Elements base exception class.
static std::string name()
const ELEMENTS_API ModuleInfo & getThisExecutableInfo()
static Logging getLogger(const std::string &name="")
double divideNumbers(const double first, const double second) const
Divide two double variables.
ELEMENTS_API void printProject()
static std::string versionString()
void passingUniquePointer(std::unique_ptr< std::vector< double >> vector_unique_ptr) const
Example method with a unique pointer argument.
Abstract class for all Elements programs.
#define MAIN_FOR(ELEMENTS_PROGRAM_NAME)
double fundamentalTypeMethod(const double input_variable) const
Simple method example.
void passingObjectInGeneral(const std::vector< double > &input_object) const
Example method taking an object in input.
header to get the module info statically
constexpr double e
The base of the natural logarithm .
ExitCode mainMethod(map< string, VariableValue > &args) override
The "main" method.