1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#ifndef GENERS_WRITEONLYCATALOG_HH_
#define GENERS_WRITEONLYCATALOG_HH_
#include <iostream>
#include "Alignment/Geners/interface/AbsCatalog.hh"
#include <memory>
namespace gs {
class WriteOnlyCatalog : public AbsCatalog {
public:
// The output stream should be dedicated exclusively to this catalog
WriteOnlyCatalog(std::ostream &os, unsigned long long firstId = 1);
WriteOnlyCatalog(const WriteOnlyCatalog &) = delete;
WriteOnlyCatalog &operator=(const WriteOnlyCatalog &) = delete;
inline ~WriteOnlyCatalog() override {}
inline unsigned long long size() const override { return count_; }
inline unsigned long long smallestId() const override { return smallestId_; }
inline unsigned long long largestId() const override { return largestId_; }
inline bool isContiguous() const override { return true; }
// The following methods will cause a run-time error: there is
// no way to read a write-only catalog or to search it
std::shared_ptr<const CatalogEntry> retrieveEntry(unsigned long long) const override;
bool retrieveStreampos(unsigned long long id,
unsigned *compressionCode,
unsigned long long *length,
std::streampos *pos) const override;
void search(const SearchSpecifier &namePattern,
const SearchSpecifier &categoryPattern,
std::vector<unsigned long long> *idsFound) const override;
// Added entries will be immediately written out
unsigned long long makeEntry(const ItemDescriptor &descriptor,
unsigned compressionCode,
unsigned long long itemLength,
const ItemLocation &loc,
unsigned long long offset = 0ULL) override;
inline const CatalogEntry *lastEntryMade() const override { return lastEntry_.get(); }
// Methods needed for I/O (not really useful,
// but must be overriden anyway)
ClassId classId() const override { return ClassId(*this); }
bool write(std::ostream &) const override;
static inline const char *classname() { return "gs::WriteOnlyCatalog"; }
static inline unsigned version() { return 2; }
// The following function works only if there is a dynamic cast
// which can convert "in" into std::ostream.
static WriteOnlyCatalog *read(const ClassId &id, std::istream &in);
protected:
inline bool isEqual(const AbsCatalog &) const override { return false; }
private:
std::ostream &os_;
unsigned long long count_;
unsigned long long smallestId_;
unsigned long long largestId_;
std::unique_ptr<const CatalogEntry> lastEntry_;
};
} // namespace gs
#endif // GENERS_WRITEONLYCATALOG_HH_
|