| # Gaudi Framework, version v20r4
Generated: 8 Jan 2009

# GaudiHandles::GaudiHandleArray Class Reference

Inheritance diagram for GaudiHandles::GaudiHandleArray:

[legend]

List of all members.

## Detailed Description

    A list of GaudiHandles. Only handles of one type are allowed, as specified by self.__class__.handleType

Definition at line 99 of file GaudiHandles.py.

## Public Member Functions
def | __init__
def | __repr__
def | __str__
def | __getitem__
def | __delitem__
def | __iadd__
def | append
def | isPublic
def | toStringProperty
def | __getstate__
def | __setstate__
## Public Attributes
| typesAndNames
## Static Public Attributes
| handleType = None
## Static Private Attributes
tuple | __slots__ = ( 'typesAndNames' )

## Member Function Documentation

def GaudiHandles::GaudiHandleArray::__init__ | ( |  | self,
|  |  | typesAndNames = `None` |
| ) |  |  |

Reimplemented in GaudiHandles::PublicToolHandleArray, and GaudiHandles::PrivateToolHandleArray.

Definition at line 105 of file GaudiHandles.py.

    00105                                          :
    00106         if typesAndNames is None: typesAndNames = []
    00107         list.__init__(self)
    00108         # check the type
    00109         if type(typesAndNames) != list:
    00110             raise TypeError("Argument to %s must be a list. Got a %s instead" % \
    00111                             ( self.__class__.__name__, type(typesAndNames).__name__) )
    00112         # add entries to list
    00113         for tn in typesAndNames: self.append( tn )
    00114
        def __repr__(self):

def GaudiHandles::GaudiHandleArray::__repr__ | ( |  | self | ) |

    Return class name with list of type/name strings as argument

Definition at line 115 of file GaudiHandles.py.

    00115                       :
    00116         """Return class name with list of type/name strings as argument"""
    00117         rep = self.__class__.__name__ + '(['
    00118         for h in self:
    00119             rep += repr(h.toStringProperty()) + ','
    00120         # remove last comma
    00121         if rep[-1] == ',': rep = rep[:-1]
    00122         return rep + '])'
    00123
        def __str__(self):

def GaudiHandles::GaudiHandleArray::__str__ | ( |  | self | ) |

    Print entries, one per line

Definition at line 124 of file GaudiHandles.py.

    00124                      :
    00125         """Print entries, one per line"""
    00126         shortName = self.__class__.__name__
    00127         return "%s:%s" % (shortName, linesep + linesep.join([str(s) for s in self]))
    00128
        def __getitem__(self,index):

def GaudiHandles::GaudiHandleArray::__getitem__ | ( |  | self,
|  |  | index |
| ) |  |  |

Definition at line 129 of file GaudiHandles.py.

    00129                                :
    00130         if type(index) == str:
    00131             # seach by instance name
    00132             for h in self:
    00133                 if h.getName() == index:
    00134                     return h
    00135             raise IndexError( "%s does not have a %s with instance name %s" % \
    00136                               (self.__class__.__name__, self.handleType.componentType, index) )
    00137         else:
    00138             return list.__getitem__(self,index)
    00139
        def __delitem__( self, key ):

def GaudiHandles::GaudiHandleArray::__delitem__ | ( |  | self,
|  |  | key |
| ) |  |  |

Definition at line 140 of file GaudiHandles.py.

    00140                                 :
    00141         super( GaudiHandleArray, self ).__delitem__( self.index(self[key]) )
    00142
        def __iadd__(self,array):

def GaudiHandles::GaudiHandleArray::__iadd__ | ( |  | self,
|  |  | array |
| ) |  |  |

Definition at line 143 of file GaudiHandles.py.

    00143                             :
    00144         arrayType = type(array)
    00145         if arrayType == list or arrayType == type(self):
    00146             for v in array:
    00147                 self.append( v )
    00148         else:
    00149             raise TypeError( "Can not add a %s to a %s" % (arrayType.__name__, self.__class__.__name__) )
    00150
    00151         return self
    00152
        def append( self, value ):

def GaudiHandles::GaudiHandleArray::append | ( |  | self,
|  |  | value |
| ) |  |  |

    Only allow appending compatible types. It accepts a string, a handle or a configurable.

Definition at line 153 of file GaudiHandles.py.

    00153                              :
    00154         """Only allow appending compatible types. It accepts a string, a handle or a configurable."""
    00155         if type(value) == str:
    00156             # convert string to handle
    00157             value = self.__class__.handleType(value)
    00158         elif type(value) == self.__class__.handleType:
    00159             pass # leave handle as-is
    00160         elif isinstance( value, GaudiHandle ):
    00161             # do not allow different type of handles
    00162             raise TypeError( "Can not add a %s to a %s" % (value.__class__.__name__, self.__class__.__name__) )
    00163         elif value.getGaudiType() != self.__class__.handleType.componentType:
    00164             # assume it is a configurable: allow only correct types
    00165             raise TypeError( "Can not append %s (%s) to a %s" % \
    00166                              (value.__class__.__name__, value.getGaudiType(), self.__class__.__name__) )
    00167         elif hasattr(value,'isPublic'):
    00168             # check public vs private if applicable for this configurable
    00169             pop = value.isPublic() and 'Public' or 'Private'
    00170             if value.isPublic() != self.__class__.handleType.isPublic:
    00171                 raise TypeError( "Can not append %s (%s %s) to a %s" % \
    00172                                  (value.__class__.__name__, pop, value.getGaudiType(), self.__class__.__name__) )
    00173
    00174         # check that an instance name appears only once in the list
    00175         try:
    00176             oldValue = self.__getitem__( value.getName() )
    00177         except IndexError:
    00178             # not yet there, so add it
    00179             list.append( self, value )
    00180         else:
    00181             print "%s    WARNING %r with instance name %r already in list. Not adding %r" % \
    00182                   (self.__class__.__name__, oldValue, oldValue.getName(), value)
    00183
    00184
        def isPublic(self):

def GaudiHandles::GaudiHandleArray::isPublic | ( |  | self | ) |

Definition at line 185 of file GaudiHandles.py.

    00185                       :
    00186         return self.__class__.handleType.isPublic
    00187
    00188     #
        # Member functions which are the same as Configurables

def GaudiHandles::GaudiHandleArray::toStringProperty | ( |  | self | ) |

Definition at line 191 of file GaudiHandles.py.

    00191                               :
    00192         rep = '['
    00193         # add entries
    00194         for v in self:
    00195             rep += repr( v.toStringProperty() ) + ','
    00196         # remove last comma
    00197         if rep[-1] == ',': rep = rep[:-1]
    00198         return rep + ']'
    00199
    00200     # pickle support
        def __getstate__ (self):

def GaudiHandles::GaudiHandleArray::__getstate__ | ( |  | self | ) |

Definition at line 201 of file GaudiHandles.py.

    00201                            :
    00202         return { 'typesAndNames' : self.typesAndNames }
    00203
        def __setstate__ ( self, dict ):

def GaudiHandles::GaudiHandleArray::__setstate__ | ( |  | self,
|  |  | dict |
| ) |  |  |

Definition at line 204 of file GaudiHandles.py.

    00204                                    :
    00205         self.typesAndNames = dict[ 'typesAndNames' ]
    00206
    00207
    class PublicToolHandleArray(GaudiHandleArray):

## Member Data Documentation

tuple GaudiHandles::GaudiHandleArray::__slots__ = ( 'typesAndNames' )`[static, private]`

Reimplemented in GaudiHandles::PublicToolHandleArray, and GaudiHandles::PrivateToolHandleArray.

Definition at line 102 of file GaudiHandles.py.

GaudiHandles::GaudiHandleArray::handleType = None`[static]`

Reimplemented in GaudiHandles::PublicToolHandleArray, and GaudiHandles::PrivateToolHandleArray.

Definition at line 103 of file GaudiHandles.py.

GaudiHandles::GaudiHandleArray::typesAndNames

Definition at line 205 of file GaudiHandles.py.

The documentation for this class was generated from the following file:

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r4/GaudiKernel/python/GaudiKernel/GaudiHandles.py