CMS 3D CMS Logo

StringArchive.cc
Go to the documentation of this file.
1 #include "Alignment/Geners/interface/IOException.hh"
2 #include <cassert>
3 #include <sstream>
4 
5 #include "Alignment/Geners/interface/StringArchive.hh"
6 #include "Alignment/Geners/interface/streamposIO.hh"
7 
8 namespace gs {
9  void StringArchive::search(AbsReference &reference) {
10  std::vector<unsigned long long> idlist;
11  catalog_.search(reference.namePattern(), reference.categoryPattern(), &idlist);
12  const unsigned long nfound = idlist.size();
13  for (unsigned long i = 0; i < nfound; ++i) {
14  std::shared_ptr<const CatalogEntry> pentry = catalog_.retrieveEntry(idlist[i]);
15  if (reference.isIOCompatible(*pentry))
16  addItemToReference(reference, idlist[i]);
17  }
18  }
19 
20  std::istream &StringArchive::inputStream(const unsigned long long id, long long *sz) {
21  if (!id)
22  throw gs::IOInvalidArgument("In gs::StringArchive::inputStream: invalid item id");
23  unsigned cCode;
24  std::streampos pos;
25  unsigned long long itemLen;
26  if (!catalog_.retrieveStreampos(id, &cCode, &itemLen, &pos)) {
27  std::ostringstream os;
28  os << "In gs::StringArchive::inputStream: "
29  << "failed to locate item with id " << id;
30  throw gs::IOInvalidArgument(os.str());
31  }
32  if (sz)
33  *sz = -1LL;
34  stream_.seekg(pos);
35  return stream_;
36  }
37 
38  bool StringArchive::isEqual(const AbsArchive &cata) const {
39  const StringArchive &r = static_cast<const StringArchive &>(cata);
40  return lastpos_ == r.lastpos_ && name() == r.name() && stream_ == r.stream_ && catalog_ == r.catalog_;
41  }
42 
43  bool StringArchive::write(std::ostream &of) const {
44  write_pod(of, lastpos_);
45  write_pod(of, name());
46  return !of.fail() && stream_.classId().write(of) && stream_.write(of) && catalog_.classId().write(of) &&
47  catalog_.write(of);
48  }
49 
50  StringArchive *StringArchive::read(const ClassId &id, std::istream &in) {
51  static const ClassId current(ClassId::makeId<StringArchive>());
52  current.ensureSameId(id);
53 
54  std::streampos lastpos;
55  read_pod(in, &lastpos);
56  std::string nam;
57  read_pod(in, &nam);
58  if (in.fail())
59  throw IOReadFailure("In gs::StringArchive::read: input stream failure");
60  CPP11_auto_ptr<StringArchive> archive(new StringArchive(nam.c_str()));
61  archive->lastpos_ = lastpos;
62  ClassId streamId(in, 1);
63  CharBuffer::restore(streamId, in, &archive->stream_);
64  ClassId catId(in, 1);
65  CPP11_auto_ptr<ContiguousCatalog> p(ContiguousCatalog::read(catId, in));
66  assert(p.get());
67  archive->catalog_ = *p;
68  return archive.release();
69  }
70 } // namespace gs
contentValuesCheck.nfound
nfound
Definition: contentValuesCheck.py:80
mps_fire.i
i
Definition: mps_fire.py:428
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
pos
Definition: PixelAliasList.h:18
cms::cuda::assert
assert(be >=bs)
gs
Definition: AbsArchive.cc:45
cond::persistency::search
std::vector< T >::const_iterator search(const cond::Time_t &val, const std::vector< T > &container)
Definition: IOVProxy.cc:21
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
recoMuon::in
Definition: RecoMuonEnumerators.h:6
RecoTauValidation_cfi.reference
reference
Definition: RecoTauValidation_cfi.py:234
alignCSCRings.r
r
Definition: alignCSCRings.py:93
readEcalDQMStatus.read
read
Definition: readEcalDQMStatus.py:38
writeEcalDQMStatus.write
write
Definition: writeEcalDQMStatus.py:48
L1DTConfigBti_cff.LL
LL
Definition: L1DTConfigBti_cff.py:25
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17