Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-04-30 22:24:06

0001 #ifndef FWCore_Framework_ESTagGetter_h
0002 #define FWCore_Framework_ESTagGetter_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     FWCore/Framework
0006 // Class  :     ESTagGetter
0007 //
0008 /**\class ESTagGetter ESTagGetter.h "ESTagGetter.h"
0009 
0010  Description: Used with mayConsume option of ESConsumesCollector
0011 
0012  Usage:
0013     This contains a cache of data about all Resolvers which are
0014     associated with data produces which are in the Record and which
0015     are of the proper type.
0016 
0017 */
0018 //
0019 // Original Author:  Chris Jones
0020 //         Created:  Thu, 19 Sep 2019 15:51:19 GMT
0021 //
0022 
0023 // system include files
0024 #include <string_view>
0025 #include <vector>
0026 
0027 // user include files
0028 #include "FWCore/Utilities/interface/ESIndices.h"
0029 
0030 // forward declarations
0031 
0032 namespace edm {
0033   namespace test {
0034     class ESTagGetterTester;
0035   }
0036   class ESTagGetter {
0037   public:
0038     friend test::ESTagGetterTester;
0039     struct Info {
0040       template <typename I, typename P, typename M>
0041       Info(I&& iIndex, P&& iProduct, M&& iModule)
0042           : index_(std::forward<I>(iIndex)),
0043             productLabel_(std::forward<P>(iProduct)),
0044             moduleLabel_(std::forward<M>(iModule)) {}
0045       ESResolverIndex index_;
0046       std::string productLabel_;
0047       std::string_view moduleLabel_;
0048     };
0049 
0050     ESTagGetter() = default;
0051     ESTagGetter(ESTagGetter const&) = default;
0052     ESTagGetter(ESTagGetter&&) = default;
0053 
0054     ESTagGetter(std::vector<Info> const& iLookup) : lookup_(iLookup) {}
0055 
0056     ESTagGetter& operator=(ESTagGetter const&) = default;
0057     ESTagGetter& operator=(ESTagGetter&&) = default;
0058 
0059     // ---------- const member functions ---------------------
0060     ESResolverIndex operator()(std::string_view iModuleLabel, std::string_view iProductLabel) const;
0061 
0062     ESResolverIndex nothing() const { return ESResolverIndex(); }
0063 
0064     ///Returns true if the Record being searched contains no products of the proper type
0065     bool hasNothingToGet() const { return lookup_.empty(); }
0066 
0067     std::vector<Info> const& lookup() const { return lookup_; }
0068 
0069   private:
0070     std::vector<Info> lookup_;
0071   };
0072 }  // namespace edm
0073 
0074 #endif