2#ifndef LIBSBX_SIGNAL_CONNECTION_HPP_
3#define LIBSBX_SIGNAL_CONNECTION_HPP_
7#include <libsbx/utility/lockable.hpp>
9#include <libsbx/signals/slot_state.hpp>
11namespace sbx::signals {
24 : _state{std::move(other._state)} { }
34 _state.swap(other._state);
42 : _state{std::move(state)} {
43 if (
auto state = _state.lock()) {
48 void release()
noexcept {
49 if (
auto state = _state.lock()) {
56 std::weak_ptr<slot_state> _state;
62 template<utility::lockable,
typename...>
79 bool is_valid()
const noexcept {
80 return !_state.expired();
83 bool is_connected()
const noexcept {
84 const auto state = _state.lock();
85 return state && state->is_connected();
88 bool disconnect()
noexcept {
89 auto state = _state.lock();
90 return state && state->disconnect();
93 bool is_blocked()
const noexcept {
94 const auto state = _state.lock();
95 return state && state->is_blocked();
98 void block()
noexcept {
99 if (
auto state = _state.lock()) {
104 void unblock()
noexcept {
105 if (
auto state = _state.lock()) {
116 explicit connection(std::weak_ptr<slot_state> state) noexcept
117 : _state{std::move(state)} { }
119 std::weak_ptr<slot_state> _state;
125 template <utility::lockable,
typename...>
150 _state.swap(other._state);
Definition: connection.hpp:13
Definition: connection.hpp:60
Definition: connection.hpp:123
Definition: signal.hpp:18