Package mrv :: Module enum :: Class Element
[hide private]
[frames] | no frames]

Class Element

source code

object --+
         |
        Element

Internal helper class used to represent an ordered abstract value.

The values have string representations, have strictly defined ordering (inside the set) and are never equal to anything but themselves.

They are usually created through the create factory method as values for Enumerations.

They assume that the enumeration member will be filled in before any comparisons are used. This is done by the Enumeration constructor.

Instance Methods [hide private]
 
__init__(self, name, value)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
__repr__(self)
repr(x)
source code
 
_checkType(self, other) source code
 
__cmp__(self, other)
We override cmp only because we want the ordering of elements in an enumeration to reflect their position in the enumeration.
source code
 
_checkBitflag(self) source code
 
__or__(self, other)
Allows oring values together - only works if the values are actually orable integer values
source code
 
__xor__(self, other)
Allows to x-or values together - only works if element's values are xorable integer values.
source code
 
__and__(self, other)
Allow and with integers
source code
 
value(self)
Returns: own value
source code
 
name(self)
Returns: name of the element
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, name, value)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

_checkType(self, other)

source code 
Raises:
  • TypeError - if other cannot be used with this element

__or__(self, other)
(Or operator)

source code 
Allows oring values together - only works if the values are actually orable integer values
Returns:
integer with the ored result
Raises:
  • TypeError - if we are not a bitflag or other is not an element of our enumeration

__xor__(self, other)
(Exclusive-Or operator)

source code 
Allows to x-or values together - only works if element's values are xorable integer values.
Parameters:
  • other - integer
Returns:
integer with the xored result

__and__(self, other)
(And operator)

source code 
Allow and with integers
Returns:
self if self & other == self or None if our bit is not set in other
Raises:
  • TypeError - if other is not an int

value(self)

source code 
Returns:
own value

name(self)

source code 
Returns:
name of the element