U
    Sºc   ã                   @   s   d gZ G dd „ d eƒZdS )ÚOpenTypec                   @   sV   e Zd ZdZddd„Zedd„ ƒZdd„ Zd	d
„ Zdd„ Z	dd„ Z
dd„ Zdd„ ZdS )r   a¹  Create ASN.1 type map indexed by a value

    The *OpenType* object models an untyped field of a constructed ASN.1
    type. In ASN.1 syntax it is usually represented by the
    `ANY DEFINED BY` for scalars or `SET OF ANY DEFINED BY`,
    `SEQUENCE OF ANY DEFINED BY` for container types clauses. Typically
    used together with :class:`~pyasn1.type.univ.Any` object.

    OpenType objects duck-type a read-only Python :class:`dict` objects,
    however the passed `typeMap` is not copied, but stored by reference.
    That means the user can manipulate `typeMap` at run time having this
    reflected on *OpenType* object behavior.

    The |OpenType| class models an untyped field of a constructed ASN.1
    type. In ASN.1 syntax it is usually represented by the
    `ANY DEFINED BY` for scalars or `SET OF ANY DEFINED BY`,
    `SEQUENCE OF ANY DEFINED BY` for container types clauses. Typically
    used with :class:`~pyasn1.type.univ.Any` type.

    Parameters
    ----------
    name: :py:class:`str`
        Field name

    typeMap: :py:class:`dict`
        A map of value->ASN.1 type. It's stored by reference and can be
        mutated later to register new mappings.

    Examples
    --------

    For untyped scalars:

    .. code-block:: python

        openType = OpenType(
            'id', {1: Integer(),
                   2: OctetString()}
        )
        Sequence(
            componentType=NamedTypes(
                NamedType('id', Integer()),
                NamedType('blob', Any(), openType=openType)
            )
        )

    For untyped `SET OF` or `SEQUENCE OF` vectors:

    .. code-block:: python

        openType = OpenType(
            'id', {1: Integer(),
                   2: OctetString()}
        )
        Sequence(
            componentType=NamedTypes(
                NamedType('id', Integer()),
                NamedType('blob', SetOf(componentType=Any()),
                          openType=openType)
            )
        )
    Nc                 C   s    || _ |d kri | _n|| _d S ©N)Ú_OpenType__nameÚ_OpenType__typeMap)ÚselfÚnameZtypeMap© r   ú8/tmp/pip-unpacked-wheel-hsjy238j/pyasn1/type/opentype.pyÚ__init__K   s    zOpenType.__init__c                 C   s   | j S r   )r   ©r   r   r   r   r   R   s    zOpenType.namec                 C   s
   | j  ¡ S r   )r   Úvaluesr
   r   r   r   r   X   s    zOpenType.valuesc                 C   s
   | j  ¡ S r   )r   Úkeysr
   r   r   r   r   [   s    zOpenType.keysc                 C   s
   | j  ¡ S r   )r   Úitemsr
   r   r   r   r   ^   s    zOpenType.itemsc                 C   s
   || j kS r   ©r   ©r   Úkeyr   r   r   Ú__contains__a   s    zOpenType.__contains__c                 C   s
   | j | S r   r   r   r   r   r   Ú__getitem__d   s    zOpenType.__getitem__c                 C   s
   t | jƒS r   )Úiterr   r
   r   r   r   Ú__iter__g   s    zOpenType.__iter__)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r	   Úpropertyr   r   r   r   r   r   r   r   r   r   r   r      s   ?

N)Ú__all__Úobjectr   r   r   r   r   Ú<module>   s   