Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-23 03:25:10

0001 #ifndef FWCore_Utilities_EDPutToken_h
0002 #define FWCore_Utilities_EDPutToken_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     FWCore/Utilities
0006 // Class  :     EDPutToken
0007 //
0008 /**\class EDPutToken EDPutToken.h "FWCore/Utilities/interface/EDPutToken.h"
0009 
0010  Description: A Token used to put data into the EDM
0011 
0012  Usage:
0013     A EDPutToken is created by calls to 'produces'from an EDProducer or EDFilter.
0014  The EDPutToken can then be used to quickly put data into the edm::Event, edm::LuminosityBlock or edm::Run.
0015  
0016 The templated form, EDPutTokenT<T>, is the same as EDPutToken except when used to get data the framework
0017  will skip checking that the type being requested matches the type specified during the 'produces'' call.
0018 
0019 */
0020 //
0021 // Original Author:  Chris Jones
0022 //         Created:  Mon, 18 Sep 2017 17:54:11 GMT
0023 //
0024 
0025 // system include files
0026 
0027 // user include files
0028 
0029 // forward declarations
0030 namespace edm {
0031   class ProductRegistryHelper;
0032   template <typename T>
0033   class EDPutTokenT;
0034   namespace test {
0035     class TestProcessorConfig;
0036   }
0037 
0038   class EDPutToken {
0039     friend class ProductRegistryHelper;
0040 
0041   public:
0042     using value_type = unsigned int;
0043 
0044     constexpr EDPutToken() noexcept : m_value{s_uninitializedValue} {}
0045 
0046     template <typename T>
0047     constexpr EDPutToken(EDPutTokenT<T> iOther) noexcept : m_value{iOther.m_value} {}
0048 
0049     // ---------- const member functions ---------------------
0050     constexpr value_type index() const noexcept { return m_value; }
0051     constexpr bool isUninitialized() const noexcept { return m_value == s_uninitializedValue; }
0052 
0053   private:
0054     //for testing
0055     friend class TestEDPutToken;
0056 
0057     static constexpr unsigned int s_uninitializedValue = 0xFFFFFFFF;
0058 
0059     explicit constexpr EDPutToken(unsigned int iValue) noexcept : m_value(iValue) {}
0060 
0061     // ---------- member data --------------------------------
0062     value_type m_value;
0063   };
0064 
0065   template <typename T>
0066   class EDPutTokenT {
0067     friend class ProductRegistryHelper;
0068     friend class EDPutToken;
0069     friend class edm::test::TestProcessorConfig;
0070 
0071   public:
0072     using value_type = EDPutToken::value_type;
0073 
0074     constexpr EDPutTokenT() noexcept : m_value{s_uninitializedValue} {}
0075 
0076     constexpr EDPutTokenT(const EDPutTokenT<T>&) noexcept = default;
0077     constexpr EDPutTokenT(EDPutTokenT<T>&&) noexcept = default;
0078     constexpr EDPutTokenT(EDPutTokenT<T>& iToken) noexcept : EDPutTokenT(const_cast<EDPutTokenT<T> const&>(iToken)) {}
0079 
0080     template <typename ADAPTER>
0081     constexpr explicit EDPutTokenT(ADAPTER&& iAdapter) noexcept : EDPutTokenT(iAdapter.template produces<T>()) {}
0082 
0083     constexpr EDPutTokenT& operator=(const EDPutTokenT<T>&) noexcept = default;
0084     constexpr EDPutTokenT& operator=(EDPutTokenT<T>&&) noexcept = default;
0085     constexpr EDPutTokenT& operator=(EDPutTokenT<T>& iOther) noexcept {
0086       m_value = iOther.m_value;
0087       return *this;
0088     }
0089 
0090     template <typename ADAPTER>
0091     constexpr EDPutTokenT& operator=(ADAPTER&& iAdapter) noexcept {
0092       EDPutTokenT<T> temp(iAdapter.template produces<T>());
0093       m_value = temp.m_value;
0094 
0095       return *this;
0096     }
0097 
0098     // ---------- const member functions ---------------------
0099     constexpr value_type index() const noexcept { return m_value; }
0100     constexpr bool isUninitialized() const noexcept { return m_value == s_uninitializedValue; }
0101 
0102   private:
0103     //for testing
0104     friend class TestEDPutToken;
0105 
0106     static constexpr unsigned int s_uninitializedValue = 0xFFFFFFFF;
0107 
0108     constexpr explicit EDPutTokenT(unsigned int iValue) noexcept : m_value(iValue) {}
0109     constexpr explicit EDPutTokenT(unsigned long int iValue) noexcept : m_value(iValue) {}
0110 
0111     // ---------- member data --------------------------------
0112     value_type m_value;
0113   };
0114 }  // namespace edm
0115 
0116 #endif