forked from degauden/Elements
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathProgram.h
More file actions
129 lines (110 loc) · 4.05 KB
/
Copy pathProgram.h
File metadata and controls
129 lines (110 loc) · 4.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/**
* @file ElementsKernel/Program.h
* @brief define an abstract class for all Elements program
* @date January 8, 2015
* @author Pierre Dubath
*
* @copyright 2012-2020 Euclid Science Ground Segment
*
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General
* Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
/**
* \addtogroup ElementsKernel ElementsKernel
* @{
*/
#ifndef ELEMENTSKERNEL_ELEMENTSKERNEL_PROGRAM_H_
#define ELEMENTSKERNEL_ELEMENTSKERNEL_PROGRAM_H_
#include <map> // for map
#include <string> // for string
#include <utility> // for pair
#include <boost/program_options.hpp> // for options_description, positional_options_description, variable_value, variables_map
#include "ElementsKernel/Export.h" // for ELEMENTS_API
#include "ElementsKernel/Logging.h" // for Logging
namespace Elements {
enum class ExitCode : int;
}
namespace Elements {
/**
* @class Program
* @ingroup ElementsKernel
* @brief
* Abstract class for all Elements programs
* @details
* This abstract class defines the three interfaces that should
* be implemented by all Elements programs.
*/
class ELEMENTS_API Program {
public:
// backwards compatible type aliases
using options_description = boost::program_options::options_description;
using positional_options_description = boost::program_options::positional_options_description;
using variable_value = boost::program_options::variable_value;
using variables_map = boost::program_options::variables_map;
// camel case type aliases
using OptionsDescription = options_description;
using PositionalOptionsDescription = positional_options_description;
using VariableValue = variable_value;
using VariablesMap = variables_map;
using ExitCode = Elements::ExitCode;
using Logging = Elements::Logging;
/**
* @brief Constructor
*/
Program() = default;
/**
* @brief Destructor
*/
virtual ~Program();
/**
* @brief
* This methods must be used to define specific program options
* @details
* This is the first method that must be implemented by all Elements programs
*
* @return
* A BOOST options description
*/
virtual OptionsDescription defineSpecificProgramOptions();
/**
* @brief
* This methods must be used to the program arguments.
* @details
* This is the second method that must be implemented by all Elements programs
*
* @return
* a pair of BOOST options description and positional_options_description
*/
virtual std::pair<OptionsDescription, PositionalOptionsDescription> defineProgramArguments();
/**
* @brief
* This is the "main" method of all Elements programs
* @details
* This is the second method that must be implemented by all Elements programs. It
* represents the entry point.
*
* @param args
* A map containing the values given by the user for the program options
* defined by the defineSpecificProgramOptions() method
* @return
* The exit code which should be returned when the program exits
*/
virtual ExitCode mainMethod(std::map<std::string, VariableValue>& args) = 0;
};
/** These are examples of how to create an executable program using
* the Program class.
* @example ElementsExamples/src/program/SimpleProgram.cpp
* @include ElementsExamples/src/program/Program.cpp
*/
} // namespace Elements
#endif // ELEMENTSKERNEL_ELEMENTSKERNEL_PROGRAM_H_
/**@}*/