[videodb] remove unused seasons table from episode_view
[xbmc.git] / xbmc / powermanagement / IPowerSyscall.h
blobf54186ed6fed005ee480d1cdedc3da6b75c99243
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 class IPowerEventsCallback
13 public:
14 virtual ~IPowerEventsCallback() = default;
16 virtual void OnSleep() = 0;
17 virtual void OnWake() = 0;
19 virtual void OnLowBattery() = 0;
22 class IPowerSyscall;
23 using CreatePowerSyscallFunc = IPowerSyscall* (*)();
25 class IPowerSyscall
27 public:
28 /**\brief Called by power manager to create platform power system adapter
30 * This method used to create platform specified power system adapter
32 static IPowerSyscall* CreateInstance();
33 static void RegisterPowerSyscall(CreatePowerSyscallFunc createFunc);
35 virtual ~IPowerSyscall() = default;
36 virtual bool Powerdown() = 0;
37 virtual bool Suspend() = 0;
38 virtual bool Hibernate() = 0;
39 virtual bool Reboot() = 0;
41 // Might need to be membervariables instead for speed
42 virtual bool CanPowerdown() = 0;
43 virtual bool CanSuspend() = 0;
44 virtual bool CanHibernate() = 0;
45 virtual bool CanReboot() = 0;
47 virtual int CountPowerFeatures() = 0;
49 // Battery related functions
50 virtual int BatteryLevel() = 0;
52 /*!
53 \brief Pump power related events back to xbmc.
55 PumpPowerEvents is called from Application Thread and the platform implementation may signal
56 power related events back to xbmc through the callback.
58 return true if an event occurred and false if not.
60 \param callback the callback to signal to
62 virtual bool PumpPowerEvents(IPowerEventsCallback *callback) = 0;
64 static const int MAX_COUNT_POWER_FEATURES = 4;
66 private:
67 static CreatePowerSyscallFunc m_createFunc;
70 class CAbstractPowerSyscall : public IPowerSyscall
72 public:
73 int CountPowerFeatures() override
75 return (CanPowerdown() ? 1 : 0)
76 + (CanSuspend() ? 1 : 0)
77 + (CanHibernate() ? 1 : 0)
78 + (CanReboot() ? 1 : 0);
82 class CPowerSyscallWithoutEvents : public CAbstractPowerSyscall
84 public:
85 CPowerSyscallWithoutEvents() { m_OnResume = false; m_OnSuspend = false; }
87 bool Suspend() override { m_OnSuspend = true; return false; }
88 bool Hibernate() override { m_OnSuspend = true; return false; }
90 bool PumpPowerEvents(IPowerEventsCallback *callback) override
92 if (m_OnSuspend)
94 callback->OnSleep();
95 m_OnSuspend = false;
96 m_OnResume = true;
97 return true;
99 else if (m_OnResume)
101 callback->OnWake();
102 m_OnResume = false;
103 return true;
105 else
106 return false;
108 private:
109 bool m_OnResume;
110 bool m_OnSuspend;