Main Page   Modules   Namespace List   Class Hierarchy   Data Structures   File List   Namespace Members   Data Fields   Globals   Related Pages  

ScanResultStreamer.cpp

Go to the documentation of this file.
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     //Downcast should always work!
00019     const ScanResult& raw = dynamic_cast<const ScanResult&>(ob);
00020 
00021     //Write out the version
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     //Downcast should always work!
00031     ScanResult& raw = dynamic_cast<ScanResult&>(ob);
00032 
00033     //cout << "ScanResultIS refreshing" << endl;
00034     //read in the version number and check it.
00035     unsigned short version = (unsigned)-1;
00036     in >> version;
00037     //cout << "Version: " << version << endl;
00038     if (version != 0)
00039         throw VersionNotSupportedException("We only support version 0 in ScanResultStreamer", __FILE__, __LINE__);
00040 
00041     //Now read everthing else in.
00042     helper.set(raw);
00043     manager.readImpl(in, helper.getHeader(), false);
00044     //cout << "Done header" << endl;
00045     manager.readImpl(in, helper.getPoints(), false);
00046     //cout << "Done ScanPoints" << endl;
00047     manager.readImpl(in, helper.getConfiguration(), false);
00048     //cout << "Done all "<<endl;
00049 }
00050 }
00051 }

Generated on Mon Dec 15 19:36:15 2003 for SCT DAQ/DCS Software by doxygen1.3-rc3