Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes
RTT::Service Class Reference

#include <Service.hpp>

Inheritance diagram for RTT::Service:
Inheritance graph
[legend]

List of all members.

Public Types

typedef OperationInterface Factory
typedef std::vector< std::string > ProviderNames
typedef boost::shared_ptr
< const Service
shared_constptr
typedef boost::shared_ptr
< Service
shared_ptr

Public Member Functions

bool addLocalOperation (base::OperationBase &op)
template<class Signature >
Operation< Signature > & addOperation (Operation< Signature > &op)
template<class Func , class Class >
Operation< typename
internal::GetSignature< Func >
::Signature > & 
addOperation (const std::string name, Func func, Class *obj, ExecutionThread et=ClientThread)
template<class Func >
Operation< Func > & addOperation (const std::string name, Func *func, ExecutionThread et=ClientThread)
template<class Func , class ObjT >
Operation< typename
internal::GetSignatureDS< Func >
::Signature > & 
addOperationDS (const std::string &name, Func func, internal::DataSource< boost::shared_ptr< ObjT > > *sp, ExecutionThread et=ClientThread)
template<class Signature , class ObjT >
Operation< Signature > & addOperationDS (internal::DataSource< boost::shared_ptr< ObjT > > *sp, Operation< Signature > &op)
virtual bool addService (shared_ptr obj)
template<class Signature >
Operation< Signature > & addSynchronousOperation (Operation< Signature > &op)
template<class Func , class Class >
Operation< typename
internal::GetSignature< Func >
::Signature > & 
addSynchronousOperation (const std::string name, Func func, Class *obj, ExecutionThread et=ClientThread)
void clear ()
internal::OperationCallerC create (std::string name, ExecutionEngine *caller)
const std::string & doc () const
void doc (const std::string &description)
boost::shared_ptr
< base::DisposableInterface
getLocalOperation (std::string name)
const std::string & getName () const
OperationInterfacePartgetOperation (std::string name)
base::DataSourceBase::shared_ptr getOperation (std::string name, const std::vector< base::DataSourceBase::shared_ptr > &args, ExecutionEngine *caller) const
std::vector< std::string > getOperationNames () const
TaskContextgetOwner () const
ExecutionEnginegetOwnerExecutionEngine () const
shared_ptr getParent () const
virtual ProviderNames getProviderNames () const
shared_ptr getService (const std::string &service_name)
bool hasOperation (const std::string &name) const
bool hasService (const std::string &service_name)
Service::shared_ptr provides ()
Service::shared_ptr provides (const std::string &service_name)
void removeOperation (const std::string &name)
virtual void removeService (std::string const &service_name)
bool resetOperation (std::string name, base::OperationBase *impl)
 Service (const std::string &name, TaskContext *owner=0)
void setName (const std::string &name)
bool setOperationThread (std::string const &name, ExecutionThread et)
void setOwner (TaskContext *new_owner)
void setParent (shared_ptr new_parent)
virtual ~Service ()

Static Public Member Functions

static Service::shared_ptr Create (const std::string &name, TaskContext *owner=0)

Protected Types

typedef std::vector
< base::OperationBase * > 
OperationList
typedef std::map< std::string,
shared_ptr
Services
typedef std::map< std::string,
base::OperationBase * > 
SimpleOperations

Protected Member Functions

bool testOperation (base::OperationBase &op)

Protected Attributes

std::string mdescription
std::string mname
TaskContextmowner
OperationList ownedoperations
shared_ptr parent
Services services
 the services we implement.
SimpleOperations simpleoperations

Detailed Description

This class allows storage and retrieval of operations, ports, attributes and properties provided by a component.

Services can be nested in sub-services, but all sub-services will be owned by the same TaskContext.

Definition at line 96 of file Service.hpp.


Member Typedef Documentation

Definition at line 103 of file Service.hpp.

typedef std::vector<base::OperationBase*> RTT::Service::OperationList [protected]

Definition at line 570 of file Service.hpp.

typedef std::vector<std::string> RTT::Service::ProviderNames

Definition at line 106 of file Service.hpp.

typedef std::map< std::string, shared_ptr > RTT::Service::Services [protected]

Definition at line 564 of file Service.hpp.

typedef boost::shared_ptr<const Service> RTT::Service::shared_constptr

Definition at line 105 of file Service.hpp.

typedef boost::shared_ptr<Service> RTT::Service::shared_ptr
typedef std::map<std::string,base::OperationBase* > RTT::Service::SimpleOperations [protected]

Definition at line 569 of file Service.hpp.


Constructor & Destructor Documentation

RTT::Service::Service ( const std::string &  name,
TaskContext owner = 0 
)

Creates a Service with a name and an owner. Each service must be owned by a TaskContext and the owner can be set afterwards with setOwner.

Parameters:
nameThe name of this service.
ownerThe TaskContext that will execute the operations of this service.
Warning:
When using boost < 1.40, the owner is not stored in the Service, until the Service object is effectively added to the TaskContext.
See also:
getOwner()

Definition at line 59 of file Service.cpp.

RTT::Service::~Service ( ) [virtual]

Definition at line 68 of file Service.cpp.


Member Function Documentation

Add an Operation object to the operation interface. This version of addOperation does not add the Operation object to the remote interface and only to the local, in-process C++ interface.

Note:
Do not use this function unless you know what you're doing.
See also:
addOperation() for adding normal, remotely available operations.
Parameters:
opThe Operation object to add
Returns:
true if it could be added, false otherwise.

Definition at line 187 of file Service.cpp.

template<class Signature >
Operation<Signature>& RTT::Service::addOperation ( Operation< Signature > &  op) [inline]

Add an operation object to the interface. This version of addOperation exports an existing Operation object to the public interface of this component.

Parameters:
opThe operation object to add.
Returns:
The given parameter op

Definition at line 344 of file Service.hpp.

template<class Func , class Class >
Operation< typename internal::GetSignature<Func>::Signature >& RTT::Service::addOperation ( const std::string  name,
Func  func,
Class *  obj,
ExecutionThread  et = ClientThread 
) [inline]

Add an operation to the interface by means of a C++ Class member function. The function func must be a C++ member function and obj is the object having that function.

Parameters:
nameThe name of the new operation
funcA pointer to a function, for example, &Bar::foo (C++ class function).
objA pointer to the object that will execute the function.
etThe ExecutionThread choice: will the owning TaskContext of this service execute the function func in its own thread, or will the client's thread (the caller) execute func ?
Returns:
A newly created operation object, which you may further document or query.

Definition at line 405 of file Service.hpp.

template<class Func >
Operation< Func >& RTT::Service::addOperation ( const std::string  name,
Func *  func,
ExecutionThread  et = ClientThread 
) [inline]

Add an operation to the interface by means of a free C/C++ function. The function func must be a free C/C++ function.

Parameters:
nameThe name of the new operation
funcA pointer to a C function, for example, &foo (or a static C++ class function).
etThe ExecutionThread choice: will the owning TaskContext of this service execute the function func in its own thread, or will the client's thread (the caller) execute func ?
Returns:
A newly created operation object, which you may further document or query.

Definition at line 426 of file Service.hpp.

template<class Func , class ObjT >
Operation< typename internal::GetSignatureDS<Func>::Signature>& RTT::Service::addOperationDS ( const std::string &  name,
Func  func,
internal::DataSource< boost::shared_ptr< ObjT > > *  sp,
ExecutionThread  et = ClientThread 
) [inline]

For internal use only. The pointer of the object of which a member function must be invoked is stored in a internal::DataSource such that the pointer can change during program execution. Required in scripting for state machines.

Definition at line 509 of file Service.hpp.

template<class Signature , class ObjT >
Operation<Signature>& RTT::Service::addOperationDS ( internal::DataSource< boost::shared_ptr< ObjT > > *  sp,
Operation< Signature > &  op 
) [inline]

For internal use only. The pointer of the object of which a member function must be invoked is stored in a internal::DataSource such that the pointer can change during program execution. Required in scripting for state machines.

Definition at line 524 of file Service.hpp.

Add a new sub-service to this Service.

Parameters:
objThis object becomes owned by this Service.
Note:
obj will take a Service::shared_ptr to this and vice versa. In case this Service is not yet reference counted, obj will hold the only reference count to this.
Returns:
true if it could be added, false if such service already exists.

Definition at line 83 of file Service.cpp.

template<class Signature >
Operation<Signature>& RTT::Service::addSynchronousOperation ( Operation< Signature > &  op) [inline]

Add an operation object to the interface. This version exports an existing Operation object to the synchronous interface of the component

Parameters:
opThe operation object to add.
Returns:
The given parameter op

Definition at line 382 of file Service.hpp.

template<class Func , class Class >
Operation< typename internal::GetSignature<Func>::Signature >& RTT::Service::addSynchronousOperation ( const std::string  name,
Func  func,
Class *  obj,
ExecutionThread  et = ClientThread 
) [inline]

Add an operation to the synchronous interface by means of a function. The function func must be a C++ Class member function.

Parameters:
nameThe name of the new operation
funcA pointer to a function, for example &Bar::foo (C++ class function).
objA pointer to the object that will execute the function in case of a C++ class function,
etThe ExecutionThread choice: will the owning TaskContext of this service execute the function func in its own thread, or will the client's thread (the caller) execute func ?
Returns:
A newly created operation object, which you may further document or query.

Definition at line 495 of file Service.hpp.

Clear all added operations, properties and sub-services from this Service.

Note:
Since sub-services hold a reference to this Service, clear() may also delete this Service. In order to protect against such deletion, take a Service::shared_ptr to this before calling clear().

Reimplemented from RTT::ConfigurationInterface.

Reimplemented in RTT::scripting::ScriptingService.

Definition at line 219 of file Service.cpp.

Service::shared_ptr RTT::Service::Create ( const std::string &  name,
TaskContext owner = 0 
) [static]

Creates a Service with a name and an owner. Each service must be owned by a TaskContext and the owner can be set afterwards with setOwner.

Parameters:
nameThe name of this service.
ownerThe TaskContext that will execute the operations of this service.
Warning:
When using boost < 1.40, the owner is not stored in the Service, until the Service object is effectively added to the TaskContext.
See also:
getOwner()

Definition at line 52 of file Service.cpp.

internal::OperationCallerC RTT::Service::create ( std::string  name,
ExecutionEngine caller 
)

Create a OperationCallerC object, a template-less operation invocation object. This function is inferior to getOperation(std::string name).

Parameters:
nameThe name of the operation
Returns:
An object which can invoke a operation.

Definition at line 285 of file Service.cpp.

const std::string& RTT::Service::doc ( ) const [inline]

Returns a descriptive text for this service.

Definition at line 147 of file Service.hpp.

void RTT::Service::doc ( const std::string &  description) [inline]

Sets the descriptive text for this service.

Definition at line 152 of file Service.hpp.

boost::shared_ptr< base::DisposableInterface > RTT::Service::getLocalOperation ( std::string  name)

Get a locally added operation from this interface.

Note:
Do not use this function unless you know what you're doing.
See also:
getOperation() for getting normal, remotely available operations.

Definition at line 212 of file Service.cpp.

const std::string& RTT::Service::getName ( ) const [inline]

Returns the name of this service instance.

Definition at line 142 of file Service.hpp.

Get a previously added operation for use in a C++ OperationCaller object. Store the result of this function in a OperationCaller<Signature> object.

Parameters:
nameThe name of the operation to retrieve.
Returns:
A pointer to an operation interface part or a null pointer if name was not found.

Definition at line 151 of file Service.cpp.

base::DataSourceBase::shared_ptr RTT::Service::getOperation ( std::string  name,
const std::vector< base::DataSourceBase::shared_ptr > &  args,
ExecutionEngine caller 
) const [inline]

For internal use only. Get a previously added operation as a DataSource. This function is inferior to getOperation(std::string name)

Parameters:
nameThe name of the operation
argsThe arguments of the operation as Data Sources.
Returns:
A internal::DataSource which, when evaluated, invokes the operation.

Definition at line 543 of file Service.hpp.

std::vector< std::string > RTT::Service::getOperationNames ( ) const

Returns the names of all operations added to this interface.

See also:
getNames() to get a list of all operations available to scripting.

Definition at line 236 of file Service.cpp.

TaskContext* RTT::Service::getOwner ( ) const [inline]

The owner is the top-level TaskContext owning this service (indirectly). A Service can only belong to one TaskContext.

Note:
This function will only return the owner after the Service has been added to the TaskContext.

Reimplemented from RTT::DataFlowInterface.

Definition at line 188 of file Service.hpp.

Return the execution engine of this service owner.

See also:
getOwner

Definition at line 77 of file Service.cpp.

shared_ptr RTT::Service::getParent ( ) const [inline]

The parent is the direct parent of this service.

Definition at line 174 of file Service.hpp.

vector< string > RTT::Service::getProviderNames ( ) const [virtual]

Return a standard container which contains all the sub-service names of this Service

Definition at line 73 of file Service.cpp.

Service::shared_ptr RTT::Service::getService ( const std::string &  service_name)

Returns a shared pointer to strictly a sub-service of a null pointer if !hasService(service_name). This method will not return the this pointer when service_name equals "this" or create new service objects.

Parameters:
service_nameThe name of the sub-service to be returned. or created, or the result of provides() in case of "this".

Definition at line 144 of file Service.cpp.

bool RTT::Service::hasOperation ( const std::string &  name) const

Query for the existence of a Operation in this interface.

See also:
hasMember() to verify if a operation is available to scripting as well.

Definition at line 242 of file Service.cpp.

bool RTT::Service::hasService ( const std::string &  service_name)

Check if this service has the sub-service service_name.

Parameters:
service_nameThe name of the sub-service to be queried.

Definition at line 181 of file Service.cpp.

Returns this Service, unless no shared_ptr yet exists.

Returns:
a shared pointer from this.
Exceptions:
std::runtime_exceptionwhen no Service::shared_ptr to this exists yet.

Definition at line 114 of file Service.cpp.

Service::shared_ptr RTT::Service::provides ( const std::string &  service_name)

Returns a sub-Service which resorts under this Service, creating a new one if it does not yet exists. Use getService() if no Service object creation should be done.

Parameters:
service_nameThe name of the sub-service to be returned or created, or the result of provides() in case of "this".
See also:
provides() for querying for "this".

Definition at line 124 of file Service.cpp.

void RTT::Service::removeOperation ( const std::string &  name)

Removes a previously added operation.

Definition at line 248 of file Service.cpp.

void RTT::Service::removeService ( std::string const &  service_name) [virtual]

Remove a previously added sub-service, potentially freeing it (and this) from memory.

Parameters:
service_namethe name of the service to remove.
Note:
Since service_name holds a reference to this Service, removeService may also delete this Service. In order to protect against such deletion, take a Service::shared_ptr to this before calling removeService.

Definition at line 105 of file Service.cpp.

bool RTT::Service::resetOperation ( std::string  name,
base::OperationBase impl 
)

Reset the implementation of a operation.

Definition at line 161 of file Service.cpp.

void RTT::Service::setName ( const std::string &  name) [inline]

Changes the name of this service.

Definition at line 157 of file Service.hpp.

bool RTT::Service::setOperationThread ( std::string const &  name,
ExecutionThread  et 
)

Sets the thread of execution of a previously added operation. Only the component itself should modify this property. Don't call this function from outside the component, it has unspecified behaviour when not called from within one of the member functions or a service of the current component.

This function is typically used to change the ExecutionThread of the standard component hooks such as startHook(), configureHook() etc. which all have the ClientThread policy by default.

Parameters:
nameThe name of the operation to modify. For example, "start".
etThe ExecutionThread type in which the function of the operation will be executed, being OwnThread or ClientThread.
Returns:
true if name was a local, present operation, false otherwise.

Definition at line 169 of file Service.cpp.

void RTT::Service::setOwner ( TaskContext new_owner)

Sets the owning TaskContext that will execute the operations in this service.

Definition at line 260 of file Service.cpp.

Sets the parent service in case this service is a sub-service.

Definition at line 281 of file Service.cpp.


Member Data Documentation

std::string RTT::Service::mdescription [protected]

Definition at line 574 of file Service.hpp.

std::string RTT::Service::mname [protected]

Definition at line 573 of file Service.hpp.

Definition at line 575 of file Service.hpp.

Definition at line 572 of file Service.hpp.

Definition at line 576 of file Service.hpp.

the services we implement.

Definition at line 566 of file Service.hpp.

Definition at line 571 of file Service.hpp.


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


rtt
Author(s): RTT Developers
autogenerated on Wed Aug 26 2015 16:16:23