-
Notifications
You must be signed in to change notification settings - Fork 0
/
HoldersMac.h
105 lines (87 loc) · 2.59 KB
/
HoldersMac.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#ifndef CHOLDERSMAC_H
#define CHOLDERSMAC_H
#include <ApplicationServices/ApplicationServices.h>
class CEventTap {
public:
CEventTap() noexcept
: eventTap(nullptr)
{}
explicit CEventTap(CFMachPortRef eventTap) noexcept
: eventTap(eventTap)
{}
CEventTap(CEventTap&& other) noexcept
: eventTap(other.Release())
{}
CEventTap(nullptr_t) noexcept
: eventTap(nullptr)
{}
~CEventTap() noexcept;
CEventTap& operator = (CEventTap&& other) noexcept;
CEventTap& operator = (nullptr_t) noexcept;
operator bool () const noexcept;
CFMachPortRef Release() noexcept;
CFMachPortRef Get() const noexcept;
void Set(CFMachPortRef eventTap) noexcept;
private:
void Free() noexcept;
CFMachPortRef eventTap;
};
class CMessagePort {
public:
CMessagePort() noexcept
: messagePort(nullptr)
{}
explicit CMessagePort(CFMessagePortRef messagePort) noexcept
: messagePort(messagePort)
{}
CMessagePort(CMessagePort&& other) noexcept
: messagePort(other.Release())
{}
CMessagePort(nullptr_t) noexcept
: messagePort(nullptr)
{}
~CMessagePort() noexcept;
CMessagePort& operator = (CMessagePort&& other) noexcept;
CMessagePort& operator = (nullptr_t) noexcept;
operator bool () const noexcept;
CFMessagePortRef Release() noexcept;
CFMessagePortRef Get() const noexcept;
void Set(CFMessagePortRef messagePort) noexcept;
int SendRequest(
int msgid,
CFDataRef data,
CFTimeInterval sendTimeout,
CFTimeInterval rcvTimeout,
// NULL if oneway message
CFStringRef replyMode,
CFDataRef* returnData) const;
private:
void Free() noexcept;
CFMessagePortRef messagePort;
};
class CRunLoopSource {
public:
CRunLoopSource() noexcept
: runLoopSource(nullptr)
{}
explicit CRunLoopSource(CFRunLoopSourceRef runLoopSource) noexcept
: runLoopSource(runLoopSource)
{}
CRunLoopSource(CRunLoopSource&& other) noexcept
: runLoopSource(other.Release())
{}
CRunLoopSource(nullptr_t) noexcept
: runLoopSource(nullptr)
{}
~CRunLoopSource() noexcept;
CRunLoopSource& operator = (CRunLoopSource&& other) noexcept;
CRunLoopSource& operator = (nullptr_t) noexcept;
operator bool () const noexcept;
CFRunLoopSourceRef Release() noexcept;
CFRunLoopSourceRef Get() const noexcept;
void Set(CFRunLoopSourceRef eventTap) noexcept;
private:
void Free() noexcept;
CFRunLoopSourceRef runLoopSource;
};
#endif // CHOLDERSMAC_H