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:16

◆ 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 16 of file CloneTool.cxx.

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