Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:12:02

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     <usage>
0014 
0015 */
0016 //
0017 // Original Author:  Chris Jones
0018 //         Created:  Thu, 19 Sep 2019 15:51:19 GMT
0019 //
0020 
0021 // system include files
0022 #include <string_view>
0023 #include <vector>
0024 
0025 // user include files
0026 #include "FWCore/Utilities/interface/ESIndices.h"
0027 
0028 // forward declarations
0029 
0030 namespace edm {
0031   namespace test {
0032     class ESTagGetterTester;
0033   }
0034   class ESTagGetter {
0035   public:
0036     friend test::ESTagGetterTester;
0037     struct Info {
0038       template <typename I, typename P, typename M>
0039       Info(I&& iIndex, P&& iProduct, M&& iModule)
0040           : index_(std::forward<I>(iIndex)),
0041             productLabel_(std::forward<P>(iProduct)),
0042             moduleLabel_(std::forward<M>(iModule)) {}
0043       ESResolverIndex index_;
0044       std::string productLabel_;
0045       std::string_view moduleLabel_;
0046     };
0047 
0048     ESTagGetter() = default;
0049     ESTagGetter(ESTagGetter const&) = default;
0050     ESTagGetter(ESTagGetter&&) = default;
0051 
0052     ESTagGetter(std::vector<Info> const& iLookup) : lookup_(iLookup) {}
0053 
0054     ESTagGetter& operator=(ESTagGetter const&) = default;
0055     ESTagGetter& operator=(ESTagGetter&&) = default;
0056 
0057     // ---------- const member functions ---------------------
0058     ESResolverIndex operator()(std::string_view iModuleLabel, std::string_view iProductLabel) const;
0059 
0060     ESResolverIndex nothing() const { return ESResolverIndex(); }
0061 
0062     ///Returns true if the Record being searched contains no products of the proper type
0063     bool hasNothingToGet() const { return lookup_.empty(); }
0064 
0065   private:
0066     std::vector<Info> lookup_;
0067   };
0068 }  // namespace edm
0069 
0070 #endif