3 #include "Alignment/Geners/interface/AbsReference.hh" 4 #include "Alignment/Geners/interface/CatalogEntry.hh" 5 #include "Alignment/Geners/interface/AbsArchive.hh" 6 #include "Alignment/Geners/interface/IOException.hh" 17 std::istream& AbsReference::positionInputStream(
18 const unsigned long long id)
const 20 return archive_.inputStream(
id,
nullptr);
25 AbsReference* modifiable =
const_cast<AbsReference*
>(
this);
30 CPP11_shared_ptr<const CatalogEntry>
record =
31 archive_.catalogEntry(searchId_);
32 const unsigned long long idFound = record->id();
35 if (idFound && this->isIOCompatible(*record))
37 if (idFound != searchId_)
throw IOInvalidData(
38 "In AbsReference::initialize: catalog is corrupted");
39 modifiable->itemId_ = searchId_;
45 archive_.search(*modifiable);
50 const unsigned long nFound = idList_.size();
51 const unsigned long long*
ids = &idList_[0];
53 for (
unsigned long i=1;
i<nFound; ++
i)
54 if (ids[
i-1] >= ids[
i])
60 std::sort(modifiable->idList_.begin(),
61 modifiable->idList_.end());
64 modifiable->initialized_ =
true;
67 bool AbsReference::isIOCompatible(
const CatalogEntry&
r)
const 69 return !classId_.name().empty() &&
70 classId_.name() == r.type().name() &&
71 ioProto_ == r.ioPrototype();
78 return itemId_ == 0 && idList_.empty();
85 return itemId_ && idList_.empty();
92 return itemId_ ? 1UL : idList_.size();
99 if (itemId_ && index == 0UL)
101 else if (index < idList_.size())
102 return idList_[index];
104 throw gs::IOOutOfRange(
"In gs::AbsReference::id: " 105 "index out of range");
108 CPP11_shared_ptr<const CatalogEntry>
109 AbsReference::indexedCatalogEntry(
const unsigned long index)
const 111 return archive_.catalogEntry(
id(index));
114 bool AbsReference::isSameIOPrototype(
const CatalogEntry& r)
const 116 return ioProto_ == r.ioPrototype();
119 void AbsReference::addItemId(
const unsigned long long idIn)
121 if (!idIn)
throw gs::IOInvalidArgument(
122 "In AbsReference::addItemId: invalid item id");
123 const unsigned long mySize = itemId_ ? 1UL : idList_.size();
132 idList_.push_back(itemId_);
133 idList_.push_back(idIn);
138 idList_.push_back(idIn);
143 AbsReference::AbsReference(AbsArchive& ar,
const ClassId& classId,
144 const char* ioPrototype,
145 const unsigned long long itemId)
148 ioProto_(ioPrototype ? ioPrototype :
""),
155 if (!itemId)
throw gs::IOInvalidArgument(
156 "In AbsReference constructor: invalid item id");
159 AbsReference::AbsReference(AbsArchive& ar,
const ClassId& classId,
160 const char* ioPrototype,
161 const SearchSpecifier& namePattern,
162 const SearchSpecifier& categoryPattern)
165 ioProto_(ioPrototype ? ioPrototype :
""),
167 namePattern_(namePattern),
168 categoryPattern_(categoryPattern),
static AlgebraicMatrix initialize()
def unique(seq, keepstr=True)