Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | Namespace Members | Class Members

EventQueueViewer Class Reference

#include <src/EventQueueViewer.h>

List of all members.


Detailed Description

Extend the OSG viewer to add a thread-safe asynchronous event queue.

The goal is to post-pone OSG-critical events (like scene graph changes) to when they can be safely executed (the update method of the viewer).

Any thread can post such events at any time, they will be executed in order they were received at the next scene graph update.

Note: This is not a whole simulator, especially there is no notion of a deterministic simulated time. But the template way of posting events was "inspired" from a more complete simulator framework. See http://nicolas.brodu.free.fr/en/programmation/crogai/index.html for a project using this simulator.

Author:
Nicolas Brodu


Public Member Functions

 EventQueueViewer ()
 Parent constructor "overload".
 EventQueueViewer (Producer::CameraConfig *cfg)
 Parent constructor "overload".
 EventQueueViewer (const std::string &configFile)
 Parent constructor "overload".
 EventQueueViewer (osg::ArgumentParser &arguments)
 Parent constructor "overload".
virtual ~EventQueueViewer ()
 Parent destructor "overload".
virtual void post (const GenericDispatcher *dispatcher)
 Post an event, scheduled to be executed at next frame update.
void post (void(*method)())
 Post an event, scheduled to be executed at next frame update.
template<class A>
void post (void(*method)(A), A argument)
 Post an event, scheduled to be executed at next frame update.
template<class A1, class A2>
void post (void(*method)(A1, A2), A1 argument1, A2 argument2)
 Post an event, scheduled to be executed at next frame update.
template<class A1, class A2, class A3>
void post (void(*method)(A1, A2, A3), A1 argument1, A2 argument2, A3 argument3)
 Post an event, scheduled to be executed at next frame update.
template<class T>
void post (T *object, void(T::*method)())
 Post an event, scheduled to be executed at next frame update.
template<class T, class A>
void post (T *object, void(T::*method)(A), A argument)
 Post an event, scheduled to be executed at next frame update.
template<class T, class A1, class A2>
void post (T *object, void(T::*method)(A1, A2), A1 argument1, A2 argument2)
 Post an event, scheduled to be executed at next frame update.
template<class T, class A1, class A2, class A3>
void post (T *object, void(T::*method)(A1, A2, A3), A1 argument1, A2 argument2, A3 argument3)
 Post an event, scheduled to be executed at next frame update.
virtual void update ()
 Process queued events, then call parent code in globally locked section to prevent concurrent modifications of the scene graph.

Protected Attributes

std::vector< const GenericDispatcher * > events
 Globally locks or unlocks the viewer.
OpenThreads::Mutex eventsAccessMutex
OpenThreads::Mutex globalAccessMutex

Classes

struct  Dispatcher
struct  Dispatcher1
struct  Dispatcher2
struct  Dispatcher3
struct  GenericDispatcher
 Base class of templatized object method wrappers This is put in the public namespace of the Viewer so it can be used with the generic post methods. More...
struct  StaticDispatcher
struct  StaticDispatcher1
struct  StaticDispatcher2
struct  StaticDispatcher3


Constructor & Destructor Documentation

EventQueueViewer::EventQueueViewer  ) 
 

Parent constructor "overload".

See parent doc.

EventQueueViewer::EventQueueViewer Producer::CameraConfig *  cfg  ) 
 

Parent constructor "overload".

See parent doc.

EventQueueViewer::EventQueueViewer const std::string &  configFile  ) 
 

Parent constructor "overload".

See parent doc.

EventQueueViewer::EventQueueViewer osg::ArgumentParser &  arguments  ) 
 

Parent constructor "overload".

See parent doc.

EventQueueViewer::~EventQueueViewer  )  [virtual]
 

Parent destructor "overload".

See parent doc.


Member Function Documentation

template<class T, class A1, class A2, class A3>
void EventQueueViewer::post T *  object,
void(T::*)(A1, A2, A3)  method,
A1  argument1,
A2  argument2,
A3  argument3
[inline]
 

Post an event, scheduled to be executed at next frame update.

Any C++ method on any arbitrary object can be called this way.

The events are posted in a thread-safe way. Use this function to delay code at a place where is it safe for OSG: ex removing a scene graph branch. This code may not be safe in you own thread.

Note: This is not a whole simulator, especially there is no notion of a deterministic simulated time. But the template way of posting events was "inspired" from a more complete simulator framework. See http://nicolas.brodu.free.fr/en/programmation/crogai/index.html for a project using this simulator.

See parent "update" method too.

Parameters:
object any C++ object
function any C++ method on this object with three arguments
argument1 the first argument to pass to the method
argument2 the second argument to pass to the method
argument3 the third argument to pass to the method

template<class T, class A1, class A2>
void EventQueueViewer::post T *  object,
void(T::*)(A1, A2)  method,
A1  argument1,
A2  argument2
[inline]
 

Post an event, scheduled to be executed at next frame update.

Any C++ method on any arbitrary object can be called this way.

The events are posted in a thread-safe way. Use this function to delay code at a place where is it safe for OSG: ex removing a scene graph branch. This code may not be safe in you own thread.

Note: This is not a whole simulator, especially there is no notion of a deterministic simulated time. But the template way of posting events was "inspired" from a more complete simulator framework. See http://nicolas.brodu.free.fr/en/programmation/crogai/index.html for a project using this simulator.

See parent "update" method too.

Parameters:
object any C++ object
function any C++ method on this object with two arguments
argument1 the first argument to pass to the method
argument2 the second argument to pass to the method

template<class T, class A>
void EventQueueViewer::post T *  object,
void(T::*)(A)  method,
argument
[inline]
 

Post an event, scheduled to be executed at next frame update.

Any C++ method on any arbitrary object can be called this way.

The events are posted in a thread-safe way. Use this function to delay code at a place where is it safe for OSG: ex removing a scene graph branch. This code may not be safe in you own thread.

Note: This is not a whole simulator, especially there is no notion of a deterministic simulated time. But the template way of posting events was "inspired" from a more complete simulator framework. See http://nicolas.brodu.free.fr/en/programmation/crogai/index.html for a project using this simulator.

See parent "update" method too.

Parameters:
object any C++ object
function any C++ method on this object with one argument
argument the argument to pass to the method

template<class T>
void EventQueueViewer::post T *  object,
void(T::*)()  method
[inline]
 

Post an event, scheduled to be executed at next frame update.

Any C++ method on any arbitrary object can be called this way.

The events are posted in a thread-safe way. Use this function to delay code at a place where is it safe for OSG: ex removing a scene graph branch. This code may not be safe in you own thread.

Note: This is not a whole simulator, especially there is no notion of a deterministic simulated time. But the template way of posting events was "inspired" from a more complete simulator framework. See http://nicolas.brodu.free.fr/en/programmation/crogai/index.html for a project using this simulator.

See parent "update" method too.

Parameters:
object any C++ object
method any C++ method on this object with no argument

template<class A1, class A2, class A3>
void EventQueueViewer::post void(*)(A1, A2, A3)  method,
A1  argument1,
A2  argument2,
A3  argument3
[inline]
 

Post an event, scheduled to be executed at next frame update.

Any C "void method(..)" with three arguments can be called this way.

The events are posted in a thread-safe way. Use this function to delay code at a place where is it safe for OSG: ex removing a scene graph branch. This code may not be safe in you own thread.

Note: This is not a whole simulator, especially there is no notion of a deterministic simulated time. But the template way of posting events was "inspired" from a more complete simulator framework. See http://nicolas.brodu.free.fr/en/programmation/crogai/index.html for a project using this simulator.

See parent "update" method too.

Parameters:
method any C "void method(..)" with three arguments
argument1 the first argument to pass to the method
argument2 the second argument to pass to the method
argument3 the third argument to pass to the method

template<class A1, class A2>
void EventQueueViewer::post void(*)(A1, A2)  method,
A1  argument1,
A2  argument2
[inline]
 

Post an event, scheduled to be executed at next frame update.

Any C "void method(..)" with two arguments can be called this way.

The events are posted in a thread-safe way. Use this function to delay code at a place where is it safe for OSG: ex removing a scene graph branch. This code may not be safe in you own thread.

Note: This is not a whole simulator, especially there is no notion of a deterministic simulated time. But the template way of posting events was "inspired" from a more complete simulator framework. See http://nicolas.brodu.free.fr/en/programmation/crogai/index.html for a project using this simulator.

See parent "update" method too.

Parameters:
method any C "void method(..)" with two arguments
argument1 the first argument to pass to the method
argument2 the second argument to pass to the method

template<class A>
void EventQueueViewer::post void(*)(A)  method,
argument
[inline]
 

Post an event, scheduled to be executed at next frame update.

Any C "void method(..)" with one argument can be called this way.

The events are posted in a thread-safe way. Use this function to delay code at a place where is it safe for OSG: ex removing a scene graph branch. This code may not be safe in you own thread.

Note: This is not a whole simulator, especially there is no notion of a deterministic simulated time. But the template way of posting events was "inspired" from a more complete simulator framework. See http://nicolas.brodu.free.fr/en/programmation/crogai/index.html for a project using this simulator.

See parent "update" method too.

Parameters:
method any C "void method()" with one argument
argument the argument to pass to the method

void EventQueueViewer::post void(*)()  method  )  [inline]
 

Post an event, scheduled to be executed at next frame update.

Any C "void method()" can be called this way.

The events are posted in a thread-safe way. Use this function to delay code at a place where is it safe for OSG: ex removing a scene graph branch. This code may not be safe in you own thread.

Note: This is not a whole simulator, especially there is no notion of a deterministic simulated time. But the template way of posting events was "inspired" from a more complete simulator framework. See http://nicolas.brodu.free.fr/en/programmation/crogai/index.html for a project using this simulator.

See parent "update" method too.

Parameters:
method any C "void method()" with no argument

void EventQueueViewer::post const GenericDispatcher dispatcher  )  [virtual]
 

Post an event, scheduled to be executed at next frame update.

The events are posted in a thread-safe way. Use this function to delay code at a place where is it safe for OSG: ex removing a scene graph branch. This code may not be safe in you own thread.

Note: This is not a whole simulator, especially there is no notion of a deterministic simulated time. But the template way of posting events was "inspired" from a more complete simulator framework. See http://nicolas.brodu.free.fr/en/programmation/crogai/index.html for a project using this simulator.

Note2: In this implementation, the dispatcher MUST have been allocated with new. This is the case with all templatized versions of post, but you've been warned if you use your own dispatcher.

See parent "update" method too.


Member Data Documentation

std::vector<const GenericDispatcher*> EventQueueViewer::events [protected]
 

Globally locks or unlocks the viewer.

Guarantee that during a protected section, the scenegraph may be safely modified Also makes things deterministic, unlike posting an event to the next update => use event posts to next update when non-determinism isn't a problem (like changing a color, etc...) => use global lock when the order is very important (like a simulator step adding a new agent)


The documentation for this class was generated from the following files:
Generated on Mon Mar 28 11:27:05 2005 for Crogai by  doxygen 1.4.1