Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

Service.h

Go to the documentation of this file.
00001 // $Header: /nfs/slac/g/glast/ground/cvs/GaudiKernel/GaudiKernel/Service.h,v 1.1.1.1 2001/04/18 18:14:18 tlindner Exp $
00002 #ifndef GAUDIKERNEL_SERVICE_H
00003 #define GAUDIKERNEL_SERVICE_H
00004 
00005 // Include files
00006 #include "GaudiKernel/IService.h"
00007 #include "GaudiKernel/IProperty.h"
00008 #include "GaudiKernel/PropertyMgr.h"
00009 
00010 #include <vector>
00011 
00012 // Forward delarations
00013 class ISvcLocator;
00014 class IMessageSvc;
00015 class IJobOptions;
00016 
00023 class Service : public virtual IService,
00024                 public virtual IProperty {
00025 public:
00027   enum State { OFFLINE, INITIALIZED };
00028 
00033   virtual StatusCode queryInterface(const IID& riid, void** ppvUnknown);
00034 
00036   virtual unsigned long addRef();
00037 
00039   virtual unsigned long release();
00040 
00042   virtual const std::string& name() const;
00044   virtual const IID& type() const;
00046   State state( ) const { return m_state; }
00048   virtual StatusCode initialize();
00050   virtual StatusCode finalize();
00051 
00052   // Default implementations for ISetProperty
00053   virtual StatusCode setProperty(const Property& p);
00054   virtual StatusCode setProperty( std::istream& s );
00055   virtual StatusCode setProperty( const std::string& n, const std::string& v);
00056   virtual StatusCode getProperty(Property* p) const;
00057   virtual const Property& getProperty( const std::string& name) const;
00058   virtual StatusCode getProperty( const std::string& n, std::string& v ) const;
00059   virtual const std::vector<Property*>& getProperties( ) const;
00060 
00062   Service( const std::string& name, ISvcLocator* svcloc);
00064   ISvcLocator* serviceLocator() const;
00066   IMessageSvc* msgSvc();
00067   IMessageSvc* msgSvc() const;
00068   // Obsoleted name, kept due to the backwards compatibility
00069   IMessageSvc* messageService();
00070   IMessageSvc* messageService() const;
00071 
00072 
00076   StatusCode setProperties();
00077 
00080   template <class T>
00081   StatusCode service( const std::string& name, T*& svc, bool createIf = false ) const {
00082     IService* theSvc;
00083     StatusCode sc = serviceLocator()->getService( name, theSvc, createIf );
00084     if ( sc.isSuccess() ) {
00085       return theSvc->queryInterface(T::interfaceID(), (void**)&svc);
00086     }
00087     svc = 0;
00088     return sc;
00089   }
00090 
00092   template <class T>
00093   StatusCode declareProperty( const std::string& name, T& property ) const {
00094         m_propertyMgr->declareProperty(name, property);
00095         return StatusCode::SUCCESS;
00096   }
00097 
00098 protected:
00100   virtual ~Service();
00102   int           m_outputLevel; 
00103 private:
00105   std::string   m_name;
00107   unsigned long m_refCount;
00109   ISvcLocator*  m_svcLocator;
00111   IMessageSvc*  m_messageSvc;
00113   IJobOptions*  m_jobOptions;
00115   State         m_state;
00117   PropertyMgr*  m_propertyMgr;
00118 };
00119 
00120 #endif // GAUDIKERNEL_SERVICE_H

Generated at Wed Nov 21 12:22:05 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000