Main Page   Modules   Namespace List   Class Hierarchy   Data Structures   File List   Namespace Members   Data Fields   Globals   Related Pages  

TestResultStreamer.cpp

Go to the documentation of this file.
00001 #include "TestResultStreamer.h"
00002 #include "../TestResult.h"
00003 #include "../ConfigurationVariable.h"
00004 
00005 #include <string>
00006 
00007 using namespace std;
00008 using namespace Sct;
00009 
00010 namespace SctData {
00011 namespace IO {
00012 
00013 TestResultStreamer::TestResultStreamer() throw() {}
00014 
00015 void TestResultStreamer::write(OStream& out, const Streamable& ob, const IOManager& manager) const throw(LogicError, IoError) {
00016     // cout <<"TestResultIS publishing"<<endl;
00017     const TestResult& mytest = dynamic_cast<const TestResult&>(ob);
00018     
00019     out << mytest.getRunNumber() << mytest.getModuleName(); 
00020 
00021     manager.writeImpl(out, mytest.getTestVariable(), false);
00022     manager.writeImpl(out, mytest.getScanVariable(), false);
00023 
00024     out << mytest.getNScans();
00025     for (unsigned int i=0; i<mytest.getNScans(); ++i) {
00026         out << mytest.getScanNumberAt(i) << mytest.getTestPointAt(i);
00027     }
00028     manager.writeImpl(out, mytest.getDefects() , false);
00029     manager.writeImpl(out, mytest.getUpdatedConfiguration(), false);
00030     
00031     out << mytest.getPassed();
00032     out << mytest.getProblem();
00033     vector<string> comments = mytest.getComments();
00034     out << comments.size();
00035     for (unsigned int i=0; i<comments.size(); ++i) {
00036     out << comments[i];
00037     }
00038 }
00039 
00040 void TestResultStreamer::read(IStream& in, Streamable& ob, const IOManager& manager) const throw(LogicError, IoError) {  
00041     TestResult& mytest = dynamic_cast<TestResult&>(ob);
00042 
00043     //cout << "TestResultIS refreshing" << endl;
00044 
00045     unsigned int runNumber = 0;
00046     string moduleName;
00047 
00048     in >> runNumber >> moduleName;
00049 
00050     shared_ptr<Streamable> ob2 = manager.readImpl(in, "SctData::ConfigurationVariable");
00051     mytest.setTestVariable(*boost::dynamic_pointer_cast<ConfigurationVariable>(ob2));   
00052     
00053     ob2 = manager.readImpl(in, "SctData::ConfigurationVariable");
00054     mytest.setScanVariable(*boost::dynamic_pointer_cast<ConfigurationVariable>(ob2));   
00055     
00056     mytest.setRunNumber(runNumber);
00057     mytest.setModuleName(moduleName);
00058     
00059     //cout << "   found "<<runNumber << moduleName << endl;
00060 
00061     unsigned int size=0;
00062     in >> size;
00063     for (unsigned int i=0; i<size; ++i) {
00064         unsigned int scanNumber;
00065         double testPoint;
00066         in >> scanNumber >> testPoint;
00067         mytest.addScan(scanNumber, testPoint);
00068         //cout << "TestResultIS refresh : added scan "<<scanNumber<<endl;
00069     }
00070     manager.readImpl(in, mytest.getDefects(), false);
00071     manager.readImpl(in, mytest.getUpdatedConfiguration(), false);
00072     
00073     bool passed, problem;
00074     unsigned int nComments;    
00075     string comment;
00076     in >> passed;   mytest.setPassed(passed);
00077     in >> problem;  mytest.setProblem(problem);
00078     
00079     in >> nComments;
00080     for (unsigned int i=0; i<nComments; ++i) {
00081     in >> comment;  mytest.addComment(comment);
00082     }
00083     
00084     //cout << "TestResultIS refresh done" << endl;
00085 }
00086 }
00087 }
00088 

Generated on Mon Dec 15 19:36:20 2003 for SCT DAQ/DCS Software by doxygen1.3-rc3