00001 #include "../SingleVariableTestResult.h"
00002 #include "SingleVariableTestResultStreamer_v1.h"
00003 #include <vector>
00004
00005 using namespace Sct;
00006
00007 namespace SctData {
00008 namespace IO {
00009
00010
00011 unsigned SingleVariableTestResultStreamer_v1::s_version=1;
00012
00013 SingleVariableTestResultStreamer_v1::SingleVariableTestResultStreamer_v1() throw() {
00014 }
00015
00016 bool SingleVariableTestResultStreamer_v1::inMap = IOManager::addToMap("SctData::SingleVariableTestResult", auto_ptr<Streamer>(new SingleVariableTestResultStreamer_v1()));
00017
00018 shared_ptr<Streamable> SingleVariableTestResultStreamer_v1::read(IStream& in, const IOManager& manager) const throw(LogicError, IoError) {
00019 throw Sct::IllegalStateError("Request to make a SingleVariableTestResult, which is an abstract class", __FILE__, __LINE__);
00020 }
00021
00022 void SingleVariableTestResultStreamer_v1::write(OStream& out, const Streamable& ob, const IOManager& manager) const throw(LogicError, IoError) {
00023
00024 manager.writeImpl(out, ob, "SctData::TestResult");
00025
00026 const SingleVariableTestResult& mytest = dynamic_cast<const SingleVariableTestResult&>(ob);
00027
00028 out << (double) 0.;
00029
00030 unsigned int nopt=mytest.getNOptima();
00031 out << nopt;
00032 for (unsigned int i=0; i<nopt; ++i) {
00033 out << mytest.getOptimum(i);
00034 }
00035 }
00036
00037 void SingleVariableTestResultStreamer_v1::read(IStream& in, Streamable& ob, const IOManager& manager) const throw(LogicError, IoError) {
00038 manager.readImpl(in, ob, "SctData::TestResult");
00039
00040 SingleVariableTestResult& mytest = dynamic_cast<SingleVariableTestResult&>(ob);
00041 double fraction;
00042 in >> fraction;
00043 unsigned int nopt;
00044 in >> nopt;
00045 mytest.setNOptima(nopt);
00046 for (unsigned int ichip=0; ichip<nopt; ++ichip) {
00047 double opt;
00048 in >> opt ;
00049 mytest.setOptimum(ichip, opt);
00050 }
00051 }
00052
00053 }
00054 }