00001 00002 #include "FileReporting.hpp" 00003 #include <rtt/RTT.hpp> 00004 #include <rtt/Logger.hpp> 00005 #include "TableMarshaller.hpp" 00006 #include "NiceHeaderMarshaller.hpp" 00007 00008 00009 #include "ocl/Component.hpp" 00010 ORO_LIST_COMPONENT_TYPE(OCL::FileReporting) 00011 00012 namespace OCL 00013 { 00014 using namespace RTT; 00015 using namespace std; 00016 00017 FileReporting::FileReporting(const std::string& fr_name) 00018 : ReportingComponent( fr_name ), 00019 repfile("ReportFile","Location on disc to store the reports.", "reports.dat") 00020 { 00021 this->properties()->addProperty( repfile ); 00022 } 00023 00024 bool FileReporting::startHook() 00025 { 00026 mfile.open( repfile.get().c_str() ); 00027 if (mfile) { 00028 if ( this->writeHeader) 00029 fheader = new RTT::NiceHeaderMarshaller<std::ostream>( mfile ); 00030 else 00031 fheader = 0; 00032 fbody = new RTT::TableMarshaller<std::ostream>( mfile ); 00033 00034 this->addMarshaller( fheader, fbody ); 00035 } else { 00036 log(Error) << "Could not open file "+repfile.get()+" for reporting."<<endlog(); 00037 } 00038 00039 return ReportingComponent::startHook(); 00040 } 00041 00042 void FileReporting::stopHook() 00043 { 00044 ReportingComponent::stopHook(); 00045 00046 this->removeMarshallers(); 00047 if (mfile) 00048 mfile.close(); 00049 } 00050 00051 bool FileReporting::screenComponent( const std::string& comp) 00052 { 00053 Logger::In in("FileReporting::screenComponent"); 00054 ofstream file( (comp + ".screen").c_str() ); 00055 if (!file) 00056 return false; 00057 return this->screenImpl( comp, file ); 00058 } 00059 00060 }