CMS 3D CMS Logo

OutputFile Class Reference

This file contains Class definitions for the Class representing Output (Streamer/Index) file. More...

#include <IOPool/Streamer/interface/StreamerFileIO.h>

List of all members.

Public Member Functions

uint32 adler32 () const
uint64 current_offset () const
uint64 events () const
std::string fileName () const
uint64 first_event_offset () const
void inc_events ()
uint64 last_event_offset () const
 OutputFile (const std::string &name)
uint64 run () const
void set_current_offset (uint64 v)
void set_do_adler (bool v)
void set_events (uint64 v)
void set_first_event_offset (uint64 v)
void set_last_event_offset (uint64 v)
void set_run (uint64 v)
bool write (const char *ptr, size_t n)
 ~OutputFile ()
 CTOR, takes file path name as argument.

Static Public Member Functions

static void adler32 (const char *data, size_t len, uint32 &a, uint32 &b)
static uint32 adler32 (const char *data, size_t len)

Private Attributes

uint32 adlera_
uint32 adlerb_
uint64 current_offset_
bool do_adler_
uint32 events_
std::string filename_
uint64 first_event_offset_
 Location of current ioptr.
uint64 last_event_offset_
std::ofstream * ost_
uint32 run_


Detailed Description

This file contains Class definitions for the Class representing Output (Streamer/Index) file.

Class representing Output (Streamer/Index) file.

Definition at line 15 of file StreamerFileIO.h.


Constructor & Destructor Documentation

OutputFile::OutputFile ( const std::string &  name  )  [explicit]

Definition at line 6 of file StreamerFileIO.cc.

References Exception, and ost_.

00006                                              :
00007     current_offset_(1), 
00008     first_event_offset_(0),
00009     last_event_offset_(0),
00010     events_(0),
00011     run_(0),
00012     do_adler_(0),
00013     adlera_(1),
00014     adlerb_(0),
00015     ost_(new std::ofstream(name.c_str(), std::ios_base::binary | std::ios_base::out)),
00016     filename_(name)
00017   {
00018     if(!ost_->is_open()) {
00019       throw cms::Exception("OutputFile","OutputFile")
00020         << "Error Opening Output File: "<<name<<"\n";
00021     }
00022     ost_->rdbuf()->pubsetbuf(0,0);
00023   }

OutputFile::~OutputFile (  ) 

CTOR, takes file path name as argument.

Definition at line 25 of file StreamerFileIO.cc.

References ost_.

00026   {
00027     ost_->close();
00028     delete ost_;
00029   }


Member Function Documentation

void OutputFile::adler32 ( const char *  data,
size_t  len,
uint32 a,
uint32 b 
) [static]

Definition at line 48 of file StreamerFileIO.cc.

References MOD_ADLER, and ptr.

00049 {
00050  /* data: Pointer to the data to be summed; len is in bytes */
00051 
00052   #define MOD_ADLER 65521
00053  
00054   const unsigned char *ptr = (const unsigned char *)data;
00055   while (len > 0) 
00056   {
00057     size_t tlen = len > 5552 ? 5552 : len;
00058     len -= tlen;
00059     do 
00060     {
00061       a += *ptr++;
00062       b += a;
00063     } while (--tlen);
00064     
00065     a %= MOD_ADLER;
00066     b %= MOD_ADLER;
00067   }
00068 
00069   #undef MOD_ADLER
00070 }

uint32 OutputFile::adler32 ( const char *  data,
size_t  len 
) [static]

Definition at line 72 of file StreamerFileIO.cc.

References a, adler32(), and b.

00073 {
00074  /* data: Pointer to the data to be summed; len is in bytes */
00075 
00076   uint32_t a = 1, b = 0;
00077   adler32(data,len,a,b);
00078   return (b << 16) | a;
00079 }

uint32 OutputFile::adler32 (  )  const [inline]

Definition at line 35 of file StreamerFileIO.h.

References adlera_, and adlerb_.

Referenced by StreamerOutputFile::adler32(), adler32(), StreamerOutputIndexFile::adler32(), and write().

00035 { return (adlerb_ << 16) | adlera_; }

uint64 OutputFile::current_offset (  )  const [inline]

Definition at line 30 of file StreamerFileIO.h.

References current_offset_.

Referenced by StreamerOutputFile::write(), and StreamDQMOutputFile::write().

00030 { return current_offset_; }

uint64 OutputFile::events (  )  const [inline]

Definition at line 33 of file StreamerFileIO.h.

References events_.

Referenced by StreamerOutputIndexFile::write(), StreamerOutputFile::writeEOF(), and StreamerOutputIndexFile::writeEOF().

00033 { return events_; }

std::string OutputFile::fileName (  )  const [inline]

Definition at line 29 of file StreamerFileIO.h.

References filename_.

Referenced by StreamerOutputFile::write(), StreamerOutputFile::writeEOF(), StreamerOutputFile::writeEventHeader(), and StreamerOutputFile::writeStart().

00029 { return filename_; }

uint64 OutputFile::first_event_offset (  )  const [inline]

Definition at line 31 of file StreamerFileIO.h.

References first_event_offset_.

Referenced by StreamerOutputFile::writeEOF(), and StreamerOutputIndexFile::writeEOF().

00031 { return first_event_offset_; }

void OutputFile::inc_events (  )  [inline]

Definition at line 42 of file StreamerFileIO.h.

References events_.

Referenced by StreamerOutputFile::write(), StreamerOutputIndexFile::write(), and StreamDQMOutputFile::write().

00042 { ++events_; }

uint64 OutputFile::last_event_offset (  )  const [inline]

Definition at line 32 of file StreamerFileIO.h.

References last_event_offset_.

Referenced by StreamerOutputFile::writeEOF(), and StreamerOutputIndexFile::writeEOF().

00032 { return last_event_offset_; }

uint64 OutputFile::run ( void   )  const [inline]

Definition at line 34 of file StreamerFileIO.h.

References run_.

Referenced by StreamerOutputFile::writeEOF(), and StreamerOutputIndexFile::writeEOF().

00034 { return run_; }

void OutputFile::set_current_offset ( uint64  v  )  [inline]

Definition at line 38 of file StreamerFileIO.h.

References current_offset_.

00038 { current_offset_ = v; }

void OutputFile::set_do_adler ( bool  v  )  [inline]

Definition at line 37 of file StreamerFileIO.h.

References do_adler_.

Referenced by StreamerOutputFile::StreamerOutputFile(), and StreamerOutputIndexFile::StreamerOutputIndexFile().

00037 { do_adler_ = v; }

void OutputFile::set_events ( uint64  v  )  [inline]

Definition at line 41 of file StreamerFileIO.h.

References events_.

00041 { events_ = v; }

void OutputFile::set_first_event_offset ( uint64  v  )  [inline]

Definition at line 39 of file StreamerFileIO.h.

References first_event_offset_.

Referenced by StreamerOutputFile::write(), and StreamerOutputIndexFile::write().

00039 { first_event_offset_ = v; }

void OutputFile::set_last_event_offset ( uint64  v  )  [inline]

Definition at line 40 of file StreamerFileIO.h.

References last_event_offset_.

Referenced by StreamerOutputFile::write(), StreamerOutputIndexFile::write(), and StreamDQMOutputFile::write().

00040 { last_event_offset_ = v; }

void OutputFile::set_run ( uint64  v  )  [inline]

Definition at line 43 of file StreamerFileIO.h.

References run_.

Referenced by StreamerOutputIndexFile::write(), and StreamerOutputFile::writeStart().

00043 { run_ = v; }

bool OutputFile::write ( const char *  ptr,
size_t  n 
)

Definition at line 31 of file StreamerFileIO.cc.

References adler32(), adlera_, adlerb_, current_offset_, do_adler_, and ost_.

Referenced by StreamerOutputFile::write(), StreamerOutputIndexFile::write(), StreamDQMOutputFile::write(), StreamDQMOutputFile::writeDQMEventHeader(), StreamerOutputFile::writeEOF(), StreamerOutputIndexFile::writeEOF(), StreamerOutputFile::writeEventHeader(), StreamerOutputIndexFile::writeIndexFileHeader(), and StreamerOutputFile::writeStart().

00032   {
00033     ost_->write(ptr,n);
00034     if(!ost_->fail()) {
00035       current_offset_ += (uint64)(n);
00036       if (do_adler_)
00037         adler32(ptr,n,adlera_,adlerb_);
00038       return 0;
00039     }
00040     return 1;
00041   }


Member Data Documentation

uint32 OutputFile::adlera_ [private]

Definition at line 57 of file StreamerFileIO.h.

Referenced by adler32(), and write().

uint32 OutputFile::adlerb_ [private]

Definition at line 58 of file StreamerFileIO.h.

Referenced by adler32(), and write().

uint64 OutputFile::current_offset_ [private]

Definition at line 50 of file StreamerFileIO.h.

Referenced by current_offset(), set_current_offset(), and write().

bool OutputFile::do_adler_ [private]

Definition at line 56 of file StreamerFileIO.h.

Referenced by set_do_adler(), and write().

uint32 OutputFile::events_ [private]

Definition at line 53 of file StreamerFileIO.h.

Referenced by events(), inc_events(), and set_events().

std::string OutputFile::filename_ [private]

Definition at line 61 of file StreamerFileIO.h.

Referenced by fileName().

uint64 OutputFile::first_event_offset_ [private]

Location of current ioptr.

Definition at line 51 of file StreamerFileIO.h.

Referenced by first_event_offset(), and set_first_event_offset().

uint64 OutputFile::last_event_offset_ [private]

Definition at line 52 of file StreamerFileIO.h.

Referenced by last_event_offset(), and set_last_event_offset().

std::ofstream* OutputFile::ost_ [private]

Definition at line 60 of file StreamerFileIO.h.

Referenced by OutputFile(), write(), and ~OutputFile().

uint32 OutputFile::run_ [private]

Definition at line 54 of file StreamerFileIO.h.

Referenced by run(), and set_run().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:29:26 2009 for CMSSW by  doxygen 1.5.4