CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes
MultiFileBlob Class Reference

#include <MultiFileBlob.h>

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 More...
 
unsigned long long size (const std::string &name) const
 
void write (const std::string &name, std::ostream &os) const
 write to ostream More...
 
 ~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.

7  :
8  compressed(false), isize(0), expanded(false) {}
unsigned long long isize
Definition: MultiFileBlob.h:56
MultiFileBlob::~MultiFileBlob ( )

Definition at line 10 of file MultiFileBlob.cc.

10 {}

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().

68  {
69  if (expanded) return;
70  if (!compressed) {
71  expanded=true;
72  return;
73  }
74  std::vector<unsigned char> out(isize);
75  uLongf destLen = out.size();
76  int zerr = uncompress(&out.front(), &destLen,
77  &blob.front(), blob.size());
78  if (zerr!=0 || out.size()!=destLen)
79  edm::LogError("FileBlob")<< "uncompressing error " << zerr
80  << " original size was " << isize
81  << " new size is " << destLen;
82  blob.swap(out);
83  expanded=true;
84 }
std::vector< unsigned char > blob
Definition: MultiFileBlob.h:52
tuple out
Definition: dbtoconf.py:99
unsigned long long isize
Definition: MultiFileBlob.h:56
void MultiFileBlob::finalized ( bool  compress)

Definition at line 12 of file MultiFileBlob.cc.

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

12  {
13  if (!compress) return;
14  if (0==isize) return;
15  compressed=true;
16  expanded=false;
17  std::vector<unsigned char> out(isize);
18  uLongf destLen = compressBound(isize);
19  int zerr = compress2(&out.front(), &destLen,
20  &blob.front(), isize,
21  9);
22  if (zerr!=0) edm::LogError("MultiFileBlob")<< "Compression error " << zerr;
23  out.resize(destLen);
24  blob.swap(out);
25 }
std::vector< unsigned char > blob
Definition: MultiFileBlob.h:52
tuple out
Definition: dbtoconf.py:99
unsigned long long isize
Definition: MultiFileBlob.h:56
unsigned long long MultiFileBlob::fullSize ( ) const
inline

Definition at line 38 of file MultiFileBlob.h.

References isize.

38 {return isize;}
unsigned long long isize
Definition: MultiFileBlob.h:56
bool MultiFileBlob::isCompressed ( ) const
inline

Definition at line 36 of file MultiFileBlob.h.

References compressed.

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

Definition at line 47 of file MultiFileBlob.cc.

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

Referenced by size(), and write().

47  {
48  const_cast<MultiFileBlob*>(this)->expand();
49  Positions::const_iterator pos = positions.find(name);
50  if (pos==positions.end()) {
51  edm::LogError("MultiFileBlob:")<< name << "not in this object";
52  return Range(0,0);
53  }
54  unsigned long long b = (*pos).second;
55  unsigned long long e = isize;
56  pos++;
57  if (pos!=positions.end()) e= (*pos).second;
58 
59  return Range(&blob[b],&blob[e]);
60 }
std::vector< unsigned char > blob
Definition: MultiFileBlob.h:52
std::pair< unsigned char const *, unsigned char const * > Range
Definition: MultiFileBlob.h:12
unsigned long long isize
Definition: MultiFileBlob.h:56
Positions positions
Definition: MultiFileBlob.h:54
double b
Definition: hdecay.h:120
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, AlCaRecoCosmics_cfg::name, pos, and positions.

Referenced by python.Vispa.Plugins.EdmBrowser.EdmDataAccessor.EdmDataAccessor::goto(), and python.Vispa.Plugins.EdmBrowser.EdmDataAccessor.EdmDataAccessor::setFilterBranches().

28  {
29  Positions::const_iterator pos = positions.find(name);
30  if (pos!=positions.end()) {
31  edm::LogError("MultiFileBlob:")<< name << "already in this object";
32  return;
33  }
35  char c;
36  while (is.get(c))
37  blob.push_back( (unsigned char)c);
38  isize=blob.size();
39 }
std::vector< unsigned char > blob
Definition: MultiFileBlob.h:52
unsigned long long isize
Definition: MultiFileBlob.h:56
Positions positions
Definition: MultiFileBlob.h:54
unsigned long long MultiFileBlob::size ( const std::string &  name) const

Definition at line 63 of file MultiFileBlob.cc.

References csvReporter::r, and rawBlob().

63  {
64  Range r = rawBlob(name);
65  return r.second-r.first;
66 }
std::pair< unsigned char const *, unsigned char const * > Range
Definition: MultiFileBlob.h:12
Range rawBlob(const std::string &name) const
void MultiFileBlob::write ( const std::string &  name,
std::ostream &  os 
) const

write to ostream

Definition at line 41 of file MultiFileBlob.cc.

References csvReporter::r, and rawBlob().

41  {
42  Range r = rawBlob(name);
43  os.write((const char *)(r.first),r.second-r.first);
44 
45 }
std::pair< unsigned char const *, unsigned char const * > Range
Definition: MultiFileBlob.h:12
Range rawBlob(const std::string &name) const

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().

Positions MultiFileBlob::positions
private

Definition at line 54 of file MultiFileBlob.h.

Referenced by rawBlob(), and read().