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

FitScanResultStreamer.cpp

Go to the documentation of this file.
00001 #include "FitScanResultStreamer.h"
00002 #include "../FitScanResult.h"
00003 #include "../FitObject.h"
00004 #include "Sct/VersionNotSupportedException.h"
00005 
00006 using namespace Sct;
00007 using namespace boost;
00008 
00009 namespace SctData {
00010 namespace IO {
00011 
00012 FitScanResultStreamer::FitScanResultStreamer() throw() {}
00013 
00014 bool FitScanResultStreamer::inMap = IOManager::addToMap("SctData::FitScanResult", auto_ptr<Streamer>(new FitScanResultStreamer()));
00015 
00016 
00017 shared_ptr<Streamable> FitScanResultStreamer::read(IStream& in, const IOManager& manager) const throw(LogicError, IoError) {
00018     shared_ptr<Streamable> ad (&helper.create());
00019     read(in, *ad, manager);
00020     return ad;
00021 }
00022 
00023 void FitScanResultStreamer::write(OStream& out, const Streamable& ob, const IOManager& manager) const throw(LogicError, IoError) {
00024     //Let superclass do its worker
00025     ScanResultStreamer::write(out, ob, manager);
00026 
00027     //Downcast should always work!
00028     const FitScanResult& fit = dynamic_cast<const FitScanResult&>(ob);
00029     out << (unsigned) 3; // version number; 
00030     
00031     unsigned int n = 0;
00032     string className;
00033     
00034     n = fit.getNLinkFits();
00035     out << n;
00037     if (n>0) out << fit.getLinkFit(0).getClassName();
00038     for (unsigned i=0; i<n; i++) {
00039         FitObject& fo = fit.getLinkFit(i);
00040         manager.writeImpl(out, fo, false);
00041     }
00042     
00043     n = fit.getNChipFits();
00044     out << n;
00045     if (n>0) out << fit.getChipFit(0).getClassName();
00046     for (unsigned i=0; i<n; i++) {
00047         FitObject& fo = fit.getChipFit(i);
00048         manager.writeImpl(out, fo, false);
00049     }
00050     
00051     n = fit.getNChannelFits();
00052     out << n;
00053     if (n>0) out << fit.getChannelFit(0).getClassName();
00054     for (unsigned i=0; i<fit.getNChannelFits(); i++) {
00055         FitObject& fo = fit.getChannelFit(i);
00056         manager.writeImpl(out, fo, false);
00057     }
00058     
00059     manager.writeImpl(out, fit.getDefects(), false);
00060 }
00061 
00062 
00063 void FitScanResultStreamer::read(IStream& in, Streamable& ob, const IOManager& manager) const throw(LogicError, IoError) {
00064     ScanResultStreamer::read(in, ob, manager);
00065 
00066     FitScanResult& fit = dynamic_cast<FitScanResult&>(ob);
00067     
00068     unsigned size, version;
00069     string className;
00070     
00071     in >> version; 
00072     if (version!=3) throw VersionNotSupportedException("FitScanResult version error", __FILE__, __LINE__);
00073  
00074     in >> size;    
00075     fit.setNLinkFits(size);
00076     if (size > 0) in >> className;
00077     for (unsigned i=0; i<size ; i++) {
00078         shared_ptr<FitObject> fo (dynamic_pointer_cast<FitObject>(manager.readImpl(in, className)));
00079     fit.setLinkFit(i, fo);
00080     }
00081     
00082     in >> size;    
00083     fit.setNChipFits(size);
00084     if (size > 0) in >> className;
00085     for (unsigned i=0; i<size ; i++) {
00086         shared_ptr<FitObject> fo (dynamic_pointer_cast<FitObject>(manager.readImpl(in, className)));
00087     fit.setChipFit(i, fo);
00088     }
00089     
00090     in >> size;    
00091     fit.setNChannelFits(size);
00092     if (size > 0) in >> className;
00093     for (unsigned i=0; i<size ; i++) {
00094         shared_ptr<FitObject> fo (dynamic_pointer_cast<FitObject>(manager.readImpl(in, className)));
00095     fit.setChannelFit(i, fo);
00096     }
00097     manager.readImpl(in, fit.getDefects(), false);
00098 }
00099 
00100 }
00101 }

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