| # Gaudi Framework, version v21r6 |

Home |  | Generated: 11 Nov 2009

# Converter.cpp

Go to the documentation of this file.

    00001 // $Header: /tmp/svngaudi/tmp.jEpFh25751/Gaudi/GaudiKernel/src/Lib/Converter.cpp,v 1.17 2007/12/12 16:02:32 marcocle Exp $
    00002
    00003 // Include Files
    00004 #include "GaudiKernel/Converter.h"
    00005 #include "GaudiKernel/ISvcLocator.h"
    00006 #include "GaudiKernel/IMessageSvc.h"
    00007 #include "GaudiKernel/IDataManagerSvc.h"
    00008 #include "GaudiKernel/IDataProviderSvc.h"
    00009 #include "GaudiKernel/GaudiException.h"
    00010 #include "GaudiKernel/ServiceLocatorHelper.h"
    00011 #include "GaudiKernel/ThreadGaudi.h"
    00012 #include "GaudiKernel/ConversionSvc.h"
    00013
    00015 const CLID& Converter::objType() const    {
    00016   return m_classType;
    00017 }
    00018
    00020 long Converter::i_repSvcType() const   {
    00021   return m_storageType;
    00022 }
    00023
    00025 StatusCode Converter::createObj(IOpaqueAddress*, DataObject*&)   {
    00026   return StatusCode::SUCCESS;
    00027 }
    00028
    00029
    00031 StatusCode Converter::fillObjRefs(IOpaqueAddress*, DataObject*)    {
    00032   return StatusCode::SUCCESS;
    00033 }
    00034
    00036 StatusCode Converter::updateObj(IOpaqueAddress*, DataObject*)   {
    00037   return StatusCode::SUCCESS;
    00038 }
    00039
    00041 StatusCode Converter::updateObjRefs(IOpaqueAddress*, DataObject*)  {
    00042   return StatusCode::SUCCESS;
    00043 }
    00044
    00046 StatusCode Converter::createRep(DataObject*, IOpaqueAddress*&)  {
    00047   return StatusCode::SUCCESS;
    00048 }
    00049
    00051 StatusCode Converter::fillRepRefs(IOpaqueAddress*, DataObject*)  {
    00052   return StatusCode::SUCCESS;
    00053 }
    00054
    00056 StatusCode Converter::updateRep(IOpaqueAddress*, DataObject*)  {
    00057   return StatusCode::SUCCESS;
    00058 }
    00059
    00061 StatusCode Converter::updateRepRefs(IOpaqueAddress*, DataObject*)    {
    00062   return StatusCode::SUCCESS;
    00063 }
    00064
    00066 StatusCode Converter::initialize()    {
    00067   // Get a reference to the Message Service
    00068   if ( !msgSvc().isValid() )   {
    00069     return StatusCode::FAILURE;
    00070   }
    00071   return StatusCode::SUCCESS;
    00072 }
    00073
    00075 StatusCode Converter::finalize() {
    00076   // release services
    00077   m_messageSvc = 0;
    00078   m_dataManager = 0;
    00079   m_dataProvider = 0;
    00080   m_conversionSvc = 0;
    00081   m_addressCreator = 0;
    00082   return StatusCode::SUCCESS;
    00083 }
    00084
    00086 StatusCode Converter::setDataProvider(IDataProviderSvc* svc) {
    00087   m_dataProvider = svc;
    00088   m_dataManager = svc;
    00089   return StatusCode::SUCCESS;
    00090 }
    00091
    00093 SmartIF<IDataProviderSvc>& Converter::dataProvider()  const    {
    00094   return m_dataProvider;
    00095 }
    00096
    00098 SmartIF<IDataManagerSvc>& Converter::dataManager()  const    {
    00099   return m_dataManager;
    00100 }
    00101
    00103 StatusCode Converter::setConversionSvc(IConversionSvc* svc)   {
    00104   m_conversionSvc = svc;
    00105   return StatusCode::SUCCESS;
    00106 }
    00107
    00109 SmartIF<IConversionSvc>& Converter::conversionSvc()  const    {
    00110   return m_conversionSvc;
    00111 }
    00112
    00114 StatusCode Converter::setAddressCreator(IAddressCreator* creator)   {
    00115   m_addressCreator = creator;
    00116   return StatusCode::SUCCESS;
    00117 }
    00118
    00120 SmartIF<IAddressCreator>& Converter::addressCreator()  const   {
    00121   return m_addressCreator;
    00122 }
    00123
    00125 SmartIF<ISvcLocator>& Converter::serviceLocator()  const     {
    00126   return m_svcLocator;
    00127 }
    00128
    00130 SmartIF<IMessageSvc>& Converter::msgSvc()  const   {
    00131   if ( !m_messageSvc.isValid() ) {
    00132     m_messageSvc = serviceLocator();
    00133     if( !m_messageSvc.isValid() ) {
    00134       throw GaudiException("Service [MessageSvc] not found", "Converter", StatusCode::FAILURE);
    00135     }
    00136   }
    00137   return m_messageSvc;
    00138 }
    00139
    00140 // Obsoleted name, kept due to the backwards compatibility
    00141 SmartIF<IMessageSvc>& Converter::messageService()  const   {
    00142   return msgSvc();
    00143 }
    00144
    00146 Converter::Converter(long storage_type, const CLID& class_type, ISvcLocator* svc) :
    00147   m_storageType(storage_type),
    00148   m_classType(class_type),
    00149   m_svcLocator(svc)
    00150 {
    00151 }
    00152
    00154 Converter::~Converter() {
    00155 }
    00156
    00157 StatusCode
    00158 Converter::service_i(const std::string& svcName, bool createIf,
    00159                      const InterfaceID& iid, void** ppSvc) const {
    00160   // Check for name of conversion service
    00161   SmartIF<IService> cnvsvc(conversionSvc());
    00162   if (cnvsvc.isValid()) {
    00163     const ServiceLocatorHelper helper(*serviceLocator(), "Converter", cnvsvc->name());
    00164     return helper.getService(svcName, createIf, iid, ppSvc);
    00165   }
    00166   return StatusCode::FAILURE;
    00167 }
    00168
    00169 StatusCode
    00170 Converter::service_i(const std::string& svcType, const std::string& svcName,
    00171                      const InterfaceID& iid, void** ppSvc) const {
    00172   // Check for name of conversion service
    00173   SmartIF<IService> cnvsvc(conversionSvc());
    00174   if (cnvsvc.isValid()) {
    00175     const ServiceLocatorHelper helper(*serviceLocator(), "Converter", cnvsvc->name());
    00176     return helper.createService(svcType, svcName, iid, ppSvc);
    00177   }
    00178   return StatusCode::FAILURE;
    00179 }
    00180
    00181 SmartIF<IService> Converter::service(const std::string& name, const bool createIf) const {
    00182   SmartIF<IService> cnvsvc(conversionSvc());
    00183   SmartIF<IService> svc;
    00184   if (cnvsvc.isValid()) {
    00185     const ServiceLocatorHelper helper(*serviceLocator(), "Converter", cnvsvc->name());
    00186     svc = helper.service(name, false, createIf);
    00187   }
    00188   return svc;
    00189 }