File indexing completed on 2023-03-17 11:02:03
0001 #ifndef Framework_HCMethods_h
0002 #define Framework_HCMethods_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include "FWCore/Framework/interface/HCTypeTag.h"
0021 #include <type_traits>
0022
0023
0024 namespace edm {
0025 namespace eventsetup {
0026 namespace heterocontainer {
0027 template <class Type, class Key, class IdTag>
0028 inline Key makeKey(const IdTag& iIdTag) {
0029 HCTypeTag typeTag = HCTypeTag::make<Type>();
0030 return Key(typeTag, iIdTag);
0031 }
0032
0033 template <class Type, class Key>
0034 inline Key makeKey() {
0035 HCTypeTag typeTag = HCTypeTag::make<Type>();
0036 return Key(typeTag);
0037 }
0038
0039
0040
0041
0042
0043
0044 template <class Key, class ItemType>
0045 struct type_from_itemtype {
0046 typedef typename std::remove_const<ItemType>::type Type;
0047 };
0048
0049 template <class Key, class ItemType, class Storage, class IdTag>
0050 inline bool insert(Storage& iStorage, ItemType* iItem, const IdTag& iIdTag) {
0051 return iStorage.insert(makeKey<typename type_from_itemtype<Key, ItemType>::Type, Key>(iIdTag), iItem);
0052 }
0053
0054 template <class Key, class ItemType, class Storage>
0055 inline bool insert(Storage& iStorage, ItemType* iItem) {
0056 return iStorage.insert(makeKey<ItemType, Key>(), iItem);
0057 }
0058
0059 template <class Key, class ItemType, class Storage, class IdTag>
0060 inline ItemType* find(const Storage& iStorage, const IdTag& iIdTag) {
0061
0062 return static_cast<ItemType*>(
0063 iStorage.find(makeKey<typename type_from_itemtype<Key, ItemType>::Type, Key>(iIdTag)));
0064 }
0065
0066 template <class Key, class ItemType, class Storage>
0067 inline ItemType* find(const Storage& iStorage) {
0068
0069 return static_cast<ItemType*>(iStorage.find(makeKey<typename type_from_itemtype<Key, ItemType>::Type, Key>()));
0070 }
0071 }
0072 }
0073 }
0074 #endif