CuteHMI - Daemon (cutehmi.daemon.2)
Daemon.hpp
1 #ifndef H_TOOLS_CUTEHMI_DAEMON_2_SRC_CUTEHMI_DAEMON_DAEMON_HPP
2 #define H_TOOLS_CUTEHMI_DAEMON_2_SRC_CUTEHMI_DAEMON_DAEMON_HPP
3 
4 #include "CoreData.hpp"
5 
6 #include <functional>
7 
8 namespace cutehmi {
9 namespace daemon {
10 
11 class _Daemon;
12 
13 class Daemon final
14 {
15  public:
16  static constexpr int EXIT_AGAIN = 129; // 128 + SIGHUP (1).
17 
18  Daemon(CoreData * data, std::function<int(CoreData &)> & core);
19 
20  ~Daemon(); // Non-virtual destructor, but class is final.
21 
22  int exitCode() const;
23 
24  protected:
25  void setExitCode(int exitCode);
26 
27  int exec();
28 
29  CoreData * data() const;
30 
31  private:
32  void _init();
33 
34  void _exec();
35 
36  void _destroy();
37 
38  CoreData * m_data;
39  std::function<int(CoreData &)> & m_core;
40  int m_exitCode;
41  _Daemon * _daemon;
42 };
43 
44 }
45 }
46 
47 #endif
48 
49 //(c)C: Copyright © 2020, Michał Policht <michal@policht.pl>. All rights reserved.
50 //(c)C: This file is a part of CuteHMI.
51 //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
52 //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
53 //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see <https://www.gnu.org/licenses/>.
std::function
cutehmi::daemon::CoreData
Definition: CoreData.hpp:10
cutehmi
cutehmi::daemon::Daemon::EXIT_AGAIN
static constexpr int EXIT_AGAIN
Definition: Daemon.hpp:16
cutehmi::daemon::Daemon::~Daemon
~Daemon()
Definition: Daemon.cpp:16
cutehmi::daemon::Daemon::setExitCode
void setExitCode(int exitCode)
Definition: Daemon.cpp:26
cutehmi::daemon::Daemon::exec
int exec()
Definition: Daemon.cpp:31
cutehmi::daemon::Daemon::exitCode
int exitCode() const
Definition: Daemon.cpp:21
cutehmi::daemon::Daemon::data
CoreData * data() const
Definition: Daemon.cpp:40
cutehmi::daemon::Daemon::Daemon
Daemon(CoreData *data, std::function< int(CoreData &)> &core)
Definition: Daemon.cpp:6
cutehmi::daemon::_Daemon
Unix-specific daemon helper.
Definition: Daemon_unix.hpp:17
cutehmi::daemon::Daemon
Definition: Daemon.hpp:13