soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
SMsgLoop-i.h
1#ifndef __SMSGLOOP_I__H__
2#define __SMSGLOOP_I__H__
3
4#include <windows.h>
5#include <interface/obj-ref-i.h>
6#include <interface/SRunnable-i.h>
7
8SNSBEGIN
9
10#undef INTERFACE
11#define INTERFACE IMsgFilter
12/// @interface IMsgFilter
13/// @brief Interface for message filtering.
14DECLARE_INTERFACE(IMsgFilter)
15{
16 /**
17 * @brief Preprocesses a message.
18 * @param pMsg Pointer to the message.
19 * @return TRUE if the message is handled, FALSE otherwise.
20 */
21 STDMETHOD_(BOOL, PreTranslateMessage)(THIS_ MSG * pMsg) PURE;
22};
23
24#undef INTERFACE
25#define INTERFACE IIdleHandler
26/// @interface IIdleHandler
27/// @brief Interface for handling idle time.
28DECLARE_INTERFACE(IIdleHandler)
29{
30 /**
31 * @brief Handles idle time.
32 * @return TRUE if further idle processing is needed, FALSE otherwise.
33 */
34 STDMETHOD_(BOOL, OnIdle)(THIS) PURE;
35};
36
37#undef INTERFACE
38#define INTERFACE IMessageLoop
39/// @interface IMessageLoop
40/// @brief Interface for message loops.
41DECLARE_INTERFACE_(IMessageLoop, IObjRef)
42{
43 /**
44 * @brief Adds a reference to the object.
45 * @return Current reference count.
46 */
47 STDMETHOD_(long, AddRef)(THIS) PURE;
48
49 /**
50 * @brief Releases a reference to the object.
51 * @return Current reference count.
52 */
53 STDMETHOD_(long, Release)(THIS) PURE;
54
55 /**
56 * @brief Finalizes the release of the object.
57 */
58 STDMETHOD_(void, OnFinalRelease)(THIS) PURE;
59
60 // Message filter operations
61
62 /**
63 * @brief Adds a message filter.
64 * @param pMessageFilter Pointer to the message filter.
65 * @return TRUE if successful, FALSE otherwise.
66 */
67 STDMETHOD_(BOOL, AddMessageFilter)(THIS_ IMsgFilter * pMessageFilter) PURE;
68
69 /**
70 * @brief Removes a message filter.
71 * @param pMessageFilter Pointer to the message filter.
72 * @return TRUE if successful, FALSE otherwise.
73 */
74 STDMETHOD_(BOOL, RemoveMessageFilter)(THIS_ IMsgFilter * pMessageFilter) PURE;
75
76 // Idle handler operations
77
78 /**
79 * @brief Adds an idle handler.
80 * @param pIdleHandler Pointer to the idle handler.
81 * @return TRUE if successful, FALSE otherwise.
82 */
83 STDMETHOD_(BOOL, AddIdleHandler)(THIS_ IIdleHandler * pIdleHandler) PURE;
84
85 /**
86 * @brief Removes an idle handler.
87 * @param pIdleHandler Pointer to the idle handler.
88 * @return TRUE if successful, FALSE otherwise.
89 */
90 STDMETHOD_(BOOL, RemoveIdleHandler)(THIS_ IIdleHandler * pIdleHandler) PURE;
91
92 // Override to change message filtering
93
94 /**
95 * @brief Preprocesses a message.
96 * @param pMsg Pointer to the message.
97 * @return TRUE if the message is handled, FALSE otherwise.
98 */
99 STDMETHOD_(BOOL, PreTranslateMessage)(THIS_ MSG * pMsg) PURE;
100
101 // Override to change idle processing
102
103 /**
104 * @brief Handles idle time.
105 * @param nIdleCount Idle count.
106 * @return TRUE if further idle processing is needed, FALSE otherwise.
107 */
108 STDMETHOD_(BOOL, OnIdle)(THIS_ int nIdleCount) PURE;
109
110 /**
111 * @brief Runs the message loop.
112 * @return Return value of the message loop.
113 */
114 STDMETHOD_(int, Run)(THIS) PURE;
115
116 /**
117 * @brief Checks if the message loop is running.
118 * @return TRUE if running, FALSE otherwise.
119 */
120 STDMETHOD_(BOOL, IsRunning)(CTHIS) SCONST PURE;
121
122 /**
123 * @brief Processes a message.
124 * @param pMsg Pointer to the message.
125 */
126 STDMETHOD_(void, OnMsg)(THIS_ LPMSG pMsg) PURE;
127
128 /**
129 * @brief Quits the message loop.
130 * @param exitCode Exit code.
131 */
132 STDMETHOD_(void, Quit)(THIS_ int exitCode DEF_VAL(0)) PURE;
133
134 /**
135 * @brief Posts a task to the message loop.
136 * @param runable Pointer to the runnable object.
137 * @return TRUE if successful, FALSE otherwise.
138 */
139 STDMETHOD_(BOOL, PostTask)(THIS_ IRunnable * runable) PURE;
140
141 /**
142 * @brief Removes tasks associated with an object.
143 * @param pObj Pointer to the object.
144 * @return Number of tasks removed.
145 */
146 STDMETHOD_(int, RemoveTasksForObject)(THIS_ void *pObj) PURE;
147
148 /**
149 * @brief Executes pending tasks.
150 */
151 STDMETHOD_(void, ExecutePendingTask)(THIS) PURE;
152
153 /**
154 * @brief Peeks at messages in the message queue.
155 * @param pMsg Pointer to the message.
156 * @param wMsgFilterMin Minimum message filter value.
157 * @param wMsgFilterMax Maximum message filter value.
158 * @param bRemove Whether to remove the message.
159 * @return TRUE if a message is available, FALSE otherwise.
160 */
161 STDMETHOD_(BOOL, PeekMsg)(THIS_ LPMSG pMsg, UINT wMsgFilterMin, UINT wMsgFilterMax, BOOL bRemove) PURE;
162
163 /**
164 * @brief Waits for a message.
165 * @return TRUE if successful, FALSE otherwise.
166 */
167 STDMETHOD_(BOOL, WaitMsg)(THIS) PURE;
168
169 /**
170 * @brief Handles a message.
171 * @return Return value of message handling.
172 */
173 STDMETHOD_(int, HandleMsg)(THIS) PURE;
174};
175
176#undef INTERFACE
177#define INTERFACE IMsgLoopFactory
178/// @interface IMsgLoopFactory
179/// @brief Interface for creating message loops.
180DECLARE_INTERFACE_(IMsgLoopFactory, IObjRef)
181{
182 /**
183 * @brief Creates a message loop.
184 * @param ppMsgLoop Pointer to the message loop pointer.
185 * @param pParentLoop Pointer to the parent message loop (optional).
186 * @return HRESULT
187 */
188 STDMETHOD_(HRESULT, CreateMsgLoop)(THIS_ IMessageLoop * *ppMsgLoop, IMessageLoop * pParentLoop DEF_VAL(NULL)) PURE;
189};
190
191SNSEND
192#endif // __SMSGLOOP_I__H__
Interface for handling idle time.
Definition SMsgLoop-i.h:29
BOOL OnIdle() PURE
Handles idle time.
Interface for message loops.
Definition SMsgLoop-i.h:42
BOOL AddIdleHandler(IIdleHandler *pIdleHandler) PURE
Adds an idle handler.
long AddRef() PURE
Adds a reference to the object.
void Quit(int exitCode=0) PURE
Quits the message loop.
int Run() PURE
Runs the message loop.
BOOL WaitMsg() PURE
Waits for a message.
BOOL PostTask(IRunnable *runable) PURE
Posts a task to the message loop.
long Release() PURE
Releases a reference to the object.
void OnMsg(LPMSG pMsg) PURE
Processes a message.
BOOL PreTranslateMessage(MSG *pMsg) PURE
Preprocesses a message.
BOOL RemoveMessageFilter(IMsgFilter *pMessageFilter) PURE
Removes a message filter.
BOOL IsRunning() SCONST PURE
Checks if the message loop is running.
void OnFinalRelease() PURE
Finalizes the release of the object.
BOOL OnIdle(int nIdleCount) PURE
Handles idle time.
int HandleMsg() PURE
Handles a message.
void ExecutePendingTask() PURE
Executes pending tasks.
BOOL PeekMsg(LPMSG pMsg, UINT wMsgFilterMin, UINT wMsgFilterMax, BOOL bRemove) PURE
Peeks at messages in the message queue.
BOOL RemoveIdleHandler(IIdleHandler *pIdleHandler) PURE
Removes an idle handler.
BOOL AddMessageFilter(IMsgFilter *pMessageFilter) PURE
Adds a message filter.
int RemoveTasksForObject(void *pObj) PURE
Removes tasks associated with an object.
Interface for message filtering.
Definition SMsgLoop-i.h:15
BOOL PreTranslateMessage(MSG *pMsg) PURE
Preprocesses a message.
Interface for creating message loops.
Definition SMsgLoop-i.h:181
HRESULT CreateMsgLoop(IMessageLoop **ppMsgLoop, IMessageLoop *pParentLoop=NULL) PURE
Creates a message loop.
Interface for reference counting.
Definition obj-ref-i.h:19