Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:27:43

0001 #ifndef Framework_DataKey_h
0002 #define Framework_DataKey_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     Framework
0006 // Class  :     DataKey
0007 //
0008 /**\class DataKey DataKey.h FWCore/Framework/interface/DataKey.h
0009 
0010  Description: Key used to identify data within a EventSetupRecord
0011 
0012  Usage:
0013     <usage>
0014 
0015 */
0016 //
0017 // Author:      Chris Jones
0018 // Created:     Thu Mar 31 14:31:03 EST 2005
0019 //
0020 
0021 // system include files
0022 
0023 // user include files
0024 #include "FWCore/Framework/interface/DataKeyTags.h"
0025 #include "FWCore/Framework/interface/HCTypeTag.h"
0026 
0027 // forward declarations
0028 namespace edm::eventsetup {
0029   class DataKey {
0030     friend void swap(DataKey&, DataKey&);
0031 
0032   public:
0033     enum DoNotCopyMemory { kDoNotCopyMemory };
0034 
0035     DataKey();
0036     DataKey(const TypeTag& iType, const IdTags& iId) : type_(iType), name_(iId), ownMemory_() { makeCopyOfMemory(); }
0037 
0038     DataKey(const TypeTag& iType, const IdTags& iId, DoNotCopyMemory) : type_(iType), name_(iId), ownMemory_(false) {}
0039 
0040     DataKey(const DataKey& iRHS) : type_(iRHS.type_), name_(iRHS.name_), ownMemory_() { makeCopyOfMemory(); }
0041 
0042     DataKey(DataKey&& iRHS) : type_(iRHS.type_), name_(iRHS.name_), ownMemory_(iRHS.ownMemory_) {
0043       iRHS.ownMemory_ = false;
0044     }
0045 
0046     DataKey& operator=(const DataKey&);
0047     DataKey& operator=(DataKey&&);
0048 
0049     ~DataKey() { releaseMemory(); }
0050 
0051     // ---------- const member functions ---------------------
0052     const TypeTag& type() const { return type_; }
0053     const NameTag& name() const { return name_; }
0054 
0055     bool operator==(const DataKey& iRHS) const;
0056     inline bool operator!=(const DataKey& iRHS) const { return not(*this == iRHS); }
0057     bool operator<(const DataKey& iRHS) const;
0058 
0059     // ---------- static member functions --------------------
0060     template <class T>
0061     static TypeTag makeTypeTag() {
0062       return heterocontainer::HCTypeTag::make<T>();
0063     }
0064 
0065     // ---------- member functions ---------------------------
0066 
0067   private:
0068     void makeCopyOfMemory();
0069     void releaseMemory() {
0070       if (ownMemory_) {
0071         deleteMemory();
0072         ownMemory_ = false;
0073       }
0074     }
0075     void deleteMemory();
0076     void swap(DataKey&);
0077 
0078     // ---------- member data --------------------------------
0079     TypeTag type_{};
0080     NameTag name_{};
0081     bool ownMemory_{false};
0082   };
0083 
0084   // Free swap function
0085   inline void swap(DataKey& a, DataKey& b) { a.swap(b); }
0086 }  // namespace edm::eventsetup
0087 #endif