CMS 3D CMS Logo

InternalDataKey.h
Go to the documentation of this file.
1 #ifndef DataFormats_FWLite_InternalDataKey_h
2 #define DataFormats_FWLite_InternalDataKey_h
3 
4 // -*- C++ -*-
5 //
6 // Package: FWLite
7 // Class : internal::DataKey
8 //
17 //
18 // Original Author: Eric Vaandering
19 // Created: Jan 29 09:01:20 CDT 2009
20 //
21 
25 
26 #include "TBranch.h"
27 
28 #include <cstring>
29 
30 namespace edm {
31  class WrapperBase;
32 }
33 
34 namespace fwlite {
35  namespace internal {
36  class DataKey {
37  public:
38  //NOTE: Do not take ownership of strings. This is done to avoid
39  // doing 'new's and string copies when we just want to lookup the data
40  // This means something else is responsible for the pointers remaining
41  // valid for the time for which the pointers are still in use
42  DataKey(const edm::TypeID& iType, char const* iModule, char const* iProduct, char const* iProcess)
43  : type_(iType),
44  module_(iModule != nullptr ? iModule : kEmpty()),
45  product_(iProduct != nullptr ? iProduct : kEmpty()),
46  process_(iProcess != nullptr ? iProcess : kEmpty()) {}
47 
48  ~DataKey() {}
49 
50  bool operator<(const DataKey& iRHS) const {
51  if (type_ < iRHS.type_) {
52  return true;
53  }
54  if (iRHS.type_ < type_) {
55  return false;
56  }
57  int comp = std::strcmp(module_, iRHS.module_);
58  if (0 != comp) {
59  return comp < 0;
60  }
61  comp = std::strcmp(product_, iRHS.product_);
62  if (0 != comp) {
63  return comp < 0;
64  }
65  comp = std::strcmp(process_, iRHS.process_);
66  return comp < 0;
67  }
68  char const* kEmpty() const { return ""; }
69  char const* module() const { return module_; }
70  char const* product() const { return product_; }
71  char const* process() const { return process_; }
72  const edm::TypeID& typeID() const { return type_; }
73 
74  private:
76  char const* module_;
77  char const* product_;
78  char const* process_;
79  };
80 
81  struct Data {
83  Long64_t lastProduct_;
84  edm::ObjectWithDict obj_; // For wrapped object
85  void* pObj_; // ROOT requires the address of the pointer be stable
86  edm::WrapperBase const* pProd_; // WrapperBase of the wrapped object
87 
88  ~Data() { obj_.destruct(true); }
89  };
90 
91  class ProductGetter;
92  } // namespace internal
93 
94 } // namespace fwlite
95 
96 #endif
const edm::TypeID & typeID() const
char const * process() const
void destruct(bool dealloc) const
edm::propagate_const< TBranch * > branch_
char const * product() const
edm::ObjectWithDict obj_
edm::WrapperBase const * pProd_
char const * module() const
bool operator<(const DataKey &iRHS) const
HLT enums.
DataKey(const edm::TypeID &iType, char const *iModule, char const *iProduct, char const *iProcess)
char const * kEmpty() const