File indexing completed on 2024-09-07 04:34:30
0001 #ifndef GENERS_ABSARCHIVE_HH_
0002 #define GENERS_ABSARCHIVE_HH_
0003
0004 #include <vector>
0005
0006 #include "Alignment/Geners/interface/AbsRecord.hh"
0007 #include "Alignment/Geners/interface/AbsReference.hh"
0008 #include "Alignment/Geners/interface/CatalogEntry.hh"
0009 #include "Alignment/Geners/interface/SearchSpecifier.hh"
0010
0011 #include <memory>
0012
0013 namespace gs {
0014 class AbsArchive;
0015 }
0016
0017 gs::AbsArchive &operator<<(gs::AbsArchive &ar, const gs::AbsRecord &record);
0018
0019 namespace gs {
0020
0021
0022
0023
0024
0025 class AbsArchive {
0026 public:
0027 AbsArchive(const char *name);
0028 inline virtual ~AbsArchive() {}
0029
0030
0031 const std::string &name() const { return name_; }
0032
0033
0034 virtual bool isOpen() const = 0;
0035
0036
0037
0038 virtual std::string error() const = 0;
0039
0040
0041 virtual bool isReadable() const = 0;
0042
0043
0044 virtual bool isWritable() const = 0;
0045
0046
0047
0048 virtual unsigned long long size() const = 0;
0049
0050
0051 virtual unsigned long long smallestId() const = 0;
0052 virtual unsigned long long largestId() const = 0;
0053
0054
0055
0056 virtual bool idsAreContiguous() const = 0;
0057
0058
0059
0060 virtual bool itemExists(unsigned long long id) const = 0;
0061
0062
0063
0064 virtual void itemSearch(const SearchSpecifier &namePattern,
0065 const SearchSpecifier &categoryPattern,
0066 std::vector<unsigned long long> *found) const = 0;
0067
0068
0069
0070
0071 virtual std::shared_ptr<const CatalogEntry> catalogEntry(unsigned long long id) = 0;
0072
0073
0074
0075 virtual void flush() = 0;
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089 unsigned long long copyItem(unsigned long long id,
0090 AbsArchive *destination,
0091 const char *newName = nullptr,
0092 const char *newCategory = nullptr);
0093
0094
0095
0096
0097 inline unsigned long long lastItemId() const { return lastItemId_; }
0098 inline unsigned long long lastItemLength() const { return lastItemLength_; }
0099
0100 inline bool operator==(const AbsArchive &r) const { return (typeid(*this) == typeid(r)) && this->isEqual(r); }
0101 inline bool operator!=(const AbsArchive &r) const { return !(*this == r); }
0102
0103 protected:
0104 void addItemToReference(AbsReference &r, unsigned long long id) const;
0105
0106
0107
0108 virtual bool isEqual(const AbsArchive &) const { return false; }
0109
0110 private:
0111 friend class AbsReference;
0112 friend gs::AbsArchive & ::operator<<(gs::AbsArchive & ar, const gs::AbsRecord & record);
0113
0114
0115
0116
0117
0118 virtual void search(AbsReference &reference) = 0;
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133 virtual std::istream &inputStream(unsigned long long id, long long *sz) = 0;
0134
0135
0136 virtual std::ostream &outputStream() = 0;
0137
0138
0139
0140 virtual unsigned long long addToCatalog(const AbsRecord &record,
0141 unsigned compressCode,
0142 unsigned long long itemLength) = 0;
0143
0144
0145
0146 virtual std::ostream &compressedStream(std::ostream &uncompressed) { return uncompressed; }
0147
0148
0149
0150
0151 virtual unsigned flushCompressedRecord(std::ostream & ) { return 0U; }
0152
0153 std::string name_;
0154 unsigned long long lastItemId_;
0155 unsigned long long lastItemLength_;
0156 };
0157 }
0158
0159 #endif