a
    yn„f¼  ã                   @  sB   d dl mZ d dlmZmZ G dd„ deƒZG dd„ deeƒZdS )é    )Úannotations)ÚProtocolÚSelfc                      s^   e Zd ZU ded< eddœ‡ fdd„ƒZedd„ ƒZdd	„ Zd
d„ Zeddœdd„ƒZ	‡  Z
S )ÚPrivateSingletonr   Ú	_instance©Úreturnc                   s:   t | dƒrtd| j› d�ƒ‚tƒ  | ¡}| ¡  || _|S )Nr   zinternal_error: singleton z was already instantiated)ÚhasattrÚRuntimeErrorÚ__name__ÚsuperÚ__new__Ú__init__r   )ÚclsÚself©Ú	__class__© úU/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/awkward/_singleton.pyÚ_new   s    
ÿzPrivateSingleton._newc                 C  s(   z| j W S  ty"   |  ¡  Y S 0 d S ©N)r   ÚAttributeErrorr   ©r   r   r   r   Ú_ensure_instance   s    z!PrivateSingleton._ensure_instancec                 O  s   t d| j› d�ƒ‚d S )Nzinternal_error: z- class should never be directly instantiated.)Ú	TypeErrorr   )r   ÚargsÚkwargsr   r   r   r      s    ÿzPrivateSingleton.__new__c                 C  s   t | ƒjdfS )Nr   )Útyper   )r   r   r   r   Ú
__reduce__$   s    zPrivateSingleton.__reduce__c                 C  s   | j S r   )r   r   r   r   r   Ú_reduce_constructor'   s    z$PrivateSingleton._reduce_constructor)r   Ú
__module__Ú__qualname__Ú__annotations__Úclassmethodr   r   r   r   r   Ú__classcell__r   r   r   r   r      s   

r   c                   @  s   e Zd Zeddœdd„ƒZdS )ÚPublicSingletonr   r   c                 C  s   |   ¡ S r   )r   r   r   r   r   Úinstance-   s    zPublicSingleton.instanceN)r   r    r!   r#   r&   r   r   r   r   r%   ,   s   r%   N)Ú
__future__r   Zawkward._typingr   r   r   r%   r   r   r   r   Ú<module>   s   $