Commit 223ce088 authored by Charles Leggett's avatar Charles Leggett
Browse files

Merge branch 'GAUDI-1183' into 'master'

reorganize DataHandleHolder visitor acces to avoid non-retrieved tools

This is not a perfect fix, more a workaround.

The method `initToolHandles` have been modified to fill the list of used `ToolHandle`s only with the tools retrieved explicitly in the `initialize` method.

`GaudiCommon` required the introduction of a hook so that the custom _fixer_ visitor could be created in the `GaudiCommon::initialize`, but used only at the end of `PBASE::sysInitialize` (eb392741).

I also fixed an issue (double delete) with the use of `ToolHandle` from `GaudiCommon` (0a1bec84).

Fixes GAUDI-1183.

See merge request !120
parents 9a318120 4ddc4bd2
......@@ -731,7 +731,7 @@ private:
// ==========================================================================
private:
/// List of active tools
mutable AlgTools m_tools ;
mutable AlgTools m_managedTools;
/// List of active services
mutable Services m_services ;
// ==========================================================================
......
......@@ -144,6 +144,7 @@ inline TOOL* GaudiCommon<PBASE>::tool( const std::string& type ,
{ Exception("tool():: Could not retrieve Tool '" + type + "'/'" + name + "'" ) ; }
// insert tool into list of tools
PBASE::registerTool(Tool);
m_managedTools.push_back(Tool);
// return *VALID* located tool
return Tool ;
}
......@@ -168,6 +169,7 @@ inline TOOL* GaudiCommon<PBASE>::tool( const std::string& type ,
{ Exception("tool():: Could not retrieve Tool '" + type + "'" ) ; }
// add the tool into the list of known tools to be properly released
PBASE::registerTool(Tool);
m_managedTools.push_back(Tool);
// return *VALID* located tool
return Tool ;
}
......
......@@ -227,8 +227,8 @@ StatusCode GaudiCommon<PBASE>::
}
auto fixLocation = [&] (const std::string & location) -> std::string {
std::string result = fullTESLocation( (const std::string&)location, UseRootInTES);
auto fixLocation = [this, rootName] (const std::string & location) -> std::string {
std::string result = fullTESLocation(location, UseRootInTES);
//check whether we have an absolute path if yes return it - else prepend DataManager Root
result = (result[0] == '/' ? result : rootName + result);
......@@ -241,8 +241,7 @@ StatusCode GaudiCommon<PBASE>::
class DHHFixer : public IDataHandleVisitor {
public:
DHHFixer(){};
DHHFixer(std::function<std::string (const std::string&)> f): m_f(f) {};
DHHFixer(std::function<std::string (const std::string&)> f): m_f(f) {}
virtual void visit(const IDataHandleHolder* idhh) {
if (idhh == 0) return;
......@@ -262,9 +261,7 @@ StatusCode GaudiCommon<PBASE>::
std::function<std::string (const std::string&)> m_f;
};
DHHFixer dhf( fixLocation );
PBASE::acceptDHVisitor( &dhf );
this->m_updateDataHandles.reset(new DHHFixer(fixLocation));
return sc;
}
......@@ -311,13 +308,13 @@ StatusCode GaudiCommon<PBASE>::
if ( this->msgLevel(MSG::DEBUG) )
{
this->debug() << "Tools to release :";
for ( const auto& i : PBASE::tools() )
for ( const auto& i : m_managedTools )
{
this->debug() << " " << i->name();
}
this->debug() << endmsg;
}
while ( !PBASE::tools().empty() ) { sc = releaseTool( PBASE::tools().back() ) && sc; }
while ( !m_managedTools.empty() ) { sc = releaseTool( m_managedTools.back() ) && sc; }
// release all located services
if ( this->msgLevel(MSG::DEBUG) )
......@@ -387,8 +384,8 @@ StatusCode GaudiCommon<PBASE>::releaseTool ( const IAlgTool* algTool ) const
if( !this->toolSvc() )
{ return Error ( "releaseTool(IAlgTool):: IToolSvc* points to NULL!" ) ; }
// find a tool in the list of active tools
auto it = std::find( PBASE::tools().rbegin() , PBASE::tools().rend() , algTool ) ;
if( PBASE::tools().rend() == it )
auto it = std::find(m_managedTools.begin(), m_managedTools.end(), algTool);
if (m_managedTools.end() == it)
{ return Warning("releaseTool(IAlgTool):: IAlgTool* is not active" ) ; }
// get the tool
IAlgTool* t = *it ;
......@@ -398,13 +395,14 @@ StatusCode GaudiCommon<PBASE>::releaseTool ( const IAlgTool* algTool ) const
{ this->debug() << "Releasing tool '" << name << "'" << endmsg; }
// remove the tool from the lists
PBASE::deregisterTool(t);
m_managedTools.erase(it);
// release tool
if ( this->msgLevel(MSG::DEBUG) ) {
this->debug() << "The tool '" << t->name() << "' of type '"
<< System::typeinfoName(typeid(*t))
<< "' is released" << endmsg;
}
const StatusCode sc = this->toolSvc()->releaseTool( t ) ;
const StatusCode sc = this->toolSvc()->releaseTool(t) ;
return sc.isSuccess() ?
sc :
Warning( "releaseTool(IAlgTool):: error from IToolSvc releasing "+name , sc ) ;
......
......@@ -16,6 +16,7 @@ MyGaudiAlgorithm::MyGaudiAlgorithm(const std::string& name, ISvcLocator* ploc)
m_myPrivToolHandle("MyTool/PrivToolHandle",this),
m_myPubToolHandle("MyTool/PubToolHandle"),
m_myGenericToolHandle("MyTool/GenericToolHandle"),
m_myUnusedToolHandle("TestToolFailing"),
m_tracks("/Event/Rec/Tracks",Gaudi::DataHandle::Reader, this),
m_hits("/Event/Rec/Hits",Gaudi::DataHandle::Reader,this),
m_raw("/Rec/RAW",Gaudi::DataHandle::Reader,this),
......@@ -27,6 +28,7 @@ MyGaudiAlgorithm::MyGaudiAlgorithm(const std::string& name, ISvcLocator* ploc)
declareProperty("PrivToolHandle", m_myPrivToolHandle);
declareProperty("PubToolHandle", m_myPubToolHandle);
declareProperty("GenericToolHandle", m_myGenericToolHandle);
declareProperty("UnusedToolHandle", m_myUnusedToolHandle);
declareProperty("tracks", m_tracks, "the tracks");
declareProperty("hits", m_hits, "the hits");
......
......@@ -40,6 +40,8 @@ private:
ToolHandle<IAlgTool> m_myGenericToolHandle;
ToolHandle<IAlgTool> m_myUnusedToolHandle;
ToolHandleArray<IMyTool> m_tha;
DataObjectHandle<DataObject> m_tracks;
......
JobOptionsSvc INFO # =======> /afs/cern.ch/work/m/marcocle/workspace/Gaudi/GaudiExamples/options/Services.opts
JobOptionsSvc INFO # =======> /scratch/z5/marcocle/JIRA/GAUDI-1183/build/GAUDI/GAUDI_HEAD/GaudiExamples/options/Services.opts
JobOptionsSvc INFO # (12,1): AuditorSvc.Auditors = ["ChronoAuditor"]
JobOptionsSvc INFO # =======> /afs/cern.ch/work/m/marcocle/workspace/Gaudi/GaudiExamples/options/Common.opts
JobOptionsSvc INFO # =======> /scratch/z5/marcocle/JIRA/GAUDI-1183/build/GAUDI/GAUDI_HEAD/GaudiExamples/options/Common.opts
JobOptionsSvc INFO # (9,1): ApplicationMgr.StatusCodeCheck = 1
JobOptionsSvc INFO # =======> /afs/cern.ch/work/m/marcocle/workspace/Gaudi/GaudiExamples/options/AlgTools2.opts
JobOptionsSvc INFO # =======> /scratch/z5/marcocle/JIRA/GAUDI-1183/build/GAUDI/GAUDI_HEAD/GaudiExamples/options/AlgTools2.opts
JobOptionsSvc INFO # (10,1): ApplicationMgr.TopAlg = ["MyGaudiAlgorithm/MyAlg"]
JobOptionsSvc INFO # (13,1): MessageSvc.OutputLevel = 3
JobOptionsSvc INFO # (18,1): ApplicationMgr.EvtMax = 10
......@@ -23,22 +23,23 @@ JobOptionsSvc INFO # (44,1): ToolSvc.ToolA.Tools = ["TestTool/ToolB"]
JobOptionsSvc INFO # (45,1): ToolSvc.ToolB.Tools = ["TestTool/ToolA"]
JobOptionsSvc INFO # (46,1): ToolSvc.ToolA.OutputLevel = 2
JobOptionsSvc INFO # (47,1): ToolSvc.ToolB.OutputLevel = 2
JobOptionsSvc INFO Job options successfully read in from /afs/cern.ch/work/m/marcocle/workspace/Gaudi/GaudiExamples/options/AlgTools2.opts
JobOptionsSvc INFO Job options successfully read in from /scratch/z5/marcocle/JIRA/GAUDI-1183/build/GAUDI/GAUDI_HEAD/GaudiExamples/options/AlgTools2.opts
ApplicationMgr SUCCESS
====================================================================================================================================
Welcome to ApplicationMgr (GaudiCoreSvc v4r0)
running on pclhcb117 on Thu Feb 11 14:53:00 2016
running on pclhcb117 on Wed Feb 24 13:57:50 2016
====================================================================================================================================
ApplicationMgr INFO Application Manager Configured successfully
StatusCodeSvc INFO initialize
MyAlg DEBUG Property update for OutputLevel : new value = 2
MyAlg DEBUG Initialize base class GaudiCommon<Algorithm>
MyAlg DEBUG could not locate CounterSummarySvc, no counter summary will be made
MyAlg DEBUG List of ALL properties of MyGaudiAlgorithm/MyAlg #properties = 44
MyAlg DEBUG List of ALL properties of MyGaudiAlgorithm/MyAlg #properties = 45
MyAlg DEBUG Property ['Name': Value] = 'trackSelection':('/Event/MyAnalysis/Tracks') m: 16 o: MyAlg opt: 0
MyAlg DEBUG Property ['Name': Value] = 'raw':('/Rec/RAW') m: 4 o: MyAlg opt: 0
MyAlg DEBUG Property ['Name': Value] = 'hits':('/Event/Rec/Hits') m: 4 o: MyAlg opt: 0
MyAlg DEBUG Property ['Name': Value] = 'tracks':('/Event/Rec/Tracks') m: 4 o: MyAlg opt: 0
MyAlg DEBUG Property ['Name': Value] = 'UnusedToolHandle':TestToolFailing
MyAlg DEBUG Property ['Name': Value] = 'GenericToolHandle':MyTool/GenericToolHandle
MyAlg DEBUG Property ['Name': Value] = 'PubToolHandle':MyTool/PubToolHandle
MyAlg DEBUG Property ['Name': Value] = 'PrivToolHandle':MyTool/PrivToolHandle
......@@ -79,25 +80,6 @@ MyAlg DEBUG Property ['Name': Value] = 'ErrorCounter':0
MyAlg DEBUG Property ['Name': Value] = 'ErrorMax':1
MyAlg DEBUG Property ['Name': Value] = 'Enable':True
MyAlg DEBUG Property ['Name': Value] = 'OutputLevel':2
MyAlg.PrivToolH... DEBUG Property update for OutputLevel : new value = 2
MyAlg.PrivToolH... INFO intialize() has been called
MyAlg.PrivToolH... INFO Int = 100
MyAlg.PrivToolH... INFO Double = 100
MyAlg.PrivToolH... INFO String = hundred
MyAlg.PrivToolH... INFO Bool = 1
MyAlg DEBUG Adding Private ToolHandle tool MyAlg.PrivToolHandle (MyTool)
ToolSvc.PubTool... INFO intialize() has been called
ToolSvc.PubTool... INFO Int = 100
ToolSvc.PubTool... INFO Double = 100
ToolSvc.PubTool... INFO String = hundred
ToolSvc.PubTool... INFO Bool = 1
MyAlg DEBUG Adding Public ToolHandle tool ToolSvc.PubToolHandle (MyTool)
ToolSvc.Generic... INFO intialize() has been called
ToolSvc.Generic... INFO Int = 100
ToolSvc.Generic... INFO Double = 100
ToolSvc.Generic... INFO String = hundred
ToolSvc.Generic... INFO Bool = 1
MyAlg DEBUG Adding Public ToolHandle tool ToolSvc.GenericToolHandle (MyTool)
MyAlg INFO initializing....
ToolSvc.MyTool INFO intialize() has been called
ToolSvc.MyTool INFO Int = 201
......@@ -162,6 +144,22 @@ MyAlg.ToolWithName INFO String = hundred
MyAlg.ToolWithName INFO Bool = 1
MyAlg DEBUG Registering tool MyAlg.ToolWithName
MyAlg DEBUG Registering tool MyAlg.MyGaudiTool
MyAlg.PrivToolH... DEBUG Property update for OutputLevel : new value = 2
MyAlg.PrivToolH... INFO intialize() has been called
MyAlg.PrivToolH... INFO Int = 100
MyAlg.PrivToolH... INFO Double = 100
MyAlg.PrivToolH... INFO String = hundred
MyAlg.PrivToolH... INFO Bool = 1
ToolSvc.PubTool... INFO intialize() has been called
ToolSvc.PubTool... INFO Int = 100
ToolSvc.PubTool... INFO Double = 100
ToolSvc.PubTool... INFO String = hundred
ToolSvc.PubTool... INFO Bool = 1
ToolSvc.Generic... INFO intialize() has been called
ToolSvc.Generic... INFO Int = 100
ToolSvc.Generic... INFO Double = 100
ToolSvc.Generic... INFO String = hundred
ToolSvc.Generic... INFO Bool = 1
MyAlg INFO /Event/Rec/Tracks
MyAlg INFO /Event/Rec/Hits
MyAlg INFO /Rec/RAW
......@@ -169,6 +167,10 @@ MyAlg INFO /Event/MyAnalysis/Tracks
MyAlg INFO ....initialization done
MyAlg DEBUG input handles: 3
MyAlg DEBUG output handles: 1
MyAlg DEBUG Adding private ToolHandle tool MyAlg.PrivToolHandle (MyTool)
MyAlg DEBUG Adding public ToolHandle tool ToolSvc.PubToolHandle (MyTool)
MyAlg DEBUG Adding public ToolHandle tool ToolSvc.GenericToolHandle (MyTool)
MyAlg DEBUG ToolHandle TestToolFailing not used
MyAlg DEBUG Data Deps for MyAlg
+ INPUT ('/Rec/RAW')
+ INPUT ('/Event/Rec/Hits')
......@@ -402,7 +404,7 @@ ToolSvc.PubTool... INFO doIt() has been called
ApplicationMgr INFO Application Manager Stopped successfully
MyAlg INFO finalizing....
MyAlg DEBUG Finalize base class GaudiAlgorithm
MyAlg DEBUG Tools to release : MyAlg.PrivToolHandle ToolSvc.PubToolHandle ToolSvc.GenericToolHandle ToolSvc.MyTool MyAlg.MyTool ToolSvc.MyGaudiTool MyAlg.MyGaudiTool MyAlg.ToolWithName MyAlg.MyGaudiTool
MyAlg DEBUG Tools to release : ToolSvc.MyTool MyAlg.MyTool ToolSvc.MyGaudiTool MyAlg.MyGaudiTool MyAlg.ToolWithName MyAlg.MyGaudiTool
MyAlg DEBUG Releasing tool 'MyAlg.MyGaudiTool'
MyAlg DEBUG De-Registering tool MyAlg.MyGaudiTool
MyAlg DEBUG The tool 'MyAlg.MyGaudiTool' of type 'MyGaudiTool' is released
......@@ -421,15 +423,6 @@ MyAlg DEBUG The tool 'MyAlg.MyTool' of type 'MyTool' is released
MyAlg DEBUG Releasing tool 'ToolSvc.MyTool'
MyAlg DEBUG De-Registering tool ToolSvc.MyTool
MyAlg DEBUG The tool 'ToolSvc.MyTool' of type 'MyTool' is released
MyAlg DEBUG Releasing tool 'ToolSvc.GenericToolHandle'
MyAlg DEBUG De-Registering tool ToolSvc.GenericToolHandle
MyAlg DEBUG The tool 'ToolSvc.GenericToolHandle' of type 'MyTool' is released
MyAlg DEBUG Releasing tool 'ToolSvc.PubToolHandle'
MyAlg DEBUG De-Registering tool ToolSvc.PubToolHandle
MyAlg DEBUG The tool 'ToolSvc.PubToolHandle' of type 'MyTool' is released
MyAlg DEBUG Releasing tool 'MyAlg.PrivToolHandle'
MyAlg DEBUG De-Registering tool MyAlg.PrivToolHandle
MyAlg DEBUG The tool 'MyAlg.PrivToolHandle' of type 'MyTool' is released
MyAlg DEBUG Services to release :
EventLoopMgr INFO Histograms converted successfully according to request.
ToolSvc INFO Removing all tools created by ToolSvc
......
# setting LC_ALL to "C"
# --> Including file '/afs/cern.ch/work/m/marcocle/workspace/Gaudi/GaudiExamples/options/AlgTools.py'
# <-- End of file '/afs/cern.ch/work/m/marcocle/workspace/Gaudi/GaudiExamples/options/AlgTools.py'
# --> Including file '/scratch/z5/marcocle/JIRA/GAUDI-1183/build/GAUDI/GAUDI_HEAD/GaudiExamples/options/AlgTools.py'
# <-- End of file '/scratch/z5/marcocle/JIRA/GAUDI-1183/build/GAUDI/GAUDI_HEAD/GaudiExamples/options/AlgTools.py'
# applying configuration of GaudiExamplesCommonConf
# /***** User GaudiExamplesCommonConf/GaudiExamplesCommonConf ****************************************
# |-OutputLevel = 3
......@@ -9,7 +9,7 @@
ApplicationMgr SUCCESS
====================================================================================================================================
Welcome to ApplicationMgr (GaudiCoreSvc v4r0)
running on pclhcb117 on Thu Feb 11 12:52:43 2016
running on pclhcb117 on Wed Feb 24 13:57:49 2016
====================================================================================================================================
ApplicationMgr INFO Application Manager Configured successfully
StatusCodeSvc INFO initialize
......@@ -40,21 +40,6 @@ MyAlg.ToolWithName INFO Double = 20
MyAlg.ToolWithName INFO String = abc
MyAlg.ToolWithName INFO Bool = 0
MyAlg INFO ....initialization done
MyGaudiAlg.Priv... INFO intialize() has been called
MyGaudiAlg.Priv... INFO Int = 100
MyGaudiAlg.Priv... INFO Double = 100
MyGaudiAlg.Priv... INFO String = Is a private tool
MyGaudiAlg.Priv... INFO Bool = 1
ToolSvc.TestPub... INFO intialize() has been called
ToolSvc.TestPub... INFO Int = 100
ToolSvc.TestPub... INFO Double = 100
ToolSvc.TestPub... INFO String = Is a public tool
ToolSvc.TestPub... INFO Bool = 1
ToolSvc.Generic... INFO intialize() has been called
ToolSvc.Generic... INFO Int = 100
ToolSvc.Generic... INFO Double = 100
ToolSvc.Generic... INFO String = hundred
ToolSvc.Generic... INFO Bool = 1
MyGaudiAlg INFO initializing....
MyGaudiAlg.MyTool INFO intialize() has been called
MyGaudiAlg.MyTool INFO Int = 100
......@@ -71,6 +56,21 @@ MyGaudiAlg.Tool... INFO Int = 100
MyGaudiAlg.Tool... INFO Double = 100
MyGaudiAlg.Tool... INFO String = hundred
MyGaudiAlg.Tool... INFO Bool = 1
MyGaudiAlg.Priv... INFO intialize() has been called
MyGaudiAlg.Priv... INFO Int = 100
MyGaudiAlg.Priv... INFO Double = 100
MyGaudiAlg.Priv... INFO String = Is a private tool
MyGaudiAlg.Priv... INFO Bool = 1
ToolSvc.TestPub... INFO intialize() has been called
ToolSvc.TestPub... INFO Int = 100
ToolSvc.TestPub... INFO Double = 100
ToolSvc.TestPub... INFO String = Is a public tool
ToolSvc.TestPub... INFO Bool = 1
ToolSvc.Generic... INFO intialize() has been called
ToolSvc.Generic... INFO Int = 100
ToolSvc.Generic... INFO Double = 100
ToolSvc.Generic... INFO String = hundred
ToolSvc.Generic... INFO Bool = 1
MyGaudiAlg INFO /Event/Rec/Tracks
MyGaudiAlg INFO /Event/Rec/Hits
MyGaudiAlg INFO /Rec/RAW
......
......@@ -400,6 +400,9 @@ protected:
std::vector<IAlgTool *> & tools();
/// Hook for for derived classes to provide a custom visitor for data handles.
std::unique_ptr<IDataHandleVisitor> m_updateDataHandles;
private:
//place IAlgTools defined via ToolHandles in m_tools
void initToolHandles() const;
......
......@@ -599,67 +599,26 @@ public:
void deregisterTool(IAlgTool * tool) const;
template<class T>
StatusCode declareTool(ToolHandle<T> &handle,
std::string toolTypeAndName = "",
bool createIf = true) {
if (handle.isPublic()) {
return declarePublicTool(handle, toolTypeAndName, createIf);
} else {
return declarePrivateTool(handle, toolTypeAndName, createIf);
}
}
/** Declare used Private tool
*
* @param handle ToolHandle<T>
* @param toolTypeAndName
* @param parent, default public tool
* @param create if necessary, default true
*/
template<class T>
StatusCode declarePrivateTool(ToolHandle<T> & handle,
std::string toolTypeAndName = "",
bool createIf = true) {
if (toolTypeAndName == "")
// toolTypeAndName = System::typeinfoName(typeid(T));
toolTypeAndName = handle.typeAndName();
StatusCode sc = handle.initialize(toolTypeAndName, this, createIf);
if (UNLIKELY(!sc)) {
throw GaudiException{"Cannot create handle for private tool " + toolTypeAndName,
name(), sc};
}
m_toolHandles.push_back(&handle);
return sc;
}
/** Declare used Public tool
*
* @param handle ToolHandle<T>
* @param toolTypeAndName
* @param parent, default public tool
* @param create if necessary, default true
*/
template<class T>
StatusCode declarePublicTool(ToolHandle<T> & handle, std::string toolTypeAndName = "",
bool createIf = true) {
if (toolTypeAndName == "")
toolTypeAndName = handle.typeAndName();
StatusCode sc = handle.initialize(toolTypeAndName, 0, createIf);
if (UNLIKELY(!sc)) {
throw GaudiException{"Cannot create handle for public tool " + toolTypeAndName,
name(), sc};
}
m_toolHandles.push_back(&handle);
return sc;
StatusCode declareTool(ToolHandle<T> &handle,
std::string toolTypeAndName = "",
bool createIf = true) {
if (toolTypeAndName == "")
toolTypeAndName = handle.typeAndName();
StatusCode sc = handle.initialize(toolTypeAndName,
handle.isPublic() ? nullptr : this,
createIf);
if (UNLIKELY(!sc)) {
throw GaudiException{std::string{"Cannot create handle for "} +
(handle.isPublic() ? "public" : "private") +
" tool " + toolTypeAndName,
name(), sc};
}
m_toolHandles.push_back(&handle);
return sc;
}
const std::vector<IAlgTool *> & tools() const;
......@@ -735,6 +694,10 @@ private:
SmartIF<ISvcLocator> m_pSvcLocator; ///< Pointer to service locator service
protected:
SmartIF<PropertyMgr> m_propertyMgr; ///< For management of properties
/// Hook for for derived classes to provide a custom visitor for data handles.
std::unique_ptr<IDataHandleVisitor> m_updateDataHandles;
private:
IntegerProperty m_outputLevel; ///< Algorithm output level
int m_errorMax; ///< Algorithm Max number of errors
......
......@@ -16,7 +16,7 @@ class IDataHandleVisitor;
class GAUDI_API IDataHandleHolder : virtual public INamedInterface {
public:
virtual ~IDataHandleHolder() {};
virtual ~IDataHandleHolder() {}
virtual std::vector<Gaudi::DataHandle*> inputHandles() const = 0;
virtual std::vector<Gaudi::DataHandle*> outputHandles() const = 0;
......@@ -33,12 +33,11 @@ public:
protected:
virtual void declareInput(Gaudi::DataHandle*) = 0;
virtual void declareOutput(Gaudi::DataHandle*) = 0;
};
class IDataHandleVisitor {
public:
virtual ~IDataHandleVisitor() {}
virtual void visit(const IDataHandleHolder*) = 0;
};
......
......@@ -78,6 +78,9 @@ public:
StatusCode retrieve(IAlgTool*& tool) const {
return i_retrieve(tool);
}
virtual IAlgTool* get() const = 0;
virtual std::string typeAndName() const = 0;
};
/** @class ToolHandle ToolHandle.h GaudiKernel/ToolHandle.h
......@@ -190,9 +193,16 @@ public:
return m_pToolSvc->releaseTool( algTool );
}
IAlgTool *get() const override {
return GaudiHandle<T>::get();
}
std::string typeAndName() const override {
return GaudiHandleBase::typeAndName();
}
protected:
StatusCode i_retrieve(IAlgTool*& algTool) const override {
return m_pToolSvc->retrieve( GaudiHandleBase::typeAndName(), IAlgTool::interfaceID(),
return m_pToolSvc->retrieve( typeAndName(), IAlgTool::interfaceID(),
algTool,
ToolHandleInfo::parent(), ToolHandleInfo::createIf() );
}
......
......@@ -277,7 +277,11 @@ StatusCode AlgTool::sysInitialize() {
m_auditorInitialize ? auditorSvc() : nullptr,
IAuditor::Initialize);
StatusCode sc = initialize();
if (sc.isSuccess()) m_state = m_targetState;
if (!sc) return sc;
m_state = m_targetState;
if (m_updateDataHandles)
acceptDHVisitor(m_updateDataHandles.get());
return sc;
} );
......@@ -454,24 +458,21 @@ AlgTool::~AlgTool()
void AlgTool::initToolHandles() const{
for(auto th : m_toolHandles){
IAlgTool * tool = nullptr;
//if(th->retrieve().isFailure())
//debug() << "Error in retrieving tool from ToolHandle" << endmsg;
//get generic tool interface from ToolHandle
if(th->retrieve(tool).isSuccess() && tool != nullptr){
m_tools.push_back(tool);
debug() << "Adding ToolHandle tool " << tool->name() << " (" << tool->type() << ")" << endmsg;
} else {
debug() << "Trying to add nullptr tool" << endmsg;
}
}
m_toolHandlesInit = true;
for(auto th : m_toolHandles){
IAlgTool * tool = th->get();
if(tool){
m_tools.push_back(tool);
if (UNLIKELY(msgLevel(MSG::DEBUG)))
debug() << "Adding "
<< (th->isPublic() ? "Public" : "Private" )
<< " ToolHandle tool " << tool->name()
<< " (" << tool->type() << ")" << endmsg;
} else {
if (UNLIKELY(msgLevel(MSG::DEBUG)))
debug() << "ToolHandle " << th->typeAndName() << " not used" << endmsg;
}
}
m_toolHandlesInit = true;
}
const std::vector<IAlgTool *> & AlgTool::tools() const {
......
......@@ -200,6 +200,9 @@ StatusCode Algorithm::sysInitialize() {
debug() << "output handles: " << outputHandles().size() << endmsg;
}
if (m_updateDataHandles)
acceptDHVisitor(m_updateDataHandles.get());
// visit all sub-algs and tools, build full set
DHHVisitor avis(m_inputDataObjs, m_outputDataObjs);
acceptDHVisitor(&avis);
......@@ -988,30 +991,22 @@ bool Algorithm::hasProperty(const std::string& name) const {
}
void Algorithm::initToolHandles() const{
for(auto th : m_toolHandles){
IAlgTool * tool = th->get();
if(tool){
if (UNLIKELY(msgLevel(MSG::DEBUG)))
debug() << "Adding "
<< (th->isPublic() ? "public" : "private" )
<< " ToolHandle tool " << tool->name()
<< " (" << tool->type() << ")" << endmsg;
m_tools.push_back(tool);
} else {
if (UNLIKELY(msgLevel(MSG::DEBUG)))
debug() << "ToolHandle " << th->typeAndName() << " not used" << endmsg;
}
}
for(auto th : m_toolHandles){
IAlgTool * tool = nullptr;
//if(th->retrieve().isFailure())
//debug() << "Error in retrieving tool from ToolHandle" << endmsg;
//get generic tool interface from ToolHandle
auto sc = th->retrieve(tool);
if(sc.isSuccess() && tool){
m_tools.push_back(tool);
if (UNLIKELY(msgLevel(MSG::DEBUG)))
debug() << "Adding "
<< (th->isPublic() ? "Public" : "Private" )
<< " ToolHandle tool " << tool->name()
<< " (" << tool->type() << ")" << endmsg;
} else {
if (UNLIKELY(msgLevel(MSG::DEBUG)))
debug() << "Trying to add nullptr tool" << endmsg;
}
}
m_toolHandlesInit = true;
m_toolHandlesInit = true;
}
const std::vector<IAlgTool *> & Algorithm::tools() const {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment