File indexing completed on 2024-04-06 11:56:18
0001 #ifndef GENERS_GENERALCATALOG_HH_
0002 #define GENERS_GENERALCATALOG_HH_
0003
0004 #include <map>
0005
0006 #include "Alignment/Geners/interface/AbsCatalog.hh"
0007
0008 namespace gs {
0009 class GeneralCatalog : public AbsCatalog {
0010 public:
0011
0012 GeneralCatalog();
0013 inline ~GeneralCatalog() override {}
0014
0015 inline unsigned long long size() const override { return records_.size(); }
0016 inline unsigned long long smallestId() const override { return smallestId_; }
0017 inline unsigned long long largestId() const override { return largestId_; }
0018 inline bool isContiguous() const override { return false; }
0019 inline bool itemExists(const unsigned long long id) const override { return records_.find(id) != records_.end(); }
0020
0021 std::shared_ptr<const CatalogEntry> retrieveEntry(const unsigned long long id) const override;
0022
0023 bool retrieveStreampos(unsigned long long id,
0024 unsigned *compressionCode,
0025 unsigned long long *length,
0026 std::streampos *pos) const override;
0027
0028
0029
0030 unsigned long long makeEntry(const ItemDescriptor &descriptor,
0031 unsigned compressionCode,
0032 unsigned long long itemLength,
0033 const ItemLocation &loc,
0034 unsigned long long offset = 0ULL) override;
0035
0036 inline const CatalogEntry *lastEntryMade() const override { return lastEntry_.get(); }
0037
0038
0039
0040
0041 bool addEntry(std::shared_ptr<const CatalogEntry> ptr);
0042
0043
0044
0045 bool removeEntry(unsigned long long id);
0046
0047
0048 void search(const SearchSpecifier &namePattern,
0049 const SearchSpecifier &categoryPattern,
0050 std::vector<unsigned long long> *idsFound) const override;
0051
0052
0053 ClassId classId() const override { return ClassId(*this); }
0054 bool write(std::ostream &os) const override;
0055
0056 static inline const char *classname() { return "gs::GeneralCatalog"; }
0057 static inline unsigned version() { return 2; }
0058 static GeneralCatalog *read(const ClassId &id, std::istream &in);
0059
0060 protected:
0061 bool isEqual(const AbsCatalog &) const override;
0062
0063 private:
0064 typedef std::shared_ptr<const CatalogEntry> SPtr;
0065
0066
0067
0068 typedef std::multimap<std::string, SPtr> NameMap;
0069
0070
0071 typedef std::map<std::string, NameMap> RecordMap;
0072
0073
0074 typedef std::map<unsigned long long, SPtr> IdMap;
0075
0076 void findByName(const NameMap &nmap,
0077 const SearchSpecifier &namePattern,
0078 std::vector<unsigned long long> *found) const;
0079
0080 IdMap records_;
0081 RecordMap recordMap_;
0082 unsigned long long smallestId_;
0083 unsigned long long largestId_;
0084 SPtr lastEntry_;
0085
0086 static GeneralCatalog *read_v1(std::istream &in);
0087 };
0088 }
0089
0090 #endif