INTRODUCTION
Overview
Download and Install
Quick Start
Documentation
Publications

NONFRAMEWORK CODE
Driver Interfaces
Drivers
Libraries
Utilities

FRAMEWORK CODE
Interfaces
Components
Libraries
Utilities

Full Software Listings

DEVELOPER
Tutorials
Examples
Dev Guide
Dashboard

PEOPLE
Contributors
Users

SourceForge.net Logo
Project
Download
Mailing lists

 

         

hydroiceutil::EventLoop Class Reference

#include <eventloop.h>

Inherits hydroiceutil::JobQueue.

List of all members.

Public Member Functions

 EventLoop (gbxutilacfr::Tracer &tracer, const JobQueue::Config &config=JobQueue::Config())
 Constructor.
void postEvent (EventReceiver &receiver, const EventPtr &event, const std::string &signature="", bool debug=false)
void postEvent (EventReceiver &receiver, int type, const std::string &signature="", bool debug=false)
 Executes an EventJob which sends an Event of type type to the event receiver receiver.
void postEvent (const std::string &receiverId, const EventPtr &event, const std::string &senderId="", bool debug=false)
void postEvent (const std::string &receiverId, int type, const std::string &senderId="", bool debug=false)
void postEventToAll (const EventPtr &event, const std::string &senderId="", bool debug=false)
 Posts event event to all registered receivers.
void postEventToAll (int type, const std::string &senderId="", bool debug=false)
 Posts event of type type to all registered receivers.
void addReceiver (const std::string &receiverId, EventReceiver *receiver)
void removeReceiver (const std::string &receiverId)
EventReceiverreceiver (const std::string &receiverId)
 Returns null pointer if the specified ID is not registered.

Detailed Description

This is a convenience class which makes the JobQueue appear like an event loop. Uses specialized EventJob jobs to dispatch events through the JobQueue.

This class queues events and executes them. For a class which does not execute the events, see EventQueue.

Typically, an event loop has a single execution thread to ensure that the events are delivered in the order in which they were added. This class does not enforce this convention and leaves it up to the user to decide (the default size of the thread pool in JobQueue::Config is 1).

EventLoop offers a facility to store event receiver ID's which can be used later to dispatch events. All public methods utilizing the receiver registry are thread safe.


Member Function Documentation

void EventLoop::addReceiver ( const std::string &  receiverId,
EventReceiver receiver 
)

Registers receiver with specified ID. ID can be any string. If a receiver with the specified ID is already registered, it's overwritten. If you want to check for uniqueness first, use receiver() function. It is OK to register the same receiver multiple times under different names (e.g. to create a well known alias). Throws gbxutilacfr::Exception if receiver is a null pointer.

void EventLoop::postEvent ( const std::string &  receiverId,
int  type,
const std::string &  senderId = "",
bool  debug = false 
)

Executes an EventJob which sends an Event of type type to the event receiver with ID receiverID. Throws ReceiverIdNotExistException if no receiver with specified ID is registered.

References postEvent().

void EventLoop::postEvent ( const std::string &  receiverId,
const EventPtr event,
const std::string &  senderId = "",
bool  debug = false 
)

Executes an EventJob which sends an event event to the event receiver with ID receiverID. Throws ReceiverIdNotExistException if no receiver with specified ID is registered.

References hydroiceutil::JobQueue::add().

void EventLoop::postEvent ( EventReceiver receiver,
const EventPtr event,
const std::string &  signature = "",
bool  debug = false 
)

Adds the event event, with the receiver as the receiver of the event, to an event queue and returns immediately. It is not safe to modify or delete the event after it has been posted.

References hydroiceutil::JobQueue::add().

Referenced by postEvent().

void EventLoop::removeReceiver ( const std::string &  receiverId  ) 

Unregisters receiver with specified ID. If a receiver with the specified ID is not registered the request is quietly ignored.


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

Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)


Generated for Orca Robotics by  doxygen 1.4.5