Orocos Real-Time Toolkit
2.6.0
|
Load and save property files to a Service's PropertyBag. More...
#include <rtt/marsh/PropertyLoader.hpp>
Public Member Functions | |
PropertyLoader (TaskContext *task) | |
Constructor. | |
PropertyLoader (Service *service) | |
Constructor. | |
bool | load (const std::string &filename) const |
Read the XML cpf file and create (or refresh the matching properties) of the given Service. | |
bool | store (const std::string &filename) const |
Stores all properties of a Service in a new file or overwrite an existing one. | |
bool | configure (const std::string &filename, bool all=true) const |
Read the XML cpf file and 'refresh' the matching properties of the given Service. | |
bool | save (const std::string &filename, bool all=true) const |
Write the XML cpf file with the properties of the given Service. | |
bool | configure (const std::string &filename, const std::string &name) const |
Read a single property from a file. | |
bool | save (const std::string &filename, const std::string &name) const |
Write a single property to a file, or update an existing file. |
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.
PropertyLoader::PropertyLoader | ( | TaskContext * | task | ) |
Constructor.
task | The TaskContext to load the new properties into. |
Definition at line 56 of file PropertyLoader.cpp.
PropertyLoader::PropertyLoader | ( | Service * | service | ) |
Constructor.
service | The Service to load the new properties into. |
Definition at line 60 of file PropertyLoader.cpp.
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.
filename | The file to read from. |
all | Configure all properties of target. Return an error if not all properties were found in filename. |
Referenced by RTT::marsh::MarshallingService::readProperties(), RTT::marsh::MarshallingService::readProperty(), and RTT::marsh::MarshallingService::updateProperties().
bool RTT::marsh::PropertyLoader::configure | ( | const std::string & | filename, |
const std::string & | name | ||
) | const |
Read a single property from a file.
filename | The file to read from. |
name | The 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 |
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.
filename | The file to read from. |
Definition at line 64 of file PropertyLoader.cpp.
References RTT::types::composePropertyBag(), RTT::copyProperties(), RTT::deletePropertyBag(), RTT::Service::getName(), RTT::ConfigurationInterface::properties(), RTT::refreshProperties(), and RTT::updateProperties().
Referenced by RTT::marsh::MarshallingService::loadProperties().
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.
filename | The file to read from and write to (updating). |
all | Write out all properties of target to filename, add missing ones if necessary. |
Referenced by RTT::marsh::MarshallingService::updateFile(), RTT::marsh::MarshallingService::writeProperties(), and RTT::marsh::MarshallingService::writeProperty().
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.
filename | The file to update or write to. |
name | The 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 |
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.
filename | The file to store to. |
Definition at line 197 of file PropertyLoader.cpp.
References RTT::deletePropertyBag(), RTT::marsh::PropertyBagIntrospector::introspect(), and RTT::ConfigurationInterface::properties().
Referenced by RTT::marsh::MarshallingService::storeProperties().