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 | Friends
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 ()
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Private Attributes

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

Friends

class boost::serialization::access
 
template<typename CondSerializationT , typename Enabled >
struct cond::serialization::access
 

Detailed Description

Definition at line 11 of file MultiFileBlob.h.

Member Typedef Documentation

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

Definition at line 55 of file MultiFileBlob.h.

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

Definition at line 14 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:58
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, GenerateHcalLaserBadRunList::out, and spu::zerr().

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 }
void zerr(int)
std::vector< unsigned char > blob
Definition: MultiFileBlob.h:54
unsigned long long isize
Definition: MultiFileBlob.h:58
void MultiFileBlob::finalized ( bool  compress)

Definition at line 12 of file MultiFileBlob.cc.

References blob, compressed, expanded, isize, GenerateHcalLaserBadRunList::out, and spu::zerr().

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 }
void zerr(int)
std::vector< unsigned char > blob
Definition: MultiFileBlob.h:54
unsigned long long isize
Definition: MultiFileBlob.h:58
unsigned long long MultiFileBlob::fullSize ( ) const
inline

Definition at line 40 of file MultiFileBlob.h.

References isize.

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

Definition at line 38 of file MultiFileBlob.h.

References compressed.

38 {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, 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:54
std::pair< unsigned char const *, unsigned char const * > Range
Definition: MultiFileBlob.h:14
unsigned long long isize
Definition: MultiFileBlob.h:58
Positions positions
Definition: MultiFileBlob.h:56
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, EnergyCorrector::c, isize, mergeVDriftHistosByStation::name, and positions.

Referenced by edmIntegrityCheck.PublishToFileSystem::get(), Vispa.Plugins.EdmBrowser.EdmDataAccessor.EdmDataAccessor::goto(), and 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:54
unsigned long long isize
Definition: MultiFileBlob.h:58
Positions positions
Definition: MultiFileBlob.h:56
template<class Archive >
void MultiFileBlob::serialize ( Archive &  ar,
const unsigned int  version 
)
private
unsigned long long MultiFileBlob::size ( const std::string &  name) const

Definition at line 63 of file MultiFileBlob.cc.

References alignCSCRings::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:14
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 alignCSCRings::r, and rawBlob().

Referenced by pkg.AbstractPkg::generate().

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:14
Range rawBlob(const std::string &name) const

Friends And Related Function Documentation

friend class boost::serialization::access
friend

Definition at line 61 of file MultiFileBlob.h.

template<typename CondSerializationT , typename Enabled >
friend struct cond::serialization::access
friend

Definition at line 61 of file MultiFileBlob.h.

Member Data Documentation

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

Definition at line 54 of file MultiFileBlob.h.

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

bool MultiFileBlob::compressed
private

Definition at line 57 of file MultiFileBlob.h.

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

bool MultiFileBlob::expanded
private

Definition at line 59 of file MultiFileBlob.h.

Referenced by expand(), and finalized().

unsigned long long MultiFileBlob::isize
private

Definition at line 58 of file MultiFileBlob.h.

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

Positions MultiFileBlob::positions
private

Definition at line 56 of file MultiFileBlob.h.

Referenced by rawBlob(), and read().