BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
DIDaemon.h
1 #pragma once
2 
3 #include <string>
4 #include <vector>
5 
6 #include <Poco/ErrorHandler.h>
7 #include <Poco/Exception.h>
8 #include <Poco/Util/ServerApplication.h>
9 #include <Poco/Util/Option.h>
10 
11 #include "util/About.h"
12 #include "util/Loggable.h"
13 
14 namespace Poco {
15 namespace Util {
16 
17 class OptionSet;
18 
19 }
20 }
21 
22 namespace BeeeOn {
23 
24 class DIDaemon : public Poco::Util::ServerApplication {
25 public:
26  DIDaemon(const About &about);
27  virtual ~DIDaemon();
28 
29  static int up(int argc, char **argv,
30  const About &about = About());
31 
32 protected:
33  class UnhandledErrorHandler : public Poco::ErrorHandler, Loggable {
34  public:
35  virtual ~UnhandledErrorHandler();
36 
37  void exception(const Poco::Exception &e) override;
38  void exception(const std::exception &e) override;
39  void exception() override;
40  };
41 
42  void initialize(Poco::Util::Application &self) override;
43  int main(const std::vector<std::string> &args) override;
44  void defineOptions(Poco::Util::OptionSet &options) override;
45  void handleHelp(const std::string &name, const std::string &value);
46  void handleVersion(const std::string &name, const std::string &value);
47  void handleDebugStartup(const std::string &name, const std::string &value);
48  void handleDefine(const std::string &name, const std::string &value);
49  void handleConfig(const std::string &name, const std::string &value);
50  void handleNoEarly(const std::string &name, const std::string &value);
51  void startRunner(const std::string &name);
52  void printHelp() const;
53  void printVersion() const;
54  void notifyStarted() const;
55  void testPocoCompatibility() const;
56  void logStartup() const;
57  bool isUnix() const;
58  bool helpRequested() const;
59  bool versionRequested() const;
60  bool noEarlyRequested() const;
61  std::vector<std::string> libraryPaths();
62  std::string runnerName();
63  std::string version() const;
64 
65 private:
66  bool m_helpRequested = false;
67  bool m_versionRequested = false;
68  bool m_noEarlyRequested = false;
69  About m_about;
70  UnhandledErrorHandler m_errorHandler;
71  Poco::Util::Option m_helpOption;
72  Poco::Util::Option m_versionOption;
73  Poco::Util::Option m_debugStartupOption;
74  Poco::Util::Option m_defineOption;
75  Poco::Util::Option m_configOption;
76  Poco::Util::Option m_notifyStartedOption;
77  Poco::Util::Option m_noEarlyOption;
78 };
79 
80 }
Definition: DIDaemon.h:24
static int up(int argc, char **argv, const About &about=About())
Definition: DIDaemon.cpp:95
Definition: Loggable.h:19
Definition: About.h:7