CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/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 // $Id: DataKey.h,v 1.8 2010/01/15 20:35:48 chrjones Exp $
00020 //
00021 
00022 // system include files
00023 
00024 // user include files
00025 #include "FWCore/Framework/interface/DataKeyTags.h"
00026 #include "FWCore/Framework/interface/HCTypeTag.h"
00027 
00028 // forward declarations
00029 namespace edm {
00030    namespace eventsetup {
00031 class DataKey
00032 {
00033 
00034    friend void swap(DataKey&, DataKey&);
00035    public:
00036    enum DoNotCopyMemory { kDoNotCopyMemory };
00037    
00038       DataKey();
00039       DataKey(const TypeTag& iType, 
00040                const IdTags& iId) :
00041          type_(iType),
00042          name_(iId),
00043          ownMemory_() {
00044            makeCopyOfMemory();
00045          }
00046 
00047       DataKey(const TypeTag& iType, 
00048                const IdTags& iId,
00049                DoNotCopyMemory) :
00050          type_(iType),
00051          name_(iId),
00052          ownMemory_(false) {}
00053       
00054       DataKey(const DataKey& iRHS) : 
00055          type_(iRHS.type_),
00056          name_(iRHS.name_),
00057          ownMemory_() {
00058            makeCopyOfMemory();
00059          }
00060       
00061       const DataKey& operator=(const DataKey&); // stop default
00062       
00063       ~DataKey() { releaseMemory(); }
00064       
00065       // ---------- const member functions ---------------------
00066       const TypeTag& type() const { return type_; }
00067       const NameTag& name() const { return name_; }
00068       
00069       bool operator==(const DataKey& iRHS) const;
00070       bool operator<(const DataKey& iRHS) const;
00071       
00072       // ---------- static member functions --------------------
00073       template<class T>
00074          static TypeTag makeTypeTag() {
00075             return heterocontainer::HCTypeTag::make<T>();
00076          }
00077       
00078       // ---------- member functions ---------------------------
00079 
00080    private:
00081       void makeCopyOfMemory();
00082       void releaseMemory() {
00083          if(ownMemory_) {
00084             deleteMemory();
00085             ownMemory_ = false;
00086          }
00087       }
00088       void deleteMemory();
00089       void swap(DataKey&);
00090       
00091       // ---------- member data --------------------------------
00092       TypeTag type_;
00093       NameTag name_;
00094       bool ownMemory_;
00095 };
00096 
00097     // Free swap function
00098     inline
00099     void
00100     swap(DataKey& a, DataKey& b) 
00101     {
00102       a.swap(b);
00103     }
00104   }
00105 }
00106 #endif