Files
pip/main.cpp
2022-04-24 19:15:51 +03:00

90 lines
2.1 KiB
C++

#include "pip.h"
REGISTER_VARIANT_TYPEINFO(PIVector<double>)
PIEthernet eth;
class OH: public PIObject {
PIOBJECT(OH)
public:
EVENT_HANDLER0(void, eh0) {
piCout << "eh0";
}
EVENT_HANDLER1(void, eh1, PIStringList, sl) {
piCout << "eh1" << sl;
}
EVENT_HANDLER2(void, eh2, PIStringList, sl, const PIVector< double > &, vd) {
piCout << "eh2" << sl << vd;
}
EVENT_HANDLER3(void, eh3, PIStringList, sl, const PIVector<double> &, vd, PISystemTime, st) {
piCout << "eh3" << sl << vd << st;
}
private:
int cnt = 0;
};
class OE: public PIThread {
PIOBJECT_SUBCLASS(OE, PIThread)
public:
EVENT0(e0);
EVENT1(e1, PIStringList, sl);
EVENT2(e2, PIStringList, sl, PIVector< double>, vd);
EVENT3(e3, PIStringList, sl, PIVector< double>, vd, PISystemTime, st);
private:
};
PIThreadNotifier notifier;
PITimeMeasurer time;
class Worker: public PIThread {
PIOBJECT_SUBCLASS(Worker, PIThread)
public:
Worker(const PIString & n) {
setName(n);
}
void run() override {
piCoutObj << (int)time.elapsed_m() << "wait ...";
notifier.wait();
piCoutObj << (int)time.elapsed_m() << "done";
};
};
int main(int argc, char * argv[]) {
typedef int(*MyFunc)(int,int);
PILibrary * lib = new PILibrary();
if (lib->load("libpip_plugin.dll")) {
MyFunc fadd = (MyFunc)lib->resolve("exportedSum");
MyFunc fmul = (MyFunc)lib->resolve("exportedMul");
if (fadd) {
int sum = fadd(1, 2);
piCout << "sum =" << sum;
} else {
piCout << "Can`t resolve" << "exportedSum";
}
if (fmul) {
int mul = fadd(10, 20);
piCout << "mul =" << mul;
} else {
piCout << "Can`t resolve" << "exportedMul";
}
} else {
piCout << lib->lastError();
}
delete lib;
/*OH oh;
OE oe;
CONNECTU(&oe, e3, &oh, eh0);
CONNECTU(&oe, e3, &oh, eh1);
CONNECTU(&oe, e3, &oh, eh2);
CONNECTU(&oe, e3, &oh, eh3);
//oh.dump();
oe.dump();
oe.e0();
oe.e1({"a", "b", "c"});
oe.e2({"a", "b", "c"}, {1., 1.5, 2.});
oe.e3({"a", "b", "c"}, {1., 1.5, 2.}, PISystemTime::current());
//piCout << oe.methodsEH();*/
return 0;
}