14#include <AUI/Thread/AMutex.h>
15#include <AUI/Traits/concepts.h>
16#include <AUI/Traits/members.h>
18#include "AUI/Common/ASet.h"
20#include "AUI/Traits/values.h"
21#include "SharedPtrTypes.h"
29concept AAnySignal =
requires(T) {
30 std::is_base_of_v<AAbstractSignal, T>;
35concept ASignalInvokable =
requires(C&& c) { c.invokeSignal(std::declval<AObject*>()); };
37template <
typename F,
typename Signal>
38concept ACompatibleSlotFor =
true;
56 static void disconnect();
58 [[nodiscard]]
_<AObject> sharedPtr() {
return std::enable_shared_from_this<AObject>::shared_from_this(); }
60 [[nodiscard]]
_weak<AObject> weakPtr() {
return std::enable_shared_from_this<AObject>::weak_from_this(); }
62 void clearSignals()
noexcept;
76 template <AAnySignal Signal, aui::derived_from<AObject> Object, ACompatibleSlotFor<Signal> Function>
77 static void connect(Signal& signal, Object*
object, Function&&
function) {
78 signal.connect(
object, std::forward<Function>(
function));
93 template <AAnySignal Signal, aui::derived_from<AObject> Object, ACompatibleSlotFor<Signal> Function>
94 static void connect(Signal& signal, Object&
object, Function&&
function) {
95 signal.connect(&
object, std::forward<Function>(
function));
109 template <AAnySignal Signal, ACompatibleSlotFor<Signal> Function>
110 void connect(Signal& signal, Function&&
function) {
111 signal.connect(
this, std::forward<Function>(
function));
126 template <AAnySignal Signal, aui::derived_from<AObject> Object, ACompatibleSlotFor<Signal> Function>
127 static void connect(Signal& signal,
_<Object> object, Function&&
function) {
128 signal.connect(
object.get(), std::forward<Function>(
function));
131 void setSignalsEnabled(
bool enabled) { mSignalsEnabled = enabled; }
133 [[nodiscard]]
bool isSignalsEnabled()
const noexcept {
return mSignalsEnabled; }
135 template <ASignalInvokable T>
136 void operator^(T&& t) {
137 if (mSignalsEnabled) {
138 t.invokeSignal(
this);
144 bool isSlotsCallsOnlyOnMyThread()
const noexcept {
return mSlotsCallsOnlyOnMyThread; }
148 void setSlotsCallsOnlyOnMyThread(
bool slotsCallsOnlyOnMyThread) {
149 mSlotsCallsOnlyOnMyThread = slotsCallsOnlyOnMyThread;
162 bool mSignalsEnabled =
true;
170 bool mSlotsCallsOnlyOnMyThread =
false;
172 static bool& isDisconnected();
196#define emit (*this) ^
224#define AUI_EMIT_FOREIGN(object, signal, ...) (*object) ^ object->signal(__VA_ARGS__)
226#include "SharedPtr.h"
Base class for signal.
Definition: AAbstractSignal.h:368
Represents an abstract thread. Not all threads are created through AThread - these are interfaced wit...
Definition: AThread.h:33
A base object class.
Definition: AObject.h:49
void setThread(_< AAbstractThread > thread)
Set thread of the object.
Definition: AObject.h:156
A std::set with AUI extensions.
Definition: ASet.h:25
Represents a Unicode character string.
Definition: AString.h:37
An std::weak_ptr with AUI extensions.
Definition: SharedPtrTypes.h:177
Basic syscall-based synchronization primitive.
Definition: AMutex.h:33
An std::weak_ptr with AUI extensions.
Definition: SharedPtrTypes.h:51
Does not allow escaping, allowing to accept lvalue ref, rvalue ref, shared_ptr and etc without overhe...
Definition: values.h:127
Forbids copy of your class.
Definition: values.h:40