Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:29:08

0001 #ifndef ServiceRegistry_Service_h
0002 #define ServiceRegistry_Service_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     ServiceRegistry
0006 // Class  :     Service
0007 //
0008 /**\class Service Service.h FWCore/ServiceRegistry/interface/Service.h
0009 
0010  Description: Smart pointer used to give easy access to Service's
0011 
0012  Usage:
0013     
0014 
0015 */
0016 //
0017 // Original Author:  Chris Jones
0018 //         Created:  Wed Sep  7 15:17:17 EDT 2005
0019 //
0020 
0021 // system include files
0022 
0023 // user include files
0024 #include "FWCore/ServiceRegistry/interface/ServiceRegistry.h"
0025 
0026 // forward declarations
0027 
0028 namespace edm {
0029   template <class T>
0030   class Service {
0031   public:
0032     Service() {}
0033     //virtual ~Service();
0034 
0035     // ---------- const member functions ---------------------
0036     T* operator->() const { return &(ServiceRegistry::instance().template get<T>()); }
0037 
0038     T& operator*() const { return ServiceRegistry::instance().template get<T>(); }
0039 
0040     bool isAvailable() const { return ServiceRegistry::instance().template isAvailable<T>(); }
0041 
0042     operator bool() const { return isAvailable(); }
0043 
0044     // ---------- static member functions --------------------
0045 
0046     // ---------- member functions ---------------------------
0047 
0048   private:
0049   };
0050 
0051 }  // namespace edm
0052 
0053 #endif