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