41 #include "rtt-config.h" 42 #ifdef OROPKG_CORELIB_PROPERTIES_MARSHALLING 43 #include ORODAT_CORELIB_PROPERTIES_MARSHALLING_INCLUDE 44 #include ORODAT_CORELIB_PROPERTIES_DEMARSHALLING_INCLUDE 46 #include "../Logger.hpp" 47 #include "../TaskContext.hpp" 49 #include "../types/PropertyComposition.hpp" 57 : target(task->provides().get())
67 #ifndef OROPKG_CORELIB_PROPERTIES_MARSHALLING 68 log(
Error) <<
"No Property DemarshallInterface configured !" <<
endlog();
78 <<
"' with '"<<filename<<
"'."<<
endlog();
80 OROCLS_CORELIB_PROPERTIES_DEMARSHALLING_DRIVER* demarshaller = 0;
83 demarshaller =
new OROCLS_CORELIB_PROPERTIES_DEMARSHALLING_DRIVER (filename);
90 vector<ActionInterface*> assignComs;
92 if ( demarshaller->deserialize( propbag ) )
118 log(
Error) <<
"Some error occured while parsing "<< filename.c_str() <<
endlog();
124 <<
"Uncaught exception in deserialise !"<<
endlog();
129 #endif // OROPKG_CORELIB_PROPERTIES_MARSHALLING 136 #ifndef OROPKG_CORELIB_PROPERTIES_MARSHALLING 137 log(
Error) <<
"No Property DemarshallInterface configured !" <<
endlog();
147 <<
"' with '"<<filename<<
"'."<<
endlog();
148 bool failure =
false;
149 OROCLS_CORELIB_PROPERTIES_DEMARSHALLING_DRIVER* demarshaller = 0;
152 demarshaller =
new OROCLS_CORELIB_PROPERTIES_DEMARSHALLING_DRIVER (filename);
160 if ( demarshaller->deserialize( propbag ) )
181 log(
Error) <<
"Some error occured while parsing "<< filename.c_str() <<
endlog();
188 <<
"Uncaught exception in deserialise !"<<
endlog();
193 #endif // OROPKG_CORELIB_PROPERTIES_MARSHALLING 200 #ifndef OROPKG_CORELIB_PROPERTIES_MARSHALLING 204 std::ofstream file( filename.c_str() );
215 OROCLS_CORELIB_PROPERTIES_MARSHALLING_DRIVER<std::ostream> marshaller( file );
216 marshaller.serialize( allProps );
221 log(
Error) <<
"Could not open file "<< filename <<
" for writing."<<
endlog();
231 #ifndef OROPKG_CORELIB_PROPERTIES_MARSHALLING 232 log(
Error) <<
"No Property MarshallInterface configured !" <<
endlog();
238 <<
" does not have Properties to save." <<
endlog();
245 std::ifstream ifile( filename.c_str() );
251 OROCLS_CORELIB_PROPERTIES_DEMARSHALLING_DRIVER demarshaller( filename );
252 if ( demarshaller.deserialize( allProps ) == false ) {
260 return store(filename);
271 bool updater =
false;
280 if (updater ==
false) {
281 log(
Error) <<
"Could not update properties of file "<< filename <<
"."<<
endlog();
288 std::ofstream file( filename.c_str() );
291 OROCLS_CORELIB_PROPERTIES_MARSHALLING_DRIVER<std::ostream> marshaller( file );
292 marshaller.serialize( allProps );
296 log(
Error) <<
"Could not open file "<< filename <<
" for writing."<<
endlog();
310 #ifndef OROPKG_CORELIB_PROPERTIES_MARSHALLING 311 log(
Error) <<
"No Property DemarshallInterface configured !" <<
endlog();
315 log(
Info) <<
"Reading Property '" <<name
316 <<
"' from file '"<<filename<<
"'."<<
endlog();
317 bool failure =
false;
318 OROCLS_CORELIB_PROPERTIES_DEMARSHALLING_DRIVER* demarshaller = 0;
321 demarshaller =
new OROCLS_CORELIB_PROPERTIES_DEMARSHALLING_DRIVER (filename);
328 if ( demarshaller->deserialize( propbag ) )
341 log(
Error) <<
"Some error occured while parsing "<< filename.c_str() <<
endlog();
352 #endif // OROPKG_CORELIB_PROPERTIES_MARSHALLING 358 #ifndef OROPKG_CORELIB_PROPERTIES_MARSHALLING 359 log(
Error) <<
"No Property MarshallInterface configured !" <<
endlog();
367 std::ifstream ifile( filename.c_str() );
373 OROCLS_CORELIB_PROPERTIES_DEMARSHALLING_DRIVER demarshaller( filename );
374 if ( demarshaller.deserialize( fileProps ) == false ) {
395 log(
Error) <<
"Could not update properties of file "<< filename <<
"."<<
endlog();
400 std::ofstream file( filename.c_str() );
403 OROCLS_CORELIB_PROPERTIES_MARSHALLING_DRIVER<std::ostream> marshaller( file );
404 marshaller.serialize( fileProps );
405 log(
Info) <<
"Wrote Property "<<name <<
" to "<< filename <<
endlog();
408 log(
Error) <<
"Could not open file "<< filename <<
" for writing."<<
endlog();
const std::string & getName() const
bool updateProperty(PropertyBag &target, const PropertyBag &source, const std::string &name, const std::string &separator)
PropertyLoader(TaskContext *task)
bool updateProperties(PropertyBag &target, const PropertyBag &source)
bool configure(const std::string &filename, bool all=true) const
PropertyBag * properties()
bool refreshProperties(const PropertyBag &target, const PropertyBag &source, bool allprops)
bool copyProperties(PropertyBag &target, const PropertyBag &source)
This class fills up a given bag with the results of an introspection.
bool load(const std::string &filename) const
bool RTT_API composePropertyBag(PropertyBag const &sourcebag, PropertyBag &target)
A container for holding references to properties.
void introspect(const PropertyBag &v)
bool save(const std::string &filename, bool all=true) const
void deletePropertyBag(PropertyBag &target)
bool refreshProperty(const PropertyBag &target, const PropertyBase &source)
bool store(const std::string &filename) const
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
static Logger::LogFunction endlog()