CMS 3D CMS Logo

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