pymasep.common.object_state
Classes
Class to handle an ObjectState of an Object |
Module Contents
- class pymasep.common.object_state.ObjectState(environment, name=None, parent=None, xml_node=None, template=None, src_copy=None)
Bases:
pymasep.common.BaseObjectClass to handle an ObjectState of an Object
- Parameters:
environment – an Environment instance
name (Optional[str]) – name of the ObjectState. Not used in this case, ‘state’ is set for ObjectState
xml_node (Optional[xml.etree.ElementTree.Element]) – XML used to create the object.
template – Template of the object. Needed if no xml_node. If the template is present, must include a value_type (see Templates)
src_copy (Optional[ObjectState]) – The ObjectState to copy. Needed if no xml_node or template. The copy is not made into the constructor.
parent (Optional[pymasep.common.BaseObject])
- Raises:
pymasep.common.exception.CreationException – If no XML or no template or src_copy is present
- name = 'state'
name of the object state
- characteristics
Characteristics of the object state
- state()
State of the ObjectState. “Init” if the ObjectState or one of its characteristics is in init state.
- Returns:
The state of the ObjectState
- Return type:
str
- add_characteristic(characteristic)
Adding a characteristic object inside the ObjectState. The key id of the characteristic is its name attribute
- Parameters:
characteristic – Characteristic to add.
- Return type:
None
- id_str()
Create a string unique ID of the ObjectState. Return a concatenation of the id_str of the base object and the id_str of all characteristics
- Returns:
The string unique ID
- Return type:
str
- to_xml()
Transform the ObjectState to XML including all Characteristics. See Serialization for more information.
- Returns:
XML version of the ObjectState
- Return type:
xml.etree.ElementTree.Element
- from_xml(environment, xml_node)
Transform an XML to an ObjectState. The instance must be created before (with __init__(), passing the xml_node). See Serialization for more information.
- Parameters:
environment – The environment where the ObjectState is created.
xml_node (xml.etree.ElementTree.Element) – The XML node that contains the ObjectState data.
- Raises:
pymasep.common.exception.CreationException – SubElement must be present if initializer is not present. At creation, Initializer must be present for all characteristics if initializer is not present for ObjectState
- Return type:
None
- check_all_init_charac_have_initializer(initializer)
DEPRECATED ?
- Return type:
None
- copy_obs(params)
Deep copy the ObjectState to a new instance.
- Parameters:
params (dict) – Not used in this method.
Note : this method copy the reference of the parent. The parent should do the parent copy and assignment