00001 #ifndef ServiceRegistry_Service_h 00002 #define ServiceRegistry_Service_h 00003 // -*- C++ -*- 00004 // 00005 // Package: ServiceRegistry 00006 // Class : Service 00007 // 00016 // 00017 // Original Author: Chris Jones 00018 // Created: Wed Sep 7 15:17:17 EDT 2005 00019 // $Id: Service.h,v 1.2 2005/09/12 19:09:56 chrjones Exp $ 00020 // 00021 00022 // system include files 00023 00024 // user include files 00025 #include "FWCore/ServiceRegistry/interface/ServiceRegistry.h" 00026 00027 // forward declarations 00028 00029 namespace edm { 00030 template<class T> 00031 class Service 00032 { 00033 00034 public: 00035 Service() {} 00036 //virtual ~Service(); 00037 00038 // ---------- const member functions --------------------- 00039 T* operator->() const { 00040 return &(ServiceRegistry::instance().template get<T>()); 00041 } 00042 00043 T& operator*() const { 00044 return ServiceRegistry::instance().template get<T>(); 00045 } 00046 00047 bool isAvailable() const { 00048 return ServiceRegistry::instance().template isAvailable<T>(); 00049 } 00050 00051 operator bool() const { 00052 return isAvailable(); 00053 } 00054 00055 // ---------- static member functions -------------------- 00056 00057 // ---------- member functions --------------------------- 00058 00059 private: 00060 }; 00061 00062 } 00063 00064 #endif