| # Gaudi Framework, version v21r7p1 |

Home |  | Generated: 15 Feb 2010

# GaudiHandles::GaudiHandleArray Class Reference

Inheritance diagram for GaudiHandles::GaudiHandleArray:

[legend]
Collaboration diagram for GaudiHandles::GaudiHandleArray:

[legend]

List of all members.

## 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' )

## Detailed Description

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

Definition at line 100 of file GaudiHandles.py.

## Member Function Documentation

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

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

Definition at line 106 of file GaudiHandles.py.

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

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

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

Definition at line 116 of file GaudiHandles.py.

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

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

    Print entries, one per line

Definition at line 125 of file GaudiHandles.py.

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

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

Definition at line 130 of file GaudiHandles.py.

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

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

Definition at line 141 of file GaudiHandles.py.

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

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

Definition at line 144 of file GaudiHandles.py.

    00144                             :
    00145         arrayType = type(array)
    00146         if arrayType == list or arrayType == type(self):
    00147             for v in array:
    00148                 self.append( v )
    00149         else:
    00150             raise TypeError( "Can not add a %s to a %s" % (arrayType.__name__, self.__class__.__name__) )
    00151
    00152         return self
    00153
        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 154 of file GaudiHandles.py.

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

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

Definition at line 186 of file GaudiHandles.py.

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

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

Definition at line 192 of file GaudiHandles.py.

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

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

Definition at line 202 of file GaudiHandles.py.

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

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

Definition at line 205 of file GaudiHandles.py.

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

## Member Data Documentation

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

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

Definition at line 103 of file GaudiHandles.py.

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

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

Definition at line 104 of file GaudiHandles.py.

GaudiHandles::GaudiHandleArray::typesAndNames

Definition at line 206 of file GaudiHandles.py.

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

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