BornAgain  1.19.0
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 GUI/main/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_GUI_MAIN_APPOPTIONS_H
16 #define BORNAGAIN_GUI_MAIN_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 //! @ingroup tools_internal
30 //! @brief Handles command line and config file program options
31 
33 public:
34  ApplicationOptions(int argc = 0, char** argv = 0);
35 
36  //! access to variable with given name defined in variables container
37  const bpo::variable_value& operator[](const std::string& s) const;
38 
39  //! Returns true if option with given name has been set
40  bool find(std::string name) const;
41 
42  //! Returns true if options are consistent (no conflicts, no --help request)
43  bool isConsistent() const;
44 
45  //! Parses command line arguments
46  void parseCommandLine(int argc, char** argv);
47 
48  //! Returns reference to the variables container
49  bpo::variables_map& getVariables();
50 
51  //! Returns reference to the options description
52  bpo::options_description& getOptions();
53 
54  void processOptions();
55 
56  void printHelpMessage() const;
57 
58  QSize mainWindowSize() const;
59 
60  bool disableHighDPISupport();
61 
62 private:
63  //! true if options are consistent (no conflicts, no --help request)
65  //! options description, to be filled with add() from different program modules
66  bpo::options_description m_options;
67  //! positional options description, to be filled with addPositional() from main module
68  bpo::positional_options_description m_positional_options;
69  bpo::variables_map m_variables_map; //! parsed variables
70 };
71 
72 #endif // BORNAGAIN_GUI_MAIN_APPOPTIONS_H
Handles command line and config file program options.
Definition: appoptions.h:32
bool find(std::string name) const
Returns true if option with given name has been set.
Definition: appoptions.cpp:70
bpo::variables_map & getVariables()
Returns reference to the variables container.
Definition: appoptions.cpp:108
void parseCommandLine(int argc, char **argv)
Parses command line arguments.
Definition: appoptions.cpp:82
bpo::options_description & getOptions()
Returns reference to the options description.
Definition: appoptions.cpp:113
bool m_options_is_consistent
true if options are consistent (no conflicts, no –help request)
Definition: appoptions.h:64
bpo::options_description m_options
options description, to be filled with add() from different program modules
Definition: appoptions.h:66
ApplicationOptions(int argc=0, char **argv=0)
Definition: appoptions.cpp:49
bool disableHighDPISupport()
Definition: appoptions.cpp:151
bpo::variables_map m_variables_map
Definition: appoptions.h:69
bool isConsistent() const
Returns true if options are consistent (no conflicts, no –help request)
Definition: appoptions.cpp:75
QSize mainWindowSize() const
Definition: appoptions.cpp:145
void printHelpMessage() const
Definition: appoptions.cpp:139
bpo::positional_options_description m_positional_options
positional options description, to be filled with addPositional() from main module
Definition: appoptions.h:68
const bpo::variable_value & operator[](const std::string &s) const
access to variable with given name defined in variables container
Definition: appoptions.cpp:65
QString const & name(EShape k)
Definition: particles.cpp:21