kodi
Monitor.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "AddonCallback.h"
12 #include "AddonString.h"
13 
14 namespace XBMCAddon
15 {
16  namespace xbmc
17  {
18 
29  class Monitor : public AddonCallback
30  {
31  String Id;
32  long invokerId;
33  CEvent abortEvent;
34  public:
35  Monitor();
36 
37 #ifndef SWIG
38  inline void OnSettingsChanged() { XBMC_TRACE; invokeCallback(new CallbackFunction<Monitor>(this,&Monitor::onSettingsChanged)); }
39  inline void OnScreensaverActivated() { XBMC_TRACE; invokeCallback(new CallbackFunction<Monitor>(this,&Monitor::onScreensaverActivated)); }
40  inline void OnScreensaverDeactivated() { XBMC_TRACE; invokeCallback(new CallbackFunction<Monitor>(this,&Monitor::onScreensaverDeactivated)); }
41  inline void OnDPMSActivated() { XBMC_TRACE; invokeCallback(new CallbackFunction<Monitor>(this,&Monitor::onDPMSActivated)); }
42  inline void OnDPMSDeactivated() { XBMC_TRACE; invokeCallback(new CallbackFunction<Monitor>(this,&Monitor::onDPMSDeactivated)); }
43  inline void OnScanStarted(const String &library)
44  {
45  XBMC_TRACE;
46  invokeCallback(
47  new CallbackFunction<Monitor, const String>(this, &Monitor::onScanStarted, library));
48  }
49  inline void OnScanFinished(const String &library)
50  {
51  XBMC_TRACE;
52  invokeCallback(
53  new CallbackFunction<Monitor, const String>(this, &Monitor::onScanFinished, library));
54  }
55  inline void OnCleanStarted(const String& library)
56  {
57  XBMC_TRACE;
58  invokeCallback(
59  new CallbackFunction<Monitor, const String>(this, &Monitor::onCleanStarted, library));
60  }
61  inline void OnCleanFinished(const String& library)
62  {
63  XBMC_TRACE;
64  invokeCallback(
65  new CallbackFunction<Monitor, const String>(this, &Monitor::onCleanFinished, library));
66  }
67  inline void OnNotification(const String& sender, const String& method, const String& data)
68  {
69  XBMC_TRACE;
71  this, &Monitor::onNotification, sender, method, data));
72  }
73 
74  inline const String& GetId() { return Id; }
75  inline long GetInvokerId() { return invokerId; }
76 
80  void AbortNotify();
81 #endif
82 
83 #ifdef DOXYGEN_SHOULD_USE_THIS
84  onSettingsChanged();
92 #else
93  virtual void onSettingsChanged() { XBMC_TRACE; }
94 #endif
95 
96 #ifdef DOXYGEN_SHOULD_USE_THIS
97  onScreensaverActivated();
105 #else
106  virtual void onScreensaverActivated() { XBMC_TRACE; }
107 #endif
108 
109 #ifdef DOXYGEN_SHOULD_USE_THIS
110  onScreensaverDeactivated();
118 #else
119  virtual void onScreensaverDeactivated() { XBMC_TRACE; }
120 #endif
121 
122 #ifdef DOXYGEN_SHOULD_USE_THIS
123  onDPMSActivated();
131 #else
132  virtual void onDPMSActivated() { XBMC_TRACE; }
133 #endif
134 
135 #ifdef DOXYGEN_SHOULD_USE_THIS
136  onDPMSDeactivated();
144 #else
145  virtual void onDPMSDeactivated() { XBMC_TRACE; }
146 #endif
147 
148 #ifdef DOXYGEN_SHOULD_USE_THIS
149  onScanStarted(...);
165 #else
166  virtual void onScanStarted(const String library) { XBMC_TRACE; }
167 #endif
168 
169 #ifdef DOXYGEN_SHOULD_USE_THIS
170  onScanFinished(...);
186 #else
187  virtual void onScanFinished(const String library) { XBMC_TRACE; }
188 #endif
189 
190 #ifdef DOXYGEN_SHOULD_USE_THIS
191  onCleanStarted(...);
207 #else
208  virtual void onCleanStarted(const String library) { XBMC_TRACE; }
209 #endif
210 
211 #ifdef DOXYGEN_SHOULD_USE_THIS
212  onCleanFinished(...);
228 #else
229  virtual void onCleanFinished(const String library) { XBMC_TRACE; }
230 #endif
231 
232 #ifdef DOXYGEN_SHOULD_USE_THIS
233  onNotification(...);
249 #else
250  virtual void onNotification(const String sender, const String method, const String data)
251  {
252  XBMC_TRACE;
253  }
254 #endif
255 
256 #ifdef DOXYGEN_SHOULD_USE_THIS
257  waitForAbort(...);
288 #else
289  bool waitForAbort(double timeout = -1);
290 #endif
291 
292 #ifdef DOXYGEN_SHOULD_USE_THIS
293  abortRequested();
304 #else
305  bool abortRequested();
306 #endif
307  ~Monitor() override;
308  };
310  }
311 };
This is an Event class built from a ConditionVariable.
Definition: Event.h:35
Definition: CallbackFunction.h:44
void AbortNotify()
Called from XBPython to notify registered monitors that a script is aborting/ending.
Definition: Monitor.cpp:33
Definition: Monitor.h:29
Defining LOG_LIFECYCLE_EVENTS will log all instantiations, deletions and also reference countings (in...
Definition: Addon.cpp:25
This class is the superclass for all API classes that are expected to be able to handle cross-languag...
Definition: AddonCallback.h:23