Gaudi Framework, version v23r5

Home   Generated: Wed Nov 28 2012
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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:
Inheritance graph
[legend]
Collaboration diagram for GaudiKernel.GaudiHandles.GaudiHandleArray:
Collaboration graph
[legend]

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

Definition at line 106 of file GaudiHandles.py.

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

Member Function Documentation

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

Definition at line 141 of file GaudiHandles.py.

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

Definition at line 130 of file GaudiHandles.py.

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

Definition at line 202 of file GaudiHandles.py.

203  def __getstate__ (self):
204  return { 'typesAndNames' : self.typesAndNames }
def GaudiKernel.GaudiHandles.GaudiHandleArray.__iadd__ (   self,
  array 
)

Definition at line 144 of file GaudiHandles.py.

145  def __iadd__(self,array):
146  arrayType = type(array)
147  if arrayType == list or arrayType == type(self):
148  for v in array:
149  self.append( v )
150  else:
151  raise TypeError( "Can not add a %s to a %s" % (arrayType.__name__, self.__class__.__name__) )
152 
153  return self
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.

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

Definition at line 205 of file GaudiHandles.py.

206  def __setstate__ ( self, dict ):
207  self.typesAndNames = dict[ 'typesAndNames' ]
208 
def GaudiKernel.GaudiHandles.GaudiHandleArray.__str__ (   self)
Print entries, one per line

Definition at line 125 of file GaudiHandles.py.

126  def __str__(self):
127  """Print entries, one per line"""
128  shortName = self.__class__.__name__
129  return "%s:%s" % (shortName, linesep + linesep.join([str(s) for s in self]))
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.

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

Definition at line 186 of file GaudiHandles.py.

187  def isPublic(self):
188  return self.__class__.handleType.isPublic
def GaudiKernel.GaudiHandles.GaudiHandleArray.toStringProperty (   self)

Definition at line 192 of file GaudiHandles.py.

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

Member Data Documentation

tuple GaudiKernel.GaudiHandles.GaudiHandleArray.__slots__ ( 'typesAndNames' )
staticprivate

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:
Generated at Wed Nov 28 2012 12:17:39 for Gaudi Framework, version v23r5 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004