Go to the documentation of this file.00001 #ifndef DataFormats_Provenance_ProductHolderIndexHelper_h
00002 #define DataFormats_Provenance_ProductHolderIndexHelper_h
00003
00054 #include "FWCore/Utilities/interface/ProductHolderIndex.h"
00055 #include "FWCore/Utilities/interface/ProductKindOfType.h"
00056 #include "FWCore/Utilities/interface/TypeID.h"
00057
00058 #include <iosfwd>
00059 #include <memory>
00060 #include <set>
00061 #include <string>
00062 #include <vector>
00063
00064 namespace edm {
00065 class TypeWithDict;
00066
00067 class ProductHolderIndexHelper {
00068 public:
00069
00070 ProductHolderIndexHelper();
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096 ProductHolderIndex index(KindOfType kindOfType,
00097 TypeID const& typeID,
00098 char const* moduleLabel,
00099 char const* instance,
00100 char const* process = 0) const;
00101
00102 class Matches {
00103 public:
00104 Matches(ProductHolderIndexHelper const* productHolderIndexHelper,
00105 unsigned int startInIndexAndNames,
00106 unsigned int numberOfMatches);
00107
00108 ProductHolderIndex index(unsigned int i) const;
00109 unsigned int numberOfMatches() const { return numberOfMatches_; }
00110 bool isFullyResolved(unsigned int i) const;
00111 private:
00112 ProductHolderIndexHelper const* productHolderIndexHelper_;
00113 unsigned int startInIndexAndNames_;
00114 unsigned int numberOfMatches_;
00115 };
00116
00117
00118
00119
00120
00121 Matches
00122 relatedIndexes(KindOfType kindOfType,
00123 TypeID const& typeID,
00124 char const* moduleLabel,
00125 char const* instance) const;
00126
00127
00128 Matches
00129 relatedIndexes(KindOfType kindOfType,
00130 TypeID const& typeID) const;
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154 ProductHolderIndex
00155 insert(TypeWithDict const& typeWithDict,
00156 char const* moduleLabel,
00157 char const* instance,
00158 char const* process);
00159
00160
00161
00162
00163 void setFrozen();
00164
00165 std::vector<std::string> const& lookupProcessNames() const;
00166
00167 class Range {
00168 public:
00169 Range(unsigned int begin, unsigned int end) : begin_(begin), end_(end) { }
00170 unsigned int begin() const { return begin_; }
00171 unsigned int end() const { return end_; }
00172 private:
00173 unsigned int begin_;
00174 unsigned int end_;
00175 };
00176
00177 class IndexAndNames {
00178 public:
00179 IndexAndNames(ProductHolderIndex index, unsigned int start, unsigned int startProcess) :
00180 index_(index), startInBigNamesContainer_(start), startInProcessNames_(startProcess) { }
00181 ProductHolderIndex index() const { return index_; }
00182 unsigned int startInBigNamesContainer() const { return startInBigNamesContainer_; }
00183 unsigned int startInProcessNames() const { return startInProcessNames_; }
00184 private:
00185 ProductHolderIndex index_;
00186 unsigned int startInBigNamesContainer_;
00187 unsigned int startInProcessNames_;
00188 };
00189
00190 unsigned int beginElements() const { return beginElements_; }
00191 std::vector<TypeID> const& sortedTypeIDs() const { return sortedTypeIDs_; }
00192 std::vector<Range> const& ranges() const { return ranges_; }
00193 std::vector<IndexAndNames> const& indexAndNames() const { return indexAndNames_; }
00194 std::vector<char> const& processNames() const { return processNames_; }
00195
00196
00197
00198
00199 unsigned int indexToIndexAndNames(KindOfType kindOfType,
00200 TypeID const& typeID,
00201 char const* moduleLabel,
00202 char const* instance,
00203 char const* process) const;
00204
00205
00206
00207 unsigned int indexToType(KindOfType kindOfType, TypeID const& typeID) const;
00208
00209
00210
00211 unsigned int processIndex(char const* process) const;
00212
00213
00214
00215
00216 void sanityCheck() const;
00217
00218 ProductHolderIndex nextIndexValue() const { return nextIndexValue_; }
00219
00220
00221 void print(std::ostream& os) const;
00222
00223 private:
00224
00225
00226
00227 ProductHolderIndex nextIndexValue_;
00228
00229
00230
00231
00232 unsigned int beginElements_;
00233
00234
00235
00236
00237
00238
00239 std::vector<TypeID> sortedTypeIDs_;
00240
00241
00242
00243
00244
00245
00246 std::vector<Range> ranges_;
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258 std::vector<IndexAndNames> indexAndNames_;
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270 std::vector<char> bigNamesContainer_;
00271 std::vector<char> processNames_;
00272
00273
00274
00275 std::vector<std::string> lookupProcessNames_;
00276
00277
00278
00279
00280 class Item {
00281 public:
00282 Item(KindOfType kindOfType,
00283 TypeID const& typeID,
00284 std::string const& moduleLabel,
00285 std::string const& instance,
00286 std::string const& process,
00287 ProductHolderIndex index);
00288 KindOfType kindOfType() const { return kindOfType_; }
00289 TypeID const& typeID() const { return typeID_; }
00290 std::string const& moduleLabel() const { return moduleLabel_; }
00291 std::string const& instance() const { return instance_; }
00292 std::string const& process() const { return process_; }
00293 ProductHolderIndex index() const { return index_; }
00294
00295 void clearProcess() { process_.clear(); }
00296 void setIndex(ProductHolderIndex v) { index_ = v; }
00297
00298 bool operator<(Item const& right) const;
00299
00300 private:
00301 KindOfType kindOfType_;
00302 TypeID typeID_;
00303 std::string moduleLabel_;
00304 std::string instance_;
00305 std::string process_;
00306 ProductHolderIndex index_;
00307 };
00308
00309 std::unique_ptr<std::set<Item> > items_;
00310
00311 std::unique_ptr<std::set<std::string> > processItems_;
00312 };
00313 }
00314 #endif