CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 #if !defined(__CINT__) && !defined(__MAKECINT__)
22 
25 
26 #include "TBranch.h"
27 
28 #include <cstring>
29 
30 namespace fwlite {
31  namespace internal {
32  class DataKey {
33  public:
34  //NOTE: Do not take ownership of strings. This is done to avoid
35  // doing 'new's and string copies when we just want to lookup the data
36  // This means something else is responsible for the pointers remaining
37  // valid for the time for which the pointers are still in use
38  DataKey(const edm::TypeID& iType,
39  char const* iModule,
40  char const* iProduct,
41  char const* iProcess) :
42  type_(iType),
43  module_(iModule!=0? iModule:kEmpty()),
44  product_(iProduct!=0?iProduct:kEmpty()),
45  process_(iProcess!=0?iProcess:kEmpty()) {}
46 
48  }
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 {
82  TBranch* branch_;
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() {
89  obj_.typeOf().destruct(obj_.address(), true);
90  }
91  };
92 
93  class ProductGetter;
94  }
95 
96 }
97 
98 #endif /*__CINT__ */
99 #endif
void * address() const
edm::ObjectWithDict obj_
char const * product() const
const edm::TypeID & typeID() const
char const * kEmpty() const
char const * module() const
edm::WrapperBase const * pProd_
TypeWithDict const & typeOf() const
bool operator<(const DataKey &iRHS) const
void destruct(void *address, bool dealloc=true) const
char const * process() const
DataKey(const edm::TypeID &iType, char const *iModule, char const *iProduct, char const *iProcess)