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 { class WrapperBase; }
31 
32 namespace fwlite {
33  namespace internal {
34  class DataKey {
35  public:
36  //NOTE: Do not take ownership of strings. This is done to avoid
37  // doing 'new's and string copies when we just want to lookup the data
38  // This means something else is responsible for the pointers remaining
39  // valid for the time for which the pointers are still in use
40  DataKey(const edm::TypeID& iType,
41  char const* iModule,
42  char const* iProduct,
43  char const* iProcess) :
44  type_(iType),
45  module_(iModule != nullptr ? iModule : kEmpty()),
46  product_(iProduct != nullptr ? iProduct : kEmpty()),
47  process_(iProcess != nullptr ? iProcess : kEmpty()) {}
48 
50  }
51 
52  bool operator<(const DataKey& iRHS) const {
53  if(type_ < iRHS.type_) {
54  return true;
55  }
56  if(iRHS.type_ < type_) {
57  return false;
58  }
59  int comp = std::strcmp(module_,iRHS.module_);
60  if(0 != comp) {
61  return comp < 0;
62  }
63  comp = std::strcmp(product_,iRHS.product_);
64  if(0 != comp) {
65  return comp < 0;
66  }
67  comp = std::strcmp(process_,iRHS.process_);
68  return comp < 0;
69  }
70  char const* kEmpty() const {return "";}
71  char const* module() const {return module_;}
72  char const* product() const {return product_;}
73  char const* process() const {return process_;}
74  const edm::TypeID& typeID() const {return type_;}
75 
76  private:
78  char const* module_;
79  char const* product_;
80  char const* process_;
81  };
82 
83  struct Data {
85  Long64_t lastProduct_;
86  edm::ObjectWithDict obj_; // For wrapped object
87  void* pObj_; // ROOT requires the address of the pointer be stable
88  edm::WrapperBase const* pProd_; // WrapperBase of the wrapped object
89 
90  ~Data() {
91  obj_.destruct(true);
92  }
93  };
94 
95  class ProductGetter;
96  }
97 
98 }
99 
100 #endif
static const char module_[]
edm::propagate_const< TBranch * > branch_
#define nullptr
edm::ObjectWithDict obj_
char const * product() const
const edm::TypeID & typeID() const
char const * kEmpty() const
char const * module() const
edm::WrapperBase const * pProd_
void destruct(bool dealloc) const
bool operator<(const DataKey &iRHS) const
char const * process() const
HLT enums.
DataKey(const edm::TypeID &iType, char const *iModule, char const *iProduct, char const *iProcess)