CMS 3D CMS Logo

ItemLocation.cc
Go to the documentation of this file.
1 #include "Alignment/Geners/interface/IOException.hh"
2 #include "Alignment/Geners/interface/ItemLocation.hh"
3 #include "Alignment/Geners/interface/streamposIO.hh"
4 
5 namespace gs {
6  bool ItemLocation::operator==(const ItemLocation &r) const {
7  if (pos_ != r.pos_)
8  return false;
9  if (URI_ != r.URI_)
10  return false;
11  // If global URI does not exist, local URI must coincide exactly.
12  // If global URI exists, local URI may or may not be defined.
13  if (!URI_.empty()) {
14  if (!cachedItemURI_.empty() && !r.cachedItemURI_.empty())
15  if (cachedItemURI_ != r.cachedItemURI_)
16  return false;
17  } else if (cachedItemURI_ != r.cachedItemURI_)
18  return false;
19  return true;
20  }
21 
22  bool ItemLocation::write(std::ostream &of) const {
23  // The code for storing the stream offset is necessarily
24  // going to be implementation-dependent. The C++ standard
25  // does not specify std::streampos with enough detail.
26  write_pod(of, pos_);
27  write_pod(of, URI_);
28  write_pod(of, cachedItemURI_);
29  return !of.fail();
30  }
31 
32  ItemLocation *ItemLocation::read(const ClassId &id, std::istream &in) {
33  static const ClassId current(ClassId::makeId<ItemLocation>());
34  current.ensureSameId(id);
35 
36  std::streampos pos;
37  read_pod(in, &pos);
38 
39  std::string globURI;
40  read_pod(in, &globURI);
41 
42  std::string cachedItemURI;
43  read_pod(in, &cachedItemURI);
44 
45  if (in.fail())
46  throw IOReadFailure("In ItemLocation::read: input stream failure");
47 
48  return new ItemLocation(pos, globURI.c_str(), cachedItemURI.c_str());
49  }
50 } // namespace gs
bool operator==(const QGLikelihoodParameters &lhs, const QGLikelihoodCategory &rhs)
Test if parameters are compatible with category.
Definition: AbsArchive.cc:45
def write(self, setup)