File indexing completed on 2024-04-06 11:56:17
0001 #ifndef GENERS_ABSCATALOG_HH_
0002 #define GENERS_ABSCATALOG_HH_
0003
0004 #include "Alignment/Geners/interface/CatalogEntry.hh"
0005 #include "Alignment/Geners/interface/ItemDescriptor.hh"
0006 #include "Alignment/Geners/interface/SearchSpecifier.hh"
0007
0008 #include <cassert>
0009 #include <memory>
0010 #include <vector>
0011
0012 namespace gs {
0013
0014
0015
0016
0017
0018 struct AbsCatalog {
0019 virtual ~AbsCatalog() {}
0020
0021
0022 virtual unsigned long long size() const = 0;
0023
0024
0025 virtual unsigned long long smallestId() const = 0;
0026 virtual unsigned long long largestId() const = 0;
0027 virtual bool isContiguous() const = 0;
0028
0029
0030
0031
0032 virtual bool itemExists(const unsigned long long id) const {
0033 if (id == 0ULL)
0034 return false;
0035 assert(isContiguous());
0036 return id >= smallestId() && id <= largestId();
0037 }
0038
0039
0040 virtual unsigned long long makeEntry(const ItemDescriptor &descriptor,
0041 unsigned compressionCode,
0042 unsigned long long itemLength,
0043 const ItemLocation &loc,
0044 unsigned long long offset = 0ULL) = 0;
0045
0046
0047
0048
0049
0050
0051 virtual const CatalogEntry *lastEntryMade() const = 0;
0052
0053
0054
0055 virtual std::shared_ptr<const CatalogEntry> retrieveEntry(unsigned long long id) const = 0;
0056
0057
0058
0059
0060 virtual bool retrieveStreampos(unsigned long long id,
0061 unsigned *compressionCode,
0062 unsigned long long *length,
0063 std::streampos *pos) const = 0;
0064
0065
0066 virtual void search(const SearchSpecifier &namePattern,
0067 const SearchSpecifier &categoryPattern,
0068 std::vector<unsigned long long> *idsFound) const = 0;
0069
0070 inline bool operator==(const AbsCatalog &r) const { return (typeid(*this) == typeid(r)) && this->isEqual(r); }
0071 inline bool operator!=(const AbsCatalog &r) const { return !(*this == r); }
0072
0073
0074 virtual ClassId classId() const = 0;
0075 virtual bool write(std::ostream &) const = 0;
0076
0077 protected:
0078 virtual bool isEqual(const AbsCatalog &) const = 0;
0079 };
0080 }
0081
0082 #endif