TestResultStreamer_v3.cpp

00001 #include "TestResultStreamer_v3.h"
00002 #include "../TestResult.h"
00003 #include "../ConfigurationVariable.h"
00004 #include "../DcsData.h"
00005 
00006 #include <string>
00007 
00008 using namespace std;
00009 using namespace Sct;
00010 
00011 namespace SctData {
00012 namespace IO {
00013 
00014 /* READ NOTES ON STREAMERS AND VERSIONS BEFORE EDITING THIS FILE! */
00015 unsigned TestResultStreamer_v3::s_version=3;
00016     
00017 bool TestResultStreamer_v3::inMap = IOManager::addToMap("SctData::TestResult",  std::auto_ptr<Streamer>(new TestResultStreamer_v3()));
00018     
00019 TestResultStreamer_v3::TestResultStreamer_v3() throw() {}
00020 
00021 shared_ptr<Streamable> TestResultStreamer_v3::read(IStream&, const IOManager&) const throw(LogicError, IoError) {
00022     throw Sct::LogicError("Cannot make a TestResult - abstract class",__FILE__,__LINE__);
00023 }
00024 
00025 void TestResultStreamer_v3::write(OStream& out, const Streamable& ob, const IOManager& manager) const throw(LogicError, IoError) {
00026     // cout <<"TestResultIS publishing"<<endl;
00027     const TestResult& mytest = dynamic_cast<const TestResult&>(ob);
00028     
00029     manager.writeImpl(out, mytest.getHeader(), false);
00030     manager.writeImpl(out, mytest.getTestVariable(), false);
00031 
00032     out << mytest.getNScans();
00033     for (unsigned int i=0; i<mytest.getNScans(); ++i) {
00034         out << mytest.getScanNumberAt(i) << mytest.getTestPointAt(i);
00035     }
00036     manager.writeImpl(out, mytest.getDefects() , false);
00037     
00038     out << mytest.getPassed();
00039     out << mytest.getProblem();
00040     vector<string> comments = mytest.getComments();
00041     out << comments.size();
00042     for (unsigned int i=0; i<comments.size(); ++i) {
00043     out << comments[i];
00044     }
00045 
00046     shared_ptr<const DcsData> dcs = mytest.getDcsData();
00047 
00048     out << (bool) dcs.get();
00049     if (dcs.get()) manager.writeImpl(out, *dcs, false);
00050 }
00051 
00052 void TestResultStreamer_v3::read(IStream& in, Streamable& ob, const IOManager& manager) const throw(LogicError, IoError) {  
00053     TestResult& mytest = dynamic_cast<TestResult&>(ob);
00054 
00055     //cout << "TestResultIS refreshing" << endl;
00056 
00057     manager.readImpl(in, mytest.getHeader(), false);
00058     shared_ptr<Streamable> ob2 = manager.readImpl(in, "SctData::ConfigurationVariable");
00059     mytest.setTestVariable(*boost::dynamic_pointer_cast<ConfigurationVariable>(ob2));   
00060         
00061     //cout << "   found "<<runNumber << moduleName << endl;
00062 
00063     unsigned int size=0;
00064     in >> size;
00065     for (unsigned int i=0; i<size; ++i) {
00066         unsigned int scanNumber;
00067         double testPoint;
00068         in >> scanNumber >> testPoint;
00069         mytest.addScan(scanNumber, testPoint);
00070         //cout << "TestResultIS refresh : added scan "<<scanNumber<<endl;
00071     }
00072     manager.readImpl(in, mytest.getDefects(), false);
00073     
00074     bool passed, problem;
00075     unsigned int nComments;    
00076     string comment;
00077     in >> passed;   mytest.setPassed(passed);
00078     in >> problem;  mytest.setProblem(problem);
00079     
00080     in >> nComments;
00081     for (unsigned int i=0; i<nComments; ++i) {
00082     in >> comment;  mytest.addComment(comment);
00083     }
00084     
00085     bool hasDcs; in >> hasDcs;
00086 
00087     if (hasDcs) {
00088       shared_ptr<DcsData> dcs (new DcsData());
00089       manager.readImpl(in, *dcs, false);
00090       mytest.setDcsData(dcs);
00091     }
00092 }
00093 }
00094 }
00095 

Generated on Mon Feb 6 14:01:35 2006 for SCT DAQ/DCS Software - C++ by  doxygen 1.4.6