2022-02-04 08:53:57 +01:00
|
|
|
#include "signal.h"
|
|
|
|
|
|
|
|
void Signal::connect_static(void (*func)(Signal *)) {
|
|
|
|
StaticSignalEntry *se = new StaticSignalEntry();
|
|
|
|
se->func = func;
|
|
|
|
|
|
|
|
entries.push_back(se);
|
|
|
|
}
|
|
|
|
void Signal::disconnect_static(void (*func)(Signal *)) {
|
|
|
|
for (int i = 0; i < entries.size(); ++i) {
|
|
|
|
SignalEntry *e = entries[i];
|
|
|
|
|
|
|
|
if (e->type == SIGNAL_ENTRY_TYPE_STATIC) {
|
|
|
|
StaticSignalEntry *se = static_cast<StaticSignalEntry *>(e);
|
|
|
|
|
|
|
|
if (se->func == func) {
|
|
|
|
entries.remove_keep_order(i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool Signal::is_connected_static(void (*func)(Signal *)) {
|
|
|
|
for (int i = 0; i < entries.size(); ++i) {
|
|
|
|
SignalEntry *e = entries[i];
|
|
|
|
|
|
|
|
if (e->type == SIGNAL_ENTRY_TYPE_STATIC) {
|
|
|
|
StaticSignalEntry *se = static_cast<StaticSignalEntry *>(e);
|
|
|
|
|
|
|
|
if (se->func == func) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-02-04 08:56:15 +01:00
|
|
|
void Signal::emit(Object *p_emitter) {
|
|
|
|
emitter = p_emitter;
|
|
|
|
|
2022-02-04 08:53:57 +01:00
|
|
|
for (int i = 0; i < entries.size(); ++i) {
|
|
|
|
entries[i]->call(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-04 08:56:15 +01:00
|
|
|
void Signal::emit(Object *p_emitter, const Variant &p1) {
|
|
|
|
emitter = p_emitter;
|
|
|
|
|
2022-02-04 08:53:57 +01:00
|
|
|
params.push_back(p1);
|
|
|
|
|
|
|
|
for (int i = 0; i < entries.size(); ++i) {
|
|
|
|
entries[i]->call(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
params.clear();
|
|
|
|
}
|
2022-02-04 08:56:15 +01:00
|
|
|
void Signal::emit(Object *p_emitter, const Variant &p1, const Variant &p2) {
|
|
|
|
emitter = p_emitter;
|
|
|
|
|
2022-02-04 08:53:57 +01:00
|
|
|
params.push_back(p1);
|
|
|
|
params.push_back(p2);
|
|
|
|
|
|
|
|
for (int i = 0; i < entries.size(); ++i) {
|
|
|
|
entries[i]->call(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
params.clear();
|
|
|
|
}
|
2022-02-04 08:56:15 +01:00
|
|
|
void Signal::emit(Object *p_emitter, const Variant &p1, const Variant &p2, const Variant &p3) {
|
|
|
|
emitter = p_emitter;
|
|
|
|
|
2022-02-04 08:53:57 +01:00
|
|
|
params.push_back(p1);
|
|
|
|
params.push_back(p2);
|
|
|
|
params.push_back(p3);
|
|
|
|
|
|
|
|
for (int i = 0; i < entries.size(); ++i) {
|
|
|
|
entries[i]->call(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
params.clear();
|
|
|
|
}
|
|
|
|
|
2022-02-04 08:56:15 +01:00
|
|
|
void Signal::emit(Object *p_emitter, const Variant &p1, const Variant &p2, const Variant &p3, const Variant &p4) {
|
|
|
|
emitter = p_emitter;
|
|
|
|
|
2022-02-04 08:53:57 +01:00
|
|
|
params.push_back(p1);
|
|
|
|
params.push_back(p2);
|
|
|
|
params.push_back(p3);
|
|
|
|
params.push_back(p4);
|
|
|
|
|
|
|
|
for (int i = 0; i < entries.size(); ++i) {
|
|
|
|
entries[i]->call(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
params.clear();
|
|
|
|
}
|
|
|
|
|
2022-02-04 08:56:15 +01:00
|
|
|
void Signal::emit(Object *p_emitter, const Variant &p1, const Variant &p2, const Variant &p3, const Variant &p4, const Variant &p5) {
|
|
|
|
emitter = p_emitter;
|
2022-02-04 08:59:15 +01:00
|
|
|
|
2022-02-04 08:53:57 +01:00
|
|
|
params.push_back(p1);
|
|
|
|
params.push_back(p2);
|
|
|
|
params.push_back(p3);
|
|
|
|
params.push_back(p4);
|
|
|
|
params.push_back(p5);
|
|
|
|
|
|
|
|
for (int i = 0; i < entries.size(); ++i) {
|
|
|
|
entries[i]->call(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
params.clear();
|
|
|
|
}
|
|
|
|
|
2022-02-04 08:59:15 +01:00
|
|
|
Signal::Signal() {
|
2022-02-04 08:53:57 +01:00
|
|
|
}
|
|
|
|
Signal::~Signal() {
|
|
|
|
}
|