Pyro higlevel API
|
Classes | |
class | Private |
Public Types | |
typedef std::map< int, Handler * > | handler_map |
Public Member Functions | |
Looper (const String &cName, int nPriority=NORMAL_PRIORITY, int nPortSize=DEFAULT_PORT_SIZE) | |
The looper constructor. More... | |
virtual | ~Looper () |
Looper destructor. More... | |
void | SetName (const String &cName) |
Rename the looper. More... | |
String | GetName () const |
Get the loopers name. More... | |
bool | IsPublic () const |
See if the looper's message port is public. More... | |
void | SetPublic (bool bPublic) |
Make port public/private. More... | |
port_id | GetMsgPort () const |
Obtain the low-level message port used by this looper. More... | |
thread_id | GetThread () const |
Obtain the thread id of the looper thread. More... | |
proc_id | GetProcess () const |
Obtain the process ID of the loopers thread. More... | |
status_t | Lock () |
Lock the looper object. More... | |
status_t | Lock (bigtime_t nTimeout) |
Lock the looper with a timeout. More... | |
status_t | SafeLock () |
Attempt to lock the looper. More... | |
status_t | Unlock () |
Unlock the looper. More... | |
void | SetMutex (Locker *pcMutex) |
Set a custom mutex to be used by the looper. More... | |
Locker * | GetMutex () const |
Get a pointer to the loopers mutex. More... | |
int | GetLockCount () const |
Obtain the number of locks held on the looper. More... | |
thread_id | GetLockingThread () const |
Obtaing the owner of the looper lock. More... | |
bool | IsLocked () const |
Check if the looper lock is owned by the calling thread. More... | |
virtual thread_id | Run () |
Start and unlock the looper. More... | |
int | Wait () const |
Wait for the looper thread to die. More... | |
status_t | PostMessage (uint32 nCode) |
Deliver a message to the looper. More... | |
status_t | PostMessage (Message *pcMsg) |
Deliver a message to the looper. More... | |
status_t | PostMessage (uint32 cCode, Handler *pcHandler, Handler *pcReplyTo=NULL) |
Deliver a message to the looper. More... | |
status_t | PostMessage (Message *pcMsg, Handler *pcHandler, Handler *pcReplyTo=NULL) |
Deliver a message to the looper. More... | |
void | SpoolMessages () |
Drain the low-level message port. More... | |
Message * | GetCurrentMessage () const |
Obtain the message currently being processed. More... | |
Message * | DetachCurrentMessage () |
Steal the current message. More... | |
virtual void | DispatchMessage (Message *pcMessage, Handler *pcHandler) |
The loopers message handling callback. More... | |
virtual void | Started () |
Called by the looper thread before entering the message loop. More... | |
virtual bool | Idle () |
Hook called each time the message queue is drained. More... | |
MessageQueue * | GetMessageQueue () const |
Obtain the internal message queue used by the looper. More... | |
virtual bool | OkToQuit () |
Check if it is ok to break the loop. More... | |
virtual void | Quit () |
Unconditionally terminate the looper. More... | |
void | Terminate () |
Unconditionally terminate the looper. More... | |
void | AddTimer (Handler *pcTarget, int nID, bigtime_t nTimeout, bool bOneShot=true) |
Add a timer to the looper. More... | |
bool | RemoveTimer (Handler *pcTarget, int nID) |
Delete a timer. More... | |
const handler_map & | GetHandlerMap () const |
Get the internal handler list. More... | |
void | AddHandler (Handler *pcHandler) |
Add a handler to the looper. More... | |
bool | RemoveHandler (Handler *pcHandler) |
Remove a handler previously added by AddHandler() More... | |
Handler * | FindHandler (const String &cName) const |
Search the looper for a named handler. More... | |
int | GetHandlerCount () const |
Obtain the count of handlers added to this looper. More... | |
void | SetDefaultHandler (Handler *pcHandler) |
Set the default target for incomming messages. More... | |
Handler * | GetDefaultHandler () const |
Obtain the default handler for the looper. More... | |
void | AddCommonFilter (MessageFilter *pcFilter) |
void | RemoveCommonFilter (MessageFilter *pcFilter) |
const MsgFilterList & | GetCommonFilterList () const |
Public Member Functions inherited from os::Handler | |
Handler (const String &cName) | |
Construct a handler. More... | |
virtual | ~Handler () |
Destructor. More... | |
virtual void | TimerTick (int nID) |
Timer dispatch member. More... | |
virtual void | HandleMessage (Message *pcMessage) |
Handle a message targeted at this handler. More... | |
String | GetName () const |
Get the handlers name. More... | |
void | SetName (const String &cName) |
Rename the handler. More... | |
Looper * | GetLooper () const |
Get a pointer to the looper this handler belongs to. More... | |
void | SetNextHandler (Handler *pcNextHandler) |
Set a handler that should handle messages this handler is not interrested in. More... | |
Handler * | GetNextHandler () const |
Get the next handler in a handler chain. More... | |
void | AddFilter (MessageFilter *pcFilter) |
void | RemoveFilter (MessageFilter *pcFilter) |
const MsgFilterList & | GetFilterList () const |
const uint32 | GetToken () |
Get the handlers token. More... | |
Static Public Member Functions | |
static Looper * | GetLooperForThread (thread_id hThread) |
Protected Member Functions | |
bool | FilterMessage (Message *pcMsg, Handler **ppcTarget, std::list< MessageFilter * > *pcFilterList) |
Friends | |
class | Application |
class | Messenger |
class | NodeMonitor |
class | Window |
typedef std::map<int,Handler*> os::Looper::handler_map |
Looper::Looper | ( | const String & | cName, |
int | nPriority = NORMAL_PRIORITY , |
||
int | nPortSize = DEFAULT_PORT_SIZE |
||
) |
pzName | Passed down to the Handler::Handler() constructor. |
nPriority | Stored for later usage as the looper-thread priority. |
nPortSize | Maximum number of pending messages. |
References AddHandler(), Lock(), os::Looper::Private::m_hPort, os::Looper::Private::m_hThread, os::Looper::Private::m_nID, os::Looper::Private::m_nNextEvent, os::Looper::Private::m_nPriority, os::Looper::Private::m_pcCurrentMessage, os::Looper::Private::m_pcDefaultHandler, os::Looper::Private::m_pcFirstRestartTimer, os::Looper::Private::m_pcFirstTimer, and os::Looper::Private::m_pcMsgQueue.
|
virtual |
References os::Looper::Private::m_hPort, os::Looper::Private::m_pcFirstRestartTimer, os::Looper::Private::m_pcFirstTimer, os::Looper::Private::m_pcMsgQueue, and RemoveHandler().
void Looper::AddCommonFilter | ( | MessageFilter * | pcFilter | ) |
void Looper::AddHandler | ( | Handler * | pcHandler | ) |
pcHandler | - Pointer to the handler to be added. |
References os::Looper::Private::m_cHandlerMap, and os::Looper::Private::m_pcMutex.
Referenced by Looper().
void Looper::AddTimer | ( | Handler * | pcTarget, |
int | nID, | ||
bigtime_t | nPeriode, | ||
bool | bOneShot = true |
||
) |
pcTarget | Must be a valid ponter to a handler belonging to this looper. This is the handler that will get it's TimerTick() member called. |
nID | An user defined ID that is passed to the TimerTick() function to make it possible to distinguish different timers. |
nPeriode | Time in micro seconds before the timer fires. If not in one-shot mode, the timer will be rescheduled with the same delay until manually removed. |
bOneShot | If true the timer will fire once, and then be removed. If false the timer will be continually rescheduled until removed by Looper::RemoveTimer(). |
References RemoveTimer().
Referenced by os::ScrollBar::MouseDown(), os::ScrollBar::MouseMove(), os::ToolTip::ShowTip(), os::IconView::StartScroll(), and os::ScrollBar::TimerTick().
Message * Looper::DetachCurrentMessage | ( | ) |
References os::Looper::Private::m_pcCurrentMessage.
pcMsg | - Pointer to the received messge. Note that this message will be deleted when DispatchMessage() returns, unless detatched from the looper through DetachCurrentMessage(). |
pcHandler | - Pointer to the handler targeted by this message. If the message was not targeted at any spesific handler this argument is NULL. |
Reimplemented in os::Window.
References FilterMessage(), os::Message::GetCode(), os::Handler::HandleMessage(), os::Looper::Private::m_pcDefaultHandler, os::M_QUIT, OkToQuit(), and Unlock().
Referenced by os::Window::DispatchMessage().
|
protected |
References os::MF_DISCARD_MESSAGE, and os::MF_DISPATCH_MESSAGE.
Referenced by DispatchMessage().
pzName | The name to search for. |
References os::String::c_str(), os::Looper::Private::m_cHandlerMap, and os::Looper::Private::m_pcMutex.
const MsgFilterList & Looper::GetCommonFilterList | ( | ) | const |
References os::Looper::Private::m_cCommonFilterList.
Message * Looper::GetCurrentMessage | ( | ) | const |
References os::Looper::Private::m_pcCurrentMessage.
Referenced by os::IconDirectoryView::KeyDown().
Handler * Looper::GetDefaultHandler | ( | ) | const |
References os::Looper::Private::m_pcDefaultHandler.
int Looper::GetHandlerCount | ( | ) | const |
References os::Looper::Private::m_cHandlerMap.
const Looper::handler_map & Looper::GetHandlerMap | ( | ) | const |
References os::Looper::Private::m_cHandlerMap.
int Looper::GetLockCount | ( | ) | const |
References os::Locker::GetLockCount(), and os::Looper::Private::m_pcMutex.
thread_id Looper::GetLockingThread | ( | ) | const |
References os::Locker::GetOwner(), and os::Looper::Private::m_pcMutex.
|
inlinestatic |
MessageQueue * Looper::GetMessageQueue | ( | ) | const |
References os::Looper::Private::m_pcMsgQueue.
Referenced by os::Window::DispatchMessage(), os::IconDirectoryView::ReRead(), and os_priv::DirKeeper::Stop().
port_id Looper::GetMsgPort | ( | ) | const |
References os::Looper::Private::m_hPort.
Referenced by os::Application::Application(), os::RegistrarManager::ClearTypeExtensions(), os::RegistrarManager::ClearTypeHandlers(), os::RegistrarManager::GetType(), os::RegistrarManager::GetTypeAndIcon(), os::RegistrarManager::GetTypeCount(), os::Messenger::Messenger(), os::Event::PostEvent(), PostMessage(), os::Event::Register(), os::RegistrarManager::RegisterType(), os::RegistrarManager::RegisterTypeExtension(), os::RegistrarManager::RegisterTypeHandler(), os::RegistrarManager::RegisterTypeIcon(), os::RegistrarManager::RegistrarManager(), os::Messenger::SendMessage(), os::Message::SendReply(), os::RegistrarManager::SetDefaultHandler(), os::Event::SetMonitorEnabled(), os::RegistrarManager::UnregisterType(), os::Window::Window(), os::Event::~Event(), and os::RegistrarManager::~RegistrarManager().
Locker * Looper::GetMutex | ( | ) | const |
References os::Looper::Private::m_pcMutex.
String Looper::GetName | ( | ) | const |
References os::Looper::Private::m_cName.
Referenced by os::Settings::Private::GetAppName(), os::Application::RegisterKeyEvent(), os::Application::UnregisterKeyEvent(), and os::Application::~Application().
proc_id Looper::GetProcess | ( | ) | const |
References os::Looper::Private::m_hThread.
thread_id Looper::GetThread | ( | ) | const |
References os::Looper::Private::m_hThread.
Referenced by os::Message::SendReply().
|
virtual |
Reimplemented in os_priv::DirKeeper.
bool Looper::IsLocked | ( | ) | const |
References os::Locker::IsLocked(), and os::Looper::Private::m_pcMutex.
bool Looper::IsPublic | ( | ) | const |
References os::Looper::Private::m_hPort.
status_t Looper::Lock | ( | ) |
References os::Locker::Lock(), and os::Looper::Private::m_pcMutex.
Referenced by os::FileRequester::FileRequester(), os::Application::GetQualifiers(), Looper(), MoveFileThread(), OperationCopyFile(), os::ProgressRequester::ProgressRequester(), os::IconDirectoryView::ReRead(), MountDialogScanner::Run(), SafeLock(), MountDialogScanner::ScanPath(), os::Application::SetCatalog(), os_priv::DirKeeper::Stop(), and os::Application::~Application().
status_t Looper::Lock | ( | bigtime_t | nTimeout | ) |
nTimeout
micro seconds before timing out and fail with errno==ETIME. nTimeout | Maximum number of micro seconds to wait for the looper mutex to be available. |
References os::Locker::Lock(), and os::Looper::Private::m_pcMutex.
|
virtual |
Reimplemented in HandlerSelector, os::FontRequester, os::InputBox, os::ColorRequester, os::FileRequester, and os::Splash.
Referenced by DispatchMessage().
status_t Looper::PostMessage | ( | uint32 | nCode | ) |
nCode | The code that should be assigned to the sendt message |
Referenced by os::IconDirectoryView::DetachedFromWindow(), os::Alert::Go(), os::Handler::HandleMessage(), os::DropdownMenu::HandleMessage(), os::Alert::HandleMessage(), os::IconDirectoryView::HandleMessage(), os::IconDirectoryView::KeyDown(), MoveFileThread(), os::Splash::OkToQuit(), PostMessage(), os::RegistrarManager::Put(), os::IconDirectoryView::ReRead(), os::MenuWindow::ShutDown(), Terminate(), os::DropdownMenu::WheelMoved(), and os::DropdownMenu::~DropdownMenu().
status_t Looper::PostMessage | ( | Message * | pcMsg | ) |
pcMsg | The message to post. |
References GetMsgPort().
nCode | The code that should be assigned to the sendt message |
pcHandler | Must point to a valid handler that will receive the message. |
pcReplyTo | If not NULL should point to the handler that should receive the reply sendt to the message. |
References PostMessage().
status_t Looper::PostMessage | ( | Message * | pcMsg, |
Handler * | pcHandler, | ||
Handler * | pcReplyHandler = NULL |
||
) |
nCode | The code that should be assigned to the sendt message |
pcHandler | Must point to a valid handler that will receive the message. |
pcReplyTo | If not NULL should point to the handler that should receive the reply sendt to the message. |
References os::Handler::GetLooper(), and GetMsgPort().
|
virtual |
References Terminate().
void Looper::RemoveCommonFilter | ( | MessageFilter * | pcFilter | ) |
References os::Looper::Private::m_cCommonFilterList.
Referenced by AddCommonFilter().
bool Looper::RemoveHandler | ( | Handler * | pcHandler | ) |
pcHandler | The handler to remove |
References os::Looper::Private::m_cHandlerMap, os::Looper::Private::m_pcDefaultHandler, and os::Looper::Private::m_pcMutex.
Referenced by os::Handler::~Handler(), and ~Looper().
bool Looper::RemoveTimer | ( | Handler * | pcTarget, |
int | nID | ||
) |
- | pcTarget - The handler for which a timer is to be removed. |
- | nID - The ID of the timer to be removed. |
References os::Looper::Private::m_pcFirstRestartTimer, and os::Looper::Private::m_pcFirstTimer.
Referenced by AddTimer(), os::ScrollBar::MouseMove(), os::ScrollBar::MouseUp(), and os::IconView::StopScroll().
|
virtual |
Reimplemented in os::Application.
References os::String::c_str(), os::Locker::Lock(), os::Looper::Private::m_cName, os::Looper::Private::m_hThread, os::Looper::Private::m_nPriority, os::Locker::Unlock(), and Unlock().
Referenced by os::IconDirectoryView::AttachedToWindow(), os::RegistrarManager::Get(), os::Window::Show(), and os::Window::Start().
status_t Looper::SafeLock | ( | ) |
References os::Locker::Lock(), Lock(), os::Looper::Private::m_nID, and os::Locker::Unlock().
Referenced by os::Messenger::LockTarget(), and Terminate().
void Looper::SetDefaultHandler | ( | Handler * | pcHandler | ) |
pcHandler | The handler to set as default, or NULL |
References os::Looper::Private::m_pcDefaultHandler, and os::Looper::Private::m_pcMutex.
Referenced by os::Window::SetFocusChild().
void Looper::SetMutex | ( | Locker * | pcMutex | ) |
pcMutex | Pointer to the new mutex object or NULL to restore the default mutex |
References os::Looper::Private::m_cDefaultMutex, and os::Looper::Private::m_pcMutex.
Referenced by os::Menu::Open(), and os::Menu::Track().
void Looper::SetName | ( | const String & | cName | ) |
cName | The new looper name |
References os::String::c_str(), os::Looper::Private::m_cName, and os::Looper::Private::m_hThread.
void Looper::SetPublic | ( | bool | bPublic | ) |
References os::Looper::Private::m_hPort.
void Looper::SpoolMessages | ( | ) |
References os::Looper::Private::m_hPort.
Referenced by os::Window::DispatchMessage(), os::IconDirectoryView::ReRead(), and os_priv::DirKeeper::Stop().
|
virtual |
void Looper::Terminate | ( | ) |
References os::Looper::Private::m_hThread, os::M_TERMINATE, PostMessage(), SafeLock(), and Unlock().
Referenced by Quit(), and os::Application::~Application().
status_t Looper::Unlock | ( | ) |
References os::Looper::Private::m_pcMutex, and os::Locker::Unlock().
Referenced by os::Bitmap::Bitmap(), DispatchMessage(), os::FileRequester::FileRequester(), os::Application::GetQualifiers(), MoveFileThread(), OperationCopyFile(), os::ProgressRequester::ProgressRequester(), os::IconDirectoryView::ReRead(), Run(), MountDialogScanner::Run(), os::Application::Run(), MountDialogScanner::ScanPath(), os::Application::SetCatalog(), os::Window::Start(), os_priv::DirKeeper::Stop(), Terminate(), and os::Application::~Application().
int Looper::Wait | ( | ) | const |
References os::Looper::Private::m_hThread.
|
friend |
|
friend |
Referenced by os::Application::Application(), os::Application::CommitColorConfig(), os::FileRequester::FileRequester(), os::Application::GetCurrentKeyShortcuts(), os::Application::GetIdleTime(), os::Application::GetKeyboardConfig(), os::Application::GetScreenModeCount(), os::Application::GetScreenModeInfo(), os::Window::MakeFocus(), os::Application::PopCursor(), os::Application::PushCursor(), os::Application::RegisterKeyEvent(), os::RegistrarManager::RegistrarManager(), os::Window::SetAlignment(), os::Window::SetFlags(), os::Window::SetIcon(), os::Application::SetKeyboardTimings(), os::Application::SetKeymap(), os::Window::SetSizeLimits(), os::Window::SetTitle(), os::Application::UnregisterKeyEvent(), and os::Application::~Application().
|
friend |
|
friend |