+
    ic  c                   sV    ^ RI Ht ^ RIHt RR.t ! R R]R7      t ! R R]]4      tR# )	i    )ABCMeta)PropertiesInterfaceBasicInterfaceTemplateInterfaceTemplatec                   s@   a  ] tR t^t o RtR t]R 4       tR tRt	V t
R# )r   a  Basic template for a DBus interface.

This template uses a software design pattern called proxy.

This class provides a recommended way how to define DBus interfaces
and create publishable DBus objects. The class that defines a DBus
interface should inherit this class and be decorated with @dbus_class
or @dbus_interface decorator. The implementation of this interface will
be provided by a separate object called implementation. Therefore the
methods of this class should call the methods of the implementation,
the signals should be connected to the signals of the implementation
and the getters and setters of properties should access the properties
of the implementation.

.. code-block:: python

    @dbus_interface("org.myproject.X")
    class InterfaceX(BasicInterfaceTemplate):
        def DoSomething(self) -> Str:
            return self.implementation.do_something()

    class X(object):
        def do_something(self):
            return "Done!"

    x = X()
    i = InterfaceX(x)

    DBus.publish_object("/org/myproject/X", i)

c                s2    Wn         V P                  4        R# )z^Create a publishable DBus object.

:param implementation: an implementation of this interface
N)_implementationconnect_signalsselfimplementation   &&;/usr/lib/python3.14/site-packages/dasbus/server/template.py__init__ZBasicInterfaceTemplate.__init__@   s    
  .    c                s    V P                   # )zIReturn the implementation of this interface.

:return: an implementation
r   r      &r
   r   Z%BasicInterfaceTemplate.implementationH   s     ###r   c                s    R# )zInterconnect the signals.

You should connect the emit methods of the interface
signals to the signals of the implementation. Every
time the implementation emits a signal, this interface
reemits the signal on DBus.
N r   r   r
   r   Z&BasicInterfaceTemplate.connect_signalsP   s     	r   r   N)__name__
__module____qualname____firstlineno____doc__r   Zpropertyr   r   __static_attributes____classdictcell__Z__classdict__   @r
   r   r      s.     @ $ $ r   )Z	metaclassc                   s0   a  ] tR t^[t o RtR tR tRtV tR# )r   a9  Template for a DBus interface.

The interface provides the support for the standard interface
org.freedesktop.DBus.Properties.

Usage:

.. code-block:: python

    def connect_signals(self):
        super().connect_signals()
        self.implementation.module_properties_changed.connect(
            self.flush_changes
        )
        self.watch_property("X", self.implementation.x_changed)

    @property
    def X(self, x) -> Int:
        return self.implementation.x

    @emits_properties_changed
    def SetX(self, x: Int):
        self.implementation.set_x(x)

c                s\    \         P                  ! V 4       \        P                  W4       R # N)r   r   r   r   r	   r
   r   ZInterfaceTemplate.__init__v   s    $$T*''=r   c                sp   a a S P                   P                  S4       VV 3R lpVP                  V4       R# )zWatch a DBus property.

Report a change when the property is changed.

:param property_name: a name of a DBus property
:param signal: a signal that emits when the property is changed
c                  s*   < SP                  S4       R # r   )Zreport_changed_property)ZargsZkwargsproperty_namer   s   *,r
   callbackZ2InterfaceTemplate.watch_property.<locals>.callback   s    ((7r   N)Z_properties_changesZcheck_propertyZconnect)r   r   Zsignalr   s   ff& r
   watch_propertyZ InterfaceTemplate.watch_propertyz   s,     	  //>	8 	x r   r   N)	r   r   r   r   r   r   r   r   r   r   r   r
   r   r   [   s     4>! !r   N)Zabcr    Zdasbus.server.propertyr   Z__all__r   r   r   r   r
   <module>r      s9   *  6 9w 9x,!.0C ,!r   