CMS 3D CMS Logo

InputTag.cc
Go to the documentation of this file.
4 
5 namespace edm {
6 
7  const std::string InputTag::kSkipCurrentProcess("@skipCurrentProcess");
8  const std::string InputTag::kCurrentProcess("@currentProcess");
9  static std::string const separator(":");
10 
12  : label_(),
13  instance_(),
14  process_(),
15  typeID_(),
16  productRegistry_(nullptr),
18  branchType_(NumBranchTypes),
19  skipCurrentProcess_(false) {}
20 
22  : label_(label),
23  instance_(instance),
24  process_(processName),
25  typeID_(),
30 
31  InputTag::InputTag(char const* label, char const* instance, char const* processName)
32  : label_(label),
33  instance_(instance),
34  process_(processName),
35  typeID_(),
40 
42  : label_(),
43  instance_(),
44  process_(),
45  typeID_(),
50  // string is delimited by colons
51  std::vector<std::string> tokens = tokenize(s, separator);
52  size_t nwords = tokens.size();
53  if (nwords > 3) {
54  throw edm::Exception(errors::Configuration, "InputTag") << "Input tag " << s << " has " << nwords << " tokens";
55  }
56  if (nwords > 0)
57  label_ = tokens[0];
58  if (nwords > 1)
59  instance_ = tokens[1];
60  if (nwords > 2)
61  process_ = tokens[2];
63  }
64 
66 
68  : label_(other.label()),
69  instance_(other.instance()),
70  process_(other.process()),
71  typeID_(),
76  ProductResolverIndex otherIndex = other.index_.load();
77  if (otherIndex < ProductResolverIndexInitializing) {
78  branchType_ = other.branchType_;
79  typeID_ = other.typeID_;
81  index_.store(otherIndex);
82  }
83  }
84 
86  : label_(std::move(other.label())),
89  typeID_(),
94  ProductResolverIndex otherIndex = other.index_.load();
95  if (otherIndex < ProductResolverIndexInitializing) {
96  branchType_ = other.branchType_;
97  typeID_ = other.typeID_;
98  productRegistry_ = other.productRegistry_;
99  index_.store(otherIndex);
100  }
101  }
102 
104  if (this != &other) {
105  label_ = other.label_;
106  instance_ = other.instance_;
107  process_ = other.process_;
109 
110  ProductResolverIndex otherIndex = other.index_.load();
111  if (otherIndex < ProductResolverIndexInitializing) {
112  branchType_ = other.branchType_;
113  typeID_ = other.typeID_;
115  index_.store(otherIndex);
116  } else {
118  typeID_ = TypeID();
119  productRegistry_ = nullptr;
121  }
122  }
123  return *this;
124  }
125 
127  if (this != &other) {
128  label_ = std::move(other.label_);
129  instance_ = std::move(other.instance_);
130  process_ = std::move(other.process_);
131  skipCurrentProcess_ = other.skipCurrentProcess_;
132 
133  ProductResolverIndex otherIndex = other.index_.load();
134  if (otherIndex < ProductResolverIndexInitializing) {
135  branchType_ = other.branchType_;
136  typeID_ = other.typeID_;
137  productRegistry_ = other.productRegistry_;
138  index_.store(otherIndex);
139  } else {
141  typeID_ = TypeID();
142  productRegistry_ = nullptr;
144  }
145  }
146  return *this;
147  }
148 
150  char const* p1 = kSkipCurrentProcess.c_str();
151  char const* p2 = process_.c_str();
152  while (*p1 && (*p1 == *p2)) {
153  ++p1;
154  ++p2;
155  }
156  return *p1 == *p2;
157  }
158 
160  //NOTE: since the encoding gets used to form the configuration hash I did not want
161  // to change it so that not specifying a process would cause two colons to appear in the
162  // encoding and thus not being backwards compatible
164  if (!instance_.empty() || !process_.empty()) {
165  result += separator + instance_;
166  }
167  if (!process_.empty()) {
168  result += separator + process_;
169  }
170  return result;
171  }
172 
173  bool InputTag::operator==(InputTag const& tag) const {
174  return (label_ == tag.label_) && (instance_ == tag.instance_) && (process_ == tag.process_);
175  }
176 
179  void const* productRegistry) const {
181 
182  // This will no longer be necessary when the compiler supports the memory
183  // order associated with atomics.
184  __sync_synchronize();
185 
186  if (index < ProductResolverIndexInitializing && typeID_ == typeID && branchType_ == branchType &&
187  productRegistry_ == productRegistry) {
188  return index;
189  }
191  }
192 
194  TypeID const& typeID,
196  void const* productRegistry) const {
197  unsigned int invalidValue = static_cast<unsigned int>(ProductResolverIndexInvalid);
198  if (index_.compare_exchange_strong(invalidValue, static_cast<unsigned int>(ProductResolverIndexInitializing))) {
199  typeID_ = typeID;
201  productRegistry_ = productRegistry;
202 
203  // This will no longer be necessary when the compiler supports the memory
204  // order associated with atomics.
205  __sync_synchronize();
206 
207  index_.store(index);
208  }
209  }
210 
211  std::ostream& operator<<(std::ostream& ost, InputTag const& tag) {
212  static std::string const process(", process = ");
213  ost << "InputTag: label = " << tag.label() << ", instance = " << tag.instance()
214  << (tag.process().empty() ? std::string() : (process + tag.process()));
215  return ost;
216  }
217 } // namespace edm
unsigned int ProductResolverIndex
InputTag & operator=(InputTag const &other)
Definition: InputTag.cc:103
#define nullptr
std::string instance_
Definition: InputTag.h:60
std::string encode() const
Definition: InputTag.cc:159
BranchType
Definition: BranchType.h:11
ProductResolverIndex indexFor(TypeID const &typeID, BranchType branchType, void const *productRegistry) const
Definition: InputTag.cc:177
void tryToCacheIndex(ProductResolverIndex index, TypeID const &typeID, BranchType branchType, void const *productRegistry) const
Definition: InputTag.cc:193
static const std::string kSkipCurrentProcess
Definition: InputTag.h:53
static const std::string kCurrentProcess
Definition: InputTag.h:54
std::string process_
Definition: InputTag.h:61
bool calcSkipCurrentProcess() const
Definition: InputTag.cc:149
std::string label_
Definition: InputTag.h:59
double p2[4]
Definition: TauolaWrapper.h:90
void const * productRegistry_
Definition: InputTag.h:64
bool willSkipCurrentProcess() const
Definition: InputTag.h:42
bool operator==(InputTag const &tag) const
Definition: InputTag.cc:173
std::string const & label() const
Definition: InputTag.h:36
std::string const & process() const
Definition: InputTag.h:40
bool skipCurrentProcess_
Definition: InputTag.h:70
HLT enums.
double p1[4]
Definition: TauolaWrapper.h:89
char branchType_
Definition: InputTag.h:68
static std::string const separator(":")
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
std::string const & instance() const
Definition: InputTag.h:37
std::atomic< unsigned int > index_
Definition: InputTag.h:66
def move(src, dest)
Definition: eostools.py:511
def branchType(schema, name)
Definition: revisionDML.py:114
TypeID typeID_
Definition: InputTag.h:63
std::vector< std::string > tokenize(std::string const &input, std::string const &separator)
breaks the input string into tokens, delimited by the separator