Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-13 23:27:02

0001 #ifndef Framework_ConstProductRegistry_h
0002 #define Framework_ConstProductRegistry_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     Framework
0006 // Class  :     ConstProductRegistry
0007 //
0008 /**\class ConstProductRegistry ConstProductRegistry.h FWCore/Framework/interface/ConstProductRegistry.h
0009 
0010 Description: Provides a 'service' interface to the ProductRegistry
0011 
0012 Usage:
0013 <usage>
0014 
0015 */
0016 //
0017 // Original Author:  Chris Jones
0018 //         Created:  Thu Sep 22 18:01:21 CEST 2005
0019 //
0020 
0021 // system include files
0022 #include <vector>
0023 #include <string>
0024 
0025 // user include files
0026 #include "FWCore/Framework/interface/SignallingProductRegistry.h"
0027 #include "FWCore/ServiceRegistry/interface/connect_but_block_self.h"
0028 #include "FWCore/Utilities/interface/propagate_const.h"
0029 
0030 // forward declarations
0031 namespace edm {
0032   class ConstProductRegistry {
0033   public:
0034     typedef ProductRegistry::ProductList ProductList;
0035 
0036     ConstProductRegistry(SignallingProductRegistry& iReg) : reg_(&iReg) {}
0037 
0038     ConstProductRegistry(ConstProductRegistry const&) = delete;             // Disallow copying and moving
0039     ConstProductRegistry& operator=(ConstProductRegistry const&) = delete;  // Disallow copying and moving
0040 
0041     // ---------- const member functions ---------------------
0042     ProductRegistry const& productRegistry() const { return *reg_; }
0043 
0044     ProductList const& productList() const { return reg_->productList(); }
0045 
0046     // Return all the branch names currently known to *this.  This
0047     // does a return-by-value of the vector so that it may be used in
0048     // a colon-initialization list.
0049     std::vector<std::string> allBranchNames() const { return reg_->allBranchNames(); }
0050 
0051     // Return pointers to (const) BranchDescriptions for all the
0052     // BranchDescriptions known to *this.  This does a
0053     // return-by-value of the vector so that it may be used in a
0054     // colon-initialization list.
0055     std::vector<BranchDescription const*> allBranchDescriptions() const { return reg_->allBranchDescriptions(); }
0056 
0057     bool anyProductProduced() const { return reg_->anyProductProduced(); }
0058 
0059     template <class T>
0060     void watchProductAdditions(const T& iFunc) {
0061       serviceregistry::connect_but_block_self(reg_->productAddedSignal_, iFunc);
0062     }
0063     template <class T, class TMethod>
0064     void watchProductAdditions(T const& iObj, TMethod iMethod) {
0065       using std::placeholders::_1;
0066       serviceregistry::connect_but_block_self(reg_->productAddedSignal_, std::bind(iMethod, iObj, _1));
0067     }
0068 
0069   private:
0070     // ---------- member data --------------------------------
0071     edm::propagate_const<SignallingProductRegistry*> reg_;
0072   };
0073 }  // namespace edm
0074 
0075 #endif