| # Gaudi Framework, version v21r10p1 |

Home |  | Generated: 29 Jul 2010

# 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/INamedInterface.h"
    00006 #include "GaudiKernel/ISvcLocator.h"
    00007 #include "GaudiKernel/IMessageSvc.h"
    00008 #include "GaudiKernel/IDataManagerSvc.h"
    00009 #include "GaudiKernel/IDataProviderSvc.h"
    00010 #include "GaudiKernel/GaudiException.h"
    00011 #include "GaudiKernel/ServiceLocatorHelper.h"
    00012 #include "GaudiKernel/ThreadGaudi.h"
    00013 #include "GaudiKernel/ConversionSvc.h"
    00014
    00016 const CLID& Converter::objType() const    {
    00017   return m_classType;
    00018 }
    00019
    00021 long Converter::i_repSvcType() const   {
    00022   return m_storageType;
    00023 }
    00024
    00026 StatusCode Converter::createObj(IOpaqueAddress*, DataObject*&)   {
    00027   return StatusCode::SUCCESS;
    00028 }
    00029
    00030
    00032 StatusCode Converter::fillObjRefs(IOpaqueAddress*, DataObject*)    {
    00033   return StatusCode::SUCCESS;
    00034 }
    00035
    00037 StatusCode Converter::updateObj(IOpaqueAddress*, DataObject*)   {
    00038   return StatusCode::SUCCESS;
    00039 }
    00040
    00042 StatusCode Converter::updateObjRefs(IOpaqueAddress*, DataObject*)  {
    00043   return StatusCode::SUCCESS;
    00044 }
    00045
    00047 StatusCode Converter::createRep(DataObject*, IOpaqueAddress*&)  {
    00048   return StatusCode::SUCCESS;
    00049 }
    00050
    00052 StatusCode Converter::fillRepRefs(IOpaqueAddress*, DataObject*)  {
    00053   return StatusCode::SUCCESS;
    00054 }
    00055
    00057 StatusCode Converter::updateRep(IOpaqueAddress*, DataObject*)  {
    00058   return StatusCode::SUCCESS;
    00059 }
    00060
    00062 StatusCode Converter::updateRepRefs(IOpaqueAddress*, DataObject*)    {
    00063   return StatusCode::SUCCESS;
    00064 }
    00065
    00067 StatusCode Converter::initialize()    {
    00068   // Get a reference to the Message Service
    00069   if ( !msgSvc().isValid() )   {
    00070     return StatusCode::FAILURE;
    00071   }
    00072   return StatusCode::SUCCESS;
    00073 }
    00074
    00076 StatusCode Converter::finalize() {
    00077   // release services
    00078   m_messageSvc = 0;
    00079   m_dataManager = 0;
    00080   m_dataProvider = 0;
    00081   m_conversionSvc = 0;
    00082   m_addressCreator = 0;
    00083   return StatusCode::SUCCESS;
    00084 }
    00085
    00087 StatusCode Converter::setDataProvider(IDataProviderSvc* svc) {
    00088   m_dataProvider = svc;
    00089   m_dataManager = svc;
    00090   return StatusCode::SUCCESS;
    00091 }
    00092
    00094 SmartIF<IDataProviderSvc>& Converter::dataProvider()  const    {
    00095   return m_dataProvider;
    00096 }
    00097
    00099 SmartIF<IDataManagerSvc>& Converter::dataManager()  const    {
    00100   return m_dataManager;
    00101 }
    00102
    00104 StatusCode Converter::setConversionSvc(IConversionSvc* svc)   {
    00105   m_conversionSvc = svc;
    00106   return StatusCode::SUCCESS;
    00107 }
    00108
    00110 SmartIF<IConversionSvc>& Converter::conversionSvc()  const    {
    00111   return m_conversionSvc;
    00112 }
    00113
    00115 StatusCode Converter::setAddressCreator(IAddressCreator* creator)   {
    00116   m_addressCreator = creator;
    00117   return StatusCode::SUCCESS;
    00118 }
    00119
    00121 SmartIF<IAddressCreator>& Converter::addressCreator()  const   {
    00122   return m_addressCreator;
    00123 }
    00124
    00126 SmartIF<ISvcLocator>& Converter::serviceLocator()  const     {
    00127   return m_svcLocator;
    00128 }
    00129
    00131 SmartIF<IMessageSvc>& Converter::msgSvc()  const   {
    00132   if ( !m_messageSvc.isValid() ) {
    00133     m_messageSvc = serviceLocator();
    00134     if( !m_messageSvc.isValid() ) {
    00135       throw GaudiException("Service [MessageSvc] not found", "Converter", StatusCode::FAILURE);
    00136     }
    00137   }
    00138   return m_messageSvc;
    00139 }
    00140
    00141 // Obsoleted name, kept due to the backwards compatibility
    00142 SmartIF<IMessageSvc>& Converter::messageService()  const   {
    00143   return msgSvc();
    00144 }
    00145
    00147 Converter::Converter(long storage_type, const CLID& class_type, ISvcLocator* svc) :
    00148   m_storageType(storage_type),
    00149   m_classType(class_type),
    00150   m_svcLocator(svc)
    00151 {
    00152 }
    00153
    00155 Converter::~Converter() {
    00156 }
    00157
    00158 StatusCode
    00159 Converter::service_i(const std::string& svcName, bool createIf,
    00160                      const InterfaceID& iid, void** ppSvc) const {
    00161   // Check for name of conversion service
    00162   SmartIF<INamedInterface> cnvsvc(conversionSvc());
    00163   if (cnvsvc.isValid()) {
    00164     const ServiceLocatorHelper helper(*serviceLocator(), "Converter", cnvsvc->name());
    00165     return helper.getService(svcName, createIf, iid, ppSvc);
    00166   }
    00167   return StatusCode::FAILURE;
    00168 }
    00169
    00170 StatusCode
    00171 Converter::service_i(const std::string& svcType, const std::string& svcName,
    00172                      const InterfaceID& iid, void** ppSvc) const {
    00173   // Check for name of conversion service
    00174   SmartIF<INamedInterface> cnvsvc(conversionSvc());
    00175   if (cnvsvc.isValid()) {
    00176     const ServiceLocatorHelper helper(*serviceLocator(), "Converter", cnvsvc->name());
    00177     return helper.createService(svcType, svcName, iid, ppSvc);
    00178   }
    00179   return StatusCode::FAILURE;
    00180 }
    00181
    00182 SmartIF<IService> Converter::service(const std::string& name, const bool createIf) const {
    00183   SmartIF<INamedInterface> cnvsvc(conversionSvc());
    00184   SmartIF<IService> svc;
    00185   if (cnvsvc.isValid()) {
    00186     const ServiceLocatorHelper helper(*serviceLocator(), "Converter", cnvsvc->name());
    00187     svc = helper.service(name, false, createIf);
    00188   }
    00189   return svc;
    00190 }