feat: fix signaling and implement a ping-pong signal/slot test
This commit is contained in:
@@ -23,93 +23,63 @@
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <typeinfo>
|
||||
|
||||
|
||||
#include "testing-prototype.h"
|
||||
#include "Core/Types.h"
|
||||
#include "Core/Object.h"
|
||||
#include "Core/Signal.h"
|
||||
|
||||
#include "Core/Types.h"
|
||||
#include "testing-prototype.h"
|
||||
|
||||
using namespace uLib;
|
||||
|
||||
|
||||
|
||||
|
||||
class Ob1 : public Object {
|
||||
public:
|
||||
|
||||
|
||||
signals:
|
||||
void V0();
|
||||
|
||||
int V1(int a);
|
||||
void V0();
|
||||
|
||||
void V1(int a);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
// should be done by moc //
|
||||
void Ob1::V0() {
|
||||
ULIB_SIGNAL_EMIT(Ob1::V0);
|
||||
}
|
||||
|
||||
int Ob1::V1(int a) {
|
||||
ULIB_SIGNAL_EMIT(Ob1::V1,a);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Ob1::V0() { ULIB_SIGNAL_EMIT(Ob1::V0); }
|
||||
|
||||
void Ob1::V1(int a) { ULIB_SIGNAL_EMIT(Ob1::V1, a); }
|
||||
|
||||
class Ob2 : public Object {
|
||||
|
||||
public slots:
|
||||
void PrintV0() {
|
||||
std::cout << "Ob2 prints V0\n" << std::flush;
|
||||
}
|
||||
void PrintV0() { std::cout << "Ob2 prints V0\n" << std::flush; }
|
||||
};
|
||||
|
||||
class Ob3 : public Object {
|
||||
|
||||
public slots:
|
||||
void PrintV0() {
|
||||
std::cout << "Ob3 prints V0\n" << std::flush;
|
||||
}
|
||||
void PrintV0() { std::cout << "Ob3 prints V0\n" << std::flush; }
|
||||
|
||||
void PrintNumber(int n) {
|
||||
std::cout << "Ob3 is printing number: " << n << "\n";
|
||||
}
|
||||
void PrintNumber(int n) {
|
||||
std::cout << "Ob3 is printing number: " << n << "\n";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
int main() {
|
||||
BEGIN_TESTING(Signals);
|
||||
BEGIN_TESTING(Signals);
|
||||
|
||||
Ob1 ob1;
|
||||
Ob2 ob2;
|
||||
Ob3 ob3;
|
||||
Ob1 ob1;
|
||||
Ob2 ob2;
|
||||
Ob3 ob3;
|
||||
|
||||
Object::connect(&ob1,&Ob1::V0,&ob2,&Ob2::PrintV0);
|
||||
Object::connect(&ob1,&Ob1::V0,&ob3,&Ob3::PrintV0);
|
||||
Object::connect(&ob1,&Ob1::V1,&ob3,&Ob3::PrintNumber);
|
||||
Object::connect(&ob1, &Ob1::V0, &ob2, &Ob2::PrintV0);
|
||||
Object::connect(&ob1, &Ob1::V0, &ob3, &Ob3::PrintV0);
|
||||
Object::connect(&ob1, &Ob1::V1, &ob3, &Ob3::PrintNumber);
|
||||
|
||||
// not working yet
|
||||
// Object::connect(&ob1,SIGNAL(V0(),&ob2,SLOT(PrintV0())
|
||||
// not working yet
|
||||
// Object::connect(&ob1,SIGNAL(V0(),&ob2,SLOT(PrintV0())
|
||||
|
||||
ob1.PrintSelf(std::cout);
|
||||
ob1.PrintSelf(std::cout);
|
||||
|
||||
emit ob1.V0();
|
||||
emit ob1.V1(5552368);
|
||||
emit ob1.V0();
|
||||
emit ob1.V1(5552368);
|
||||
|
||||
END_TESTING;
|
||||
END_TESTING;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user