CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
edm::streamer::OutputFile Class Reference

#include <StreamerFileIO.h>

Public Member Functions

uint32 adler32 () const
 
void close ()
 
uint64 current_offset () const
 
std::string fileName () const
 
 OutputFile (const std::string &name)
 
void set_current_offset (uint64 v)
 
void set_do_adler (bool v)
 
bool write (const char *ptr, size_t n)
 
 ~OutputFile ()
 

Private Attributes

uint32 adlera_
 
uint32 adlerb_
 
uint64 current_offset_
 
bool do_adler_
 
std::string filename_
 
edm::propagate_const< std::shared_ptr< std::ofstream > > ost_
 

Detailed Description

Class representing Output (Streamer) file.

Definition at line 17 of file StreamerFileIO.h.

Constructor & Destructor Documentation

◆ OutputFile()

edm::streamer::OutputFile::OutputFile ( const std::string &  name)
explicit

Definition at line 8 of file StreamerFileIO.cc.

9  : current_offset_(1),
10  do_adler_(false),
11  adlera_(1),
12  adlerb_(0),
13  ost_(new std::ofstream(name.c_str(), std::ios_base::binary | std::ios_base::out)),
14  filename_(name) {
15  if (!ost_->is_open()) {
16  throw cms::Exception("OutputFile", "OutputFile") << "Error Opening Output File: " << name << "\n";
17  }
18  ost_->rdbuf()->pubsetbuf(nullptr, 0);
19  }

References Exception, Skims_PA_cff::name, and ost_.

◆ ~OutputFile()

edm::streamer::OutputFile::~OutputFile ( )

CTOR, takes file path name as argument

Definition at line 21 of file StreamerFileIO.cc.

21 { ost_->close(); }

References ost_.

Member Function Documentation

◆ adler32()

uint32 edm::streamer::OutputFile::adler32 ( ) const
inline

Definition at line 33 of file StreamerFileIO.h.

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

References adlera_, and adlerb_.

◆ close()

void edm::streamer::OutputFile::close ( void  )

Definition at line 34 of file StreamerFileIO.cc.

34 { ost_->close(); }

References ost_.

Referenced by esMonitoring.AsyncLineReaderMixin::handle_close(), and esMonitoring.FDJsonServer::handle_close().

◆ current_offset()

uint64 edm::streamer::OutputFile::current_offset ( ) const
inline

Definition at line 32 of file StreamerFileIO.h.

32 { return current_offset_; }

References current_offset_.

◆ fileName()

std::string edm::streamer::OutputFile::fileName ( ) const
inline

Definition at line 31 of file StreamerFileIO.h.

31 { return filename_; }

References filename_.

◆ set_current_offset()

void edm::streamer::OutputFile::set_current_offset ( uint64  v)
inline

Definition at line 36 of file StreamerFileIO.h.

36 { current_offset_ = v; }

References current_offset_, and findQualityFiles::v.

◆ set_do_adler()

void edm::streamer::OutputFile::set_do_adler ( bool  v)
inline

Definition at line 35 of file StreamerFileIO.h.

35 { do_adler_ = v; }

References do_adler_, and findQualityFiles::v.

◆ write()

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

Definition at line 23 of file StreamerFileIO.cc.

23  {
24  ost_->write(ptr, n);
25  if (!ost_->fail()) {
26  current_offset_ += (uint64)(n);
27  if (do_adler_)
28  cms::Adler32(ptr, n, adlera_, adlerb_);
29  return false;
30  }
31  return true;
32  }

References cms::Adler32(), adlera_, adlerb_, current_offset_, do_adler_, dqmiodumpmetadata::n, and ost_.

Member Data Documentation

◆ adlera_

uint32 edm::streamer::OutputFile::adlera_
private

Definition at line 43 of file StreamerFileIO.h.

Referenced by adler32(), and write().

◆ adlerb_

uint32 edm::streamer::OutputFile::adlerb_
private

Definition at line 44 of file StreamerFileIO.h.

Referenced by adler32(), and write().

◆ current_offset_

uint64 edm::streamer::OutputFile::current_offset_
private

Definition at line 40 of file StreamerFileIO.h.

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

◆ do_adler_

bool edm::streamer::OutputFile::do_adler_
private

Location of current ioptr

Definition at line 42 of file StreamerFileIO.h.

Referenced by set_do_adler(), and write().

◆ filename_

std::string edm::streamer::OutputFile::filename_
private

Definition at line 47 of file StreamerFileIO.h.

Referenced by fileName().

◆ ost_

edm::propagate_const<std::shared_ptr<std::ofstream> > edm::streamer::OutputFile::ost_
private

Definition at line 46 of file StreamerFileIO.h.

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

edm::streamer::OutputFile::filename_
std::string filename_
Definition: StreamerFileIO.h:47
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
findQualityFiles.v
v
Definition: findQualityFiles.py:179
cms::Adler32
void Adler32(char const *data, size_t len, uint32_t &a, uint32_t &b)
Definition: Adler32Calculator.cc:10
edm::streamer::OutputFile::ost_
edm::propagate_const< std::shared_ptr< std::ofstream > > ost_
Definition: StreamerFileIO.h:46
edm::streamer::OutputFile::current_offset_
uint64 current_offset_
Definition: StreamerFileIO.h:40
edm::streamer::OutputFile::adlera_
uint32 adlera_
Definition: StreamerFileIO.h:43
Exception
Definition: hltDiff.cc:245
uint64
unsigned long long uint64
Definition: MsgTools.h:14
edm::streamer::OutputFile::adlerb_
uint32 adlerb_
Definition: StreamerFileIO.h:44
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
edm::streamer::OutputFile::do_adler_
bool do_adler_
Definition: StreamerFileIO.h:42