The EventService represents the event interface. More...
#include <rtt/EventService.hpp>
Public Types | |
typedef OperationFactory < ActionInterface * > | Factory |
typedef std::vector < ArgumentDescription > | Descriptions |
The descriptions of an argumentlist. | |
typedef std::vector < DataSourceBase::shared_ptr > | Arguments |
The arguments for an operation. | |
Public Member Functions | |
EventService (ExecutionEngine *ee) | |
Create an EventService with an associated ExecutionEngine. | |
EventService (EventProcessor *ep=0) | |
Create an EventService with an associated EventService. | |
EventProcessor * | getEventProcessor () |
void | setEventProcessor (EventProcessor *ep) |
void | clear () |
Clear all added methods from the repository, saving memory space. | |
std::vector< std::string > | getEvents () const |
Returns the names of all events added to this interface. | |
template<class EventT > | |
bool | addEvent (EventT *e) |
Add an Event to the event interface. | |
template<class Signature > | |
boost::shared_ptr < ActionInterface > | getEvent (const std::string &ename) |
Get a previously added event for use in a C++ Event object. | |
template<class EventT > | |
bool | addEvent (EventT *e, const char *description) |
Add an Event to the event interface. | |
template<class EventT > | |
bool | addEvent (EventT *e, const char *description, const char *arg1, const char *arg1_description) |
Add an Event to the event interface. | |
template<class EventT > | |
bool | addEvent (EventT *e, const char *description, const char *arg1, const char *arg1_description, const char *arg2, const char *arg2_description) |
Add an Event to the event interface. | |
template<class EventT > | |
bool | addEvent (EventT *e, const char *description, const char *arg1, const char *arg1_description, const char *arg2, const char *arg2_description, const char *arg3, const char *arg3_description) |
Add an Event to the event interface. | |
template<class EventT > | |
bool | addEvent (EventT *e, const char *description, const char *arg1, const char *arg1_description, const char *arg2, const char *arg2_description, const char *arg3, const char *arg3_description, const char *arg4, const char *arg4_description) |
Add an Event to the event interface. | |
bool | hasEvent (const std::string &ename) const |
Query for the existence of an Event in this Service. | |
int | arity (const std::string &name) const |
Return the number of arguments a given event has. | |
bool | removeEvent (const std::string &ename) |
Remove an added Event from this Service. | |
EventC | setupEmit (const std::string &ename) const |
Setup an object to emit events with arguments. | |
ConnectionC | setupConnection (const std::string &ename) const |
Setup a ConnectionC object to connect a number of synchronous or asynchronous callbacks to an event. | |
Handle | setupSyn (const std::string &ename, boost::function< void(void)> func, std::vector< DataSourceBase::shared_ptr > args) const |
For internal use only. | |
ActionInterface * | getEvent (const std::string &ename, const std::vector< DataSourceBase::shared_ptr > &args) const |
For internal use only. | |
std::vector< std::string > | getNames () const |
Get a list of all the names of the added operations. | |
bool | hasMember (const std::string &name) const |
Query if an operation is present. | |
int | getArity (const std::string &name) const |
Query the number of arguments of an operation. | |
ActionInterface * | produce (const std::string &name, const PropertyBag &args) const |
Produce an object that contains an operation. | |
ActionInterface * | produce (const std::string &name, const std::vector< DataSourceBase::shared_ptr > &args) const |
Produce an object that contains an operation. | |
Descriptions | getArgumentList (const std::string &name) const |
Get the names and descriptions of all arguments of an operation. | |
std::string | getResultType (const std::string &name) const |
Get the type name of the result type of an operation. | |
std::string | getDescription (const std::string &name) const |
Get the description of an operation. | |
void | add (const std::string &name, detail::OperationFactoryPart< ActionInterface * > *part) |
Add a new operation to the interface. | |
void | remove (const std::string &name) |
Remove an added operation from the interface. | |
Handle | setupAsyn (const std::string &ename, boost::function< void(void)> afunc, const std::vector< DataSourceBase::shared_ptr > &args, EventProcessor *ep=CompletionProcessor::Instance(), EventProcessor::AsynStorageType s_type=EventProcessor::OnlyFirst) const |
For internal use only. | |
Protected Types | |
typedef std::map< std::string, detail::OperationFactoryPart < ActionInterface * > * > | map_t |
Protected Attributes | |
map_t | data |
The EventService represents the event interface.
It stores pointers to event objects and allows clients to retrieve event objects which can then be emitted or subscribed to.
Definition at line 61 of file EventService.hpp.
RTT::EventService::EventService | ( | ExecutionEngine * | ee | ) |
Create an EventService with an associated ExecutionEngine.
If you want the owner task of this object to process an event use EventService::getEventProcessor() in the setup functions below.
RTT::EventService::EventService | ( | EventProcessor * | ep = 0 |
) |
Create an EventService with an associated EventService.
The EventProcessor is optional and defaults to the CompletionProcessor. If you want the owner task of this object to process an event use EventService::getEventProcessor() in the setup functions below.
void RTT::OperationFactory< ActionInterface * >::add | ( | const std::string & | name, | |
detail::OperationFactoryPart< ActionInterface * > * | part | |||
) | [inline, inherited] |
Add a new operation to the interface.
name | The name of the operation | |
part | A part which creates the operation. |
Definition at line 557 of file OperationFactory.hpp.
bool RTT::EventService::addEvent | ( | EventT * | e, | |
const char * | description, | |||
const char * | arg1, | |||
const char * | arg1_description, | |||
const char * | arg2, | |||
const char * | arg2_description, | |||
const char * | arg3, | |||
const char * | arg3_description, | |||
const char * | arg4, | |||
const char * | arg4_description | |||
) | [inline] |
Add an Event to the event interface.
This version of addEvent adds the event e to the C++ interface and to the scripting interface.
e | An event which takes four arguments. It must be ready(). | |
description | The description of this event. | |
arg1 | The name of the first argument of e. | |
arg1_description | A description of the first argument of e. | |
arg2 | The name of the second argument of e. | |
arg2_description | A description of the second argument of e. | |
arg3 | The name of the third argument of e. | |
arg3_description | A description of the third argument of e. | |
arg4 | The name of the fourth argument of e. | |
arg4_description | A description of the fourth argument of e. |
Definition at line 306 of file EventService.hpp.
bool RTT::EventService::addEvent | ( | EventT * | e, | |
const char * | description, | |||
const char * | arg1, | |||
const char * | arg1_description, | |||
const char * | arg2, | |||
const char * | arg2_description, | |||
const char * | arg3, | |||
const char * | arg3_description | |||
) | [inline] |
Add an Event to the event interface.
This version of addEvent adds the event e to the C++ interface and to the scripting interface.
e | An event which takes four arguments. It must be ready(). | |
description | The description of this event. | |
arg1 | The name of the first argument of e. | |
arg1_description | A description of the first argument of e. | |
arg2 | The name of the second argument of e. | |
arg2_description | A description of the second argument of e. | |
arg3 | The name of the third argument of e. | |
arg3_description | A description of the third argument of e. |
Definition at line 266 of file EventService.hpp.
bool RTT::EventService::addEvent | ( | EventT * | e, | |
const char * | description, | |||
const char * | arg1, | |||
const char * | arg1_description, | |||
const char * | arg2, | |||
const char * | arg2_description | |||
) | [inline] |
Add an Event to the event interface.
This version of addEvent adds the event e to the C++ interface and to the scripting interface.
e | An event which takes two arguments. It must be ready(). | |
description | The description of this event. | |
arg1 | The name of the first argument of e. | |
arg1_description | A description of the first argument of e. | |
arg2 | The name of the second argument of e. | |
arg2_description | A description of the second argument of e. |
Definition at line 229 of file EventService.hpp.
bool RTT::EventService::addEvent | ( | EventT * | e, | |
const char * | description, | |||
const char * | arg1, | |||
const char * | arg1_description | |||
) | [inline] |
Add an Event to the event interface.
This version of addEvent adds the event e to the C++ interface and to the scripting interface.
e | An event which takes one argument. It must be ready(). | |
description | The description of this event. | |
arg1 | The name of the first argument of e. | |
arg1_description | A description of the first argument of e. |
Definition at line 196 of file EventService.hpp.
bool RTT::EventService::addEvent | ( | EventT * | e, | |
const char * | description | |||
) | [inline] |
Add an Event to the event interface.
This version of addEvent adds the event e to the C++ interface and to the scripting interface.
e | An event which takes no arguments. It must be ready(). | |
description | The description of this event. |
Definition at line 167 of file EventService.hpp.
bool RTT::EventService::addEvent | ( | EventT * | e | ) | [inline] |
Add an Event to the event interface.
This version of addEvent only adds e to the C++ interface and not to the scripting interface.
e | The event to add |
Definition at line 119 of file EventService.hpp.
int RTT::EventService::arity | ( | const std::string & | name | ) | const |
Return the number of arguments a given event has.
-1 | The event does not exist. |
Descriptions RTT::OperationFactory< ActionInterface * >::getArgumentList | ( | const std::string & | name | ) | const [inline, inherited] |
Get the names and descriptions of all arguments of an operation.
name | The name of the operation |
Definition at line 516 of file OperationFactory.hpp.
int RTT::OperationFactory< ActionInterface * >::getArity | ( | const std::string & | name | ) | const [inline, inherited] |
Query the number of arguments of an operation.
name | The name of the operation |
Definition at line 468 of file OperationFactory.hpp.
std::string RTT::OperationFactory< ActionInterface * >::getDescription | ( | const std::string & | name | ) | const [inline, inherited] |
Get the description of an operation.
name | The name of the operation |
Definition at line 544 of file OperationFactory.hpp.
ActionInterface* RTT::EventService::getEvent | ( | const std::string & | ename, | |
const std::vector< DataSourceBase::shared_ptr > & | args | |||
) | const |
For internal use only.
Get an event which takes its arguments by Datasource. Call result->execute() to emit the event with the given args.
ename | The name of the previously added Event. | |
args | DataSources holding the values for each parameter of the event. They are read at the moment of execute(). |
boost::shared_ptr<ActionInterface> RTT::EventService::getEvent | ( | const std::string & | ename | ) | [inline] |
Get a previously added event for use in a C++ Event object.
Store the result of this method in an Event<Signature> object.
Signature | Signature of the Event, for example void(int, int) | |
ename | The name of the event to lookup. |
Definition at line 150 of file EventService.hpp.
std::vector<std::string> RTT::EventService::getEvents | ( | ) | const |
Returns the names of all events added to this interface.
std::string RTT::OperationFactory< ActionInterface * >::getResultType | ( | const std::string & | name | ) | const [inline, inherited] |
Get the type name of the result type of an operation.
name | The name of the operation |
Definition at line 530 of file OperationFactory.hpp.
bool RTT::EventService::hasEvent | ( | const std::string & | ename | ) | const |
Query for the existence of an Event in this Service.
ActionInterface * RTT::OperationFactory< ActionInterface * >::produce | ( | const std::string & | name, | |
const std::vector< DataSourceBase::shared_ptr > & | args | |||
) | const [inline, inherited] |
Produce an object that contains an operation.
name | The name of the operation | |
args | The arguments filled in as data sources. |
Definition at line 501 of file OperationFactory.hpp.
ActionInterface * RTT::OperationFactory< ActionInterface * >::produce | ( | const std::string & | name, | |
const PropertyBag & | args | |||
) | const [inline, inherited] |
Produce an object that contains an operation.
name | The name of the operation | |
args | The arguments filled in as properties. |
Definition at line 482 of file OperationFactory.hpp.
void RTT::OperationFactory< ActionInterface * >::remove | ( | const std::string & | name | ) | [inline, inherited] |
Remove an added operation from the interface.
name | The name of the operation |
Definition at line 572 of file OperationFactory.hpp.
Handle RTT::EventService::setupAsyn | ( | const std::string & | ename, | |
boost::function< void(void)> | afunc, | |||
const std::vector< DataSourceBase::shared_ptr > & | args, | |||
EventProcessor * | ep = CompletionProcessor::Instance() , |
|||
EventProcessor::AsynStorageType | s_type = EventProcessor::OnlyFirst | |||
) | const |
For internal use only.
Setup a asynchronous Event handler which will set args and call afunc asynchronously (in task t) when event ename occurs.
ename | The name of the previously added Event. | |
afunc | A function object which will be called. | |
args | The arguments which will be set before afunc is called. They must be of type AssignableDataSource<Tn> or DataSource<Tn&>, where Tn is the type of the n'th argument of the Event. | |
t | The task in which the args will be set and afunc will be called. | |
ep | The EventProcessor in which the args will be set and afunc will be called. | |
s_type | The method used when event overruns happen. By default, only the first event is propagated to the callbacks. |
ConnectionC RTT::EventService::setupConnection | ( | const std::string & | ename | ) | const |
Setup a ConnectionC object to connect a number of synchronous or asynchronous callbacks to an event.
Use this method as in
Handle h = setupConnection("EventName").callback( &my_function ).handle(); h.connect(); // or for adding a class method: h = setupConnection("EventName").callback( boost::bind( &MyClass::function, obj) ).handle(); h.connect();
name_not_found_exception |
EventC RTT::EventService::setupEmit | ( | const std::string & | ename | ) | const |
Setup an object to emit events with arguments.
Use this method as in
createEmit("EventName").arg(2.0).arg(1.0).emit(); // or: EventC em = createEmit("EventName").arg(2.0).arg(1.0); em.emit();
Also variables or reference to variables may be given within arg().
Handle RTT::EventService::setupSyn | ( | const std::string & | ename, | |
boost::function< void(void)> | func, | |||
std::vector< DataSourceBase::shared_ptr > | args | |||
) | const |
For internal use only.
Setup a synchronous Event handler which will set args and then call func synchronously when event ename occurs.