ATLAS Offline Software
Loading...
Searching...
No Matches
CloneTool Namespace Reference

Functions

StatusCode typeless_clone (const IAlgTool &cloned, const std::string &cloneName, const InterfaceID &cloneID, IAlgTool *&result)
 implementation, experts only
template<class CLONEDTOOL>
StatusCode clone (const CLONEDTOOL &cloned, const std::string &cloneName, CLONEDTOOL *&result)
 given a reference to a cloned AlgTool sets a reference to its clone

Function Documentation

◆ clone()

template<class CLONEDTOOL>
StatusCode CloneTool::clone ( const CLONEDTOOL & cloned,
const std::string & cloneName,
CLONEDTOOL *& result )

given a reference to a cloned AlgTool sets a reference to its clone

Definition at line 20 of file CloneTool.h.

22 {
23 return typeless_clone(cloned, cloneName, CLONEDTOOL::interfaceID(),
24 static_cast<IAlgTool*&>(result));
25 }
StatusCode typeless_clone(const IAlgTool &cloned, const std::string &cloneName, const InterfaceID &cloneID, IAlgTool *&result)
implementation, experts only
Definition CloneTool.cxx:17

◆ typeless_clone()

StatusCode CloneTool::typeless_clone ( const IAlgTool & cloned,
const std::string & cloneName,
const InterfaceID & cloneID,
IAlgTool *& result )

implementation, experts only

given a pointer to a cloned tool sets a reference to its clone

Definition at line 17 of file CloneTool.cxx.

21 {
22 //FIXME this only creates an uninitialized AlgTool
23 //FIXME it would be better if one could say cloned.clone()
24 //FIXME (its default implementation could be this one)
25
26 const AlgTool* pCloned(dynamic_cast<const AlgTool*>(&cloned));
27 if (0 == pCloned) {
28 std::println (std::cerr,
29 "CloneTool::FATAL: Could not dcast IAlgTool {} to an AlgTool",
30 cloned.name());
31 return StatusCode::FAILURE;
32 }
33
34 // can we access the AlgTool locator interface?
35 IToolSvc* toolSvc(pCloned->toolSvc());
36 assert (0 != toolSvc);
37
38 MsgStream mlog( pCloned->msgSvc(), "CloneAlgTool::clone" );
39 if (!toolSvc->retrieve(pCloned->type(),
40 cloneName,
41 cloneID,
42 result,
43 pCloned->parent(), //cloned's owner
44 /*createIf=*/true).isSuccess()) {
45 mlog << MSG::FATAL << "Could not clone AlgTool "
46 << pCloned->name() << " to " << cloneName << endmsg;
47 return StatusCode::FAILURE;
48 }
49
50 //now copy cloned's properties into result
51 std::vector<Gaudi::Details::PropertyBase*>::const_iterator iProp(pCloned->getProperties().begin());
52 std::vector<Gaudi::Details::PropertyBase*>::const_iterator eProp(pCloned->getProperties().end());
53
54 AlgTool* aResult=dynamic_cast<AlgTool*>(result);
55 if (0 == aResult) {
56 mlog << MSG::FATAL << "Could not dcast IAlgTool "
57 << result->name() << " to an AlgTool" << endmsg;
58 return StatusCode::FAILURE;
59 }
60 while (iProp != eProp &&
61 (aResult->setProperty(**iProp)).isSuccess()) ++iProp;
62 if (iProp != eProp) {
63 mlog << MSG::ERROR
64 << "Failed to set result property " << (**iProp).name()
65 << endmsg;
66 return StatusCode::FAILURE;
67 } else {
68 mlog << MSG::DEBUG
69 << cloneName << " properties set"
70 << endmsg;
71 }
72
73 //finally put the service in the same state as the cloned
74 //FIXME should we handle the case in which the cloned is RUNNING?
75 if (Gaudi::StateMachine::INITIALIZED == pCloned->FSMState() &&
76 Gaudi::StateMachine::CONFIGURED == aResult->FSMState())
77 return aResult->sysInitialize();
78 else {
79 mlog << MSG::DEBUG
80 << "Did not initialize " << cloneName
81 << endmsg;
82 return StatusCode::SUCCESS;
83 }
84 }
#define endmsg