Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:50:54

0001 #ifndef CondFormats_MultiFileBlob_h
0002 #define CondFormats_MultiFileBlob_h
0003 
0004 #include "CondFormats/Serialization/interface/Serializable.h"
0005 
0006 #include <vector>
0007 #include <string>
0008 #include <map>
0009 #include <iosfwd>
0010 
0011 class MultiFileBlob {
0012 public:
0013   typedef std::pair<unsigned char const*, unsigned char const*> Range;
0014 
0015   ///
0016   MultiFileBlob();
0017 
0018   ///
0019   ~MultiFileBlob();
0020 
0021   ///
0022   void finalized(bool compress);
0023 
0024   /// read from real file give it name name
0025   // void read(const std::string& name, const std::string& fname);
0026   /// write name to real file
0027   // void write(const std::string& name, const std::string& fname) const;
0028 
0029   /// read from istream
0030   void read(const std::string& name, std::istream& is);
0031   /// write to ostream
0032   void write(const std::string& name, std::ostream& os) const;
0033 
0034   // return blob
0035   Range rawBlob(const std::string& name) const;
0036 
0037   bool isCompressed() const { return compressed; }
0038 
0039   unsigned long long fullSize() const { return isize; }
0040 
0041   unsigned long long size(const std::string& name) const;
0042 
0043 private:
0044   // expand locally;
0045   void expand();
0046 
0047   // static unsigned int computeFileSize(const std::string & ifile);
0048   // static unsigned int computeStreamSize(std::istream & is);
0049 
0050   std::vector<unsigned char> blob;
0051   typedef std::map<std::string, unsigned long long> Positions;
0052   Positions positions;
0053   bool compressed;  // persistent status
0054   unsigned long long isize;
0055   bool expanded COND_TRANSIENT;  // transient status
0056 
0057   COND_SERIALIZABLE;
0058 };
0059 
0060 #endif