GNode library (C++)
Loading...
Searching...
No Matches
gnode::EventConnection Class Reference

Manages the lifetime of a subscription to an Event. More...

#include <event.hpp>

Public Member Functions

 EventConnection ()=default
 
 EventConnection (std::function< void()> disconnect)
 Construct a connection with a custom disconnect callback.
 
 ~EventConnection ()
 Destructor automatically triggers the disconnect action.
 
 EventConnection (const EventConnection &)=delete
 
EventConnection & operator= (const EventConnection &)=delete
 
 EventConnection (EventConnection &&other) noexcept
 Move constructor.
 
EventConnection & operator= (EventConnection &&other) noexcept
 Move assignment operator.
 
void disconnect ()
 Manually disconnect the subscription.
 

Private Attributes

std::function< void()> disconnect_
 

Detailed Description

Manages the lifetime of a subscription to an Event.

Automatically disconnects the subscription upon destruction unless manually disconnected beforehand.

Constructor & Destructor Documentation

◆ EventConnection() [1/4]

gnode::EventConnection::EventConnection ( )
default

◆ EventConnection() [2/4]

gnode::EventConnection::EventConnection ( std::function< void()>  disconnect)
inline

Construct a connection with a custom disconnect callback.

Parameters
disconnectCallable to execute when disconnecting.

◆ ~EventConnection()

gnode::EventConnection::~EventConnection ( )
inline

Destructor automatically triggers the disconnect action.

◆ EventConnection() [3/4]

gnode::EventConnection::EventConnection ( const EventConnection &  )
delete

◆ EventConnection() [4/4]

gnode::EventConnection::EventConnection ( EventConnection &&  other)
inlinenoexcept

Move constructor.

Member Function Documentation

◆ disconnect()

void gnode::EventConnection::disconnect ( )
inline

Manually disconnect the subscription.

Triggers the stored callback and releases it. Safe to call multiple times.

◆ operator=() [1/2]

EventConnection & gnode::EventConnection::operator= ( const EventConnection &  )
delete

◆ operator=() [2/2]

EventConnection & gnode::EventConnection::operator= ( EventConnection &&  other)
inlinenoexcept

Move assignment operator.

Member Data Documentation

◆ disconnect_

std::function<void()> gnode::EventConnection::disconnect_
private

The documentation for this class was generated from the following file: