CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/FWCore/Framework/interface/DataKey.h

Go to the documentation of this file.
00001 #ifndef Framework_DataKey_h
00002 #define Framework_DataKey_h
00003 // -*- C++ -*-
00004 //
00005 // Package:     Framework
00006 // Class  :     DataKey
00007 // 
00016 //
00017 // Author:      Chris Jones
00018 // Created:     Thu Mar 31 14:31:03 EST 2005
00019 //
00020 
00021 // system include files
00022 
00023 // user include files
00024 #include "FWCore/Framework/interface/DataKeyTags.h"
00025 #include "FWCore/Framework/interface/HCTypeTag.h"
00026 
00027 // forward declarations
00028 namespace edm {
00029    namespace eventsetup {
00030 class DataKey
00031 {
00032 
00033    friend void swap(DataKey&, DataKey&);
00034    public:
00035    enum DoNotCopyMemory { kDoNotCopyMemory };
00036    
00037       DataKey();
00038       DataKey(const TypeTag& iType, 
00039                const IdTags& iId) :
00040          type_(iType),
00041          name_(iId),
00042          ownMemory_() {
00043            makeCopyOfMemory();
00044          }
00045 
00046       DataKey(const TypeTag& iType, 
00047                const IdTags& iId,
00048                DoNotCopyMemory) :
00049          type_(iType),
00050          name_(iId),
00051          ownMemory_(false) {}
00052       
00053       DataKey(const DataKey& iRHS) : 
00054          type_(iRHS.type_),
00055          name_(iRHS.name_),
00056          ownMemory_() {
00057            makeCopyOfMemory();
00058          }
00059       
00060       DataKey& operator=(const DataKey&); // stop default
00061       
00062       ~DataKey() { releaseMemory(); }
00063       
00064       // ---------- const member functions ---------------------
00065       const TypeTag& type() const { return type_; }
00066       const NameTag& name() const { return name_; }
00067       
00068       bool operator==(const DataKey& iRHS) const;
00069       bool operator<(const DataKey& iRHS) const;
00070       
00071       // ---------- static member functions --------------------
00072       template<class T>
00073          static TypeTag makeTypeTag() {
00074             return heterocontainer::HCTypeTag::make<T>();
00075          }
00076       
00077       // ---------- member functions ---------------------------
00078 
00079    private:
00080       void makeCopyOfMemory();
00081       void releaseMemory() {
00082          if(ownMemory_) {
00083             deleteMemory();
00084             ownMemory_ = false;
00085          }
00086       }
00087       void deleteMemory();
00088       void swap(DataKey&);
00089       
00090       // ---------- member data --------------------------------
00091       TypeTag type_;
00092       NameTag name_;
00093       bool ownMemory_;
00094 };
00095 
00096     // Free swap function
00097     inline
00098     void
00099     swap(DataKey& a, DataKey& b) 
00100     {
00101       a.swap(b);
00102     }
00103   }
00104 }
00105 #endif