3 #include "Alignment/Geners/interface/AbsArchive.hh"
4 #include "Alignment/Geners/interface/AbsReference.hh"
5 #include "Alignment/Geners/interface/CatalogEntry.hh"
6 #include "Alignment/Geners/interface/IOException.hh"
17 std::istream &AbsReference::positionInputStream(
const unsigned long long id)
const {
18 return archive_.inputStream(
id,
nullptr);
22 AbsReference *modifiable =
const_cast<AbsReference *
>(
this);
26 std::shared_ptr<const CatalogEntry>
record = archive_.catalogEntry(searchId_);
27 const unsigned long long idFound = record->id();
30 if (idFound && this->isIOCompatible(*record)) {
31 if (idFound != searchId_)
32 throw IOInvalidData(
"In AbsReference::initialize: catalog is corrupted");
33 modifiable->itemId_ = searchId_;
37 archive_.search(*modifiable);
38 if (!idList_.empty()) {
41 const unsigned long nFound = idList_.size();
42 const unsigned long long *ids = &idList_[0];
44 for (
unsigned long i = 1;
i < nFound; ++
i)
45 if (ids[
i - 1] >= ids[
i]) {
50 std::sort(modifiable->idList_.begin(), modifiable->idList_.end());
53 modifiable->initialized_ =
true;
56 bool AbsReference::isIOCompatible(
const CatalogEntry &
r)
const {
57 return !classId_.name().empty() && classId_.name() == r.type().name() && ioProto_ == r.ioPrototype();
63 return itemId_ == 0 && idList_.empty();
69 return itemId_ && idList_.empty();
75 return itemId_ ? 1UL : idList_.size();
81 if (itemId_ && index == 0UL)
83 else if (index < idList_.size())
84 return idList_[index];
86 throw gs::IOOutOfRange(
87 "In gs::AbsReference::id: "
88 "index out of range");
91 std::shared_ptr<const CatalogEntry> AbsReference::indexedCatalogEntry(
const unsigned long index)
const {
92 return archive_.catalogEntry(
id(index));
95 bool AbsReference::isSameIOPrototype(
const CatalogEntry &r)
const {
return ioProto_ == r.ioPrototype(); }
97 void AbsReference::addItemId(
const unsigned long long idIn) {
99 throw gs::IOInvalidArgument(
"In AbsReference::addItemId: invalid item id");
100 const unsigned long mySize = itemId_ ? 1UL : idList_.size();
108 idList_.push_back(itemId_);
109 idList_.push_back(idIn);
114 idList_.push_back(idIn);
119 AbsReference::AbsReference(AbsArchive &ar,
120 const ClassId &classId,
121 const char *ioPrototype,
122 const unsigned long long itemId)
125 ioProto_(ioPrototype ? ioPrototype :
""),
127 namePattern_(nullptr),
128 categoryPattern_(nullptr),
130 initialized_(
false) {
132 throw gs::IOInvalidArgument(
"In AbsReference constructor: invalid item id");
135 AbsReference::AbsReference(AbsArchive &ar,
136 const ClassId &classId,
137 const char *ioPrototype,
138 const SearchSpecifier &namePattern,
139 const SearchSpecifier &categoryPattern)
142 ioProto_(ioPrototype ? ioPrototype :
""),
144 namePattern_(namePattern),
145 categoryPattern_(categoryPattern),
147 initialized_(
false) {}
static AlgebraicMatrix initialize()
uint16_t *__restrict__ id
tuple size
Write out results.