BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
AppOptions.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file App/AppOptions.h
6 //! @brief Collection of utilities to parse command line options
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_APP_APPOPTIONS_H
16 #define BORNAGAIN_APP_APPOPTIONS_H
17 
18 #include <boost/program_options/options_description.hpp>
19 #include <boost/program_options/positional_options.hpp>
20 #include <boost/program_options/variables_map.hpp>
21 
22 #include <string>
23 
24 class QSize;
25 
26 namespace bpo = boost::program_options;
27 
28 //! @class ApplicationOptions
29 //! @brief Handles command line and config file program options
30 
32 public:
33  ApplicationOptions(int argc = 0, char** argv = 0);
34 
35  //! access to variable with given name defined in variables container
36  const bpo::variable_value& operator[](const std::string& s) const;
37 
38  QSize mainWindowSize() const;
39 
40  bool disableHighDPISupport() const;
41 
42  //! Returns true if option with given name has been set
43  bool find(std::string name) const;
44 
45 private:
46  //! Parses command line arguments
47  void parseCommandLine(int argc, char** argv);
48 
49  //! Returns reference to the variables container
50  bpo::variables_map& getVariables();
51 
52  //! Returns reference to the options description
53  bpo::options_description& getOptions();
54 
55  void processOptions();
56 
57  //! true if options are consistent (no conflicts, no --help request)
59  //! options description, to be filled with add() from different program modules
60  bpo::options_description m_options;
61  //! positional options description, to be filled with addPositional() from main module
62  bpo::positional_options_description m_positional_options;
63  bpo::variables_map m_variables_map; //! parsed variables
64 };
65 
66 #endif // BORNAGAIN_APP_APPOPTIONS_H
Handles command line and config file program options.
Definition: AppOptions.h:31
bool find(std::string name) const
Returns true if option with given name has been set.
Definition: AppOptions.cpp:81
bpo::variables_map & getVariables()
Returns reference to the variables container.
Definition: AppOptions.cpp:115
void parseCommandLine(int argc, char **argv)
Parses command line arguments.
Definition: AppOptions.cpp:88
bpo::options_description & getOptions()
Returns reference to the options description.
Definition: AppOptions.cpp:120
bool m_options_is_consistent
true if options are consistent (no conflicts, no –help request)
Definition: AppOptions.h:58
bpo::options_description m_options
options description, to be filled with add() from different program modules
Definition: AppOptions.h:60
ApplicationOptions(int argc=0, char **argv=0)
Definition: AppOptions.cpp:60
bool disableHighDPISupport() const
Definition: AppOptions.cpp:151
bpo::variables_map m_variables_map
Definition: AppOptions.h:63
QSize mainWindowSize() const
Definition: AppOptions.cpp:145
bpo::positional_options_description m_positional_options
positional options description, to be filled with addPositional() from main module
Definition: AppOptions.h:62
const bpo::variable_value & operator[](const std::string &s) const
access to variable with given name defined in variables container
Definition: AppOptions.cpp:76
QString const & name(EShape k)
Definition: particles.cpp:20