1 #ifndef GAUDIKERNEL_GAUDIHANDLE_H
2 #define GAUDIKERNEL_GAUDIHANDLE_H
24 GaudiHandleInfo(
const std::string& myComponentType,
const std::string& myParentName )
25 : m_componentType(myComponentType), m_parentName(myParentName)
34 return m_componentType;
39 return m_propertyName;
44 m_propertyName = propName;
55 virtual const std::string pythonPropertyClassName()
const = 0;
61 virtual const std::string pythonRepr()
const = 0;
96 GaudiHandleBase(
const std::string& myTypeAndName,
const std::string& myComponentType,
97 const std::string& myParentName )
100 setTypeAndName(myTypeAndName);
108 return m_typeAndName;
112 std::string
type()
const;
115 std::string name()
const;
119 return m_typeAndName.empty();
123 void setTypeAndName(
const std::string& myTypeAndName );
126 void setName(
const std::string& myName );
134 const std::string messageName()
const;
163 GaudiHandle(
const std::string& myTypeAndName,
const std::string& myComponentType,
164 const std::string& myParentName )
165 :
GaudiHandleBase(myTypeAndName, myComponentType, myParentName), m_pObject(0)
173 if ( m_pObject ) m_pObject->addRef();
178 GaudiHandleBase::operator=( other );
183 if ( m_pObject ) m_pObject->addRef();
190 if ( retrieve( m_pObject ).isFailure() ) {
209 operator bool()
const {
240 if ( defName.empty() ) defName = getDefaultType();
258 const std::string& myType = getDefaultType();
269 return m_pObject || retrieve().isSuccess();
275 if ( !getObject() ) {
304 bool setTypesAndNames(
const std::vector< std::string >& myTypesAndNamesList );
308 const std::vector< std::string > typesAndNames()
const;
311 const std::vector< std::string > types()
const;
314 const std::vector< std::string >
names()
const;
318 const std::vector< std::string > getBaseInfos( std::string (
GaudiHandleBase::*pMemFunc)()
const )
const;
333 virtual bool push_back(
const std::string& myHandleTypeAndName ) = 0;
336 virtual void clear() = 0;
339 virtual bool empty()
const = 0;
377 const std::string& myComponentType,
const std::string& myParentName )
403 for ( ; it != itEnd; ++it ) baseArray.push_back( &*it );
410 for ( ; it != itEnd; ++it ) baseArray.push_back( &*it );
418 return m_handleArray.begin();
422 return m_handleArray.end();
426 return m_handleArray.begin();
430 return m_handleArray.end();
434 return m_handleArray.rbegin();
438 return m_handleArray.rend();
442 return m_handleArray.size();
446 m_handleArray.clear();
450 return m_handleArray.empty();
454 return m_handleArray[index];
458 return m_handleArray[index];
464 for ( ; it != itEnd; ++it ) {
465 if ( it->name() == name )
return &*it;
474 for ( ; it != itEnd; ++it ) {
475 if ( it->name() == name )
return &*it;
485 m_handleArray.push_back( myHandle );
492 for ( ; it != itEnd; ++it ) {
493 if ( it->retrieve().isFailure() ) {
505 for ( ; it != itEnd; ++it ) {
506 if ( it->release().isFailure() ) {
525 #endif // ! GAUDIKERNEL_GAUDIHANDLE_H
virtual GaudiHandleArrayBase::ConstBaseHandleArray getBaseArray() const
Get a read-only vector of const GaudiHandleBase* pointing to the real handles.
GaudiHandle & operator=(const GaudiHandle &other)
Assignment operator for correct ref-counting.
HandleVector::const_reference const_reference
HandleVector::value_type value_type
Handle to be used in lieu of naked pointers to gaudis.
std::string getDefaultType()
Helper function to get default type string from the class type.
Define general base for Gaudi exception.
virtual const std::string pythonPropertyClassName() const =0
The python class name for the property in the genconf-generated configurables.
HandleVector::iterator iterator
std::vector< const GaudiHandleBase * > ConstBaseHandleArray
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
const_iterator rend() const
virtual void clear()
Clear the list of handles.
virtual ~GaudiHandleInfo()
virtual destructor so that derived class destructor is called.
HandleVector::const_reverse_iterator const_reverse_iterator
bool getObject() const
Load the pointer to the component.
std::string getDefaultName()
const std::string & parentName() const
The name of the parent.
void setDefaultType()
Helper function to set default type from the class type T.
void assertObject() const
Load the pointer to the component.
std::string m_componentType
HandleVector::size_type size_type
GaudiHandleArray & operator=(const std::vector< std::string > &myTypesAndNamesList)
Set the array of GaudiHandles from typeAndNames given in vector of strings.
HandleVector::reference reference
virtual bool push_back(const T &myHandle)
StatusCode release() const
Release the component.
GaudiHandleArrayBase(const std::string &myComponentType, const std::string &myParentName)
void setDefaultTypeAndName()
Helper function to set default name and type.
const T & operator[](int index) const
const std::string & propertyName() const
name as used in declareProperty(name,gaudiHandle)
HandleVector m_handleArray
StatusCode retrieve()
Retrieve all tools.
GaudiHandleBase(const std::string &myTypeAndName, const std::string &myComponentType, const std::string &myParentName)
Create a handle ('smart pointer') to a gaudi component.
std::vector< GaudiHandleBase * > BaseHandleArray
const_iterator begin() const
bool setTypesAndNames(const std::vector< std::string > &myTypesAndNamesList)
Set the array of handles from list of "type/name" strings in .
This class is used for returning status codes from appropriate routines.
StatusCode retrieve() const
Retrieve the component.
std::string m_typeAndName
virtual GaudiHandleArrayBase::BaseHandleArray getBaseArray()
Get a read-write vector of GaudiHandleBase* pointing to the real handles.
GaudiHandleInfo(const std::string &myComponentType, const std::string &myParentName)
Some basic information and helper functions shared between various handles/arrays.
HandleVector::const_iterator const_iterator
Base class of array's of various gaudihandles.
const_iterator rbegin() const
virtual ~GaudiHandleArray()
HandleVector::reverse_iterator reverse_iterator
virtual bool push_back(const std::string &myHandleTypeAndName)=0
Add a handle to the array with "type/name" given in .
virtual StatusCode release(T *comp) const
Release the component.
void setTypeAndName(const std::string &myTypeAndName)
The component "type/name" string.
std::string type() const
The concrete component class name: the part before the '/'.
std::ostream & operator<<(std::ostream &os, const GaudiHandleInfo &handle)
virtual bool empty() const
Return whether the list of tools is empty.
GaudiHandle(const std::string &myTypeAndName, const std::string &myComponentType, const std::string &myParentName)
T & operator[](int index)
const T * operator[](const std::string &name) const
Get const pointer (!) to ToolHandle by instance name.
GaudiHandleArray(const std::vector< std::string > &myTypesAndNamesList, const std::string &myComponentType, const std::string &myParentName)
Generic constructor.
const_iterator end() const
Base class to handles to be used in lieu of naked pointers to various Gaudi components.
std::string typeAndName() const
The full type and name: "type/name".
T * operator[](const std::string &name)
Get pointer (!) to ToolHandle by instance name.
void setPropertyName(const std::string &propName)
set name as used in declareProperty(name,gaudiHandle).
virtual const std::string pythonRepr() const =0
Python representation of handle, i.e.
const std::string & componentType() const
std::vector< T > HandleVector
TO * reference(FROM *from)
std::string m_propertyName
GaudiHandle(const GaudiHandle &other)
Copy constructor needed for correct ref-counting.
bool empty() const
Check if the handle has been set to empty string (i.e.
T is the concrete handle type, e.g.
StatusCode release()
Release all tools.
GaudiHandleArray(const std::string &myComponentType, const std::string &myParentName)
Constructor creating an empty array.