1 #include "Alignment/Geners/interface/IOException.hh" 4 #include "Alignment/Geners/interface/CatalogEntry.hh" 5 #include "Alignment/Geners/interface/binaryIO.hh" 8 CatalogEntry::CatalogEntry()
9 : ItemDescriptor(), id_(0), len_(0), location_(ItemLocation(
std::streampos(0), nullptr)) {}
11 CatalogEntry::CatalogEntry(
const ItemDescriptor &
r,
12 const unsigned long long id,
13 const unsigned compressionCod,
14 const unsigned long long itemLength,
16 const unsigned long long offset)
21 compressionCode_(compressionCod),
24 throw gs::IOInvalidArgument(
"In CatalogEntry constructor: invalid item id");
27 bool CatalogEntry::isEqual(
const ItemDescriptor &
other)
const {
28 if ((
void *)
this == (
void *)(&
other))
30 if (!ItemDescriptor::isEqual(
other))
32 const CatalogEntry &
r =
static_cast<const CatalogEntry &
>(
other);
33 return id_ ==
r.id_ && len_ ==
r.len_ && offset_ ==
r.offset_ && compressionCode_ ==
r.compressionCode_ &&
34 location_ ==
r.location_;
39 write_pod(
of, ioPrototype());
44 write_pod(
of, compressionCode_);
47 unsigned char hasOffset = offset_ > 0ULL;
48 write_pod(
of, hasOffset);
50 write_pod(
of, offset_);
58 static const ClassId current(ClassId::makeId<CatalogEntry>());
59 current.ensureSameId(
id);
61 ClassId itemClass(
in, 1);
64 read_pod(
in, &ioPrototype);
68 unsigned long long itemId = 0, itemLen = 0;
69 read_pod(
in, &itemId);
70 read_pod(
in, &itemLen);
73 read_pod(
in, &coCode);
75 unsigned long long offset = 0;
76 unsigned char hasOffset = 0;
77 read_pod(
in, &hasOffset);
81 CatalogEntry *rec =
nullptr;
85 rec =
new CatalogEntry(ItemDescriptor(itemClass, ioPrototype.c_str(),
name.c_str(),
category.c_str()),
95 bool CatalogEntry::humanReadable(std::ostream &os)
const {
96 os <<
"Id: " << id_ <<
'\n' 97 <<
"Class: " <<
type().id() <<
'\n' 98 <<
"Name: " <<
name() <<
'\n' 99 <<
"Category: " <<
category() <<
'\n' 100 <<
"I/O prototype: " << ioPrototype() <<
'\n' 101 <<
"URI: " <<
location().URI() <<
'\n' 102 <<
"Cached: " <<
location().cachedItemURI() <<
'\n' 103 <<
"Compression: " << compressionCode_ <<
'\n' 104 <<
"Length: " << len_ <<
'\n' 105 <<
"Streampos: " <<
location().streamPosition() <<
'\n' 106 <<
"Offset: " << offset_ << std::endl;