![]() |
|
|||
File indexing completed on 2023-03-17 11:01:59
0001 #ifndef Framework_data_default_record_trait_h 0002 #define Framework_data_default_record_trait_h 0003 // -*- C++ -*- 0004 // 0005 // Package: Framework 0006 // Class : data_default_record_trait 0007 // 0008 /**\class data_default_record_trait data_default_record_trait.h FWCore/Framework/interface/data_default_record_trait.h 0009 0010 Description: trait class that assigns a default EventSetup Record to a particular data type 0011 0012 Usage: 0013 Many types of data in a EventSetup are only available in one Record type. For example, the HCal Alignment 0014 data only appears in the HCal Alignment Record. For such cases, it is annoying for users to have to specify 0015 both the Record and the Data type in order to get the data. In such a case, a specialization of 0016 data_default_record_trait for that data type can be assigned to allow access 'direct' access to that data 0017 from the EventSetup 0018 0019 ESHandle<MyData> pMyData; 0020 eventSetup.getData(pMyData); 0021 0022 which is just a short hand for 0023 0024 ESHandle<MyData> pMyData; 0025 eventSetup.get<MyDataRecord>.get(pMyData); 0026 0027 To specify the default record, you must use the macro EVENTSETUP_DATA_DEFAULT_RECORD in the header file for 0028 the data (or in a header file that users will include). For Example 0029 0030 0031 #include "..../MyDataRecord.h" 0032 0033 class MyData { ... 0034 }; 0035 0036 EVENTSETUP_DATA_DEFAULT_RECORD(MyData, MyDataRecord); 0037 */ 0038 // 0039 // Author: Chris Jones 0040 // Created: Thu Apr 7 07:59:56 CDT 2005 0041 // 0042 0043 namespace edm { 0044 0045 template <typename T> 0046 class ESHandle; 0047 0048 // Special class to denote that the default record should be used. 0049 struct DefaultRecord {}; 0050 0051 namespace eventsetup { 0052 template <class T> 0053 struct MUST_GET_RECORD_FROM_EVENTSETUP_TO_GET_DATA; 0054 0055 template <class DataT> 0056 struct data_default_record_trait { 0057 //NOTE: by default, a data item does not have a default record 0058 typedef MUST_GET_RECORD_FROM_EVENTSETUP_TO_GET_DATA<DataT> type; 0059 }; 0060 0061 template <typename T> 0062 struct default_record { 0063 using data_type = typename T::value_type; 0064 using RecordT = typename eventsetup::data_default_record_trait<data_type>::type; 0065 }; 0066 0067 template <typename T> 0068 using default_record_t = typename default_record<T>::RecordT; 0069 } // namespace eventsetup 0070 0071 template <typename T> 0072 struct ESHandleAdapter { 0073 using value_type = T; 0074 }; 0075 } // namespace edm 0076 0077 #define EVENTSETUP_DATA_DEFAULT_RECORD(_data_, _record_) \ 0078 namespace edm::eventsetup { \ 0079 template <> \ 0080 struct data_default_record_trait<_data_> { \ 0081 typedef _record_ type; \ 0082 }; \ 0083 } 0084 0085 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.2.1 LXR engine. The LXR team |
![]() ![]() |