Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef ServiceRegistry_ServiceWrapper_h
0002 #define ServiceRegistry_ServiceWrapper_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     ServiceRegistry
0006 // Class  :     ServiceWrapper
0007 //
0008 /**\class ServiceWrapper ServiceWrapper.h FWCore/ServiceRegistry/interface/ServiceWrapper.h
0009 
0010  Description: Wrapper around a Service
0011 
0012  Usage:
0013     Implementation detail of the ServiceRegistry system
0014 
0015 */
0016 //
0017 // Original Author:  Chris Jones
0018 //         Created:  Mon Sep  5 13:33:01 EDT 2005
0019 //
0020 
0021 // system include files
0022 #include <memory>
0023 
0024 // user include files
0025 #include "FWCore/ServiceRegistry/interface/ServiceWrapperBase.h"
0026 #include "FWCore/Utilities/interface/propagate_const.h"
0027 
0028 // forward declarations
0029 namespace edm {
0030   class ParameterSet;
0031   class ActivityRegistry;
0032 
0033   namespace serviceregistry {
0034 
0035     template <class T>
0036     class ServiceWrapper : public ServiceWrapperBase {
0037     public:
0038       ServiceWrapper(std::unique_ptr<T> iService) : service_(std::move(iService)) {}
0039       ServiceWrapper(const ServiceWrapper&) = delete;                   // stop default
0040       const ServiceWrapper& operator=(const ServiceWrapper&) = delete;  // stop default
0041 
0042       // ---------- const member functions ---------------------
0043       T const& get() const { return *service_; }
0044 
0045       // ---------- static member functions --------------------
0046 
0047       // ---------- member functions ---------------------------
0048       T& get() { return *service_; }
0049 
0050     private:
0051       // ---------- member data --------------------------------
0052       edm::propagate_const<std::unique_ptr<T>> service_;
0053     };
0054   }  // namespace serviceregistry
0055 }  // namespace edm
0056 
0057 #endif