00001 #include "TestResultStreamer_v1.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
00014 unsigned TestResultStreamer_v1::s_version=2;
00015
00016 bool TestResultStreamer_v1::inMap = IOManager::addToMap("SctData::TestResult", std::auto_ptr<Streamer>(new TestResultStreamer_v1()));
00017
00018 TestResultStreamer_v1::TestResultStreamer_v1() throw() {}
00019
00020 shared_ptr<Streamable> TestResultStreamer_v1::read(IStream&, const IOManager&) const throw(LogicError, IoError) {
00021 throw Sct::LogicError("Cannot make a TestResult - abstract class",__FILE__,__LINE__);
00022 }
00023
00024 void TestResultStreamer_v1::write(OStream& out, const Streamable& ob, const IOManager& manager) const throw(LogicError, IoError) {
00025
00026 const TestResult& mytest = dynamic_cast<const TestResult&>(ob);
00027
00028 manager.writeImpl(out, mytest.getHeader(), false);
00029 manager.writeImpl(out, mytest.getTestVariable(), false);
00030
00031 out << mytest.getNScans();
00032 for (unsigned int i=0; i<mytest.getNScans(); ++i) {
00033 out << mytest.getScanNumberAt(i) << mytest.getTestPointAt(i);
00034 }
00035 manager.writeImpl(out, mytest.getDefects() , false);
00036
00037 out << mytest.getPassed();
00038 out << mytest.getProblem();
00039 vector<string> comments = mytest.getComments();
00040 out << comments.size();
00041 for (unsigned int i=0; i<comments.size(); ++i) {
00042 out << comments[i];
00043 }
00044 }
00045
00046 void TestResultStreamer_v1::read(IStream& in, Streamable& ob, const IOManager& manager) const throw(LogicError, IoError) {
00047 TestResult& mytest = dynamic_cast<TestResult&>(ob);
00048
00049
00050
00051 manager.readImpl(in, mytest.getHeader(), false);
00052 shared_ptr<Streamable> ob2 = manager.readImpl(in, "SctData::ConfigurationVariable");
00053 mytest.setTestVariable(*boost::dynamic_pointer_cast<ConfigurationVariable>(ob2));
00054
00055
00056
00057 unsigned int size=0;
00058 in >> size;
00059 for (unsigned int i=0; i<size; ++i) {
00060 unsigned int scanNumber;
00061 double testPoint;
00062 in >> scanNumber >> testPoint;
00063 mytest.addScan(scanNumber, testPoint);
00064
00065 }
00066 manager.readImpl(in, mytest.getDefects(), false);
00067
00068 bool passed, problem;
00069 unsigned int nComments;
00070 string comment;
00071 in >> passed; mytest.setPassed(passed);
00072 in >> problem; mytest.setProblem(problem);
00073
00074 in >> nComments;
00075 for (unsigned int i=0; i<nComments; ++i) {
00076 in >> comment; mytest.addComment(comment);
00077 }
00078
00079
00080 }
00081 }
00082 }
00083