a
    ©ˆcÊ  ã                   @   s6   d Z ddlZddlmZ e e¡ZG dd„ deƒZdS )z' A trait type used to access services. é    N)Ú	TraitTypec                       sB   e Zd ZdZd‡ fdd„	Zdd„ Zdd	„ Zd
d„ Zdd„ Z‡  Z	S )ÚServicez­ A trait type used to access services.

    Note that this is a trait *type* and hence does *NOT* have traits itself
    (i.e. it does *not* inherit from 'HasTraits').

    NÚ c                    s.   t ƒ jf i |¤Ž || _|| _|| _|| _dS )z Constructor. N)ÚsuperÚ__init__Ú	_protocolÚ_queryÚ	_minimizeÚ	_maximize)ÚselfÚprotocolÚqueryZminimizeZmaximizeÚmetadata©Ú	__class__© úS/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/envisage/service.pyr   $   s
    zService.__init__c                 C   s   d  | j¡S )z+ String representation of a Service object zService(protocol={!r}))Úformatr   )r   r   r   r   Ú__repr__7   s    zService.__repr__c                 C   s&   |   |¡}| | j| j| j| j¡}|S )z Trait type getter. )Ú_get_service_registryZget_servicer   r   r	   r
   )r   ÚobjZ
trait_nameÚservice_registryr   r   r   Úget?   s
    
ÿzService.getc                 C   s   t dƒ‚dS )z Trait type setter. zService traits cannot be setN)ÚSystemError)r   r   ÚnameÚvaluer   r   r   ÚsetJ   s    zService.setc                 C   s*   t |ddƒ}|du r&td|| jf ƒ‚|S )z6 Return the service registry in effect for an object. r   Nz§The "Service" trait type can only be used within objects that have a reference to a service registry via their "service_registry" trait. 
Object %s
Service protocol %s)ÚgetattrÚ
ValueErrorr   )r   r   r   r   r   r   r   S   s    ýÿzService._get_service_registry)Nr   r   r   )
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   Ú__classcell__r   r   r   r   r      s    ÿ	r   )r"   ÚloggingZ
traits.apir   Ú	getLoggerr   Úloggerr   r   r   r   r   Ú<module>
   s   
