bpp-core3  3.0.0
BppApplication.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #ifndef BPP_APP_BPPAPPLICATION_H
6 #define BPP_APP_BPPAPPLICATION_H
7 
8 
9 #include "../Exceptions.h"
10 
11 // From the STL:
12 #include <string>
13 #include <map>
14 
15 namespace bpp
16 {
18 {
19 protected:
20  std::string appName_;
21  mutable std::map<std::string, std::string> params_;
23  bool verbose_;
24  int warn_;
25 
26 public:
27  BppApplication(int argc, char* argv[], const std::string& name, bool verbose = true, int warningLevel = 1);
28  virtual ~BppApplication() {}
29 
30 public:
31  virtual void startTimer();
32  virtual void done();
33 
34  virtual const std::map<std::string, std::string>& getParams() const { return params_; }
35  virtual std::map<std::string, std::string>& getParams() { return params_; }
36 
37  virtual const std::string& getParam(const std::string& name) const
38  {
39  if (params_.find(name) == params_.end()) throw Exception("BppApplication::getParam(). Parameter '" + name + "' not found.");
40  return params_[name];
41  }
42 
43  virtual std::string& getParam(const std::string& name) { return params_[name]; }
44 
45  virtual bool isVerbose() const { return verbose_; }
46 
47  virtual int getWarningLevel() const { return warn_; }
48 
49  virtual void help(const std::string& program) const;
50 };
51 } // end of namespace bpp;
52 #endif // BPP_APP_BPPAPPLICATION_H
virtual const std::map< std::string, std::string > & getParams() const
std::string appName_
virtual ~BppApplication()
virtual void done()
virtual bool isVerbose() const
virtual std::map< std::string, std::string > & getParams()
virtual const std::string & getParam(const std::string &name) const
BppApplication(int argc, char *argv[], const std::string &name, bool verbose=true, int warningLevel=1)
std::map< std::string, std::string > params_
virtual void help(const std::string &program) const
virtual std::string & getParam(const std::string &name)
virtual int getWarningLevel() const
virtual void startTimer()
Exception base class. Overload exception constructor (to control the exceptions mechanism). Destructor is already virtual (from std::exception)
Definition: Exceptions.h:20