Package pyffi :: Package object_models :: Module array_type :: Class UniformArray
[hide private]
[frames] | no frames]

Class UniformArray

source code

            object --+            
                     |            
                  list --+        
                         |        
             ValidatedList --+    
                             |    
            object --+       |    
                     |       |    
utils.graph.DetailNode --+   |    
                         |   |    
          any_type.AnyType --+    
                             |    
                      AnyArray --+
                                 |
                                UniformArray

Wrapper for array with elements of the same type; this type must be a subclass of L{pyffi.object_models.any_type.AnyType}.

>>> from pyffi.object_models.simple_type import SimpleType
>>> class MyInt(SimpleType):
...     # in practice one would implement some sort of type checking
...     # for this example we keep it simple
...     def __init__(self, value=0):
...         self._value = value
>>> class ListOfInts(UniformArray):
...     ItemType = MyInt
>>> testlist = ListOfInts()
>>> testlist.append(MyInt(value=20))
>>> testlist.extend([MyInt(value=val) for val in range(2, 10, 2)])
>>> print(testlist)
MyInt array:
  [00] 20
  [01] 2
  [02] 4
  [03] 6
  [04] 8
<BLANKLINE>
>>> [item.value for item in testlist[::-2]]
[8, 4, 20]

@cvar ItemType: Type of the elements of this array. :type ItemType: L{pyffi.object_models.any_type.AnyType}

Nested Classes [hide private]
  __metaclass__
Metaclass for L{UniformArray}.
  ItemType
Abstract base class from which all types are derived.
Instance Methods [hide private]

Inherited from AnyArray: __str__, get_detail_child_names, get_detail_child_nodes, is_interchangeable

Inherited from ValidatedList: __init__, __setitem__, append, extend, insert

Inherited from list: __add__, __contains__, __delitem__, __delslice__, __eq__, __ge__, __getattribute__, __getitem__, __getslice__, __gt__, __iadd__, __imul__, __iter__, __le__, __len__, __lt__, __mul__, __ne__, __new__, __repr__, __reversed__, __rmul__, __setslice__, __sizeof__, count, index, pop, remove, reverse, sort

Inherited from any_type.AnyType: read, write

Inherited from utils.graph.DetailNode: get_detail_child_edge_types, get_detail_display, get_detail_iterator, replace_global_node

Inherited from object: __delattr__, __format__, __reduce__, __reduce_ex__, __setattr__, __subclasshook__

Class Methods [hide private]
 
validate(cls, item)
Check if item can be added.
source code
Class Variables [hide private]

Inherited from AnyArray (private): _MAXSTR

Inherited from list: __hash__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

validate(cls, item)
Class Method

source code 
Check if item can be added.
Overrides: ValidatedList.validate