FINAL CUT
backend_monitor.h
1 /***********************************************************************
2 * backend_monitor.h - Monitoring general objects *
3 * *
4 * This file is part of the FINAL CUT widget toolkit *
5 * *
6 * Copyright 2023 Markus Gans *
7 * *
8 * FINAL CUT is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as *
10 * published by the Free Software Foundation; either version 3 of *
11 * the License, or (at your option) any later version. *
12 * *
13 * FINAL CUT is distributed in the hope that it will be useful, but *
14 * WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this program. If not, see *
20 * <http://www.gnu.org/licenses/>. *
21 ***********************************************************************/
22 
23 /* Inheritance diagram
24  * ═══════════════════
25  *
26  * ▕▔▔▔▔▔▔▔▔▔▏
27  * ▕ Monitor ▏
28  * ▕▁▁▁▁▁▁▁▁▁▏
29  * ▲
30  * │
31  * ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏1 1▕▔▔▔▔▔▔▔▔▔▔▏
32  * ▕ BackendMonitor ▏- - - - -▕ PipeData ▏
33  * ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▁▁▁▏
34  */
35 
36 #ifndef BACKEND_MONITOR_H
37 #define BACKEND_MONITOR_H
38 
39 #include "final/eventloop/monitor.h"
40 #include "final/eventloop/pipedata.h"
41 #include "final/util/fstring.h"
42 
43 namespace finalcut
44 {
45 
46 //----------------------------------------------------------------------
47 // class BackendMonitor
48 //----------------------------------------------------------------------
49 
50 class BackendMonitor final : public Monitor
51 {
52  public:
53  explicit BackendMonitor (EventLoop*);
54 
55  // Disable default constructor
56  BackendMonitor() = delete;
57 
58  // Disable copy constructor
59  BackendMonitor(const BackendMonitor&) = delete;
60 
61  // Disable move constructor
62  BackendMonitor(const BackendMonitor&&) = delete;
63 
64  // Destructor
65  ~BackendMonitor() noexcept override;
66 
67  // Disable copy assignment operator (=)
68  auto operator = (const BackendMonitor&) -> BackendMonitor& = delete;
69 
70  // Disable move assignment operator (=)
71  auto operator = (BackendMonitor&&) noexcept -> BackendMonitor& = delete;
72 
73  // Accessor
74  auto getClassName() const -> FString override;
75 
76  // Mutator
77  void setEvent() const noexcept;
78 
79  // Methods
80  template <typename T>
81  void init (handler_t, T&&);
82  void trigger (short) override;
83 
84  private:
85  // Mutator
86  void clearEvent() const;
87 
88  // Methods
89  void init();
90 
91  // Data members
92  PipeData self_pipe{NO_FILE_DESCRIPTOR, NO_FILE_DESCRIPTOR};
93 };
94 
95 // BackendMonitor inline functions
96 //----------------------------------------------------------------------
97 inline auto BackendMonitor::getClassName() const -> FString
98 { return "BackendMonitor"; }
99 
100 //----------------------------------------------------------------------
101 template <typename T>
102 inline void BackendMonitor::init (handler_t hdl, T&& uc)
103 {
104  if ( isInitialized() )
105  throw monitor_error{"This instance has already been initialised."};
106 
107  setHandler (std::move(hdl));
108  setUserContext (std::forward<T>(uc));
109  init();
110 }
111 
112 } // namespace finalcut
113 
114 #endif // BACKEND_MONITOR_H
Definition: monitor.h:81
Definition: eventloop.h:48
Definition: class_template.cpp:25
Definition: monitor.h:52
Definition: fstring.h:79
Definition: backend_monitor.h:50
Definition: pipedata.h:47