#include <rtt/EventService.hpp>

It stores pointers to event objects and allows clients to retrieve event objects which can then be emitted or subscribed to.
Definition at line 65 of file 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. | |
| ~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. | |
| ResultT | produce (const std::string &name, const PropertyBag &args) const |
| Produce an object that contains an operation. | |
| ResultT | 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< ResultT > *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, ActivityInterface *t, EventProcessor::AsynStorageType s_type=EventProcessor::OnlyFirst) const |
| For internal use only. | |
| 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 < ResultT > * > | map_t |
Protected Attributes | |
| map_t | data |
| 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.
Definition at line 51 of file EventService.cpp.
| 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.
Definition at line 52 of file EventService.cpp.
| std::vector< std::string > getEvents | ( | ) | const |
Returns the names of all events added to this interface.
Definition at line 68 of file EventService.cpp.
References RTT::keys().
| bool 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 123 of file EventService.hpp.
References RTT::Debug, and RTT::Error.
| boost::shared_ptr<ActionInterface> 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 151 of file EventService.hpp.
Referenced by EventC::D::checkAndCreate().
| bool 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 168 of file EventService.hpp.
| bool 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 197 of file EventService.hpp.
| bool 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 230 of file EventService.hpp.
| 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 | |||
| ) | [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 267 of file EventService.hpp.
| 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 | |||
| ) | [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 307 of file EventService.hpp.
| bool hasEvent | ( | const std::string & | ename | ) | const |
Query for the existence of an Event in this Service.
Definition at line 63 of file EventService.cpp.
Referenced by EventC::D::checkAndCreate().
| int arity | ( | const std::string & | name | ) | const |
Return the number of arguments a given event has.
| -1 | The event does not exist. |
Definition at line 73 of file EventService.cpp.
References OperationFactory::getArity().
Referenced by EventC::D::checkAndCreate(), and EventC::emit().
| EventC 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();
Definition at line 108 of file EventService.cpp.
References RTT::Error.
| ConnectionC 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 |
Definition at line 116 of file EventService.cpp.
References RTT::Error.
| Handle 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.
| ename | The name of the previously added Event. | |
| func | A function object which will be called. | |
| args | The arguments which will be set before func 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. |
Definition at line 124 of file EventService.cpp.
References RTT::Error, and EventHookBase::setupSyn().
Referenced by ConnectionC::D::checkAndCreate().
| Handle setupAsyn | ( | const std::string & | ename, | |
| boost::function< void(void)> | afunc, | |||
| const std::vector< DataSourceBase::shared_ptr > & | args, | |||
| ActivityInterface * | t, | |||
| 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. |
Referenced by ConnectionC::D::checkAndCreate().
| 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.
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. |
Definition at line 137 of file EventService.cpp.
References RTT::Error, and EventHookBase::setupAsyn().
| ActionInterface * 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(). |
Definition at line 152 of file EventService.cpp.
References OperationFactory::produce().
| int 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.
Referenced by EventService::arity(), MethodC::D::checkAndCreate(), CommandC::D::checkAndCreate(), MethodC::execute(), and CommandC::execute().
| ResultT 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.
Referenced by MethodC::D::checkAndCreate(), CommandC::D::checkAndCreate(), CommandRepository::getCommand(), CommandRepository::getCondition(), EventService::getEvent(), and MethodRepository::getMethod().
| ResultT 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.
| Descriptions 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.
| std::string 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.
| std::string 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.
| void add | ( | const std::string & | name, | |
| detail::OperationFactoryPart< ResultT > * | 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.
Referenced by ControlTaskProxy::fetchObjects(), and ControlTaskProxy::synchronize().
| void 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.
1.5.3