00001 #include "ScanResultStreamer.h"
00002 #include "../ScanResult.h"
00003 #include "Sct/VersionNotSupportedException.h"
00004 #include "Sct/LogicErrors.h"
00005 #include "Sct/IoExceptions.h"
00006
00007 #include <string>
00008
00009 using namespace std;
00010 using namespace Sct;
00011
00012 namespace SctData {
00013 namespace IO {
00014
00015 ScanResultStreamer::ScanResultStreamer() throw() {}
00016
00017 void ScanResultStreamer::write(OStream& out, const Streamable& ob, const IOManager& manager) const throw(LogicError, IoError) {
00018
00019 const ScanResult& raw = dynamic_cast<const ScanResult&>(ob);
00020
00021
00022 out << (unsigned short)0;
00023
00024 manager.writeImpl(out, raw.getHeader(), false);
00025 manager.writeImpl(out, raw.getPoints(), false);
00026 manager.writeImpl(out, raw.getConfiguration(), false);
00027 }
00028
00029 void ScanResultStreamer::read(IStream& in, Streamable& ob, const IOManager& manager) const throw(LogicError, IoError) {
00030
00031 ScanResult& raw = dynamic_cast<ScanResult&>(ob);
00032
00033
00034
00035 unsigned short version = (unsigned)-1;
00036 in >> version;
00037
00038 if (version != 0)
00039 throw VersionNotSupportedException("We only support version 0 in ScanResultStreamer", __FILE__, __LINE__);
00040
00041
00042 helper.set(raw);
00043 manager.readImpl(in, helper.getHeader(), false);
00044
00045 manager.readImpl(in, helper.getPoints(), false);
00046
00047 manager.readImpl(in, helper.getConfiguration(), false);
00048
00049 }
00050 }
00051 }