Pyro higlevel API
|
Events. More...
Classes | |
class | Private |
Public Member Functions | |
Event () | |
Creates a new event. More... | |
~Event () | |
Deletes an event. More... | |
status_t | SetToRemote (String zID, int nIndex=0) |
Sets the object to a specific event. More... | |
void | Unset () |
Unsets the event. More... | |
bool | IsRemote () |
Returns whether the object is set to a remote event. More... | |
status_t | GetRemoteInfo (proc_id *pnProcess, port_id *phPort, int *pnMessageCode, os::String *pzDesc) |
Returns information about a remote event. More... | |
status_t | GetRemoteChildren (std::vector< os::String > *pacList) |
Returns a list of children. More... | |
status_t | SetMonitorEnabled (bool bEnabled, Handler *pcTarget=NULL, int nMessageCode=-1) |
Enables/Disables a monitor to an id string. More... | |
bool | IsMonitorEnabled () |
Returns whether monitoring of the event is enabled. More... | |
status_t | PostEvent (Message *pcData, Handler *pcReplyHandler=NULL, int nReplyCode=M_REPLY) |
Posts an event. More... | |
status_t | GetLastEventMessage (os::Message *cReply) |
Returns the last message sent to the monitors. More... | |
Static Public Member Functions | |
static Event * | Register (String zID, String zDescription, Handler *pcTarget, int nMessageCode, uint32 nFlags=0) |
Registers an event. More... | |
All events are identified using an id string. Currently this can be any string but in future revisions it has to look like this: <class>/<subclass>/<name>
We now want to call this event from another application. This code will do this:
This code will send an empty message to the event and the reply is sent to the reply handler where we can extract the reply string:
If you want to know what events with a known id string are available, you could frequently use SetToRemote() to poll for the events. This requires additional code and reduces performance. To solve this problem you can set a monitor to events with a given id string. Some code:
The event monitors can also be used to broadcast messages. If you call the PostEvent() method of an event object that you have registered yourself then the message is sent to all monitors. Please note that replies are not supported in this case.
Sometimes a direct communication is not really necessary if you just want to access some information supplied by another application. In this case this application can broadcast the message like in chapter 4. The application that wants to get the information doesn´t have to set a monitor to this event. They can use the GetLastEventMessage() method to get the last message which has been sent.
Event::Event | ( | ) |
References os::Application::GetInstance(), os::Application::GetServerPort(), and os::Event::Private::m_cServerLink.
Referenced by Register().
Event::~Event | ( | ) |
References os::Message::AddInt64(), os::Message::AddString(), os::Handler::GetLooper(), os::Looper::GetMsgPort(), os::Event::Private::m_bIsRegistered, os::Event::Private::m_bMonitorEnabled, os::Event::Private::m_cServerLink, os::Event::Private::m_pcTarget, os::Event::Private::m_zID, and os::Messenger::SendMessage().
status_t Event::GetLastEventMessage | ( | os::Message * | cReply | ) |
pcReply | - The message content will be copied to this message. |
References os::Message::AddInt64(), os::Message::AddString(), os::Event::Private::m_bIsRemote, os::Event::Private::m_cServerLink, os::Event::Private::m_nRemotePort, os::Event::Private::m_nRemoteProcess, os::Event::Private::m_zID, and os::Messenger::SendMessage().
Referenced by os::IconDirectoryView::IconDirectoryView().
status_t Event::GetRemoteChildren | ( | std::vector< os::String > * | pacList | ) |
References os::Message::AddString(), os::Message::FindString(), os::Message::GetCode(), os::Event::Private::m_cServerLink, os::Event::Private::m_zID, and os::Messenger::SendMessage().
status_t Event::GetRemoteInfo | ( | proc_id * | pnProcess, |
port_id * | phPort, | ||
int * | pnMessageCode, | ||
os::String * | pzDesc | ||
) |
References IsRemote(), os::Event::Private::m_nRemoteMsgCode, os::Event::Private::m_nRemotePort, os::Event::Private::m_nRemoteProcess, and os::Event::Private::m_zRemoteDescription.
bool Event::IsMonitorEnabled | ( | ) |
References os::Event::Private::m_bMonitorEnabled.
bool Event::IsRemote | ( | ) |
References os::Event::Private::m_bIsRemote.
Referenced by GetRemoteInfo().
status_t Event::PostEvent | ( | Message * | pcData, |
Handler * | pcReplyHandler = NULL , |
||
int | nReplyCode = M_REPLY |
||
) |
pcData | - Data that will be submitted. |
pcReplyHandler | - Handler for the reply message. Can be NULL for remote calls and has to be NULL if you have registered the event. |
nReplyCode | - The code for the reply. |
References os::Message::AddInt32(), os::Message::AddInt64(), os::Message::AddMessage(), os::Message::AddString(), os::Handler::GetLooper(), os::Looper::GetMsgPort(), os::Event::Private::m_bIsRegistered, os::Event::Private::m_bIsRemote, os::Event::Private::m_cServerLink, os::Event::Private::m_nRemoteHandler, os::Event::Private::m_nRemoteMsgCode, os::Event::Private::m_nRemotePort, os::Event::Private::m_pcTarget, os::Event::Private::m_zID, os::Messenger::SendMessage(), and os::Message::SetCode().
|
static |
zID | - ID string. |
zDescription | - Description of the call. |
pcTarget | - Handler that will receive the calls. It needs to be added to a handler. |
nMessageCode | - The code of the message that will be sent to the looper. The message can include additional data provided by the caller. |
nFlags | - Flags. |
References Event(), os::Handler::GetLooper(), os::Looper::GetMsgPort(), os::Handler::GetToken(), os::Event::Private::m_bIsRegistered, os::Event::Private::m_cServerLink, os::Event::Private::m_pcTarget, os::Event::Private::m_zID, and os::Messenger::SendMessage().
status_t Event::SetMonitorEnabled | ( | bool | bEnabled, |
os::Handler * | pcTarget = NULL , |
||
int | nMessageCode = -1 |
||
) |
bEnabled | - Enables/Disables the monitor. |
pcTarget | - Handler that should receive the monitor messages. |
nMessageCode | - The code of the message that will be sent to the looper. The message can include additional data provided by the caller. |
References os::Message::AddInt64(), os::Message::AddString(), os::Handler::GetLooper(), os::Looper::GetMsgPort(), os::Handler::GetToken(), os::Event::Private::m_bMonitorEnabled, os::Event::Private::m_cServerLink, os::Event::Private::m_pcTarget, os::Event::Private::m_zID, and os::Messenger::SendMessage().
status_t Event::SetToRemote | ( | String | zID, |
int | nIndex = 0 |
||
) |
zID | - ID string. |
nIndex | - Index of the string. |
References os::Message::AddInt64(), os::Message::AddString(), os::Message::FindInt64(), os::Message::FindString(), os::Message::GetCode(), os::Event::Private::m_bIsRegistered, os::Event::Private::m_bIsRemote, os::Event::Private::m_bMonitorEnabled, os::Event::Private::m_cServerLink, os::Event::Private::m_nRemoteHandler, os::Event::Private::m_nRemoteMsgCode, os::Event::Private::m_nRemotePort, os::Event::Private::m_nRemoteProcess, os::Event::Private::m_zID, os::Event::Private::m_zRemoteDescription, os::Messenger::SendMessage(), and Unset().
Referenced by os::IconDirectoryView::IconDirectoryView().
void Event::Unset | ( | ) |
References os::Event::Private::m_bIsRemote.
Referenced by SetToRemote().