| The Gaudi Framework v29r1 (5cd95fa2)

- 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 104 of file GaudiHandles.py.

## Constructor & Destructor Documentation

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

Definition at line 110 of file GaudiHandles.py.

110 def __init__(self, typesAndNames=None):
111 if typesAndNames is None:
112 typesAndNames = []
113 list.__init__(self)
114 # check the type
115 if type(typesAndNames) != list:
116 raise TypeError("Argument to %s must be a list. Got a %s instead" %
117 (self.__class__.__name__, type(typesAndNames).__name__))
118 # add entries to list
119 for tn in typesAndNames:
120 self.append(tn)
121
gaudirun.type
type
Definition: gaudirun.py:133
GaudiKernel.GaudiHandles.GaudiHandleArray.__init__
def __init__(self, typesAndNames=None)
Definition: GaudiHandles.py:110
GaudiKernel.GaudiHandles.GaudiHandleArray.append
def append(self, value)
Definition: GaudiHandles.py:162

## Member Function Documentation

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

Definition at line 148 of file GaudiHandles.py.

148 def __delitem__(self, key):
149 super(GaudiHandleArray, self).__delitem__(self.index(self[key]))
150
GaudiKernel.GaudiHandles.GaudiHandleArray.__delitem__
def __delitem__(self, key)
Definition: GaudiHandles.py:148

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

Definition at line 137 of file GaudiHandles.py.

137 def __getitem__(self, index):
138 if type(index) == str:
139 # seach by instance name
140 for h in self:
141 if h.getName() == index:
142 return h
143 raise IndexError("%s does not have a %s with instance name %s" %
144 (self.__class__.__name__, self.handleType.componentType, index))
145 else:
146 return list.__getitem__(self, index)
147
gaudirun.type
type
Definition: gaudirun.py:133
GaudiKernel.GaudiHandles.GaudiHandleArray.__getitem__
def __getitem__(self, index)
Definition: GaudiHandles.py:137

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

Definition at line 211 of file GaudiHandles.py.

211 def __getstate__(self):
212 return {'typesAndNames': self.typesAndNames}
213
GaudiKernel.GaudiHandles.GaudiHandleArray.typesAndNames
typesAndNames
Definition: GaudiHandles.py:215
GaudiKernel.GaudiHandles.GaudiHandleArray.__getstate__
def __getstate__(self)
Definition: GaudiHandles.py:211

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

Definition at line 151 of file GaudiHandles.py.

151 def __iadd__(self, array):
152 arrayType = type(array)
153 if arrayType == list or arrayType == type(self):
154 for v in array:
155 self.append(v)
156 else:
157 raise TypeError("Can not add a %s to a %s" %
158 (arrayType.__name__, self.__class__.__name__))
159
160 return self
161
gaudirun.type
type
Definition: gaudirun.py:133
GaudiKernel.GaudiHandles.GaudiHandleArray.__iadd__
def __iadd__(self, array)
Definition: GaudiHandles.py:151
GaudiKernel.GaudiHandles.GaudiHandleArray.append
def append(self, value)
Definition: GaudiHandles.py:162

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

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

Definition at line 122 of file GaudiHandles.py.

122 def __repr__(self):
123 """Return class name with list of type/name strings as argument"""
124 rep = self.__class__.__name__ + '(['
125 for h in self:
126 rep += repr(h.toStringProperty()) + ','
127 # remove last comma
128 if rep[-1] == ',':
129 rep = rep[:-1]
130 return rep + '])'
131
GaudiKernel.GaudiHandles.GaudiHandleArray.__repr__
def __repr__(self)
Definition: GaudiHandles.py:122

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

Definition at line 214 of file GaudiHandles.py.

214 def __setstate__(self, dict):
215 self.typesAndNames = dict['typesAndNames']
216
217
GaudiKernel.GaudiHandles.GaudiHandleArray.__setstate__
def __setstate__(self, dict)
Definition: GaudiHandles.py:214
GaudiKernel.GaudiHandles.GaudiHandleArray.typesAndNames
typesAndNames
Definition: GaudiHandles.py:215

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

    Print entries, one per line

Definition at line 132 of file GaudiHandles.py.

132 def __str__(self):
133 """Print entries, one per line"""
134 shortName = self.__class__.__name__
135 return "%s:%s" % (shortName, linesep + linesep.join([str(s) for s in self]))
136
GaudiKernel.GaudiHandles.GaudiHandleArray.__str__
def __str__(self)
Definition: GaudiHandles.py:132

def GaudiKernel.GaudiHandles.GaudiHandleArray.append | ( |  | self,
|  |  | value
| ) |  |

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

Definition at line 162 of file GaudiHandles.py.

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

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

Definition at line 194 of file GaudiHandles.py.

194 def isPublic(self):
195 return self.__class__.handleType.isPublic
196
GaudiKernel.GaudiHandles.GaudiHandleArray.isPublic
def isPublic(self)
Definition: GaudiHandles.py:194

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

Definition at line 200 of file GaudiHandles.py.

200 def toStringProperty(self):
201 rep = '['
202 # add entries
203 for v in self:
204 rep += repr(v.toStringProperty()) + ','
205 # remove last comma
206 if rep[-1] == ',':
207 rep = rep[:-1]
208 return rep + ']'
209
GaudiKernel.GaudiHandles.GaudiHandleArray.toStringProperty
def toStringProperty(self)
Definition: GaudiHandles.py:200

## Member Data Documentation

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

Definition at line 107 of file GaudiHandles.py.

GaudiKernel.GaudiHandles.GaudiHandleArray.handleType = None
| static

Definition at line 108 of file GaudiHandles.py.

GaudiKernel.GaudiHandles.GaudiHandleArray.typesAndNames

Definition at line 215 of file GaudiHandles.py.

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

- GaudiKernel/python/GaudiKernel/GaudiHandles.py