Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef Framework_ESPreFunctorDecorator_h
0002 #define Framework_ESPreFunctorDecorator_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     Framework
0006 // Class  :     ESPreFunctorDecorator
0007 //
0008 /**\class ESPreFunctorDecorator ESPreFunctorDecorator.h FWCore/Framework/interface/ESPreFunctorDecorator.h
0009 
0010  Description: A Decorator that works as a adapter to call a Functor before each call to the decorated method
0011 
0012  Usage:
0013     This Decorator can be used to create a decorator used in the ESProducer::setWhatProduced method.  This Decorator
0014 will adapt a Functor (a class that implements 'operator()') st that it is called before every call made to
0015 the ESProducer's 'produce' method.
0016 
0017 */
0018 //
0019 // Original Author:  Chris Jones
0020 //         Created:  Wed Jun 22 11:40:41 EDT 2005
0021 //
0022 
0023 // system include files
0024 
0025 // user include files
0026 
0027 // forward declarations
0028 
0029 namespace edm {
0030   namespace eventsetup {
0031 
0032     template <class TRecord, class TFunctor>
0033     class ESPreFunctorDecorator {
0034     public:
0035       ESPreFunctorDecorator(const TFunctor& iCaller) : caller_(iCaller) {}
0036       ESPreFunctorDecorator() = delete;
0037       ESPreFunctorDecorator(ESPreFunctorDecorator&&) = default;
0038       ESPreFunctorDecorator(ESPreFunctorDecorator const&) = default;
0039       ESPreFunctorDecorator& operator=(const ESPreFunctorDecorator&) = delete;  // stop default
0040       ESPreFunctorDecorator& operator=(ESPreFunctorDecorator&&) = delete;
0041 
0042       //virtual ~ESPreFunctorDecorator();
0043 
0044       // ---------- const member functions ---------------------
0045 
0046       // ---------- static member functions --------------------
0047 
0048       // ---------- member functions ---------------------------
0049       void pre(const TRecord& iRecord) { caller_(iRecord); }
0050 
0051       void post(const TRecord&) {}
0052 
0053     private:
0054       //ESPreFunctorDecorator(const ESPreFunctorDecorator&); // stop default
0055 
0056       // ---------- member data --------------------------------
0057       TFunctor caller_;
0058     };
0059 
0060   }  // namespace eventsetup
0061 }  // namespace edm
0062 
0063 #endif