Orocos Real-Time Toolkit
2.6.0
|
An object that expresses you wish to use a service. More...
#include <rtt/ServiceRequester.hpp>
Public Types | |
typedef std::vector< std::string > | RequesterNames |
typedef std::vector< std::string > | OperationCallerNames |
Public Member Functions | |
ServiceRequester (const std::string &name, TaskContext *owner=0) | |
const std::string & | getRequestName () const |
RequesterNames | getRequesterNames () const |
TaskContext * | getServiceOwner () const |
The owner is the top-level TaskContext owning this service (indirectly). | |
Service::shared_ptr | getReferencedService () |
Returns the service we're referencing. | |
bool | addOperationCaller (base::OperationCallerBaseInvoker &mbi) |
OperationCallerNames | getOperationCallerNames () const |
base::OperationCallerBaseInvoker * | getOperationCaller (const std::string &name) |
ServiceRequester * | requires () |
ServiceRequester * | requires (const std::string &service_name) |
bool | requiresService (const std::string &service_name) |
Query if this service requires certain sub-services. | |
bool | connectTo (Service::shared_ptr sp) |
Connects this service's methods to the operations provided by op. | |
bool | ready () const |
Returns true when all methods were resolved. | |
void | disconnect () |
Disconnects all methods from their implementation. | |
Protected Types | |
typedef std::map< std::string, ServiceRequester * > | Requests |
typedef std::map< std::string, base::OperationCallerBaseInvoker * > | OperationCallers |
Our methods. | |
Protected Attributes | |
Requests | mrequests |
the services we implement. | |
OperationCallers | mmethods |
std::string | mrname |
TaskContext * | mrowner |
Service::shared_ptr | mprovider |
An object that expresses you wish to use a service.
The ServiceRequester is symmetrical to the Service. Where a Service registers operations that a component can execute ('provides'), the ServiceRequester registers the methods that a caller wishes to call ('requires'). One method in a ServiceRequester maps to one operation in a Service.
Typical use is to inherit from ServiceRequester and add named OperationCaller objects to it using addOperationCaller.
Definition at line 64 of file ServiceRequester.hpp.
bool RTT::ServiceRequester::connectTo | ( | Service::shared_ptr | sp | ) |
Connects this service's methods to the operations provided by op.
This method tries to match as many as possible method-operation pairs.
You may call this function with different instances of sp to 'resolve' missing functions, only the non-connected methods will be further filled in.
sp | An interface-compatible Service. |
Definition at line 92 of file ServiceRequester.cpp.
References RTT::base::TaskCore::engine(), and ready().
Referenced by RTT::TaskContext::connectServices().
Service::shared_ptr RTT::ServiceRequester::getReferencedService | ( | ) |
Returns the service we're referencing.
In case you used connectTo to more than one service, this returns the service which was used when connectTo first returned true.
bool RTT::ServiceRequester::ready | ( | ) | const |
Returns true when all methods were resolved.
Definition at line 132 of file ServiceRequester.cpp.
Referenced by RTT::TaskContext::connectServices(), and connectTo().
bool RTT::ServiceRequester::requiresService | ( | const std::string & | service_name | ) | [inline] |
Query if this service requires certain sub-services.
service_name |
Definition at line 112 of file ServiceRequester.hpp.