CMS 3D CMS Logo

Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes

MultiFileBlob Class Reference

#include <MultiFileBlob.h>

List of all members.

Public Types

typedef std::pair< unsigned
char const *, unsigned char
const * > 
Range

Public Member Functions

void finalized (bool compress)
unsigned long long fullSize () const
bool isCompressed () const
 MultiFileBlob ()
Range rawBlob (const std::string &name) const
void read (const std::string &name, std::istream &is)
 read from real file give it name name
unsigned long long size (const std::string &name) const
void write (const std::string &name, std::ostream &os) const
 write to ostream
 ~MultiFileBlob ()

Private Types

typedef std::map< std::string,
unsigned long long > 
Positions

Private Member Functions

void expand ()

Private Attributes

std::vector< unsigned char > blob
bool compressed
bool expanded
unsigned long long isize
Positions positions

Detailed Description

Definition at line 9 of file MultiFileBlob.h.


Member Typedef Documentation

typedef std::map<std::string, unsigned long long> MultiFileBlob::Positions [private]

Definition at line 53 of file MultiFileBlob.h.

typedef std::pair<unsigned char const *, unsigned char const *> MultiFileBlob::Range

Definition at line 12 of file MultiFileBlob.h.


Constructor & Destructor Documentation

MultiFileBlob::MultiFileBlob ( )

Definition at line 7 of file MultiFileBlob.cc.

                             : 
  compressed(false), isize(0), expanded(false) {}
MultiFileBlob::~MultiFileBlob ( )

Definition at line 10 of file MultiFileBlob.cc.

{}

Member Function Documentation

void MultiFileBlob::expand ( ) [private]

Definition at line 68 of file MultiFileBlob.cc.

References blob, compressed, expanded, isize, and dbtoconf::out.

Referenced by rawBlob().

                           {
  if (expanded) return;
  if (!compressed) {
    expanded=true;
    return;
  }
  std::vector<unsigned char> out(isize);
  uLongf destLen = out.size();
  int zerr =  uncompress(&out.front(),  &destLen,
                         &blob.front(), blob.size());
  if (zerr!=0 || out.size()!=destLen) 
    edm::LogError("FileBlob")<< "uncompressing error " << zerr
                             << " original size was " << isize
                             << " new size is " << destLen;
  blob.swap(out);
  expanded=true;
}
void MultiFileBlob::finalized ( bool  compress)

Definition at line 12 of file MultiFileBlob.cc.

References blob, compressed, expanded, isize, and dbtoconf::out.

                                           {
  if (!compress) return;
  if (0==isize) return;
  compressed=true;
  expanded=false;
  std::vector<unsigned char> out(isize);
  uLongf destLen = compressBound(isize);
  int zerr =  compress2(&out.front(), &destLen,
                        &blob.front(), isize,
                        9);
    if (zerr!=0) edm::LogError("MultiFileBlob")<< "Compression error " << zerr;
    out.resize(destLen);
    blob.swap(out);
}
unsigned long long MultiFileBlob::fullSize ( ) const [inline]

Definition at line 38 of file MultiFileBlob.h.

References isize.

{return isize;}
bool MultiFileBlob::isCompressed ( ) const [inline]

Definition at line 36 of file MultiFileBlob.h.

References compressed.

{return compressed;}
MultiFileBlob::Range MultiFileBlob::rawBlob ( const std::string &  name) const

Definition at line 47 of file MultiFileBlob.cc.

References b, blob, alignCSCRings::e, expand(), isize, pos, and positions.

Referenced by size(), and write().

                                                                     {
  const_cast<MultiFileBlob*>(this)->expand();
  Positions::const_iterator pos = positions.find(name);
  if (pos==positions.end()) {
    edm::LogError("MultiFileBlob:")<< name << "not in this object";
    return Range(0,0);
  }
  unsigned long long b = (*pos).second;
  unsigned long long e = isize;
  pos++;
  if (pos!=positions.end()) e= (*pos).second;
  
  return Range(&blob[b],&blob[e]);
}
void MultiFileBlob::read ( const std::string &  name,
std::istream &  is 
)

read from real file give it name name

write name to real file read from istream

Definition at line 28 of file MultiFileBlob.cc.

References blob, trackerHits::c, isize, mergeVDriftHistosByStation::name, pos, and positions.

                                                               {
  Positions::const_iterator pos = positions.find(name);
  if (pos!=positions.end()) {
    edm::LogError("MultiFileBlob:")<< name << "already in this object";
    return;
  }
  positions[name]=isize;
  char c;
  while (is.get(c))
    blob.push_back( (unsigned char)c);
  isize=blob.size();
}
unsigned long long MultiFileBlob::size ( const std::string &  name) const

Definition at line 63 of file MultiFileBlob.cc.

References alignCSCRings::r, and rawBlob().

                                                                  {
  Range r = rawBlob(name);
  return r.second-r.first;
}
void MultiFileBlob::write ( const std::string &  name,
std::ostream &  os 
) const

write to ostream

Definition at line 41 of file MultiFileBlob.cc.

References alignCSCRings::r, and rawBlob().

                                                                      {
  Range r = rawBlob(name);
  os.write((const char *)(r.first),r.second-r.first);

}

Member Data Documentation

std::vector<unsigned char> MultiFileBlob::blob [private]

Definition at line 52 of file MultiFileBlob.h.

Referenced by expand(), finalized(), rawBlob(), and read().

bool MultiFileBlob::compressed [private]

Definition at line 55 of file MultiFileBlob.h.

Referenced by expand(), finalized(), and isCompressed().

bool MultiFileBlob::expanded [private]

Definition at line 57 of file MultiFileBlob.h.

Referenced by expand(), and finalized().

unsigned long long MultiFileBlob::isize [private]

Definition at line 56 of file MultiFileBlob.h.

Referenced by expand(), finalized(), fullSize(), rawBlob(), and read().

Definition at line 54 of file MultiFileBlob.h.

Referenced by rawBlob(), and read().