Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions | Variables
CellMLToNektar.enum Namespace Reference

Functions

def Enum
 

Variables

tuple Days = Enum('Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su')
 
tuple Confirmation = Enum('No', 'Yes')
 
 answer = Confirmation.No
 
 __value
 assert names, "Empty enums are not supported" # <- Don't like empty enums? Uncomment! More...
 

Function Documentation

def CellMLToNektar.enum.Enum (   names)

Definition at line 8 of file enum.py.

8 
9 def Enum(*names):
10  ##assert names, "Empty enums are not supported" # <- Don't like empty enums? Uncomment!
11 
12  class EnumClass(object):
13  __slots__ = names
14  def __iter__(self): return iter(constants)
15  def __len__(self): return len(constants)
16  def __getitem__(self, i): return constants[i]
17  def __repr__(self): return 'Enum' + str(names)
18  def __str__(self): return 'enum ' + str(constants)
19 
20  class EnumValue(object):
21  __slots__ = ('__value')
22  def __init__(self, value): self.__value = value
23  Value = property(lambda self: self.__value)
24  EnumType = property(lambda self: EnumType)
25  def __hash__(self): return hash(self.__value)
26  def __cmp__(self, other):
27  # C fans might want to remove the following assertion
28  # to make all enums comparable by ordinal value {;))
29  assert self.EnumType is other.EnumType, "Only values from the same enum are comparable"
30  return cmp(self.__value, other.__value)
31  def __invert__(self): return constants[maximum - self.__value]
32  def __nonzero__(self): return bool(self.__value)
33  def __repr__(self): return str(names[self.__value])
34 
35  maximum = len(names) - 1
36  constants = [None] * len(names)
37  for i, each in enumerate(names):
38  val = EnumValue(i)
39  setattr(EnumClass, each, val)
40  constants[i] = val
41  constants = tuple(constants)
42  EnumType = EnumClass()
43  return EnumType
44 

Variable Documentation

CellMLToNektar.enum.__value

assert names, "Empty enums are not supported" # <- Don't like empty enums? Uncomment!

Definition at line 21 of file enum.py.

CellMLToNektar.enum.answer = Confirmation.No

Definition at line 58 of file enum.py.

Referenced by Nektar::FieldUtils::OutputFld.Process(), and Nektar::FieldUtils::OutputPts.Process().

tuple CellMLToNektar.enum.Confirmation = Enum('No', 'Yes')

Definition at line 57 of file enum.py.

tuple CellMLToNektar.enum.Days = Enum('Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su')

Definition at line 48 of file enum.py.