CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10/src/DataFormats/FWLite/interface/InternalDataKey.h

Go to the documentation of this file.
00001 #ifndef DataFormats_FWLite_InternalDataKey_h
00002 #define DataFormats_FWLite_InternalDataKey_h
00003 
00004 // -*- C++ -*-
00005 //
00006 // Package:     FWLite
00007 // Class  :     internal::DataKey
00008 //
00017 //
00018 // Original Author:  Eric Vaandering
00019 //         Created:  Jan 29 09:01:20 CDT 2009
00020 //
00021 #if !defined(__CINT__) && !defined(__MAKECINT__)
00022 
00023 #include "FWCore/Utilities/interface/TypeID.h"
00024 
00025 #include "Reflex/Object.h"
00026 #include "TBranch.h"
00027 
00028 #include <cstring>
00029 
00030 namespace fwlite {
00031    namespace internal {
00032       class DataKey {
00033          public:
00034             //NOTE: Do not take ownership of strings.  This is done to avoid
00035             // doing 'new's and string copies when we just want to lookup the data
00036             // This means something else is responsible for the pointers remaining
00037             // valid for the time for which the pointers are still in use
00038             DataKey(const edm::TypeID& iType,
00039                     char const* iModule,
00040                     char const* iProduct,
00041                     char const* iProcess) :
00042                type_(iType),
00043                module_(iModule!=0? iModule:kEmpty()),
00044                product_(iProduct!=0?iProduct:kEmpty()),
00045                process_(iProcess!=0?iProcess:kEmpty()) {}
00046 
00047             ~DataKey() {
00048             }
00049 
00050             bool operator<(const DataKey& iRHS) const {
00051                if(type_ < iRHS.type_) {
00052                   return true;
00053                }
00054                if(iRHS.type_ < type_) {
00055                   return false;
00056                }
00057                int comp = std::strcmp(module_,iRHS.module_);
00058                if(0 != comp) {
00059                   return comp < 0;
00060                }
00061                comp = std::strcmp(product_,iRHS.product_);
00062                if(0 != comp) {
00063                   return comp < 0;
00064                }
00065                comp = std::strcmp(process_,iRHS.process_);
00066                return comp < 0;
00067             }
00068             char const* kEmpty()  const {return "";}
00069             char const* module()  const {return module_;}
00070             char const* product() const {return product_;}
00071             char const* process() const {return process_;}
00072             const edm::TypeID& typeID() const {return type_;}
00073 
00074          private:
00075             edm::TypeID type_;
00076             char const* module_;
00077             char const* product_;
00078             char const* process_;
00079       };
00080 
00081       struct Data {
00082             TBranch* branch_;
00083             Long64_t lastProduct_;
00084             Reflex::Object obj_; // For wrapped object
00085             void * pObj_; // pointer to pProd_.  ROOT requires the address of the pointer be stable
00086             void * pProd_; // pointer to wrapped product
00087             edm::WrapperInterfaceBase * interface_;
00088 
00089             ~Data() {
00090                obj_.Destruct();
00091             }
00092       };
00093 
00094       class ProductGetter;
00095    }
00096 
00097 }
00098 
00099 #endif /*__CINT__ */
00100 #endif