00001
00002
00003 #ifndef ASGTOOLS_TOOLHANDLE_H
00004 #define ASGTOOLS_TOOLHANDLE_H
00005
00006
00007 #include "AsgTools/AsgToolsConf.h"
00008
00009 #ifdef ASGTOOL_ATHENA
00010 # include "GaudiKernel/ToolHandle.h"
00011 #elif defined(ASGTOOL_STANDALONE)
00012
00013
00014 #include <string>
00015 #include <iosfwd>
00016
00017
00018 #include "AsgTools/StatusCode.h"
00019
00020 namespace asg {
00021 class IAsgTool;
00022 }
00023
00035 class ToolHandleBase {
00036
00037 public:
00039 ToolHandleBase( const std::string& typeAndName = "", asg::IAsgTool* parent = 0 );
00040
00042 const std::string& typeAndName() const;
00044 const std::string& type() const;
00046 const std::string& name() const;
00048 const std::string& parentName() const;
00049
00051 void setTypeAndName(const std::string& typeAndName);
00053 void setName(const std::string& name);
00054
00055 protected:
00057 std::string m_typeAndName;
00059 std::string m_type;
00061 std::string m_name;
00063 std::string m_parentName;
00064
00065 };
00066
00078 template< class T >
00079 class ToolHandle : public ToolHandleBase {
00080
00081 public:
00083 typedef T value_type;
00084
00086 ToolHandle( T* ptool = 0 );
00087
00089 ToolHandle( const std::string& toolname, asg::IAsgTool* parent = 0 );
00090
00092 T& operator*();
00094 const T& operator*() const;
00096 T* operator->();
00098 const T* operator->() const;
00099
00103 StatusCode retrieve() const;
00104
00106 bool empty() const;
00107
00109 bool isSet() const;
00110
00111 private:
00113 mutable T* m_ptool;
00114
00115 };
00116
00118 template< class T >
00119 std::ostream& operator<< ( std::ostream& out,
00120 const ToolHandle< T >& handle );
00121
00122
00123 #include "AsgTools/ToolHandle.icc"
00124
00125 #else
00126 # error "What environment are we in?!?"
00127 #endif // Environment selection
00128 #endif // ASGTOOLS_TOOLHANDLE_H