MultiFileBlob

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
#ifndef CondFormats_MultiFileBlob_h
#define CondFormats_MultiFileBlob_h

#include "CondFormats/Serialization/interface/Serializable.h"

#include <vector>
#include <string>
#include <map>
#include <iosfwd>

class MultiFileBlob {
public:
  typedef std::pair<unsigned char const*, unsigned char const*> Range;

  ///
  MultiFileBlob();

  ///
  ~MultiFileBlob();

  ///
  void finalized(bool compress);

  /// read from real file give it name name
  // void read(const std::string& name, const std::string& fname);
  /// write name to real file
  // void write(const std::string& name, const std::string& fname) const;

  /// read from istream
  void read(const std::string& name, std::istream& is);
  /// write to ostream
  void write(const std::string& name, std::ostream& os) const;

  // return blob
  Range rawBlob(const std::string& name) const;

  bool isCompressed() const { return compressed; }

  unsigned long long fullSize() const { return isize; }

  unsigned long long size(const std::string& name) const;

private:
  // expand locally;
  void expand();

  // static unsigned int computeFileSize(const std::string & ifile);
  // static unsigned int computeStreamSize(std::istream & is);

  std::vector<unsigned char> blob;
  typedef std::map<std::string, unsigned long long> Positions;
  Positions positions;
  bool compressed;  // persistent status
  unsigned long long isize;
  bool expanded COND_TRANSIENT;  // transient status

  COND_SERIALIZABLE;
};

#endif