Exemple #1
0
//--------------------------------------------------------------------------------------------
// implementation of IService::reinitialize
//--------------------------------------------------------------------------------------------
StatusCode MTEventLoopMgr::reinitialize() {

  // initilaize the base class
  StatusCode sc = MinimalEventLoopMgr::reinitialize();

  MsgStream log(msgSvc(), name());
  if( sc.isFailure() ) {
    log << MSG::DEBUG << "Error Initializing base class MinimalEventLoopMgr." << endmsg;
    return sc;
  }

  // Check to see whether a new Event Selector has been specified
  setProperty(m_appMgrProperty->getProperty("EvtSel"));
  if( m_evtsel != "NONE" || m_evtsel.length() == 0) {
    IEvtSelector* theEvtSel;
    IService*     theSvc;
    sc = service( "EventSelector", theEvtSel );
    sc = service( "EventSelector", theSvc );
    if( sc.isSuccess() && ( theEvtSel != m_evtSelector ) ) {
      // Setup Event Selector
      m_evtSelector = theEvtSel;
      if (theSvc->state() == IService::INITIALIZED) {
        sc = theSvc->reinitialize();
        if( sc.isFailure() ){
          log << MSG::ERROR << "Failure Reinitializing EventSelector "
              << theSvc->name( ) << endmsg;
          return sc;
        }
      } else {
        sc = theSvc->initialize();
        if( sc.isFailure() ){
          log << MSG::ERROR << "Failure Initializing EventSelector "
              << theSvc->name( ) << endmsg;
          return sc;
        }
      }
      sc = theEvtSel->createContext(m_evtCtxt);
      if( !sc.isSuccess() ) {
        log << MSG::ERROR << "Can not create Context "
            << theSvc->name( ) << endmsg;
        return sc;
      }
      log << MSG::INFO << "EventSelector service changed to "
          << theSvc->name( ) << endmsg;
    }
  }
  else {
    m_evtSelector = 0;
    m_evtCtxt = 0;
  }
  return StatusCode::SUCCESS;
}
Exemple #2
0
/// Add data service
StatusCode PersistencySvc::addCnvService(IConversionSvc* servc)    {
    if ( 0 != servc )   {
        long type = servc->repSvcType();
        long def_typ = (m_cnvDefault) ? m_cnvDefault->repSvcType() : 0;
        Services::iterator it = m_cnvServices.find( type );
        IConversionSvc* cnv_svc = 0;
        if ( it != m_cnvServices.end() )    {
            cnv_svc = (*it).second.conversionSvc();
        }
        if ( type == def_typ )     {
            m_cnvDefault = servc;
        }
        if ( cnv_svc != servc )   {
            IAddressCreator* icr = 0;
            StatusCode status  = servc->queryInterface(IAddressCreator::interfaceID(), pp_cast<void>(&icr));
            if ( status.isSuccess() )   {
                IService* isvc = 0;
                status = servc->queryInterface(IService::interfaceID(), pp_cast<void>(&isvc));
                if ( status.isSuccess() )    {
                    if ( 0 != cnv_svc )   {
                        removeCnvService (type).ignore();
                    }
                    std::pair<Services::iterator, bool> p =
                        m_cnvServices.insert( Services::value_type( type, ServiceEntry(type, isvc, servc, icr)));
                    if( p.second )    {
                        info() << "Added successfully Conversion service:" << isvc->name() << endmsg;
                        servc->addRef();
                        servc->setAddressCreator(this).ignore();
                        servc->setDataProvider(m_dataSvc).ignore();
                        return StatusCode::SUCCESS;
                    }
                    info() << "Cannot add Conversion service of type " << isvc->name() << endmsg;
                    isvc->release();
                    icr->release();
                    return StatusCode::FAILURE;
                }
                icr->release();
            }
            info() << "Cannot add Conversion service of type " << type << endmsg;
            return StatusCode::FAILURE;
        }
        else    {
            return StatusCode::SUCCESS;
        }
    }
    return BAD_STORAGE_TYPE;
}