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 
24 #include "TBranch.h"
25 #include "Reflex/Object.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  const char* iModule,
40  const char* iProduct,
41  const char* 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  const char* kEmpty() const {return "";}
69  const char* module() const {return module_;}
70  const char* product() const {return product_;}
71  const char* process() const {return process_;}
72  const edm::TypeID& typeID() const {return type_;}
73 
74  private:
76  const char* module_;
77  const char* product_;
78  const char* process_;
79  };
80 
81  struct Data {
82  TBranch* branch_;
83  Long64_t lastProduct_;
84  Reflex::Object obj_;
85  void * pObj_; //ROOT requires the address of the pointer be stable
87 
88  ~Data() {
89  obj_.Destruct();
90  }
91  };
92 
93  class ProductGetter;
94  }
95 
96 }
97 
98 #endif /*__CINT__ */
99 #endif
const char * product() const
const char * kEmpty() const
const char * process() const
const edm::TypeID & typeID() const
DataKey(const edm::TypeID &iType, const char *iModule, const char *iProduct, const char *iProcess)
bool operator<(const DataKey &iRHS) const
edm::EDProduct * pProd_
const char * module() const