11 #include "GaudiKernel/ISvcLocator.h"
12 #include "GaudiKernel/ISvcManager.h"
13 #include "GaudiKernel/MsgStream.h"
14 #include "GaudiKernel/Service.h"
15 #include "GaudiKernel/SmartIF.h"
16 #include "GaudiKernel/System.h"
25 const Service*
parent =
dynamic_cast<const Service*
>(iParent);
27 throw GaudiException(
"parent " + iParent->name() +
" is not a service!",
28 "CloneService", StatusCode::FAILURE);
29 return StatusCode::FAILURE;
32 MsgStream
mlog(
parent->msgSvc(),
"CloneService" );
33 ISvcLocator* svcLoc =
parent->serviceLocator();
37 if ( svcLoc->existsService(childName) ) {
39 <<
"Found service " << childName
43 SmartIF<ISvcManager>
svcMgr(svcLoc);
47 const std::string& parentType = System::typeinfoName(
typeid(*
parent));
48 Gaudi::Utils::TypeNameString tn(childName, parentType);
50 child =
dynamic_cast<Service*
>(
svcMgr->createService(tn).get());
53 <<
"Created service " << childName <<
" of type " << parentType
57 <<
"Failed to create " << childName <<
" of type " << parentType
59 return StatusCode::FAILURE;
64 for (Gaudi::Details::PropertyBase* prop :
parent->getProperties()) {
65 if ( child->setProperty(*prop).isFailure() ) {
67 <<
"Failed to set child property " << prop->name() <<
endmsg;
68 return StatusCode::FAILURE;
74 if (Gaudi::StateMachine::INITIALIZED ==
parent->FSMState() &&
75 Gaudi::StateMachine::CONFIGURED == child->FSMState())
76 return child->sysInitialize();
79 <<
"Did not initialize " << childName
81 return StatusCode::SUCCESS;