YODA is hosted by Hepforge, IPPP Durham

Pure virtual base class for various output writers. More...

#include <Writer.h>

Inheritance diagram for YODA::Writer:
YODA::WriterAIDA YODA::WriterFLAT YODA::WriterYODA

Public Member Functions

virtual ~Writer ()
 Virtual destructor. More...
 
void setPrecision (int precision)
 Set precision of numerical quantities in this writer's output. More...
 
Writing a single analysis object.
void write (std::ostream &stream, const AnalysisObject &ao)
 Write out object ao to output stream stream. More...
 
void write (const std::string &filename, const AnalysisObject &ao)
 Write out object ao to file filename. More...
 
Writing multiple analysis objects by collection.
template<typename RANGE >
void write (std::ostream &stream, const RANGE &aos)
 Write out a collection of objects objs to output stream stream. More...
 
template<typename RANGE >
void write (const std::string &filename, const RANGE &aos)
 Write out a collection of objects objs to file filename. More...
 
Writing multiple analysis objects by iterator range.
template<typename AOITER >
void write (std::ostream &stream, const AOITER &begin, const AOITER &end)
 
template<typename AOITER >
void write (const std::string &filename, const AOITER &begin, const AOITER &end)
 

Protected Member Functions

virtual void writeHeader (std::ostream &stream)=0
 Main writer elements. More...
 
virtual void writeBody (std::ostream &stream, const AnalysisObject &ao)
 
virtual void writeFooter (std::ostream &stream)=0
 
virtual void writeCounter (std::ostream &stream, const Counter &c)=0
 Specific AO type writer implementations. More...
 
virtual void writeHisto1D (std::ostream &os, const Histo1D &h)=0
 
virtual void writeHisto2D (std::ostream &os, const Histo2D &h)=0
 
virtual void writeProfile1D (std::ostream &os, const Profile1D &p)=0
 
virtual void writeProfile2D (std::ostream &os, const Profile2D &p)=0
 
virtual void writeScatter1D (std::ostream &os, const Scatter1D &s)=0
 
virtual void writeScatter2D (std::ostream &os, const Scatter2D &s)=0
 
virtual void writeScatter3D (std::ostream &os, const Scatter3D &s)=0
 

Detailed Description

Pure virtual base class for various output writers.

Definition at line 28 of file Writer.h.

Constructor & Destructor Documentation

virtual YODA::Writer::~Writer ( )
inlinevirtual

Virtual destructor.

Definition at line 32 of file Writer.h.

32 {}

Member Function Documentation

void YODA::Writer::setPrecision ( int  precision)
inline

Set precision of numerical quantities in this writer's output.

Definition at line 97 of file Writer.h.

Referenced by YODA::WriterAIDA::create(), YODA::WriterYODA::create(), and YODA::WriterFLAT::create().

97  {
98  _precision = precision;
99  }
void YODA::Writer::write ( std::ostream &  stream,
const AnalysisObject ao 
)

Write out object ao to output stream stream.

Definition at line 31 of file Writer.cc.

Referenced by YODA::write(), and write().

31  {
32  writeHeader(stream);
33  writeBody(stream, ao);
34  writeFooter(stream);
35  }
virtual void writeFooter(std::ostream &stream)=0
virtual void writeHeader(std::ostream &stream)=0
Main writer elements.
virtual void writeBody(std::ostream &stream, const AnalysisObject &ao)
Definition: Writer.cc:47
void YODA::Writer::write ( const std::string &  filename,
const AnalysisObject ao 
)

Write out object ao to file filename.

Definition at line 38 of file Writer.cc.

References write().

Referenced by write().

38  {
39  ofstream outstream;
40  // cout << "Opening " << filename << " for writing" << endl;
41  outstream.open(filename.c_str());
42  write(outstream, ao);
43  outstream.close();
44  }
void write(std::ostream &stream, const AnalysisObject &ao)
Write out object ao to output stream stream.
Definition: Writer.cc:31
template<typename RANGE >
void YODA::Writer::write ( std::ostream &  stream,
const RANGE &  aos 
)
inline

Write out a collection of objects objs to output stream stream.

Definition at line 52 of file Writer.h.

References write().

52  {
53  //typedef typename boost::range_iterator<const RANGE>::type const_iterator;
54  write(stream, boost::begin(aos), boost::end(aos));
55  }
void write(std::ostream &stream, const AnalysisObject &ao)
Write out object ao to output stream stream.
Definition: Writer.cc:31
template<typename RANGE >
void YODA::Writer::write ( const std::string &  filename,
const RANGE &  aos 
)
inline

Write out a collection of objects objs to file filename.

Definition at line 58 of file Writer.h.

References write().

58  {
59  //typedef typename boost::range_iterator<const RANGE>::type const_iterator;
60  write(filename, boost::begin(aos), boost::end(aos));
61  }
void write(std::ostream &stream, const AnalysisObject &ao)
Write out object ao to output stream stream.
Definition: Writer.cc:31
template<typename AOITER >
void YODA::Writer::write ( std::ostream &  stream,
const AOITER &  begin,
const AOITER &  end 
)
inline

Write out the objects specified by start iterator begin and end iterator end to output stream stream.

Definition at line 72 of file Writer.h.

References writeBody(), writeFooter(), and writeHeader().

72  {
73  writeHeader(stream);
74  for (AOITER ipao = begin; ipao != end; ++ipao) {
75  writeBody(stream, **ipao);
76  }
77  writeFooter(stream);
78  }
virtual void writeFooter(std::ostream &stream)=0
virtual void writeHeader(std::ostream &stream)=0
Main writer elements.
virtual void writeBody(std::ostream &stream, const AnalysisObject &ao)
Definition: Writer.cc:47
template<typename AOITER >
void YODA::Writer::write ( const std::string &  filename,
const AOITER &  begin,
const AOITER &  end 
)
inline

Write out the objects specified by start iterator begin and end iterator end to file filename.

Definition at line 83 of file Writer.h.

References write().

85  {
86  std::ofstream outstream;
87  outstream.open(filename.c_str());
88  write(outstream, begin, end);
89  outstream.close();
90  }
void write(std::ostream &stream, const AnalysisObject &ao)
Write out object ao to output stream stream.
Definition: Writer.cc:31
void YODA::Writer::writeBody ( std::ostream &  stream,
const AnalysisObject ao 
)
protectedvirtual

Definition at line 47 of file Writer.cc.

References YODA::AnalysisObject::type().

Referenced by write().

47  {
48  const string aotype = ao.type();
49  if (aotype == "Counter") {
50  writeCounter(stream, dynamic_cast<const Counter&>(ao));
51  } else if (aotype == "Histo1D") {
52  writeHisto1D(stream, dynamic_cast<const Histo1D&>(ao));
53  } else if (aotype == "Histo2D") {
54  writeHisto2D(stream, dynamic_cast<const Histo2D&>(ao));
55  } else if (aotype == "Profile1D") {
56  writeProfile1D(stream, dynamic_cast<const Profile1D&>(ao));
57  } else if (aotype == "Profile2D") {
58  writeProfile2D(stream, dynamic_cast<const Profile2D&>(ao));
59  } else if (aotype == "Scatter1D") {
60  writeScatter1D(stream, dynamic_cast<const Scatter1D&>(ao));
61  } else if (aotype == "Scatter2D") {
62  writeScatter2D(stream, dynamic_cast<const Scatter2D&>(ao));
63  } else if (aotype == "Scatter3D") {
64  writeScatter3D(stream, dynamic_cast<const Scatter3D&>(ao));
65  } else if (aotype[0] == '_') {
66  // skip writing AO types with underscore prefixes (needed e.g. for Rivet wrappers)
67  // maybe write a comment line in the output
68  } else {
69  ostringstream oss;
70  oss << "Unrecognised analysis object type " << aotype << " in Writer::write";
71  throw Exception(oss.str());
72  }
73  }
virtual void writeHisto1D(std::ostream &os, const Histo1D &h)=0
virtual void writeScatter1D(std::ostream &os, const Scatter1D &s)=0
virtual void writeScatter2D(std::ostream &os, const Scatter2D &s)=0
virtual void writeHisto2D(std::ostream &os, const Histo2D &h)=0
virtual void writeProfile1D(std::ostream &os, const Profile1D &p)=0
virtual void writeProfile2D(std::ostream &os, const Profile2D &p)=0
virtual void writeCounter(std::ostream &stream, const Counter &c)=0
Specific AO type writer implementations.
virtual void writeScatter3D(std::ostream &os, const Scatter3D &s)=0
virtual void YODA::Writer::writeCounter ( std::ostream &  stream,
const Counter c 
)
protectedpure virtual

Specific AO type writer implementations.

Implemented in YODA::WriterAIDA, YODA::WriterFLAT, and YODA::WriterYODA.

virtual void YODA::Writer::writeFooter ( std::ostream &  stream)
protectedpure virtual

Implemented in YODA::WriterAIDA, YODA::WriterFLAT, and YODA::WriterYODA.

Referenced by write().

virtual void YODA::Writer::writeHeader ( std::ostream &  stream)
protectedpure virtual

Main writer elements.

Implemented in YODA::WriterAIDA, YODA::WriterFLAT, and YODA::WriterYODA.

Referenced by write().

virtual void YODA::Writer::writeHisto1D ( std::ostream &  os,
const Histo1D h 
)
protectedpure virtual
virtual void YODA::Writer::writeHisto2D ( std::ostream &  os,
const Histo2D h 
)
protectedpure virtual
virtual void YODA::Writer::writeProfile1D ( std::ostream &  os,
const Profile1D p 
)
protectedpure virtual
virtual void YODA::Writer::writeProfile2D ( std::ostream &  os,
const Profile2D p 
)
protectedpure virtual
virtual void YODA::Writer::writeScatter1D ( std::ostream &  os,
const Scatter1D s 
)
protectedpure virtual
virtual void YODA::Writer::writeScatter2D ( std::ostream &  os,
const Scatter2D s 
)
protectedpure virtual
virtual void YODA::Writer::writeScatter3D ( std::ostream &  os,
const Scatter3D s 
)
protectedpure virtual

The documentation for this class was generated from the following files: