MarshallingAccess.cpp

00001 
00002 #include "RTT.hpp"
00003 #include "MarshallingAccess.hpp"
00004 #include "TaskContext.hpp"
00005 #include "TaskObject.hpp"
00006 
00007 #if !defined(ORO_EMBEDDED) && defined(OROPKG_EXECUTION_PROGRAM_PARSER)
00008 #include "Method.hpp"
00009 #endif
00010 #include "PropertyLoader.hpp" 
00011 
00012 namespace RTT
00013 {
00014     MarshallingAccess::MarshallingAccess(TaskContext* parent)
00015         : mparent(parent)
00016     {
00017 #if !defined(ORO_EMBEDDED) && defined(OROPKG_EXECUTION_PROGRAM_PARSER)
00018         OperationInterface* obj = parent->getObject("marshalling");
00019         if (!obj)
00020             obj = new TaskObject("marshalling","Read and write Properties to a file.");
00021         obj->methods()->addMethod(method("updateProperties",&MarshallingAccess::updateProperties, this),
00022                                   "Read some Properties from a file.",
00023                                   "Filename","The file to read the Properties from.");
00024         obj->methods()->addMethod(method("readProperties",&MarshallingAccess::readProperties, this),
00025                                   "Read all Properties from a file.",
00026                                   "Filename","The file to read the Properties from.");
00027         obj->methods()->addMethod(method("readProperty",&MarshallingAccess::readProperty, this),
00028                                   "Read a single Property from a file.",
00029                                   "Name", "The name of (or the path to) the property to read.",
00030                                   "Filename","The file to read the Properties from.");
00031 
00032         obj->methods()->addMethod(method("updateFile",&MarshallingAccess::updateFile, this),
00033                                   "Write some Properties to a file.",
00034                                   "Filename","The file to write the Properties to.");
00035         obj->methods()->addMethod(method("writeProperties",&MarshallingAccess::writeProperties, this),
00036                                   "Write all Properties to a file.",
00037                                   "Filename","The file to write the Properties to.");
00038         obj->methods()->addMethod(method("writeProperty",&MarshallingAccess::writeProperty, this),
00039                                   "Write a single Properties to a file.",
00040                                   "Name", "The name of (or the path to) the property to write.",
00041                                   "Filename","The file to write the Properties to.");
00042         mparent->addObject( obj );
00043 #endif
00044     }
00045     bool MarshallingAccess::readProperties(const std::string& filename) const
00046     {
00047         PropertyLoader pl;
00048         return pl.configure( filename, mparent, true); // all
00049     }
00050     bool MarshallingAccess::updateProperties(const std::string& filename) const
00051     {
00052         PropertyLoader pl;
00053         return pl.configure( filename, mparent, false); // not all
00054     }
00055     bool MarshallingAccess::writeProperties(const std::string& filename) const
00056     {
00057         PropertyLoader pl;
00058         return pl.save( filename, mparent, true); 
00059     }
00060     bool MarshallingAccess::updateFile(const std::string& filename) const
00061     {
00062         PropertyLoader pl;
00063         return pl.save( filename, mparent, false);
00064     }
00065 
00066     bool MarshallingAccess::readProperty(const std::string& name, const std::string& filename) {
00067         PropertyLoader p;
00068         return p.configure(filename, mparent, name);
00069     }
00070 
00071     bool MarshallingAccess::writeProperty(const std::string& name, const std::string& filename) {
00072         PropertyLoader p;
00073         return p.save(filename, mparent, name);
00074     }
00075 
00076 
00077 }

Generated on Tue Mar 25 17:41:47 2008 for OrocosReal-TimeToolkit by  doxygen 1.5.3