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
fwlite
Definition: TFileDirectory.h:16
propagate_const.h
edm
HLT enums.
Definition: AlignableModifier.h:19
fwlite::internal::Data::lastProduct_
Long64_t lastProduct_
Definition: InternalDataKey.h:83
edm::ObjectWithDict
Definition: ObjectWithDict.h:17
fwlite::internal::Data::obj_
edm::ObjectWithDict obj_
Definition: InternalDataKey.h:84
TypeID.h
fwlite::internal::DataKey::product
char const * product() const
Definition: InternalDataKey.h:70
fwlite::internal::DataKey::module_
char const * module_
Definition: InternalDataKey.h:76
fwlite::internal::Data::~Data
~Data()
Definition: InternalDataKey.h:88
fwlite::internal::DataKey::~DataKey
~DataKey()
Definition: InternalDataKey.h:48
AlCaHLTBitMon_QueryRunRegistry.comp
comp
Definition: AlCaHLTBitMon_QueryRunRegistry.py:249
fwlite::internal::DataKey::type_
edm::TypeID type_
Definition: InternalDataKey.h:75
ObjectWithDict.h
edm::propagate_const< TBranch * >
fwlite::internal::DataKey::product_
char const * product_
Definition: InternalDataKey.h:77
edm::ObjectWithDict::destruct
void destruct(bool dealloc) const
Definition: ObjectWithDict.cc:92
fwlite::internal::DataKey
Definition: InternalDataKey.h:36
fwlite::internal::DataKey::module
char const * module() const
Definition: InternalDataKey.h:69
fwlite::internal::Data::branch_
edm::propagate_const< TBranch * > branch_
Definition: InternalDataKey.h:82
fwlite::internal::Data
Definition: InternalDataKey.h:81
edm::WrapperBase
Definition: WrapperBase.h:23
fwlite::internal::DataKey::operator<
bool operator<(const DataKey &iRHS) const
Definition: InternalDataKey.h:50
fwlite::internal::Data::pObj_
void * pObj_
Definition: InternalDataKey.h:85
fwlite::internal::DataKey::process_
char const * process_
Definition: InternalDataKey.h:78
edm::TypeID
Definition: TypeID.h:22
internal
Definition: ROOTFilePB.pb.h:39
fwlite::internal::DataKey::DataKey
DataKey(const edm::TypeID &iType, char const *iModule, char const *iProduct, char const *iProcess)
Definition: InternalDataKey.h:42
fwlite::internal::Data::pProd_
edm::WrapperBase const * pProd_
Definition: InternalDataKey.h:86
fwlite::internal::DataKey::typeID
const edm::TypeID & typeID() const
Definition: InternalDataKey.h:72
fwlite::internal::DataKey::process
char const * process() const
Definition: InternalDataKey.h:71
fwlite::internal::DataKey::kEmpty
char const * kEmpty() const
Definition: InternalDataKey.h:68