File indexing completed on 2024-04-06 12:12:01
0001 #ifndef Framework_DataKey_h
0002 #define Framework_DataKey_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 #include "FWCore/Framework/interface/DataKeyTags.h"
0025 #include "FWCore/Framework/interface/HCTypeTag.h"
0026
0027
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
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
0060 template <class T>
0061 static TypeTag makeTypeTag() {
0062 return heterocontainer::HCTypeTag::make<T>();
0063 }
0064
0065
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
0079 TypeTag type_{};
0080 NameTag name_{};
0081 bool ownMemory_{false};
0082 };
0083
0084
0085 inline void swap(DataKey& a, DataKey& b) { a.swap(b); }
0086 }
0087 #endif