.. index:: pair: class; EE::Scene::EventConnection .. _doxid-class_e_e_1_1_scene_1_1_event_connection: class EE::Scene::EventConnection ================================ .. toctree:: :hidden: Overview ~~~~~~~~ Move-only handle that disconnects a :ref:`Node ` event listener on destruction. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include class EventConnection { public: // construction :ref:`EventConnection`(); :ref:`EventConnection`(EventConnection&& other); :target:`EventConnection`(const EventConnection&); :ref:`~EventConnection`(); // methods EventConnection& :ref:`operator=`(EventConnection&& other); EventConnection& :target:`operator=`(const EventConnection&); void :ref:`disconnect`(); :ref:`operator bool`() const; }; .. _details-class_e_e_1_1_scene_1_1_event_connection: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Move-only handle that disconnects a :ref:`Node ` event listener on destruction. :ref:`EventConnection ` provides scoped ownership for a listener registered with :ref:`Node::connect() `. If the connection is destroyed first, its listener is removed from the emitter. If the emitter is destroyed first, the connection expires and its eventual destruction is a safe no-op. A connection does not keep its emitting :ref:`Node ` alive. Moving a connection transfers listener ownership; copying is disabled so that exactly one handle owns the scoped listener. Emitter destruction silently expires the connection. :ref:`EventConnection ` is therefore not a replacement for UIWidget::OnClose: observers that must perform work when a widget closes must still connect to that widget-level notification. :ref:`Event ` registration, dispatch, disconnection, and connection destruction must all happen on the emitter's owning thread. :ref:`EventConnection ` does not make :ref:`Node ` 's event registry thread-safe. Construction ------------ .. index:: pair: function; EventConnection .. _doxid-class_e_e_1_1_scene_1_1_event_connection_1ae727769cdd7979aea98ab32958184791: .. ref-code-block:: cpp :class: doxyrest-title-code-block EventConnection() Creates a disconnected handle. .. index:: pair: function; EventConnection .. _doxid-class_e_e_1_1_scene_1_1_event_connection_1a39c697d9c999d86b28769c70b0fb0abf: .. ref-code-block:: cpp :class: doxyrest-title-code-block EventConnection(EventConnection&& other) Transfers listener ownership from ``other``. .. _doxid-class_e_e_1_1_scene_1_1_event_connection_1a6a5d32c42ad07ef5efeeb18f6c8bb560: .. ref-code-block:: cpp :class: doxyrest-title-code-block ~EventConnection() Disconnects the owned listener, if its emitter still exists. Methods ------- .. index:: pair: function; operator= .. _doxid-class_e_e_1_1_scene_1_1_event_connection_1ada430dc88eb1fd3d1898e4d53efeafd3: .. ref-code-block:: cpp :class: doxyrest-title-code-block EventConnection& operator=(EventConnection&& other) Disconnects the currently owned listener and transfers ownership from ``other``. .. index:: pair: function; disconnect .. _doxid-class_e_e_1_1_scene_1_1_event_connection_1ad9f5dbd8111a45cc6e1a4d0948b261d8: .. ref-code-block:: cpp :class: doxyrest-title-code-block void disconnect() Removes the listener and makes this handle disconnected. Calling :ref:`disconnect() ` more than once, or after the emitter has been destroyed, is safe. .. index:: pair: function; operator bool .. _doxid-class_e_e_1_1_scene_1_1_event_connection_1a9a6521b0a7ea3707a843fb8b53157d9b: .. ref-code-block:: cpp :class: doxyrest-title-code-block operator bool() const .. rubric:: Returns: True while this handle owns a listener and the emitter's event state still exists.