1 #ifndef GAUDIKERNEL_GAUDIHANDLE_H
2 #define GAUDIKERNEL_GAUDIHANDLE_H
26 : m_componentType(
std::move(myComponentType)), m_parentName(
std::move(myParentName))
35 return m_componentType;
40 return m_propertyName;
56 virtual std::string pythonPropertyClassName()
const = 0;
68 m_componentType = componentType;
73 m_parentName = parent;
113 setTypeAndName(
std::move(myTypeAndName));
121 return m_typeAndName;
132 return m_typeAndName.empty();
186 if ( m_pObject ) m_pObject->addRef();
191 GaudiHandleBase::operator=( other );
196 if ( m_pObject ) m_pObject->addRef();
207 if ( retrieve( m_pObject ).isFailure() ) {
226 return m_pObject || retrieve().isSuccess();
231 operator bool()
const {
272 if ( defName.
empty() ) defName = getDefaultType();
310 mutable T* m_pObject =
nullptr;
360 virtual bool push_back(
const std::string& myHandleTypeAndName ) = 0;
363 virtual void clear() = 0;
366 virtual bool empty()
const = 0;
370 virtual ConstBaseHandleArray getBaseArray()
const = 0;
374 virtual BaseHandleArray getBaseArray() = 0;
377 virtual bool retrieved()
const = 0;
433 iterator it =
begin(), itEnd =
end();
434 for ( ; it != itEnd; ++it ) baseArray.
push_back( &*it );
440 const_iterator it =
begin(), itEnd =
end();
441 for ( ; it != itEnd; ++it ) baseArray.
push_back( &*it );
449 return m_handleArray.begin();
453 return m_handleArray.end();
457 return m_handleArray.begin();
460 const_iterator
end()
const {
461 return m_handleArray.end();
465 return m_handleArray.rbegin();
469 return m_handleArray.rend();
473 return m_handleArray.size();
477 m_handleArray.clear();
481 return m_handleArray.empty();
485 return m_handleArray[index];
489 return m_handleArray[index];
495 return r.name() ==
name;
497 return it !=
end() ? &*it :
nullptr;
503 return r.name() ==
name;
505 return it !=
end() ? &*it :
nullptr;
512 m_handleArray.push_back( myHandle );
518 for (
auto&
i : *
this) {
529 for (
auto&
i : *
this ) {
544 bool m_retrieved {
false };
551 #endif // ! GAUDIKERNEL_GAUDIHANDLE_H
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.
void clear() override
Clear the list of handles.
std::string getDefaultType()
Helper function to get default type string from the class type.
Define general base for Gaudi exception.
HandleVector::iterator iterator
GaudiHandleArrayBase::BaseHandleArray getBaseArray() override
Get a read-write vector of GaudiHandleBase* pointing to the real handles.
void setTypeAndName(std::string myTypeAndName)
The component "type/name" string.
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
HandleVector::const_reverse_iterator const_reverse_iterator
void setComponentType(const std::string &componentType)
The component type.
std::string getDefaultName()
GaudiHandle(std::string myTypeAndName, std::string myComponentType, std::string myParentName)
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
GaudiHandleArray(const std::vector< std::string > &myTypesAndNamesList, std::string myComponentType, std::string myParentName)
Generic constructor.
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.
bool empty() const override
Return whether the list of tools is empty.
HandleVector::reference reference
virtual bool push_back(const T &myHandle)
void setParentName(const std::string &parent)
The name of the parent.
StatusCode release() const
Release the component.
bool retrieved() const
has Array been retreived?
auto begin(reverse_wrapper< T > &w)
void setDefaultTypeAndName()
Helper function to set default name and type.
virtual std::string pythonRepr() const =0
Python representation of handle, i.e.
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.
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.
GaudiHandleArrayBase::ConstBaseHandleArray getBaseArray() const override
Get a read-only vector of const GaudiHandleBase* pointing to the real handles.
StatusCode retrieve() const
Retrieve the component.
std::string m_typeAndName
auto end(reverse_wrapper< T > &w)
HandleVector::const_iterator const_iterator
bool isValid() const
Check if the handle is valid (try to retrive the object is not done yet).
Base class of array's of various gaudihandles.
virtual std::string pythonPropertyClassName() const =0
The python class name for the property in the genconf-generated configurables.
const_iterator rbegin() const
GaudiHandleInfo(std::string myComponentType, std::string myParentName)
Some basic information and helper functions shared between various handles/arrays.
void setPropertyName(std::string propName)
set name as used in declareProperty(name,gaudiHandle).
bool isSet() const
True if the wrapped pointer is not null.
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.
std::string type() const
The concrete component class name: the part before the '/'.
std::ostream & operator<<(std::ostream &os, const GaudiHandleInfo &handle)
T & operator[](int index)
const T * operator[](const std::string &name) const
Get const pointer (!) to ToolHandle by instance name.
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".
GaudiHandleArrayBase(std::string myComponentType, std::string myParentName)
T * operator[](const std::string &name)
Get pointer (!) to ToolHandle by instance name.
const std::string & componentType() const
std::vector< T > HandleVector
TO * reference(FROM *from)
GaudiHandleBase(std::string myTypeAndName, std::string myComponentType, std::string myParentName)
Create a handle ('smart pointer') to a gaudi component.
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.