Orocos Real-Time Toolkit  2.9.0
Public Types | Public Member Functions | Public Attributes | Protected Types | Protected Attributes | List of all members
RTT::Marshalling Class Reference

Service requester to load and save properties of a TaskContext. More...

#include <rtt/marsh/Marshalling.hpp>

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

Public Types

typedef std::vector< std::string > RequesterNames
 
typedef std::vector< std::string > OperationCallerNames
 
typedef boost::shared_ptr< ServiceRequestershared_ptr
 
typedef boost::shared_ptr< const ServiceRequestershared_constptr
 

Public Member Functions

 Marshalling (TaskContext *parent)
 This object is normally created by a TaskContext. More...
 
 ~Marshalling ()
 
const std::string & getRequestName () const
 
RequesterNames getRequesterNames () const
 
TaskContextgetServiceOwner () const
 The owner is the top-level TaskContext owning this service (indirectly). More...
 
void setOwner (TaskContext *new_owner)
 Sets the owning TaskContext that is considered as the caller of requested operations. More...
 
Service::shared_ptr getReferencedService ()
 Returns the service we're referencing. More...
 
bool addOperationCaller (base::OperationCallerBaseInvoker &mbi)
 
OperationCallerNames getOperationCallerNames () const
 
base::OperationCallerBaseInvokergetOperationCaller (const std::string &name)
 
ServiceRequester::shared_ptr requires ()
 
ServiceRequester::shared_ptr requires (const std::string &service_name)
 
bool addServiceRequester (shared_ptr obj)
 Add a new ServiceRequester to this TaskContext. More...
 
bool requiresService (const std::string &service_name)
 Query if this service requires certain sub-services. More...
 
virtual bool connectTo (Service::shared_ptr sp)
 Connects this service's methods to the operations provided by op. More...
 
virtual bool ready () const
 Returns true when all methods were resolved. More...
 
virtual void disconnect ()
 Disconnects all methods from their implementation. More...
 
virtual void clear ()
 Remove all operation callers from this service requester. More...
 

Public Attributes

OperationCaller< bool(const std::string &filename)> loadProperties
 Read a property file and update (or create any missing) properties in the TaskContext. More...
 
OperationCaller< bool(const std::string &filename)> storeProperties
 Stores all properties of parent TaskContext in a new file or overwrite an existing one. More...
 
OperationCaller< bool(const std::string &filename)> readProperties
 Read the property file and 'refresh' all the properties of the TaskContext. More...
 
OperationCaller< bool(const std::string &filename)> updateProperties
 Read the property file and 'refresh' some properties of the TaskContext. More...
 
OperationCaller< bool(const std::string &name, const std::string &filename)> readProperty
 Read a single property from a file. More...
 
OperationCaller< bool(const std::string &filename)> writeProperties
 Write the property file with the properties of a TaskContext. More...
 
OperationCaller< bool(const std::string &filename)> updateFile
 Write the property file with the properties of a TaskContext, which are already present in filename. More...
 
OperationCaller< bool(const std::string &name, const std::string &filename)> writeProperty
 Write a single property to a file. More...
 

Protected Types

typedef std::map< std::string, ServiceRequester::shared_ptrRequests
 
typedef std::map< std::string, base::OperationCallerBaseInvoker * > OperationCallers
 Our methods. More...
 

Protected Attributes

Requests mrequests
 the services we implement. More...
 
OperationCallers mmethods
 
std::string mrname
 
TaskContextmrowner
 
Service::shared_ptr mprovider
 

Detailed Description

Service requester to load and save properties of a TaskContext.

Definition at line 53 of file Marshalling.hpp.

Member Typedef Documentation

typedef std::vector<std::string> RTT::ServiceRequester::OperationCallerNames
inherited

Definition at line 86 of file ServiceRequester.hpp.

typedef std::map<std::string, base::OperationCallerBaseInvoker*> RTT::ServiceRequester::OperationCallers
protectedinherited

Our methods.

Definition at line 186 of file ServiceRequester.hpp.

typedef std::vector<std::string> RTT::ServiceRequester::RequesterNames
inherited

Definition at line 85 of file ServiceRequester.hpp.

typedef std::map< std::string, ServiceRequester::shared_ptr > RTT::ServiceRequester::Requests
protectedinherited

Definition at line 181 of file ServiceRequester.hpp.

typedef boost::shared_ptr<const ServiceRequester> RTT::ServiceRequester::shared_constptr
inherited

Definition at line 88 of file ServiceRequester.hpp.

typedef boost::shared_ptr<ServiceRequester> RTT::ServiceRequester::shared_ptr
inherited

Constructor & Destructor Documentation

RTT::Marshalling::Marshalling ( TaskContext parent)
RTT::Marshalling::~Marshalling ( )

Definition at line 64 of file Marshalling.cpp.

Member Function Documentation

bool RTT::ServiceRequester::addOperationCaller ( base::OperationCallerBaseInvoker mbi)
inherited
bool RTT::ServiceRequester::addServiceRequester ( ServiceRequester::shared_ptr  obj)
inherited

Add a new ServiceRequester to this TaskContext.

Parameters
objThis object becomes owned by this TaskContext.
Returns
true if it could be added, false if such service requester already exists.

Definition at line 126 of file ServiceRequester.cpp.

References RTT::Error, RTT::ServiceRequester::mrequests, and RTT::ServiceRequester::mrowner.

Referenced by RTT::ServiceRequester::requires().

void RTT::ServiceRequester::clear ( )
virtualinherited

Remove all operation callers from this service requester.

Definition at line 189 of file ServiceRequester.cpp.

References RTT::ServiceRequester::mmethods, and RTT::ServiceRequester::mrequests.

bool RTT::ServiceRequester::connectTo ( Service::shared_ptr  sp)
virtualinherited

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 140 of file ServiceRequester.cpp.

References RTT::Debug, RTT::base::TaskCore::engine(), RTT::Info, RTT::ServiceRequester::mmethods, RTT::ServiceRequester::mprovider, RTT::ServiceRequester::mrname, RTT::ServiceRequester::mrowner, and RTT::ServiceRequester::ready().

void RTT::ServiceRequester::disconnect ( )
virtualinherited

Disconnects all methods from their implementation.

Definition at line 172 of file ServiceRequester.cpp.

References RTT::base::OperationCallerBaseInvoker::disconnect(), and RTT::ServiceRequester::mmethods.

OperationCallerBaseInvoker * RTT::ServiceRequester::getOperationCaller ( const std::string &  name)
inherited

Definition at line 84 of file ServiceRequester.cpp.

References RTT::ServiceRequester::mmethods.

std::vector< std::string > RTT::ServiceRequester::getOperationCallerNames ( ) const
inherited

Definition at line 74 of file ServiceRequester.cpp.

References RTT::internal::keys(), and RTT::ServiceRequester::mmethods.

Service::shared_ptr RTT::ServiceRequester::getReferencedService ( )
inlineinherited

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.

Definition at line 120 of file ServiceRequester.hpp.

std::vector< std::string > RTT::ServiceRequester::getRequesterNames ( ) const
inherited

Definition at line 79 of file ServiceRequester.cpp.

References RTT::internal::keys(), and RTT::ServiceRequester::mrequests.

const std::string& RTT::ServiceRequester::getRequestName ( ) const
inlineinherited

Definition at line 98 of file ServiceRequester.hpp.

TaskContext* RTT::ServiceRequester::getServiceOwner ( ) const
inlineinherited

The owner is the top-level TaskContext owning this service (indirectly).

Definition at line 106 of file ServiceRequester.hpp.

bool RTT::ServiceRequester::ready ( ) const
virtualinherited

Returns true when all methods were resolved.

Returns

Definition at line 179 of file ServiceRequester.cpp.

References RTT::Debug, and RTT::ServiceRequester::mmethods.

Referenced by RTT::ServiceRequester::connectTo().

ServiceRequester::shared_ptr RTT::ServiceRequester::requires ( )
inherited

Definition at line 103 of file ServiceRequester.cpp.

References RTT::Error.

Referenced by RTT::ServiceRequester::requires().

ServiceRequester::shared_ptr RTT::ServiceRequester::requires ( const std::string &  service_name)
inherited
bool RTT::ServiceRequester::requiresService ( const std::string &  service_name)
inlineinherited

Query if this service requires certain sub-services.

Parameters
service_name
Returns

Definition at line 147 of file ServiceRequester.hpp.

void RTT::ServiceRequester::setOwner ( TaskContext new_owner)
inherited

Sets the owning TaskContext that is considered as the caller of requested operations.

Definition at line 92 of file ServiceRequester.cpp.

References RTT::base::TaskCore::engine(), RTT::ServiceRequester::mmethods, RTT::ServiceRequester::mrequests, and RTT::ServiceRequester::mrowner.

Member Data Documentation

OperationCaller<bool (const std::string& filename)> RTT::Marshalling::loadProperties

Read a property file and update (or create any missing) properties in the TaskContext.

This function allows to dynamically add properties to a component. This can be useful in combination with Orocos scripts when the script requires additional properties from the parent TaskContext.

Definition at line 70 of file Marshalling.hpp.

Referenced by Marshalling().

OperationCallers RTT::ServiceRequester::mmethods
protectedinherited
Service::shared_ptr RTT::ServiceRequester::mprovider
protectedinherited

Definition at line 191 of file ServiceRequester.hpp.

Referenced by RTT::ServiceRequester::connectTo().

Requests RTT::ServiceRequester::mrequests
protectedinherited
std::string RTT::ServiceRequester::mrname
protectedinherited

Definition at line 189 of file ServiceRequester.hpp.

Referenced by RTT::ServiceRequester::connectTo().

TaskContext* RTT::ServiceRequester::mrowner
protectedinherited
OperationCaller<bool (const std::string& filename)> RTT::Marshalling::readProperties

Read the property file and 'refresh' all the properties of the TaskContext.

There may be more properties in the file than properties in the TaskContext, but all properties of the TaskContext must be present in filename. In case a type mismatch occurs, this method will fail and update no properties.

Parameters
filenameThe file to read from.
Returns
true on success, false on error, consult Logger output for messages.

Definition at line 90 of file Marshalling.hpp.

Referenced by Marshalling().

OperationCaller<bool (const std::string& name,const std::string& filename)> RTT::Marshalling::readProperty

Read a single property from a file.

The name may be a 'path' like location of a Property in the hierarchy.

Parameters
nameThe name of the property in the file. For example "MyProp" for a top-level property or "Settings.XML.Editor" to specify a dot-separated 'path' to the property 'Editor'.
filenameThe name of the file in which to lookup name.

Definition at line 111 of file Marshalling.hpp.

Referenced by Marshalling().

OperationCaller<bool (const std::string& filename)> RTT::Marshalling::storeProperties

Stores all properties of parent TaskContext in a new file or overwrite an existing one.

The file given in filename will always be overwritten and any existing content will be lost.

Parameters
filenameThe file to store to.
Returns
true on success, false on error, consult Logger output for messages.
See also
loadProperties() for loading properties in a TaskContext.

Definition at line 80 of file Marshalling.hpp.

Referenced by Marshalling().

OperationCaller<bool (const std::string& filename)> RTT::Marshalling::updateFile

Write the property file with the properties of a TaskContext, which are already present in filename.

No new entries are created in the file, only existing ones are updated. The file is first read in, the resulting tree is updated with the task's properties, and then written to disk again.

Parameters
filenameThe file to read from and write to.
Returns
true on success, false on error, consult Logger output for messages.

Definition at line 132 of file Marshalling.hpp.

Referenced by Marshalling().

OperationCaller<bool (const std::string& filename)> RTT::Marshalling::updateProperties

Read the property file and 'refresh' some properties of the TaskContext.

There may be more properties in the file than properties in the TaskContext, and some may be missing in the file. This method will update 'as much as possible' properties. In case a type mismatch occurs, this method will fail and update no properties.

Parameters
filenameThe file to read all the properties from.
Returns
true on success, false on error, consult Logger output for messages.

Definition at line 101 of file Marshalling.hpp.

Referenced by Marshalling().

OperationCaller<bool (const std::string& filename)> RTT::Marshalling::writeProperties

Write the property file with the properties of a TaskContext.

The file is first read in, the resulting tree is updated with the task's properties and then written to disk again. This allows to share files between tasks.

Parameters
filenameThe file to read from and write to (updating).
Returns
true on success, false on error, consult Logger output for messages.

Definition at line 121 of file Marshalling.hpp.

Referenced by Marshalling().

OperationCaller<bool (const std::string& name, const std::string& filename)> RTT::Marshalling::writeProperty

Write a single property to a file.

The name may be a 'path' like location of a Property in the hierarchy.

Parameters
nameThe name of the property in the file. For example "MyProp" for a top-level property or "Settings.XML.Editor" to specify a dot-separated 'path' to the property 'Editor'.
filenameThe name of the file in which to write name.

Definition at line 142 of file Marshalling.hpp.

Referenced by Marshalling().


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