1 #include "Alignment/Geners/interface/IOException.hh" 3 #include "Alignment/Geners/interface/CPP11_auto_ptr.hh" 4 #include "Alignment/Geners/interface/CatalogEntry.hh" 5 #include "Alignment/Geners/interface/binaryIO.hh" 8 CatalogEntry::CatalogEntry()
12 location_(ItemLocation(
std::streampos(0),
nullptr))
16 CatalogEntry::CatalogEntry(
const ItemDescriptor&
r,
17 const unsigned long long id,
18 const unsigned compressionCod,
19 const unsigned long long itemLength,
20 const ItemLocation& location,
21 const unsigned long long offset)
26 compressionCode_(compressionCod),
29 if (!
id)
throw gs::IOInvalidArgument(
30 "In CatalogEntry constructor: invalid item id");
33 bool CatalogEntry::isEqual(
const ItemDescriptor&
other)
const 35 if ((
void*)
this == (
void*)(&other))
37 if (!ItemDescriptor::isEqual(other))
39 const CatalogEntry& r =
static_cast<const CatalogEntry&
>(
other);
40 return id_ == r.id_ && len_ == r.len_ &&
41 offset_ == r.offset_ &&
42 compressionCode_ == r.compressionCode_ &&
43 location_ == r.location_;
49 write_pod(of, ioPrototype());
50 write_pod(of,
name());
54 write_pod(of, compressionCode_);
57 unsigned char hasOffset = offset_ > 0ULL;
58 write_pod(of, hasOffset);
60 write_pod(of, offset_);
67 CatalogEntry* CatalogEntry::read(
const ClassId&
id,
71 static const ClassId current(ClassId::makeId<CatalogEntry>());
72 current.ensureSameId(
id);
74 ClassId itemClass(in, 1);
77 read_pod(in, &ioPrototype);
79 read_pod(in, &category);
81 unsigned long long itemId = 0, itemLen = 0;
82 read_pod(in, &itemId);
83 read_pod(in, &itemLen);
86 read_pod(in, &coCode);
88 unsigned long long offset = 0;
89 unsigned char hasOffset = 0;
90 read_pod(in, &hasOffset);
92 read_pod(in, &offset);
94 CatalogEntry* rec =
nullptr;
97 CPP11_auto_ptr<ItemLocation>
loc(ItemLocation::read(locId, in));
99 rec =
new CatalogEntry(
100 ItemDescriptor(itemClass, ioPrototype.c_str(),
101 name.c_str(), category.c_str()),
102 itemId, coCode, itemLen, *
loc, offset);
107 bool CatalogEntry::humanReadable(std::ostream& os)
const 109 os <<
"Id: " << id_ <<
'\n' 110 <<
"Class: " <<
type().id() <<
'\n' 111 <<
"Name: " <<
name() <<
'\n' 112 <<
"Category: " <<
category() <<
'\n' 113 <<
"I/O prototype: " << ioPrototype() <<
'\n' 114 <<
"URI: " << location().URI() <<
'\n' 115 <<
"Cached: " << location().cachedItemURI() <<
'\n' 116 <<
"Compression: " << compressionCode_ <<
'\n' 117 <<
"Length: " << len_ <<
'\n' 118 <<
"Streampos: " << location().streamPosition() <<
'\n' 119 <<
"Offset: " << offset_