Orocos Real-Time Toolkit  2.9.0
Public Member Functions | List of all members
RTT::marsh::PropertyLoader Class Reference

Load and save property files to a Service's PropertyBag. More...

#include <rtt/marsh/PropertyLoader.hpp>

Public Member Functions

 PropertyLoader (TaskContext *task)
 Constructor. More...
 
 PropertyLoader (Service *service)
 Constructor. More...
 
bool load (const std::string &filename) const
 Read the XML cpf file and create (or refresh the matching properties) of the given Service. More...
 
bool store (const std::string &filename) const
 Stores all properties of a Service in a new file or overwrite an existing one. More...
 
bool configure (const std::string &filename, bool all=true) const
 Read the XML cpf file and 'refresh' the matching properties of the given Service. More...
 
bool save (const std::string &filename, bool all=true) const
 Write the XML cpf file with the properties of the given Service. More...
 
bool configure (const std::string &filename, const std::string &name) const
 Read a single property from a file. More...
 
bool save (const std::string &filename, const std::string &name) const
 Write a single property to a file, or update an existing file. More...
 

Detailed Description

Load and save property files to a Service's PropertyBag.

The default file format is 'cpf' from the CPFMarshaller class.

Definition at line 53 of file PropertyLoader.hpp.

Constructor & Destructor Documentation

PropertyLoader::PropertyLoader ( TaskContext task)

Constructor.

Parameters
taskThe TaskContext to load the new properties into.

Definition at line 56 of file PropertyLoader.cpp.

PropertyLoader::PropertyLoader ( Service service)

Constructor.

Parameters
serviceThe Service to load the new properties into.

Definition at line 60 of file PropertyLoader.cpp.

Member Function Documentation

bool RTT::marsh::PropertyLoader::configure ( const std::string &  filename,
bool  all = true 
) const

Read the XML cpf file and 'refresh' the matching properties of the given Service.

There may be more properties in the file than properties in the target.

Parameters
filenameThe file to read from.
allConfigure all properties of target. Return an error if not all properties were found in filename.
Returns
true on success, false on error, consult Logger output for messages.
See also
save() to create this file.

Referenced by load(), RTT::marsh::MarshallingService::readProperties(), RTT::marsh::MarshallingService::readProperty(), RTT::marsh::MarshallingService::readServiceProperties(), RTT::marsh::MarshallingService::readServiceProperty(), store(), RTT::marsh::MarshallingService::updateProperties(), and RTT::marsh::MarshallingService::updateServiceProperties().

bool RTT::marsh::PropertyLoader::configure ( const std::string &  filename,
const std::string &  name 
) const

Read a single property from a file.

Parameters
filenameThe file to read from.
nameThe path to or name of a property in target. Separate path components with dots. For example, to safe property x: bag_1.bag_2.x
Returns
true on success, false on error, consult Logger output for messages.
bool PropertyLoader::load ( const std::string &  filename) const

Read the XML cpf file and create (or refresh the matching properties) of the given Service.

Any property in the file which is not in the target, is created in the target.

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

Definition at line 64 of file PropertyLoader.cpp.

References RTT::types::composePropertyBag(), configure(), RTT::copyProperties(), RTT::deletePropertyBag(), RTT::Error, RTT::Service::getName(), RTT::Info, OROCLS_CORELIB_PROPERTIES_DEMARSHALLING_DRIVER, RTT::ConfigurationInterface::properties(), RTT::refreshProperties(), and RTT::updateProperties().

Referenced by RTT::marsh::MarshallingService::loadProperties(), and RTT::marsh::MarshallingService::loadServiceProperties().

bool RTT::marsh::PropertyLoader::save ( const std::string &  filename,
bool  all = true 
) const

Write the XML cpf file with the properties of the given Service.

The file is first read into memory, 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).
allWrite out all properties of target to filename, add missing ones if necessary.
Returns
true on success, false on error, consult Logger output for messages.
See also
configure() to re-read this file and update matching properties.

Referenced by store(), RTT::marsh::MarshallingService::updateFile(), RTT::marsh::MarshallingService::updateServiceFile(), RTT::marsh::MarshallingService::writeProperties(), RTT::marsh::MarshallingService::writeProperty(), RTT::marsh::MarshallingService::writeServiceProperties(), and RTT::marsh::MarshallingService::writeServiceProperty().

bool RTT::marsh::PropertyLoader::save ( const std::string &  filename,
const std::string &  name 
) const

Write a single property to a file, or update an existing file.

Parameters
filenameThe file to update or write to.
nameThe path to or name of a property in target. Separate path components with dots. For example, to safe property x: bag_1.bag_2.x
Returns
true on success, false on error, consult Logger output for messages.
bool PropertyLoader::store ( const std::string &  filename) const

Stores all properties of a Service 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
load() for loading properties in a Service.

Definition at line 197 of file PropertyLoader.cpp.

References RTT::types::composePropertyBag(), configure(), RTT::deletePropertyBag(), RTT::Error, RTT::Service::getName(), RTT::Info, RTT::marsh::PropertyBagIntrospector::introspect(), OROCLS_CORELIB_PROPERTIES_DEMARSHALLING_DRIVER, RTT::ConfigurationInterface::properties(), RTT::refreshProperties(), RTT::refreshProperty(), save(), RTT::updateProperties(), and RTT::updateProperty().

Referenced by RTT::marsh::MarshallingService::storeProperties(), and RTT::marsh::MarshallingService::storeServiceProperties().


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