| The Gaudi Framework v28r2p1 (f1a77ff4)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Public Attributes | Static Public Attributes | Static Private Attributes | List of all members
GaudiKernel.GaudiHandles.GaudiHandleArray Class Reference
Inheritance diagram for GaudiKernel.GaudiHandles.GaudiHandleArray:
[legend]
Collaboration diagram for GaudiKernel.GaudiHandles.GaudiHandleArray:
[legend]

## Public Member Functions
def | __init__ (self, typesAndNames=None)
def | __repr__ (self)
def | __str__ (self)
def | __getitem__ (self, index)
def | __delitem__ (self, key)
def | __iadd__ (self, array)
def | append (self, value)
def | isPublic (self)
def | toStringProperty (self)
def | __getstate__ (self)
def | __setstate__ (self, dict)

## 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 GaudiKernel.GaudiHandles.GaudiHandleArray.__init__ | ( |  | self,
|  |  | typesAndNames = `None`
| ) |  |

Definition at line 106 of file GaudiHandles.py.

106 def __init__(self,typesAndNames=None):
107 if typesAndNames is None: typesAndNames = []
108 list.__init__(self)
109 # check the type
110 if type(typesAndNames) != list:
111 raise TypeError("Argument to %s must be a list. Got a %s instead" % \
112 ( self.__class__.__name__, type(typesAndNames).__name__) )
113 # add entries to list
114 for tn in typesAndNames: self.append( tn )
115
gaudirun.type
type
Definition: gaudirun.py:125
GaudiKernel.GaudiHandles.GaudiHandleArray.__init__
def __init__(self, typesAndNames=None)
Definition: GaudiHandles.py:106
GaudiKernel.GaudiHandles.GaudiHandleArray.append
def append(self, value)
Definition: GaudiHandles.py:154

## Member Function Documentation

def GaudiKernel.GaudiHandles.GaudiHandleArray.__delitem__ | ( |  | self,
|  |  | key
| ) |  |

Definition at line 141 of file GaudiHandles.py.

141 def __delitem__( self, key ):
142 super( GaudiHandleArray, self ).__delitem__( self.index(self[key]) )
143
GaudiKernel.GaudiHandles.GaudiHandleArray.__delitem__
def __delitem__(self, key)
Definition: GaudiHandles.py:141

def GaudiKernel.GaudiHandles.GaudiHandleArray.__getitem__ | ( |  | self,
|  |  | index
| ) |  |

Definition at line 130 of file GaudiHandles.py.

130 def __getitem__(self,index):
131 if type(index) == str:
132 # seach by instance name
133 for h in self:
134 if h.getName() == index:
135 return h
136 raise IndexError( "%s does not have a %s with instance name %s" % \
137 (self.__class__.__name__, self.handleType.componentType, index) )
138 else:
139 return list.__getitem__(self,index)
140
gaudirun.type
type
Definition: gaudirun.py:125
GaudiKernel.GaudiHandles.GaudiHandleArray.__getitem__
def __getitem__(self, index)
Definition: GaudiHandles.py:130

def GaudiKernel.GaudiHandles.GaudiHandleArray.__getstate__ | ( |  | self | ) |

Definition at line 202 of file GaudiHandles.py.

202 def __getstate__ (self):
203 return { 'typesAndNames' : self.typesAndNames }
204
GaudiKernel.GaudiHandles.GaudiHandleArray.typesAndNames
typesAndNames
Definition: GaudiHandles.py:206
GaudiKernel.GaudiHandles.GaudiHandleArray.__getstate__
def __getstate__(self)
Definition: GaudiHandles.py:202

def GaudiKernel.GaudiHandles.GaudiHandleArray.__iadd__ | ( |  | self,
|  |  | array
| ) |  |

Definition at line 144 of file GaudiHandles.py.

144 def __iadd__(self,array):
145 arrayType = type(array)
146 if arrayType == list or arrayType == type(self):
147 for v in array:
148 self.append( v )
149 else:
150 raise TypeError( "Can not add a %s to a %s" % (arrayType.__name__, self.__class__.__name__) )
151
152 return self
153
gaudirun.type
type
Definition: gaudirun.py:125
GaudiKernel.GaudiHandles.GaudiHandleArray.__iadd__
def __iadd__(self, array)
Definition: GaudiHandles.py:144
GaudiKernel.GaudiHandles.GaudiHandleArray.append
def append(self, value)
Definition: GaudiHandles.py:154

def GaudiKernel.GaudiHandles.GaudiHandleArray.__repr__ | ( |  | self | ) |

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

Definition at line 116 of file GaudiHandles.py.

116 def __repr__(self):
117 """Return class name with list of type/name strings as argument"""
118 rep = self.__class__.__name__ + '(['
119 for h in self:
120 rep += repr(h.toStringProperty()) + ','
121 # remove last comma
122 if rep[-1] == ',': rep = rep[:-1]
123 return rep + '])'
124
GaudiKernel.GaudiHandles.GaudiHandleArray.__repr__
def __repr__(self)
Definition: GaudiHandles.py:116

def GaudiKernel.GaudiHandles.GaudiHandleArray.__setstate__ | ( |  | self,
|  |  | dict
| ) |  |

Definition at line 205 of file GaudiHandles.py.

205 def __setstate__ ( self, dict ):
206 self.typesAndNames = dict[ 'typesAndNames' ]
207
208
GaudiKernel.GaudiHandles.GaudiHandleArray.__setstate__
def __setstate__(self, dict)
Definition: GaudiHandles.py:205
GaudiKernel.GaudiHandles.GaudiHandleArray.typesAndNames
typesAndNames
Definition: GaudiHandles.py:206

def GaudiKernel.GaudiHandles.GaudiHandleArray.__str__ | ( |  | self | ) |

    Print entries, one per line

Definition at line 125 of file GaudiHandles.py.

125 def __str__(self):
126 """Print entries, one per line"""
127 shortName = self.__class__.__name__
128 return "%s:%s" % (shortName, linesep + linesep.join([str(s) for s in self]))
129
GaudiKernel.GaudiHandles.GaudiHandleArray.__str__
def __str__(self)
Definition: GaudiHandles.py:125

def GaudiKernel.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.

154 def append( self, value ):
155 """Only allow appending compatible types. It accepts a string, a handle or a configurable."""
156 if type(value) == str:
157 # convert string to handle
158 value = self.__class__.handleType(value)
159 elif type(value) == self.__class__.handleType:
160 pass # leave handle as-is
161 elif isinstance( value, GaudiHandle ):
162 # do not allow different type of handles
163 raise TypeError( "Can not add a %s to a %s" % (value.__class__.__name__, self.__class__.__name__) )
164 elif value.getGaudiType() != self.__class__.handleType.componentType:
165 # assume it is a configurable: allow only correct types
166 raise TypeError( "Can not append %s (%s) to a %s" % \
167 (value.__class__.__name__, value.getGaudiType(), self.__class__.__name__) )
168 elif hasattr(value,'isPublic'):
169 # check public vs private if applicable for this configurable
170 pop = value.isPublic() and 'Public' or 'Private'
171 if value.isPublic() != self.__class__.handleType.isPublic:
172 raise TypeError( "Can not append %s (%s %s) to a %s" % \
173 (value.__class__.__name__, pop, value.getGaudiType(), self.__class__.__name__) )
174
175 # check that an instance name appears only once in the list
176 try:
177 oldValue = self.__getitem__( value.getName() )
178 except IndexError:
179 # not yet there, so add it
180 list.append( self, value )
181 else:
182 print "%s WARNING %r with instance name %r already in list. Not adding %r" % \
183 (self.__class__.__name__, oldValue, oldValue.getName(), value)
184
185
gaudirun.type
type
Definition: gaudirun.py:125
GaudiKernel.GaudiHandles.GaudiHandleArray.__getitem__
def __getitem__(self, index)
Definition: GaudiHandles.py:130
GaudiKernel.GaudiHandles.GaudiHandleArray.append
def append(self, value)
Definition: GaudiHandles.py:154

def GaudiKernel.GaudiHandles.GaudiHandleArray.isPublic | ( |  | self | ) |

Definition at line 186 of file GaudiHandles.py.

186 def isPublic(self):
187 return self.__class__.handleType.isPublic
188
GaudiKernel.GaudiHandles.GaudiHandleArray.isPublic
def isPublic(self)
Definition: GaudiHandles.py:186

def GaudiKernel.GaudiHandles.GaudiHandleArray.toStringProperty | ( |  | self | ) |

Definition at line 192 of file GaudiHandles.py.

192 def toStringProperty(self):
193 rep = '['
194 # add entries
195 for v in self:
196 rep += repr( v.toStringProperty() ) + ','
197 # remove last comma
198 if rep[-1] == ',': rep = rep[:-1]
199 return rep + ']'
200
GaudiKernel.GaudiHandles.GaudiHandleArray.toStringProperty
def toStringProperty(self)
Definition: GaudiHandles.py:192

## Member Data Documentation

tuple GaudiKernel.GaudiHandles.GaudiHandleArray.__slots__ = ( 'typesAndNames' )
| static private

Definition at line 103 of file GaudiHandles.py.

GaudiKernel.GaudiHandles.GaudiHandleArray.handleType = None
| static

Definition at line 104 of file GaudiHandles.py.

GaudiKernel.GaudiHandles.GaudiHandleArray.typesAndNames

Definition at line 206 of file GaudiHandles.py.

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

- GaudiKernel/python/GaudiKernel/GaudiHandles.py