
    s
eM                        U d Z ddlmZ ddgZddlZddlZ ej        d          Zg Zde	d<   ddZ
 G d dej        e         ej                  Z G d dee         ej        e                   ZdS )z,A simple base to create singleton instances.    )annotations	SingletonSingleInstanceOfNTz$typing.Final[typing.List[Singleton]]__singletons__returnNonec                 B    t           D ]} |                                  dS )z,Reset all singletons in application at once.N)r   reset)	singletons    Blib/python3.11/site-packages/navigator_updater/utils/singletons.py	reset_allr      s0     $  	     c                  h    e Zd ZdZdZddZedd            ZddZe	j
        dd	            Zdd
ZdS )r   z
    Container for a singleton instance of some type.

    Supports lazy initialization as soon as the instance might be required.
    )
__instancer   r	   c                H    d| _         t                              |            dS )z,Initialize new :class:`~Singleton` instance.N)_Singleton__instancer   appendselfs    r   __init__zSingleton.__init__#   s#    .2d#####r   r   c                P    | j         |                                 | _         | j         S )zSingleton instance.)r   _preparer   s    r   instancezSingleton.instance(   s#     ?""mmooDOr   c                N    | j         dS |                                  d| _         dS )z
        Reset singleton value.

        This will trigger repeated initialization of an instance on next :attr:`~Singleton.instance` call.
        N)r   _releaser   s    r   r   zSingleton.reset/   s)     ?"Fr   c                    dS )Initialize singleton instance.N r   s    r   r   zSingleton._prepare;         r   c                    dS )zCDestroy singleton instance when :meth:`~Singleton.reset` is called.Nr   r   s    r   r   zSingleton._release?   r    r   Nr   r	   r   r   )__name__
__module____qualname____doc__	__slots__r   propertyr   r   abcabstractmethodr   r   r   r   r   r   r      s           I$ $ $ $
    X
 
 
 
 	- - - -R R R R R Rr   )	metaclassc                  0     e Zd ZdZdZd
 fdZdd	Z xZS )r   zUShortcut for singletons constructed from external functions or instance constructors.)__constructorconstructortyping.Callable[[], T]r   r	   c                V    t                                                       || _        dS )z3Initialize new :class:`~SingleInstanceOf` instance.N)superr   _SingleInstanceOf__constructor)r   r/   	__class__s     r   r   zSingleInstanceOf.__init__H   s'    CNr   r   c                *    |                                  S )r   )r3   r   s    r   r   zSingleInstanceOf._prepareM   s    !!###r   )r/   r0   r   r	   r#   )r$   r%   r&   r'   r(   r   r   __classcell__)r4   s   @r   r   r   C   sb        __"IO O O O O O
$ $ $ $ $ $ $ $r   r"   )r'   
__future__r   __all__r*   typingTypeVarr   r   __annotations__r   GenericABCMetar   r   r   r   r   <module>r>      s    3 2 2 " " " " " "*
+ 



  FN3 8: 9 9 9 9   &R &R &R &R &Rq!S[ &R &R &R &RR$ $ $ $ $y|V^A%6 $ $ $ $ $r   