Skip to content
Snippets Groups Projects
Commit 3c3e9d97 authored by Lionel Dieu's avatar Lionel Dieu
Browse files

Merge branch 'GAUDI-1127' into 'master'

removed the need for ToolHandle<IAlgTool> specialization

Modified the implementation of BaseToolHandle so that the retrieve
method can be implemented without conflicting with the retrieve method
of ToolHandle<T> with T=IAlgTool.

This, BTW, fixes GAUDI-1127.

See CFHEP-177 and merge request !10.

See merge request !67
parents 44b1ef51 9a6a902e
No related branches found
Tags Paris2015-baseline
No related merge requests found
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <stdexcept> #include <stdexcept>
#include <type_traits>
// forward declarations // forward declarations
class IInterface; class IInterface;
...@@ -69,13 +70,13 @@ protected: ...@@ -69,13 +70,13 @@ protected:
: ToolHandleInfo(parent, createIf) : ToolHandleInfo(parent, createIf)
{} {}
virtual StatusCode retrieveGeneric(IAlgTool*&) const = 0; virtual StatusCode i_retrieve(IAlgTool*&) const = 0;
public: public:
virtual ~BaseToolHandle() {} virtual ~BaseToolHandle() {}
StatusCode retrieve(IAlgTool*& tool) const { StatusCode retrieve(IAlgTool*& tool) const {
return retrieveGeneric(tool); return i_retrieve(tool);
} }
}; };
...@@ -92,6 +93,8 @@ public: ...@@ -92,6 +93,8 @@ public:
template< class T > template< class T >
class ToolHandle : public BaseToolHandle, public GaudiHandle<T> { class ToolHandle : public BaseToolHandle, public GaudiHandle<T> {
static_assert(std::is_base_of<IAlgTool,T>::value, "T must inherit from IAlgTool");
friend class Algorithm; friend class Algorithm;
friend class AlgTool; friend class AlgTool;
friend class Service; friend class Service;
...@@ -100,7 +103,7 @@ public: ...@@ -100,7 +103,7 @@ public:
/** Constructor for a tool with default tool type and name. /** Constructor for a tool with default tool type and name.
Can be called only if the type T is a concrete tool type (not an interface), Can be called only if the type T is a concrete tool type (not an interface),
and you want to use the default name. */ and you want to use the default name. */
ToolHandle(const IInterface* parent=0, bool createIf = true ) ToolHandle(const IInterface* parent = nullptr, bool createIf = true)
: BaseToolHandle(parent,createIf), : BaseToolHandle(parent,createIf),
GaudiHandle<T>( GaudiHandle<T>::getDefaultType(), GaudiHandle<T>( GaudiHandle<T>::getDefaultType(),
ToolHandleInfo::toolComponentType(parent), ToolHandleInfo::toolComponentType(parent),
...@@ -178,9 +181,7 @@ public: ...@@ -178,9 +181,7 @@ public:
/** Do the real retrieval of the AlgTool. */ /** Do the real retrieval of the AlgTool. */
StatusCode retrieve( T*& algTool ) const { StatusCode retrieve( T*& algTool ) const {
return m_pToolSvc->retrieve( GaudiHandleBase::typeAndName(), T::interfaceID(), return i_retrieve(reinterpret_cast<IAlgTool*&>(algTool));
reinterpret_cast<IAlgTool*&>(algTool),
ToolHandleInfo::parent(), ToolHandleInfo::createIf() );
} }
/** Do the real release of the AlgTool. */ /** Do the real release of the AlgTool. */
...@@ -189,7 +190,7 @@ public: ...@@ -189,7 +190,7 @@ public:
} }
protected: protected:
StatusCode retrieveGeneric(IAlgTool*& algTool) const override { StatusCode i_retrieve(IAlgTool*& algTool) const override {
return m_pToolSvc->retrieve( GaudiHandleBase::typeAndName(), IAlgTool::interfaceID(), return m_pToolSvc->retrieve( GaudiHandleBase::typeAndName(), IAlgTool::interfaceID(),
algTool, algTool,
ToolHandleInfo::parent(), ToolHandleInfo::createIf() ); ToolHandleInfo::parent(), ToolHandleInfo::createIf() );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment