Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef GENERS_ABSRECORD_HH_
0002 #define GENERS_ABSRECORD_HH_
0003 
0004 #include "Alignment/Geners/interface/ItemDescriptor.hh"
0005 
0006 namespace gs {
0007   class AbsArchive;
0008   class AbsRecord;
0009 }  // namespace gs
0010 
0011 gs::AbsArchive &operator<<(gs::AbsArchive &ar, const gs::AbsRecord &record);
0012 
0013 namespace gs {
0014   class AbsRecord : public ItemDescriptor {
0015   public:
0016     inline ~AbsRecord() override {}
0017 
0018     // Item id will be set to non-0 value upon writing the item
0019     // into the archive. When the id is not 0, the record can no
0020     // longer be written out (if you really want to write out the
0021     // same item again, make another record).
0022     inline unsigned long long id() const { return itemId_; }
0023 
0024     // Item length will be set to non-0 value upon writing the item
0025     // into the archive.
0026     inline unsigned long long itemLength() const { return itemLength_; }
0027 
0028   protected:
0029     inline AbsRecord() : ItemDescriptor(), itemId_(0), itemLength_(0) {}
0030     inline AbsRecord(const ClassId &classId, const char *ioPrototype, const char *name, const char *category)
0031         : ItemDescriptor(classId, ioPrototype, name, category), itemId_(0), itemLength_(0) {}
0032 
0033   private:
0034     friend gs::AbsArchive & ::operator<<(gs::AbsArchive &ar, const gs::AbsRecord &record);
0035 
0036     // The following functions must be overriden by derived classes.
0037     // "writeData" should return "true" upon success.
0038     virtual bool writeData(std::ostream &os) const = 0;
0039 
0040     mutable unsigned long long itemId_;
0041     mutable unsigned long long itemLength_;
0042   };
0043 }  // namespace gs
0044 
0045 #endif  // GENERS_ABSRECORD_HH_