git-svn-id: svn://db.shs.com.ru/pip@496 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -324,10 +324,11 @@ endif()
|
||||
|
||||
|
||||
# Test program
|
||||
#find_package(Qt4 REQUIRED)
|
||||
#include_directories(${QT_INCLUDES})
|
||||
add_executable(pip_test "main.cpp" "ccm_kbd.cpp")
|
||||
target_link_libraries(pip_test pip pip_fftw)# ${QT_QTCORE_LIBRARY})
|
||||
find_package(Qt4 REQUIRED)
|
||||
include_directories(${QT_INCLUDES})
|
||||
qt4_wrap_cpp(CMOCS_TEST "main.h" OPTIONS -nw)
|
||||
add_executable(pip_test "main.cpp" "main.h" "ccm_kbd.cpp" ${CMOCS_TEST})
|
||||
target_link_libraries(pip_test pip pip_fftw ${QT_QTCORE_LIBRARY})
|
||||
|
||||
|
||||
# Install
|
||||
|
||||
27
main.cpp
27
main.cpp
@@ -1,25 +1,11 @@
|
||||
#include "pip.h"
|
||||
|
||||
|
||||
class A: public PIObject {
|
||||
PIOBJECT(A)
|
||||
public:
|
||||
EVENT1(ev1, float, f)
|
||||
};
|
||||
|
||||
class B: public PIObject {
|
||||
PIOBJECT(B)
|
||||
public:
|
||||
EVENT_HANDLER0(void, eh0) {piCout << "eh0";}
|
||||
EVENT_HANDLER1(void, eh1, float, f) {piCout << "eh1_1" << f;}
|
||||
EVENT_HANDLER2(void, eh1, float, f, int, s) {piCout << "eh1_2" << f << s;}
|
||||
};
|
||||
|
||||
#include "main.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
A a;
|
||||
B b;
|
||||
a.setName("__a__");
|
||||
b.setName("__b__");
|
||||
/*CONNECTU_QUEUED(&a, ev1, &b, eh0, &b);
|
||||
CONNECTU_QUEUED(&a, ev1, &b, eh1, &a);
|
||||
piCout << "start";
|
||||
@@ -29,9 +15,12 @@ int main(int argc, char *argv[]) {
|
||||
piSleep(1);
|
||||
piCout << b.maybeCallQueuedEvents();*/
|
||||
//piCout << "end";
|
||||
b.executeQueued(&a, "eh1", PIVariant(0.1), "0150", 10, 40);
|
||||
/*b.executeQueued(&a, "eh1", PIVariant(0.1), "0150", 10, 40);
|
||||
piSleep(1);
|
||||
a.maybeCallQueuedEvents();
|
||||
a.maybeCallQueuedEvents();*/
|
||||
//dumpApplication();
|
||||
b.execute("eh1", PIVariant(0.1), "0150", 10, 40);
|
||||
b.executeQueued(&a, "eh1", PIVariant(0.1), "0150", 10, 40);
|
||||
a.callQueuedEvents();
|
||||
return 0;
|
||||
}
|
||||
|
||||
27
main.h
Normal file
27
main.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef MAIN_H
|
||||
#define MAIN_H
|
||||
|
||||
#include <QObject>
|
||||
#include "pip.h"
|
||||
|
||||
struct _S {
|
||||
uchar _c[164];
|
||||
};
|
||||
|
||||
class A: public QObject, public PIObject {
|
||||
PIOBJECT(A)
|
||||
public:
|
||||
A() {}
|
||||
EVENT1(ev1, float, f)
|
||||
};
|
||||
|
||||
class B: public QObject, public PIObject {
|
||||
PIOBJECT(B)
|
||||
public:
|
||||
B() {}
|
||||
EVENT_HANDLER0(void, eh0) {piCout << "eh0" << emitter();}
|
||||
EVENT_HANDLER1(void, eh1, float, f) {piCout << "eh1_1" << f << emitter();}
|
||||
EVENT_HANDLER2(void, eh1, float, f, int, s) {piCout << "eh1_2" << f << s << emitter();}
|
||||
};
|
||||
|
||||
#endif // MAIN_H
|
||||
@@ -266,13 +266,6 @@ PIChar PIChar::toLower() const {
|
||||
}
|
||||
|
||||
|
||||
#ifdef PIP_STD_IOSTREAM
|
||||
std::ostream & operator <<(std::ostream & s, const PIChar & v) {
|
||||
s << v.toCharPtr();
|
||||
return s;
|
||||
}
|
||||
#endif
|
||||
|
||||
PICout operator <<(PICout s, const PIChar & v) {
|
||||
s.space();
|
||||
s.setControl(0, true);
|
||||
|
||||
@@ -157,11 +157,6 @@ private:
|
||||
|
||||
};
|
||||
|
||||
#ifdef PIP_STD_IOSTREAM
|
||||
//! Output operator to \c std::ostream
|
||||
std::ostream & operator <<(std::ostream & s, const PIChar & v);
|
||||
#endif
|
||||
|
||||
//! Output operator to \a PICout
|
||||
PICout operator <<(PICout s, const PIChar & v);
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ bool PIObject::execute(const PIString & method, const PIVector<PIVariant> & vl)
|
||||
bool ok = findSuitableMethodV(method, vl.size_s(), ac, func);
|
||||
if (!ok)
|
||||
return false;
|
||||
callAddrV(func.addrV, this, ac, vl);
|
||||
callAddrV(func.addrV, toThis(), ac, vl);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ bool PIObject::executeQueued(PIObject * performer, const PIString & method, cons
|
||||
bool ok = findSuitableMethodV(method, vl.size_s(), ac, func);
|
||||
if (!ok)
|
||||
return false;
|
||||
performer->postQueuedEvent(QueuedEvent(func.addrV, this, this, performer, vl));
|
||||
performer->postQueuedEvent(QueuedEvent(func.addrV, toThis(), this, performer, vl));
|
||||
performer->proc_event_queue = true;
|
||||
return true;
|
||||
}
|
||||
@@ -399,6 +399,12 @@ void PIObject::postQueuedEvent(const PIObject::QueuedEvent & e) {
|
||||
}
|
||||
|
||||
|
||||
void * PIObject::toThis() const {
|
||||
//piCout << ptrOffset() << (void*)this << (void*)((char*)this - ptrOffset());
|
||||
return (void*)((char*)this - ptrOffset());
|
||||
}
|
||||
|
||||
|
||||
PIMutex & PIObject::__meta_mutex() {
|
||||
static PIMutex ret;
|
||||
return ret;
|
||||
|
||||
@@ -195,7 +195,8 @@
|
||||
public: \
|
||||
static const PIString __classNameS() {return PIStringAscii(#name);} \
|
||||
virtual const char * className() const {return #name;} \
|
||||
private:
|
||||
private: \
|
||||
virtual int ptrOffset() const {name * o = (name*)100; return int(llong((PIObject*)o) - llong(o));}
|
||||
|
||||
#define PIOBJECT_PARENT(name) \
|
||||
class __##name##_ParentInitializer__ { \
|
||||
@@ -885,6 +886,8 @@ private:
|
||||
__MetaFunc methodEH(const void * addr) const;
|
||||
void updateConnectors();
|
||||
void postQueuedEvent(const QueuedEvent & e);
|
||||
void * toThis() const;
|
||||
virtual int ptrOffset() const {return 0;}
|
||||
|
||||
static PIVector<PIObject * > & objects();
|
||||
static void callAddrV(void * slot, void * obj, int args, const PIVector<PIVariant> & vl);
|
||||
|
||||
@@ -75,6 +75,8 @@ inline PIString StdWString2PIString(const std::wstring & v) {
|
||||
|
||||
|
||||
|
||||
//! \relatesalso PIChar \brief Output operator to \c std::ostream
|
||||
inline std::ostream & operator <<(std::ostream & s, const PIChar & v) {s << v.toCharPtr(); return s;}
|
||||
|
||||
//! \relatesalso PIString \brief Return concatenated string
|
||||
inline PIString operator +(const PIString & f, const std::string & str) {PIString s(f); s += StdString2PIString(str); return s;}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#include "piprocess.h"
|
||||
|
||||
class PIP_EXPORT PICodec: private PIProcess
|
||||
class PIP_EXPORT PICodec: protected PIProcess
|
||||
{
|
||||
PIOBJECT(PICodec)
|
||||
public:
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
/// bool exec(const PIString & program, const PIStringList & args)
|
||||
/// void terminate()
|
||||
/// bool waitForFinish(int timeout_msecs = 60000)
|
||||
class PIP_EXPORT PIProcess: private PIThread
|
||||
class PIP_EXPORT PIProcess: protected PIThread
|
||||
{
|
||||
PIOBJECT_SUBCLASS(PIProcess, PIThread)
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user