Classes | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends
UEventsManager Class Reference

#include <UEventsManager.h>

Inheritance diagram for UEventsManager:
Inheritance graph
[legend]

List of all members.

Classes

class  Pipe

Static Public Member Functions

static void addHandler (UEventsHandler *handler)
static void createPipe (const UEventsSender *sender, const UEventsHandler *receiver, const std::string &eventName)
static void post (UEvent *event, bool async=true, const UEventsSender *sender=0)
static void removeAllPipes (const UEventsSender *sender)
static void removeHandler (UEventsHandler *handler)
static void removeNullPipes (const UEventsSender *sender)
static void removePipe (const UEventsSender *sender, const UEventsHandler *receiver, const std::string &eventName)

Protected Member Functions

virtual void mainLoop ()
 UEventsManager ()
virtual ~UEventsManager ()

Static Protected Member Functions

static UEventsManagergetInstance ()

Private Member Functions

void _addHandler (UEventsHandler *handler)
void _createPipe (const UEventsSender *sender, const UEventsHandler *receiver, const std::string &eventName)
void _postEvent (UEvent *event, bool async=true, const UEventsSender *sender=0)
void _removeAllPipes (const UEventsSender *sender)
void _removeHandler (UEventsHandler *handler)
void _removeNullPipes (const UEventsSender *sender)
void _removePipe (const UEventsSender *sender, const UEventsHandler *receiver, const std::string &eventName)
virtual void dispatchEvent (UEvent *event, const UEventsSender *sender)
virtual void dispatchEvents ()
std::list< UEventsHandler * > getPipes (const UEventsSender *sender, const std::string &eventName)
virtual void mainLoopKill ()

Private Attributes

std::list< std::pair< UEvent
*, const UEventsSender * > > 
events_
UMutex eventsMutex_
std::list< UEventsHandler * > handlers_
UMutex handlersMutex_
std::list< Pipepipes_
UMutex pipesMutex_
USemaphore postEventSem_

Static Private Attributes

static UDestroyer< UEventsManagerdestroyer_
static UEventsManagerinstance_ = 0

Friends

class UDestroyer< UEventsManager >

Detailed Description

This class is used to post events between threads in the application. It is Thread-Safe and the events are sent to receivers in the same order they are posted (FIFO). It works like the design pattern Mediator. It is also a Singleton, so it can be used anywhere in the application.

To send an event, use UEventsManager::post(). Events are automatically deleted after they are posted.

The EventsManager have a list of handlers to which it sends posted events. To add an handler, use UEventsManager::addHandler(). To remove, use UEventsManager::removeHandler().

  // Anywhere in the code:
  UEventsManager::post(new MyEvent()); // where MyEvent is an implemented UEvent
See also:
UEvent
UEventsHandler
post()
addHandler()
removeHandler()

Definition at line 78 of file UEventsManager.h.


Constructor & Destructor Documentation

Definition at line 136 of file UEventsManager.cpp.

UEventsManager::~UEventsManager ( ) [protected, virtual]

Definition at line 140 of file UEventsManager.cpp.


Member Function Documentation

void UEventsManager::_addHandler ( UEventsHandler handler) [private]

Definition at line 240 of file UEventsManager.cpp.

void UEventsManager::_createPipe ( const UEventsSender sender,
const UEventsHandler receiver,
const std::string &  eventName 
) [private]

Definition at line 360 of file UEventsManager.cpp.

void UEventsManager::_postEvent ( UEvent event,
bool  async = true,
const UEventsSender sender = 0 
) [private]

Definition at line 295 of file UEventsManager.cpp.

void UEventsManager::_removeAllPipes ( const UEventsSender sender) [private]

Definition at line 437 of file UEventsManager.cpp.

void UEventsManager::_removeHandler ( UEventsHandler handler) [private]

Definition at line 264 of file UEventsManager.cpp.

void UEventsManager::_removeNullPipes ( const UEventsSender sender) [private]

Definition at line 454 of file UEventsManager.cpp.

void UEventsManager::_removePipe ( const UEventsSender sender,
const UEventsHandler receiver,
const std::string &  eventName 
) [private]

Definition at line 407 of file UEventsManager.cpp.

void UEventsManager::addHandler ( UEventsHandler handler) [static]

This method is used to add an events handler to the list of handlers.

Parameters:
handlerthe handler to be added.

Definition at line 28 of file UEventsManager.cpp.

void UEventsManager::createPipe ( const UEventsSender sender,
const UEventsHandler receiver,
const std::string &  eventName 
) [static]

Definition at line 67 of file UEventsManager.cpp.

void UEventsManager::dispatchEvent ( UEvent event,
const UEventsSender sender 
) [private, virtual]

Definition at line 199 of file UEventsManager.cpp.

void UEventsManager::dispatchEvents ( ) [private, virtual]

Definition at line 170 of file UEventsManager.cpp.

UEventsManager * UEventsManager::getInstance ( ) [static, protected]

Definition at line 125 of file UEventsManager.cpp.

std::list< UEventsHandler * > UEventsManager::getPipes ( const UEventsSender sender,
const std::string &  eventName 
) [private]

Definition at line 322 of file UEventsManager.cpp.

void UEventsManager::mainLoop ( ) [protected, virtual]

The UEventsManager's main loop.

Implements UThread.

Definition at line 156 of file UEventsManager.cpp.

void UEventsManager::mainLoopKill ( ) [private, virtual]

Reimplemented to wake up UEventsManager on termination.

Reimplemented from UThread.

Definition at line 165 of file UEventsManager.cpp.

void UEventsManager::post ( UEvent event,
bool  async = true,
const UEventsSender sender = 0 
) [static]

This method is used to post an event to handlers.

Event can be posted asynchronously or not. In the first case, the event is dispatched by the UEventsManager's thread. In the second case, the event is handled immediately by event's receivers, thus in the sender thread.

Parameters:
eventthe event to be posted.
asyncif true, the event is dispatched by the UEventsManager thread, otherwise it's in the caller thread (synchronous).

Definition at line 54 of file UEventsManager.cpp.

void UEventsManager::removeAllPipes ( const UEventsSender sender) [static]

Definition at line 99 of file UEventsManager.cpp.

void UEventsManager::removeHandler ( UEventsHandler handler) [static]

This method is used to remove an events handler from the list of handlers.

Parameters:
handlerthe handler to be removed.

Definition at line 41 of file UEventsManager.cpp.

void UEventsManager::removeNullPipes ( const UEventsSender sender) [static]

Definition at line 112 of file UEventsManager.cpp.

void UEventsManager::removePipe ( const UEventsSender sender,
const UEventsHandler receiver,
const std::string &  eventName 
) [static]

Definition at line 83 of file UEventsManager.cpp.


Friends And Related Function Documentation

friend class UDestroyer< UEventsManager > [friend]

Definition at line 155 of file UEventsManager.h.


Member Data Documentation

Definition at line 243 of file UEventsManager.h.

std::list<std::pair<UEvent*, const UEventsSender * > > UEventsManager::events_ [private]

Definition at line 244 of file UEventsManager.h.

Definition at line 246 of file UEventsManager.h.

Definition at line 245 of file UEventsManager.h.

Definition at line 247 of file UEventsManager.h.

UEventsManager * UEventsManager::instance_ = 0 [static, private]

Definition at line 242 of file UEventsManager.h.

std::list<Pipe> UEventsManager::pipes_ [private]

Definition at line 249 of file UEventsManager.h.

Definition at line 250 of file UEventsManager.h.

Definition at line 248 of file UEventsManager.h.


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


rtabmap
Author(s): Mathieu Labbe
autogenerated on Fri Aug 28 2015 12:51:43