Gaudi Framework, version v23r2p1

Home   Generated: Fri Jun 29 2012
Public Member Functions | Public Attributes | Static Public Attributes | Static Private Attributes

GaudiHandles::GaudiHandleArray Class Reference

Inheritance diagram for GaudiHandles::GaudiHandleArray:
Inheritance graph
[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.


Constructor & Destructor 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.

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


Member Function Documentation

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

Definition at line 141 of file GaudiHandles.py.

00142                                 :
00143         super( GaudiHandleArray, self ).__delitem__( self.index(self[key]) )

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

Definition at line 130 of file GaudiHandles.py.

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

def GaudiHandles::GaudiHandleArray::__getstate__ (   self )

Definition at line 202 of file GaudiHandles.py.

00203                            :
00204         return { 'typesAndNames' : self.typesAndNames }

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

Definition at line 144 of file GaudiHandles.py.

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

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

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

Definition at line 205 of file GaudiHandles.py.

00206                                    :
00207         self.typesAndNames = dict[ 'typesAndNames' ]
00208 

def GaudiHandles::GaudiHandleArray::__str__ (   self )
Print entries, one per line

Definition at line 125 of file GaudiHandles.py.

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

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.

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

def GaudiHandles::GaudiHandleArray::isPublic (   self )

Definition at line 186 of file GaudiHandles.py.

00187                       :
00188         return self.__class__.handleType.isPublic

def GaudiHandles::GaudiHandleArray::toStringProperty (   self )

Definition at line 192 of file GaudiHandles.py.

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


Member Data Documentation

Definition at line 205 of file GaudiHandles.py.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Fri Jun 29 2012 15:44:13 for Gaudi Framework, version v23r2p1 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004