3
=Ad]  ã               @   s(   d Z ddlmZmZ G dd„ deƒZdS )z! The service registry interface. é    )ÚEventÚ	Interfacec               @   sV   e Zd ZdZeZeZddd„Zdd„ Zddd„Z	d	d
„ Z
ddd„Zdd„ Zdd„ ZdS )ÚIServiceRegistryaÑ   The service registry interface.

    The service registry provides a 'Yellow Pages' style mechanism, in that
    services are published and looked up by protocol (meaning, *interface*,
    *type*, or *class* (for old-style classes!). It is called a 'Yellow Pages'
    mechanism because it is just like looking up a telephone number in the
    'Yellow Pages' phone book. You use the 'Yellow Pages' instead of the
    'White Pages' when you don't know the *name* of the person you want to
    call but you do know what *kind* of service you require. For example, if
    you have a leaking pipe, you know you need a plumber, so you pick up your
    'Yellow Pages', go to the 'Plumbers' section and choose one that seems to
    fit the bill based on price, location, certification, etc. The service
    registry does exactly the same thing as the 'Yellow Pages', only with
    objects, and it even allows you to publish your own entries for free
    (unlike the *real* one)!

    Ú c             C   s   dS )a   Return at most one service that matches the specified query.

        The protocol can be an actual class or interface, or the *name* of a
        class or interface in the form '<module_name>.<class_name>'.

        Return None if no such service is found.

        If no query is specified then a service that provides the specified
        protocol is returned (if one exists).

        NOTE: If more than one service exists that match the criteria then
        Don't try to guess *which* one it will return - it is random!

        N© )ÚselfÚprotocolÚqueryÚminimizeÚmaximizer   r   úw/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.6/site-packages/envisage-4.7.2-py3.6.egg/envisage/i_service_registry.pyÚget_service!   s    zIServiceRegistry.get_servicec             C   s   dS )z{ Return the service with the specified id.

        If no such service exists a 'ValueError' exception is raised.

        Nr   )r   Ú
service_idr   r   r   Úget_service_from_id1   s    z$IServiceRegistry.get_service_from_idc             C   s   dS )a—   Return all services that match the specified query.

        The protocol can be an actual class or interface, or the *name* of a
        class or interface in the form '<module_name>.<class_name>'.

        If no services match the query, then an empty list is returned.

        If no query is specified then all services that provide the specified
        protocol are returned (if any exist).

        Nr   )r   r   r	   r
   r   r   r   r   Úget_services8   s    zIServiceRegistry.get_servicesc             C   s   dS )a   Return the dictionary of properties associated with a service.

        If no such service exists a 'ValueError' exception is raised.

        The properties returned are 'live' i.e. changing them immediately
        changes the service registration.

        Nr   )r   r   r   r   r   Úget_service_propertiesE   s    z'IServiceRegistry.get_service_propertiesNc             C   s   dS )ax   Register a service.

        The protocol can be an actual class or interface, or the *name* of a
        class or interface in the form::

            'foo.bar.baz'

        Which is turned into the equivalent of an import statement that
        looks like::

            from foo.bar import baz

        Return a service Id that can be used to unregister the service and to
        get/set any service properties.

        If 'obj' does not implement the specified protocol then it is treated
        as a 'service factory' that will be called the first time a service of
        the appropriate type is requested. A 'service factory' is simply a
        callable that takes the properties specified here as keyword arguments
        and returns an object. For *really* lazy loading, the factory can also
        be specified as a string which is used to import the callable.

        Nr   )r   r   ÚobjÚ
propertiesr   r   r   Úregister_serviceO   s    z!IServiceRegistry.register_servicec             C   s   dS )z� Set the dictionary of properties associated with a service.

        If no such service exists a 'ValueError' exception is raised.

        Nr   )r   r   r   r   r   r   Úset_service_propertiesh   s    z'IServiceRegistry.set_service_propertiesc             C   s   dS )zg Unregister a service.

        If no such service exists a 'ValueError' exception is raised.

        Nr   )r   r   r   r   r   Úunregister_serviceo   s    z#IServiceRegistry.unregister_service)r   r   r   )r   r   r   )N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Z
registeredZunregisteredr   r   r   r   r   r   r   r   r   r   r   r      s   



r   N)r   Z
traits.apir   r   r   r   r   r   r   Ú<module>   s   