votca 2024.2-dev
Loading...
Searching...
No Matches
application.h
Go to the documentation of this file.
1/*
2 * Copyright 2009-2020 The VOTCA Development Team (http://www.votca.org)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18#ifndef VOTCA_TOOLS_APPLICATION_H
19#define VOTCA_TOOLS_APPLICATION_H
20
21// Third party includes
22#include <boost/program_options.hpp>
23
24// Local VOTCA includes
25#include "property.h"
26
27namespace votca {
28namespace tools {
29
31 public:
33 virtual ~Application();
34
41 int Exec(int argc, char **argv);
42
49 virtual std::string ProgramName() = 0;
50
55 virtual std::string VersionString() { return ""; }
56
61 virtual void HelpText(std::ostream &out) = 0;
62
69 virtual void Initialize() = 0;
70
78 virtual bool EvaluateOptions() = 0;
79
89 void CheckRequired(const std::string &option_name,
90 const std::string &error_msg = "");
91
98 virtual void Run() = 0;
99
109 boost::program_options::options_description_easy_init AddProgramOptions(
110 const std::string &group = "");
111
116 boost::program_options::variables_map &OptionsMap() { return op_vm_; }
117 boost::program_options::options_description &OptionsDesc() {
118 return op_desc_;
119 }
120
125 boost::program_options::options_description &VisibleOptions() {
126 return visible_options_;
127 }
128
137
138 protected:
139 std::map<std::string, boost::program_options::options_description> op_groups_;
140
141 virtual void ShowHelpText(std::ostream &out);
142
144
145 private:
147 boost::program_options::options_description op_desc_;
149 boost::program_options::variables_map op_vm_;
151 void ParseCommandLine(int argc, char **argv);
152
154 boost::program_options::options_description visible_options_;
155};
156
157} // namespace tools
158} // namespace votca
159
160#endif // VOTCA_TOOLS_APPLICATION_H
int Exec(int argc, char **argv)
executes the program
void ParseCommandLine(int argc, char **argv)
get input parameters from file, location may be specified in command line
boost::program_options::variables_map op_vm_
Variable map containing all program options.
virtual bool EvaluateOptions()=0
Process command line options.
boost::program_options::variables_map & OptionsMap()
get available program options & descriptions
std::map< std::string, boost::program_options::options_description > op_groups_
virtual void HelpText(std::ostream &out)=0
help text of application without version information
boost::program_options::options_description & VisibleOptions()
filters out the Hidden group from the options descriptions
virtual std::string ProgramName()=0
program name
virtual std::string VersionString()
version string of application
Definition application.h:55
void StopExecution()
call StopExecution after EvaluateOptions
boost::program_options::options_description_easy_init AddProgramOptions(const std::string &group="")
add option for command line
boost::program_options::options_description visible_options_
program options without the Hidden group
virtual void Initialize()=0
Initialize application data.
virtual void Run()=0
Main body of application.
virtual void ShowHelpText(std::ostream &out)
void CheckRequired(const std::string &option_name, const std::string &error_msg="")
Check weather required option is set.
boost::program_options::options_description op_desc_
program options required by all applications
boost::program_options::options_description & OptionsDesc()
base class for all analysis tools
Definition basebead.h:33