Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:44:51

0001 #ifndef GENERS_COLUMNBUFFER_HH_
0002 #define GENERS_COLUMNBUFFER_HH_
0003 
0004 #include <iostream>
0005 #include <vector>
0006 
0007 #include "Alignment/Geners/interface/CharBuffer.hh"
0008 #include "Alignment/Geners/interface/ClassId.hh"
0009 
0010 namespace gs {
0011   namespace Private {
0012     struct ColumnBuffer {
0013       inline ColumnBuffer() : firstrow(0), lastrowp1(0), podsize(0) {}
0014 
0015       // The actual buffer
0016       CharBuffer buf;
0017 
0018       // The range of rows stored in the buffer is [firstrow, lastrowp1)
0019       unsigned long firstrow;
0020       unsigned long lastrowp1;
0021 
0022       // The following member will be non-0 if the column
0023       // members are PODs for I/O purposes
0024       unsigned long podsize;
0025 
0026       // If the above member is 0, objects in the buffer may have
0027       // variable size. Because of this, we need to store an offset
0028       // of each object separately. To conserve space, the vector
0029       // of object offsets is not filled for PODs.
0030       std::vector<std::streampos> offsets;
0031 
0032       // Methods related to I/O
0033       bool write(std::ostream &os) const;
0034       inline const ClassId &classId() const { return static_classId(); }
0035 
0036       // The "restore" method is special and requires
0037       // use of special references. The reason is the
0038       // following: we will likely store a large number
0039       // of these buffers at a time. Storing the class id
0040       // of CharBuffer every time would be a waste of
0041       // storage space. Because of this, we will assume
0042       // that the code that manages these buffers will
0043       // stash the CharBuffer class id somewhere.
0044       static void restore(const ClassId &id, const ClassId &charBufId, std::istream &in, ColumnBuffer *buf);
0045 
0046       static inline const char *classname() { return "gs::Private::ColumnBuffer"; }
0047       static inline unsigned version() { return 1; }
0048 
0049       bool operator==(const ColumnBuffer &r) const;
0050       inline bool operator!=(const ColumnBuffer &r) const { return !(*this == r); }
0051 
0052     private:
0053       static const ClassId &static_classId();
0054     };
0055   }  // namespace Private
0056 }  // namespace gs
0057 
0058 #endif  // GENERS_COLUMNBUFFER_HH_