pyffi ::
object_models ::
simple_type ::
SimpleType ::
Class SimpleType
|
|
Class SimpleType
source code
object --+
|
utils.graph.DetailNode --+
|
any_type.AnyType --+
|
SimpleType
- Known Subclasses:
-
Base class from which all simple types are derived. Simple
types contain data which is not divided further into smaller pieces,
and that can represented efficiently by a (usually native) Python type,
typically int, float, or str.
A brief example of usage:
>>> class Short(SimpleType):
... def __init__(self):
...
... self._value = 3
... def set_value(self, value):
...
... if not isinstance(value, int):
... raise TypeError("Expected int but got %s."
... % value.__class__.__name__)
...
... if value < -0x8000 or value > 0x7fff:
... raise ValueError("Value %i out of range." % value)
... self._value = value
>>> test = Short()
>>> print(test)
3
>>> test.value = 255
>>> print(test)
255
>>> test.value = 100000
Traceback (most recent call last):
...
ValueError: ...
>>> test.value = "hello world"
Traceback (most recent call last):
...
TypeError: ...
Also override read and write if you wish to read and write data
of this type, and is_interchangeable if you wish to declare data as
equivalent.
|
__metaclass__
This metaclass binds the get_value and set_value methods to the
value property.
|
str
|
|
Whatever is appropriate.
|
|
|
|
bool
|
|
str
|
|
Inherited from any_type.AnyType :
__hash__ ,
read ,
write
Inherited from utils.graph.DetailNode :
get_detail_child_edge_types ,
get_detail_child_names ,
get_detail_child_nodes ,
get_detail_iterator ,
replace_global_node
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__init__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__sizeof__ ,
__subclasshook__
|
|
value
A property which wraps the actual data.
|
Inherited from object :
__class__
|
__str__(self)
(Informal representation operator)
| source code
|
String representation. This implementation is simply a wrapper
around str on _value.
- Returns: str
- String representation.
- Overrides:
object.__str__
|
Return the stored value.
- Returns: Whatever is appropriate.
- The stored value.
|
Set stored value. Override this method to enable validation
(type checking, range checking, and so on).
- Parameters:
value (Whatever is appropriate.) - The value to store.
|
value
A property which wraps the actual data. This property
always calls set_value to assign the value, and ensures
that the value is valid (type, range, ...). Unless you know
what you are doing, always use the value property to change
the data.
- Get Method:
- unreachable.get_value(self)
- Return the stored value.
- Set Method:
- unreachable.set_value(self,
value)
- Set stored value.
|