Flow123d  release_1.8.2-1603-g0109a2b
main.h
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file main.h
15  * @brief
16  */
17 
18 #include <string>
20 #include "input/accessors.hh"
21 #include "input/type_output.hh"
23 #include "system/exceptions.hh"
24 
25 using namespace std;
26 
27 #ifndef MAIN_H
28 #define MAIN_H
29 
30 
31 
32 class Application : public ApplicationBase {
33 public:
34  TYPEDEF_ERR_INFO( EI_InputVersionStr, string);
35  DECLARE_EXCEPTION( ExcVersionFormat,
36  << "Wrong format of the version specification: "
37  << EI_InputVersionStr::qval);
38 
39 
40  /// Root of the Input::Type tree. Description of whole input structure.
41  static Input::Type::Record & get_input_type();
42 
43  /// Application constructor.
44  Application(int argc, char ** argv);
45 
46  /**
47  * Displays program version and build info.
48  * Pass version information to Profiler.
49  *
50  * TODO: Split these two functionalities.
51  */
52  void display_version();
53 
54  /**
55  * Read main input file
56  *
57  * Returns accessor to the root Record.
58  */
59  Input::Record read_input();
60 
61  /// Destructor
62  virtual ~Application();
63 
64 protected:
65 
66  /**
67  * Run application.
68  *
69  * Read input and solve problem.
70  */
71  virtual void run();
72 
73  /**
74  * Check pause_after_run flag defined in input file.
75  */
76  virtual void after_run();
77 
78  /**
79  * Parse command line parameters.
80  * @param[in] argc command line argument count
81  * @param[in] argv command line arguments
82  */
83  virtual void parse_cmd_line(const int argc, char ** argv);
84 
85  /**
86  * Split path to directory (part up to last DIR_SEPARATOR excluded) and filename.
87  * Directory is set to "." if no DIR_SEPARATOR is found.
88  */
89  void split_path(const string& path, string& directory, string& file_name);
90 
91 private:
92 
93  /// Get version of program and other base data from rev_num.h and store them to map
94  Input::Type::RevNumData get_rev_num_data();
95 
96  /// directory of main input file (used to resolve relative paths of other input files)
98  /// filename of main input file
100 
102  char ** passed_argv_;
103 
104  /// Description of possible command line arguments.
106 
107  /// If true, we do output of profiling information.
109 
110  /// root input record
112 };
113 
114 
115 
116 
117 #endif
118 
119 //-----------------------------------------------------------------------------
120 // vim: set cindent:
121 
string main_input_filename_
filename of main input file
Definition: main.h:99
bool use_profiler
If true, we do output of profiling information.
Definition: main.h:108
#define DECLARE_EXCEPTION(ExcName, Format)
Macro for simple definition of exceptions.
Definition: exceptions.hh:144
Stores version of program and other base data of application.
Definition: type_output.hh:37
Accessor to the data with type Type::Record.
Definition: accessors.hh:277
string main_input_dir_
directory of main input file (used to resolve relative paths of other input files) ...
Definition: main.h:97
char ** passed_argv_
Definition: main.h:102
int passed_argc_
Definition: main.h:101
string program_arguments_desc_
Description of possible command line arguments.
Definition: main.h:105
#define TYPEDEF_ERR_INFO(EI_Type, Type)
Macro to simplify declaration of error_info types.
Definition: exceptions.hh:180
Record type proxy class.
Definition: type_record.hh:171
Input::Record root_record
root input record
Definition: main.h:111