Orocos Real-Time Toolkit  2.6.0
Public Types | Public Member Functions | Protected Types | Protected Attributes
RTT::ServiceRequester Class Reference

An object that expresses you wish to use a service. More...

#include <rtt/ServiceRequester.hpp>

Inheritance diagram for RTT::ServiceRequester:
RTT::Marshalling RTT::Scripting

List of all members.

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
TaskContextgetServiceOwner () 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::OperationCallerBaseInvokergetOperationCaller (const std::string &name)
ServiceRequesterrequires ()
ServiceRequesterrequires (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
TaskContextmrowner
Service::shared_ptr mprovider

Detailed Description

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.

See also:
RTT::Scripting for an example.

Definition at line 64 of file ServiceRequester.hpp.


Member Function Documentation

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.

Parameters:
spAn interface-compatible Service.
Returns:
true if all methods of that are required are provided, false if not all methods could yet be matched.

Definition at line 92 of file ServiceRequester.cpp.

References RTT::base::TaskCore::engine(), and ready().

Referenced by RTT::TaskContext::connectServices().

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.

Returns true when all methods were resolved.

Returns:

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.

Parameters:
service_name
Returns:

Definition at line 112 of file ServiceRequester.hpp.


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