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

TGraphStreamer.cpp

Go to the documentation of this file.
00001 #include "TGraphStreamer.h"
00002 #include "TGraph.h"
00003 #include "../RootStreamableAdapter.h"
00004 
00005 using namespace Sct;
00006 
00007 namespace SctData {
00008 namespace IO {
00009 
00010 bool TGraphStreamer::inMap = IOManager::addToMap(TGraph::Class()->GetName(), auto_ptr<Streamer>(new TGraphStreamer()));
00011 
00012 TGraphStreamer::TGraphStreamer() throw() {}
00013 
00014 void TGraphStreamer::write(OStream& out, const Streamable& ob, const IOManager& manager) const throw(LogicError, IoError) {
00015     const RootStreamableAdapter& ad = dynamic_cast<const RootStreamableAdapter&>(ob);
00016     TGraph* graph = (TGraph*)ad.getObject();
00017     out << static_cast<unsigned int> ( graph->GetN() );
00018     out.put(graph->GetX(), graph->GetN() );
00019     out.put(graph->GetY(), graph->GetN() );
00020 }
00021 
00022 shared_ptr<Streamable> TGraphStreamer::read(IStream& in, const IOManager& manager) const throw(LogicError, IoError) {
00023     shared_ptr<Streamable> ad (new RootStreamableAdapter(*new TGraph()));
00024     read(in, *ad, manager);
00025     return ad;
00026 }
00027 
00028 void TGraphStreamer::read(IStream& in, Streamable& ob, const IOManager& manager) const throw(LogicError, IoError) {
00029     RootStreamableAdapter& ad = dynamic_cast<RootStreamableAdapter&>(ob);
00030     TGraph* graph = (TGraph*)ad.getObject();
00031     unsigned int n = 0;
00032     in >> n;
00033     double x[n], y[n];
00034     in.get(x, n);
00035     in.get(y, n);
00036     graph->Set(n);
00037     for (unsigned int i=0; i<n; ++i)
00038         graph->SetPoint(i, x[i], y[i]);
00039 }
00040 }
00041 }

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