soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
SMessageLoop Class Reference

Message loop class for handling window messages and idle processing. This class implements the IMessageLoop interface and manages the message loop for a window. More...

#include <SMsgLoop.h>

Inheritance diagram for SMessageLoop:
TObjRefImpl< IMessageLoop > IMessageLoop IObjRef

Public Member Functions

 SMessageLoop (IMessageLoop *pParentLoop)
 Constructor for SMessageLoop.
 
virtual ~SMessageLoop ()
 Destructor for SMessageLoop.
 
BOOL AddMessageFilter (IMsgFilter *pMessageFilter) OVERRIDE
 Adds a message filter to the message loop.
 
BOOL RemoveMessageFilter (IMsgFilter *pMessageFilter) OVERRIDE
 Removes a message filter from the message loop.
 
BOOL AddIdleHandler (IIdleHandler *pIdleHandler) OVERRIDE
 Adds an idle handler to the message loop.
 
BOOL RemoveIdleHandler (IIdleHandler *pIdleHandler) OVERRIDE
 Removes an idle handler from the message loop.
 
BOOL PreTranslateMessage (MSG *pMsg) OVERRIDE
 Pre-translates a message before it is dispatched.
 
BOOL OnIdle (int nIdleCount) OVERRIDE
 Handles idle processing.
 
int Run () OVERRIDE
 Runs the message loop.
 
BOOL IsRunning () const OVERRIDE
 Checks if the message loop is running.
 
void OnMsg (LPMSG pMsg) OVERRIDE
 Processes a single message.
 
void Quit (int exitCode) OVERRIDE
 Quits the message loop.
 
BOOL PostTask (IRunnable *runable) OVERRIDE
 Posts a task to the message loop.
 
int RemoveTasksForObject (void *pObj) OVERRIDE
 Removes all tasks associated with a specific object.
 
void ExecutePendingTask () OVERRIDE
 Executes all pending tasks.
 
BOOL PeekMsg (LPMSG pMsg, UINT wMsgFilterMin, UINT wMsgFilterMax, BOOL bRemove) OVERRIDE
 Peeks at a message in the message queue without removing it.
 
BOOL WaitMsg () OVERRIDE
 Waits for a message in the message queue.
 
int HandleMsg () OVERRIDE
 Handles a message from the message queue.
 
- Public Member Functions inherited from TObjRefImpl< IMessageLoop >
 TObjRefImpl ()
 Constructor that initializes the reference count to 1.
 
virtual ~TObjRefImpl ()
 Virtual destructor.
 
long AddRef () override
 Increments the reference count.
 
long Release () override
 Decrements the reference count and deletes the object if the count reaches zero.
 
void OnFinalRelease () override
 Deletes the object.
 
- Public Member Functions inherited from IMessageLoop
BOOL IsRunning () SCONST PURE
 Checks if the message loop is running.
 
- Public Member Functions inherited from IObjRef
long AddRef () PURE
 Increases the reference count.
 
long Release () PURE
 Decreases the reference count.
 
void OnFinalRelease () PURE
 Called when the reference count reaches zero and the object is about to be released.
 

Static Public Member Functions

static BOOL IsIdleMessage (MSG *pMsg)
 Checks if a message is an idle message.
 

Protected Member Functions

void RunIdle ()
 Runs idle processing.
 

Protected Attributes

BOOL m_bRunning
 
BOOL m_bQuit
 
BOOL m_bDoIdle
 
int m_nIdleCount
 
SCriticalSection m_cs
 
SCriticalSection m_csRunningQueue
 
tid_t m_tid
 
SMessageLoopPriv * m_priv
 
- Protected Attributes inherited from TObjRefImpl< IMessageLoop >
LONG m_cRef
 Reference count.
 

Detailed Description

Message loop class for handling window messages and idle processing. This class implements the IMessageLoop interface and manages the message loop for a window.

Definition at line 17 of file SMsgLoop.h.

Constructor & Destructor Documentation

◆ SMessageLoop()

SMessageLoop::SMessageLoop ( IMessageLoop * pParentLoop)

Constructor for SMessageLoop.

Parameters
pParentLoopPointer to the parent message loop.

Definition at line 33 of file SMsgLoop.cpp.

◆ ~SMessageLoop()

SMessageLoop::~SMessageLoop ( )
virtual

Destructor for SMessageLoop.

Definition at line 43 of file SMsgLoop.cpp.

Member Function Documentation

◆ AddIdleHandler()

BOOL SMessageLoop::AddIdleHandler ( IIdleHandler * pIdleHandler)

Adds an idle handler to the message loop.

Parameters
pIdleHandlerPointer to the idle handler to add.
Returns
TRUE if the handler is added successfully, FALSE otherwise.

Implements IMessageLoop.

Definition at line 155 of file SMsgLoop.cpp.

◆ AddMessageFilter()

BOOL SMessageLoop::AddMessageFilter ( IMsgFilter * pMessageFilter)

Adds a message filter to the message loop.

Parameters
pMessageFilterPointer to the message filter to add.
Returns
TRUE if the filter is added successfully, FALSE otherwise.

Implements IMessageLoop.

Definition at line 168 of file SMsgLoop.cpp.

◆ ExecutePendingTask()

void SMessageLoop::ExecutePendingTask ( )

Executes all pending tasks.

Implements IMessageLoop.

Definition at line 226 of file SMsgLoop.cpp.

◆ HandleMsg()

int SMessageLoop::HandleMsg ( )

Handles a message from the message queue.

Returns
Result of the message handling.

Implements IMessageLoop.

Definition at line 269 of file SMsgLoop.cpp.

◆ IsIdleMessage()

BOOL SMessageLoop::IsIdleMessage ( MSG * pMsg)
static

Checks if a message is an idle message.

Parameters
pMsgPointer to the message to check.
Returns
TRUE if the message is an idle message, FALSE otherwise.

Definition at line 133 of file SMsgLoop.cpp.

◆ IsRunning()

BOOL SMessageLoop::IsRunning ( ) const

Checks if the message loop is running.

Returns
TRUE if the message loop is running, FALSE otherwise.

Definition at line 221 of file SMsgLoop.cpp.

◆ OnIdle()

BOOL SMessageLoop::OnIdle ( int nIdleCount)

Handles idle processing.

Parameters
nIdleCountIdle count.
Returns
TRUE if more idle processing is needed, FALSE otherwise.

Implements IMessageLoop.

Definition at line 99 of file SMsgLoop.cpp.

◆ OnMsg()

void SMessageLoop::OnMsg ( LPMSG pMsg)

Processes a single message.

Parameters
pMsgPointer to the message to process.

Implements IMessageLoop.

Definition at line 48 of file SMsgLoop.cpp.

◆ PeekMsg()

BOOL SMessageLoop::PeekMsg ( LPMSG pMsg,
UINT wMsgFilterMin,
UINT wMsgFilterMax,
BOOL bRemove )

Peeks at a message in the message queue without removing it.

Parameters
pMsgPointer to the message to receive.
wMsgFilterMinMinimum message value to peek.
wMsgFilterMaxMaximum message value to peek.
bRemoveTRUE to remove the message from the queue, FALSE otherwise.
Returns
TRUE if a message is available, FALSE otherwise.

Implements IMessageLoop.

Definition at line 247 of file SMsgLoop.cpp.

◆ PostTask()

BOOL SMessageLoop::PostTask ( IRunnable * runable)

Posts a task to the message loop.

Parameters
runablePointer to the task to post.
Returns
TRUE if the task is posted successfully, FALSE otherwise.

Implements IMessageLoop.

Definition at line 174 of file SMsgLoop.cpp.

◆ PreTranslateMessage()

BOOL SMessageLoop::PreTranslateMessage ( MSG * pMsg)

Pre-translates a message before it is dispatched.

Parameters
pMsgPointer to the message to translate.
Returns
TRUE if the message is translated and should not be dispatched further, FALSE otherwise.

Implements IMessageLoop.

Definition at line 117 of file SMsgLoop.cpp.

◆ Quit()

void SMessageLoop::Quit ( int exitCode)

Quits the message loop.

Parameters
exitCodeExit code for the message loop.

Implements IMessageLoop.

Definition at line 57 of file SMsgLoop.cpp.

◆ RemoveIdleHandler()

BOOL SMessageLoop::RemoveIdleHandler ( IIdleHandler * pIdleHandler)

Removes an idle handler from the message loop.

Parameters
pIdleHandlerPointer to the idle handler to remove.
Returns
TRUE if the handler is removed successfully, FALSE otherwise.

Implements IMessageLoop.

Definition at line 148 of file SMsgLoop.cpp.

◆ RemoveMessageFilter()

BOOL SMessageLoop::RemoveMessageFilter ( IMsgFilter * pMessageFilter)

Removes a message filter from the message loop.

Parameters
pMessageFilterPointer to the message filter to remove.
Returns
TRUE if the filter is removed successfully, FALSE otherwise.

Implements IMessageLoop.

Definition at line 163 of file SMsgLoop.cpp.

◆ RemoveTasksForObject()

int SMessageLoop::RemoveTasksForObject ( void * pObj)

Removes all tasks associated with a specific object.

Parameters
pObjPointer to the object whose tasks should be removed.
Returns
Number of tasks removed.

Implements IMessageLoop.

Definition at line 189 of file SMsgLoop.cpp.

◆ Run()

int SMessageLoop::Run ( )

Runs the message loop.

Returns
Exit code of the message loop.

Implements IMessageLoop.

Definition at line 64 of file SMsgLoop.cpp.

◆ RunIdle()

void SMessageLoop::RunIdle ( )
protected

Runs idle processing.

Definition at line 252 of file SMsgLoop.cpp.

◆ WaitMsg()

BOOL SMessageLoop::WaitMsg ( )

Waits for a message in the message queue.

Returns
TRUE if a message is available, FALSE otherwise.

Implements IMessageLoop.

Definition at line 261 of file SMsgLoop.cpp.

Member Data Documentation

◆ m_bDoIdle

BOOL SMessageLoop::m_bDoIdle
protected

Definition at line 158 of file SMsgLoop.h.

◆ m_bQuit

BOOL SMessageLoop::m_bQuit
protected

Definition at line 156 of file SMsgLoop.h.

◆ m_bRunning

BOOL SMessageLoop::m_bRunning
protected

Definition at line 154 of file SMsgLoop.h.

◆ m_cs

SCriticalSection SMessageLoop::m_cs
protected

Definition at line 163 of file SMsgLoop.h.

◆ m_csRunningQueue

SCriticalSection SMessageLoop::m_csRunningQueue
protected

Definition at line 165 of file SMsgLoop.h.

◆ m_nIdleCount

int SMessageLoop::m_nIdleCount
protected

Definition at line 160 of file SMsgLoop.h.

◆ m_priv

SMessageLoopPriv* SMessageLoop::m_priv
protected

Definition at line 169 of file SMsgLoop.h.

◆ m_tid

tid_t SMessageLoop::m_tid
protected

Definition at line 167 of file SMsgLoop.h.


The documentation for this class was generated from the following files: