| The Gaudi Framework v32r1 (f65d50dc)

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

## Constructor & Destructor Documentation

## ◆ __init__()

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

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

Definition at line 113 of file GaudiHandles.py.

113 def __init__(self, typesAndNames=None):
114 if typesAndNames is None:
115 typesAndNames = []
116 list.__init__(self)
117 # check the type
118 if type(typesAndNames) != list:
119 raise TypeError(
120 "Argument to %s must be a list. Got a %s instead" %
121 (self.__class__.__name__, type(typesAndNames).__name__))
122 # add entries to list
123 for tn in typesAndNames:
124 self.append(tn)
125
gaudirun.type
type
Definition: gaudirun.py:142

## Member Function Documentation

## ◆ __delitem__()

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

Definition at line 153 of file GaudiHandles.py.

153 def __delitem__(self, key):
154 super(GaudiHandleArray, self).__delitem__(self.index(self[key]))
155

## ◆ __getitem__()

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

Definition at line 142 of file GaudiHandles.py.

142 def __getitem__(self, index):
143 if type(index) == str:
144 # seach by instance name
145 for h in self:
146 if h.getName() == index:
147 return h
148 raise IndexError("%s does not have a %s with instance name %s" % (
149 self.__class__.__name__, self.handleType.componentType, index))
150 else:
151 return list.__getitem__(self, index)
152
gaudirun.type
type
Definition: gaudirun.py:142
GaudiPython.Pythonizations.__getitem__
__getitem__
Definition: Pythonizations.py:115

## ◆ __getstate__()

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

Definition at line 220 of file GaudiHandles.py.

220 def __getstate__(self):
221 return {'typesAndNames': self.typesAndNames}
222

## ◆ __iadd__()

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

Definition at line 156 of file GaudiHandles.py.

156 def __iadd__(self, array):
157 arrayType = type(array)
158 if arrayType == list or arrayType == type(self):
159 for v in array:
160 self.append(v)
161 else:
162 raise TypeError("Can not add a %s to a %s" %
163 (arrayType.__name__, self.__class__.__name__))
164
165 return self
166
gaudirun.type
type
Definition: gaudirun.py:142

## ◆ __repr__()

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

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

Definition at line 126 of file GaudiHandles.py.

126 def __repr__(self):
127 """Return class name with list of type/name strings as argument"""
128 rep = self.__class__.__name__ + '(['
129 for h in self:
130 rep += repr(h.toStringProperty()) + ','
131 # remove last comma
132 if rep[-1] == ',':
133 rep = rep[:-1]
134 return rep + '])'
135
GaudiPython.HistoUtils.__repr__
__repr__
Definition: HistoUtils.py:508

## ◆ __setstate__()

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

Definition at line 223 of file GaudiHandles.py.

223 def __setstate__(self, dict):
224 self.typesAndNames = dict['typesAndNames']
225
226

## ◆ __str__()

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

    Print entries, one per line

Definition at line 136 of file GaudiHandles.py.

136 def __str__(self):
137 """Print entries, one per line"""
138 shortName = self.__class__.__name__
139 return "%s:%s" % (shortName,
140 linesep + linesep.join([str(s) for s in self]))
141
GaudiPython.HistoUtils.__str__
__str__
Definition: HistoUtils.py:510

## ◆ append()

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

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

Definition at line 167 of file GaudiHandles.py.

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

## ◆ isPublic()

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

Definition at line 203 of file GaudiHandles.py.

203 def isPublic(self):
204 return self.__class__.handleType.isPublic
205

## ◆ toStringProperty()

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

Definition at line 209 of file GaudiHandles.py.

209 def toStringProperty(self):
210 rep = '['
211 # add entries
212 for v in self:
213 rep += repr(v.toStringProperty()) + ','
214 # remove last comma
215 if rep[-1] == ',':
216 rep = rep[:-1]
217 return rep + ']'
218

## Member Data Documentation

## ◆ __slots__

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

Definition at line 110 of file GaudiHandles.py.

## ◆ handleType

GaudiKernel.GaudiHandles.GaudiHandleArray.handleType = None
| static

Definition at line 111 of file GaudiHandles.py.

## ◆ typesAndNames

GaudiKernel.GaudiHandles.GaudiHandleArray.typesAndNames

Definition at line 224 of file GaudiHandles.py.

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

- GaudiKernel/python/GaudiKernel/GaudiHandles.py