diff --git a/main.cpp b/main.cpp index 08cd414a..e04fd19a 100644 --- a/main.cpp +++ b/main.cpp @@ -32,141 +32,37 @@ const char pult_config[] = "; */ -#include - -template -struct Info { - enum {Defined = 0}; -}; -template -struct TypeInfo { - typedef T PureType; - typedef const T ConstPureType; - typedef T * PointerType; - typedef const T * ConstPointerType; - typedef T & ReferenceType; - typedef const T & ConstReferenceType; -}; - -#define TYPEINFO_SINGLE(PT, T) \ - template<> struct TypeInfo { \ - typedef PT PureType; \ - typedef const PT ConstPureType; \ - typedef PT * PointerType; \ - typedef const PT * ConstPointerType; \ - typedef PT & ReferenceType; \ - typedef const PT & ConstReferenceType; \ - }; -#define TYPEINFO(T) \ - TYPEINFO_SINGLE(T, T &) \ - TYPEINFO_SINGLE(T, const T) \ - TYPEINFO_SINGLE(T, const T &) \ - TYPEINFO_SINGLE(T, T *) \ - TYPEINFO_SINGLE(T, const T *) - -TYPEINFO(PIString) - - -template -class A { +/* +class A: public PIObject { + PIOBJECT(A) public: - void f() { - piCout << "T"; - } + EVENT1(ev1, float, f) }; -template -class A { +class B: public PIObject { + PIOBJECT(B) public: - void f() { - piCout << "const T&"; - } + EVENT_HANDLER0(void, eh0) {piCout << "eh0";} + EVENT_HANDLER1(void, eh1, float, f) {piCout << "eh1" << f;} }; +*/ - -#include "pivector2d.h" int main(int argc, char *argv[]) { - /* - enum VCO_Aim_Type {VCO_Aim_Type_None, VCO_Aim_Type_Detected, VCO_Aim_Type_New, VCO_Aim_Type_Confirmed, VCO_Aim_Type_Deleted = 127}; -#pragma pack (push, 1) - struct VCO_Element { - VCO_Element() {} - VCO_Aim_Type type; - double elapsed; - float wls_a; // m/s - float wls_b; // m - float speed; - float acceleration; // m/s^2 - float prediction_pos; // m - float variance; // m - float power; - float angle; - int id; - int missed; - int missed_ml; - int confirmed; - int history_size; - bool tracing; - bool _found; - bool _checked; - bool _delete; - PIVector > history; - }; -#pragma pack (pop) - struct VCO_ElementX { - VCO_Aim_Type type; - double elapsed; - float wls_a; // m/s - float wls_b; // m - float speed; - float acceleration; // m/s^2 - float prediction_pos; // m - float variance; // m - float power; - float angle; - int id; - int missed; - int missed_ml; - int confirmed; - int history_size; - bool tracing; - bool _found; - bool _checked; - bool _delete; - }; - struct VCO_ElementY : VCO_ElementX { - PIVector > history; - }; - VCO_Element v; - VCO_ElementX x; - VCO_ElementY y; - piCout << sizeof(x); - piCout << sizeof(y) << sizeof(y.history) << sizeof(y) - sizeof(y.history) ; - piCout << sizeof(v) << sizeof(v.history) << sizeof(v) - sizeof(v.history) ; - return 0;*/ - - PIVector > in; - in.resize(5); - for (int i = 0; i < in.size_s(); ++i) - for (int j = 0; j < 20; ++j) - in[i] << j+i*100; -// piCout << in.size() << in[0].size(); - PIVector2D f0; - PIVector2D f1(30, 40); - //in.resize(1); - PIVector2D f2(in); - f0 = f2; -// piCout << f0; -// piCout << f1; -// piCout << f2; -// piCout << f2.rows() << f2.cols() << f2.size_all() << f2.rows()*f2.cols(); - piCout << in; - piCout << f2; - piCout << f2.toVectors(); - PIVector t = f2.toPlainVector(); - piCout << t; - piCout << PIVector2D(f2.rows(), f2.cols(), t); - return 0; + if (argc < 2) return 0; + bool r = PIString(argv[1]).toBool(); + PISharedMemory shm; + //shm.setSize(64); + shm.open("test", r ? PIIODevice::ReadOnly : PIIODevice::WriteOnly); + piCout << "open" << shm.isOpened(); + if (!r) { + int wr = shm.write(PIString("data").toByteArray()); + piCout << "wrote" << wr; + return 0; + } + piSleep(3.); + PIByteArray rb(4); + int rd = shm.read(rb.data(), rb.size_s()); + piCout << "readed" << rd << PIString(rb); // PIFFTWf fft; // fft.preparePlan(50, PIFFTWf::foReal); // PIVector out = fft.calcFFT(in);