pymasep.common.container ======================== .. py:module:: pymasep.common.container Classes ------- .. autoapisummary:: pymasep.common.container.Container Module Contents --------------- .. py:class:: Container(environment, name = None, parent = None, xml_node = None, template=None, src_copy = None) Bases: :py:obj:`pymasep.common.BaseObject` Container class containing other objects. A container is not an object itself, it is more an object property. :param environment: an Environment instance :param name: name of the Container. :param xml_node: XML used to create the Container. :param template: Template of the container. Needed if no xml_node. :param parent: Parent object (see objects hierarchy) :param src_copy: Container to copy. See copy_obs() .. py:attribute:: __slots__ :value: ['_container'] .. py:attribute:: _container .. py:method:: state() state of the Container. 'init' if the object is just created or if one contained object is in 'init' state. :return: the state of the Container .. py:method:: set_run() Set the state of a container to run. A container must be explicitly set to run. .. py:method:: add(obj) add an object to the container. :param pymasep.common.Object obj: the object to add .. py:method:: remove(obj) remove an object from the container. :param pymasep.common.Object obj: the object to remove .. py:method:: __iter__() .. py:method:: __next__() .. py:method:: __len__() .. py:method:: __getitem__(item) .. py:method:: id_str() Create a string unique ID of the Container. Return a concatenation of the id_str of the base object and the id_str of all contained objects :return: The string unique ID .. py:method:: to_xml() Transform the Container to XML with all objects contained in the Container. See :ref:`serialization` for more information. :return: XML version of the Container :raise pymasep.common.exception.ConstraintException: A container not initialized must have an initializer before streaming to XML .. py:method:: from_xml(environment, xml_node) Transform an XML to a Container. The instance must be created before (with __init__(), passing the xml_node). See :ref:`serialization` for more information. :param environment: The environment where the ObjectState is created. :param xml_node: The XML node that contains the container information. :raise pymasep.common.exception.CreationException: A container must be empty or containing only an initialized object. .. py:method:: copy_obs(params) Deep copy the Container to a new instance. :param params: Not used for a Container Note : this method copy the reference of the parent. The parent should do the parent copy and assignment