Torc  0.1
torcpowerosx.h
Go to the documentation of this file.
1 #ifndef TORCPOWEROSX_H
2 #define TORCPOWEROSX_H
3 
4 // OS X
5 #include <CoreFoundation/CoreFoundation.h>
6 #include <IOKit/pwr_mgt/IOPMLib.h>
7 #include <IOKit/IOMessage.h>
8 
9 // Torc
10 #include "torcpower.h"
11 
12 class TorcPowerOSX final : public TorcPower
13 {
14  Q_OBJECT
15 
16  public:
17  TorcPowerOSX();
18  virtual ~TorcPowerOSX();
19 
20  bool DoShutdown (void) override;
21  bool DoSuspend (void) override;
22  bool DoHibernate (void) override;
23  bool DoRestart (void) override;
24  void Refresh (void);
25 
26  protected:
27  static void PowerCallBack (void *Reference, io_service_t Service,
28  natural_t Type, void *Data);
29  static void PowerSourceCallBack (void *Reference);
30 
31  private:
32  CFRunLoopSourceRef m_powerRef;
33  io_connect_t m_rootPowerDomain;
34  io_object_t m_powerNotifier;
35  IONotificationPortRef m_powerNotifyPort;
36 };
37 
38 #endif // TORCPOWEROSX_H
A power monitoring class for OS X.
Definition: torcpowerosx.h:12
bool DoRestart(void) override
Restart the system.
bool DoShutdown(void) override
Shutdown the system.
virtual ~TorcPowerOSX()
bool DoHibernate(void) override
Hibernate the system.
static void PowerSourceCallBack(void *Reference)
Receive notification of changes to the power supply.
A generic power status class.
Definition: torcpower.h:12
void Refresh(void)
Update the current power supply status.
bool DoSuspend(void) override
Suspend the system.
static void PowerCallBack(void *Reference, io_service_t Service, natural_t Type, void *Data)
Receive notification of power status changes.