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

ModuleDefectListStreamer.cpp

Go to the documentation of this file.
00001 #include "ModuleDefectListStreamer.h"
00002 #include "../ModuleDefectList.h"
00003 #include "../ModuleDefect.h"
00004 #include "Sct/LogicErrors.h"
00005 #include "Sct/IoExceptions.h"
00006 
00007 using namespace Sct;
00008 
00009 namespace SctData {
00010 namespace IO {
00011 
00012 ModuleDefectListStreamer::ModuleDefectListStreamer() throw() {}
00013 
00014 bool ModuleDefectListStreamer::inMap = IOManager::addToMap("SctData::ModuleDefectList", auto_ptr<Streamer>(new ModuleDefectListStreamer()));
00015 
00016 void ModuleDefectListStreamer::write(OStream& out, const Streamable& ob, const IOManager& manager) const throw(LogicError, IoError) {
00017     //cast should always be safe
00018     const ModuleDefectList& m = dynamic_cast<const ModuleDefectList&>(ob);
00019 
00020     const vector< shared_ptr<const ModuleDefect> >& list = m.getAllDefects();
00021     out << list.size();
00022     for (unsigned int i=0; i<list.size(); ++i) {
00023         ModuleElement el=list[i]->getModuleElement();
00024         out << helper.getRepresentation(*(list[i])) << el.getFirst() << el.getNChannels();
00025     }
00026 }
00027 
00028 shared_ptr<Streamable> ModuleDefectListStreamer::read(IStream& in, const IOManager& manager) const throw(LogicError, IoError) {
00029     shared_ptr<Streamable> m (new ModuleDefectList());
00030     read(in, *m, manager);
00031     return m;
00032 }
00033 
00034 void ModuleDefectListStreamer::read(IStream& in, Streamable& ob, const IOManager& manager) const throw(LogicError, IoError) {
00035     ModuleDefectList& m = dynamic_cast<ModuleDefectList&>(ob);
00036 
00037     int nDefects = -1;
00038     int rep = 1;
00039     unsigned int startChannel = 0;
00040     unsigned int nChannels = 0;
00041 
00042     in >> nDefects;
00043     for (int i=0; i<nDefects; ++i) {
00044         in >> rep >> startChannel >> nChannels;
00045         m.addDefect(helper.getFromRep(rep), ModuleElement(startChannel, startChannel+nChannels-1));
00046     }
00047 }
00048 }
00049 }

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