1 #include "Alignment/Geners/interface/CPP11_auto_ptr.hh" 2 #include "Alignment/Geners/interface/IOException.hh" 3 #include "Alignment/Geners/interface/WriteOnlyCatalog.hh" 4 #include "Alignment/Geners/interface/binaryIO.hh" 9 WriteOnlyCatalog::WriteOnlyCatalog(std::ostream &os,
const unsigned long long firstId)
10 : AbsCatalog(), os_(os), count_(0), smallestId_(firstId ? firstId : 1ULL), largestId_(0) {}
12 unsigned long long WriteOnlyCatalog::makeEntry(
const ItemDescriptor &descriptor,
13 const unsigned compressionCode,
14 const unsigned long long itemLen,
15 const ItemLocation &loc,
16 const unsigned long long off) {
17 const unsigned long long id = count_ ? largestId_ + 1 : smallestId_;
19 CPP11_auto_ptr<const CatalogEntry>(
new CatalogEntry(descriptor,
id, compressionCode, itemLen, loc, off));
20 if (lastEntry_->write(os_)) {
40 return !os.fail() && ClassId::makeId<CatalogEntry>().
write(os) && ClassId::makeId<ItemLocation>().
write(os);
44 static const ClassId current(ClassId::makeId<WriteOnlyCatalog>());
45 id.ensureSameName(current);
46 id.ensureVersionInRange(1,
version());
56 CPP11_auto_ptr<WriteOnlyCatalog>
cat(
new WriteOnlyCatalog(dynamic_cast<std::ostream &>(
in)));
57 bool firstEntry =
true;
58 for (
in.peek(); !
in.eof();
in.peek()) {
62 const unsigned long long id = rec->id();
64 cat->smallestId_ =
id;
69 if (id < cat->smallestId_) {
70 cat->smallestId_ =
id;
72 }
else if (
id >
cat->largestId_) {
81 "In gs::WriteOnlyCatalog::read: " 82 "entry out of order. Catalog is " 83 "likely to be corrupted.");
86 "In gs::WriteOnlyCatalog::read: " 87 "failed to read catalog entry");
92 std::shared_ptr<const CatalogEntry> WriteOnlyCatalog::retrieveEntry(
unsigned long long)
const {
94 "In gs::WriteOnlyCatalog::retrieveEntry: " 95 "entries can not be retrieved " 96 "from a write-only catalog");
97 return std::shared_ptr<CatalogEntry>(
reinterpret_cast<CatalogEntry *
>(0));
100 bool WriteOnlyCatalog::retrieveStreampos(
unsigned long long ,
102 unsigned long long * ,
103 std::streampos * )
const {
105 "In gs::WriteOnlyCatalog::retrieveStreampos: " 106 "stream positions can not be retrieved " 107 "from a write-only catalog");
112 const SearchSpecifier &,
113 std::vector<unsigned long long> *)
const {
115 "In gs::WriteOnlyCatalog::search: " 116 "entries can not be searched " 117 "in a write-only catalog");
std::vector< T >::const_iterator search(const cond::Time_t &val, const std::vector< T > &container)