git-svn-id: svn://db.shs.com.ru/pip@501 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5

This commit is contained in:
2017-05-23 08:53:36 +00:00
parent bd95bda39a
commit 444cc9ded3
599 changed files with 5231 additions and 5283 deletions

View File

@@ -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, toThis(), this, performer, vl));
performer->postQueuedEvent(__QueuedEvent(func.addrV, toThis(), this, performer, vl));
performer->proc_event_queue = true;
return true;
}
@@ -134,7 +134,7 @@ void PIObject::piConnect(const PIString & src, const PIString & sig, void * dest
}
PIMutexLocker _ml(o->mutex_connect);
PIMutexLocker _mld(((PIObject*)dest)->mutex_connect, ((PIObject*)dest) != o);
o->connections << Connection(ev_h, 0, sig, (PIObject*)dest, dest);
o->connections << __Connection(ev_h, 0, sig, (PIObject*)dest, dest);
((PIObject*)dest)->connectors << o;
}
@@ -147,7 +147,7 @@ void PIObject::piConnect(PIObject * src, const PIString & sig, const PIString &
}
PIMutexLocker _ml(src->mutex_connect);
PIMutexLocker _mld(o->mutex_connect, src != o);
src->connections << Connection(ev_h, 0, sig, o, o);
src->connections << __Connection(ev_h, 0, sig, o, o);
((PIObject*)o)->connectors << src;
}
@@ -165,7 +165,7 @@ void PIObject::piConnect(const PIString & src, const PIString & sig, const PIStr
}
PIMutexLocker _ml(s->mutex_connect);
PIMutexLocker _mld(d->mutex_connect, s != d);
s->connections << Connection(ev_h, 0, sig, d, d);
s->connections << __Connection(ev_h, 0, sig, d, d);
d->connectors << s;
}
@@ -252,7 +252,7 @@ void PIObject::piConnect(PIObject * src, const PIString & sig, PIObject * dest_o
PIMutexLocker _ml(src->mutex_connect);
PIMutexLocker _mld(dest_o->mutex_connect, src != dest_o);
src->connections << Connection(ev_h, e_h, sig, dest_o, dest, args);
src->connections << __Connection(ev_h, e_h, sig, dest_o, dest, args);
//piCout << "piConnect" << ((PIObject*)dest) << sig << ((PIObject*)dest)->connectors.size_s() << "...";
//piCout << "addConnector" << dest_o << src;
dest_o->connectors << src;
@@ -303,7 +303,7 @@ bool PIObject::piConnectU(PIObject * src, const PIString & ename, PIObject * des
return false;
}
//piCout << "connect" << ename << "->" << hname << "with" << args << "args";
src->connections << PIObject::Connection(addr_dest, addr_src, ename, dest_o, dest, args, performer);
src->connections << PIObject::__Connection(addr_dest, addr_src, ename, dest_o, dest, args, performer);
if (que) performer->proc_event_queue = true;
dest_o->connectors << src;
return true;
@@ -314,7 +314,7 @@ void PIObject::piDisconnect(PIObject * src, const PIString & sig, PIObject * des
PIMutexLocker _ml(src->mutex_connect);
PIMutexLocker _mld(dest->mutex_connect, src != dest);
for (int i = 0; i < src->connections.size_s(); ++i) {
Connection & cc(src->connections[i]);
__Connection & cc(src->connections[i]);
if (cc.event == sig && cc.dest_o == dest && cc.slot == ev_h) {
src->connections.remove(i);
i--;
@@ -328,7 +328,7 @@ void PIObject::piDisconnect(PIObject * src, const PIString & sig, PIObject * des
PIMutexLocker _ml(src->mutex_connect);
PIMutexLocker _mld(dest->mutex_connect, src != dest);
for (int i = 0; i < src->connections.size_s(); ++i) {
Connection & cc(src->connections[i]);
__Connection & cc(src->connections[i]);
if (cc.event == sig && cc.dest_o == dest) {
src->connections.remove(i);
i--;
@@ -341,7 +341,7 @@ void PIObject::piDisconnect(PIObject * src, const PIString & sig, PIObject * des
void PIObject::piDisconnect(PIObject * src, const PIString & sig) {
PIMutexLocker _ml(src->mutex_connect);
for (int i = 0; i < src->connections.size_s(); ++i) {
Connection & cc(src->connections[i]);
__Connection & cc(src->connections[i]);
if (cc.event == sig) {
PIObject * dest = cc.dest_o;
src->connections.remove(i);
@@ -364,7 +364,7 @@ void PIObject::piDisconnect(PIObject * src) {
#ifndef ANDROID
PIMutexLocker _mld(o->mutex_connect, src != o);
#endif
PIVector<Connection> & oc(o->connections);
PIVector<__Connection> & oc(o->connections);
for (int i = 0; i < oc.size_s(); ++i) {
//piCout << " check" << (void*)(oc[i].dest_o) << "==" << (void*)(src);
if (oc[i].dest_o == src) {
@@ -373,7 +373,7 @@ void PIObject::piDisconnect(PIObject * src) {
}
}
}
piForeachC (PIObject::Connection & c, src->connections)
piForeachC (PIObject::__Connection & c, src->connections)
c.dest_o->connectors.remove(src);
src->connections.clear();
}
@@ -384,15 +384,15 @@ void PIObject::updateConnectors() {
connectors.clear();
piForeach (PIObject * o, objects()) {
if (o == this) continue;
PIVector<Connection> & oc(o->connections);
piForeach (Connection & c, oc)
PIVector<__Connection> & oc(o->connections);
piForeach (__Connection & c, oc)
if (c.dest == this)
connectors << o;
}
}
void PIObject::postQueuedEvent(const PIObject::QueuedEvent & e) {
void PIObject::postQueuedEvent(const PIObject::__QueuedEvent & e) {
mutex_queue.lock();
events_queue << e;
mutex_queue.unlock();
@@ -419,10 +419,10 @@ PIMap<PIString, PIObject::__MetaData> & PIObject::__meta_data() {
void PIObject::callQueuedEvents() {
mutex_queue.lock();
PIVector<QueuedEvent> qe = events_queue;
PIVector<__QueuedEvent> qe = events_queue;
events_queue.clear();
mutex_queue.unlock();
piForeachC (QueuedEvent & e, qe) {
piForeachC (__QueuedEvent & e, qe) {
if (e.dest_o->thread_safe_) e.dest_o->mutex_.lock();
e.dest_o->emitter_ = e.src;
callAddrV(e.slot, e.dest, e.values.size_s(), e.values);
@@ -536,7 +536,7 @@ void PIObject::dump(const PIString & line_prefix) const {
PICout(PICoutManipulators::AddNewLine) << line_prefix << " connections {";
PICout(PICoutManipulators::AddNewLine) << line_prefix << " count: " << connections.size_s();
//printf("dump %d connections\n",connections.size());
piForeachC (Connection & c, connections) {
piForeachC (__Connection & c, connections) {
PIObject * dst = c.dest_o;
__MetaFunc hf = dst->methodEH(c.slot);
__MetaFunc ef = methodEH(c.signal);

View File

@@ -611,10 +611,10 @@ public:
// / Raise events
static void raiseEvent(PIObject * sender, const PIString & event) {
for (int j = 0; j < sender->connections.size_s(); ++j) {
Connection & i(sender->connections[j]);
__Connection & i(sender->connections[j]);
if (i.event != event) continue;
if (i.performer) {
i.performer->postQueuedEvent(QueuedEvent(i.slot, i.dest, i.dest_o, sender));
i.performer->postQueuedEvent(__QueuedEvent(i.slot, i.dest, i.dest_o, sender));
} else {
if (sender->thread_safe_) i.dest_o->mutex_.lock();
i.dest_o->emitter_ = sender;
@@ -628,12 +628,12 @@ public:
template <typename T0>
static void raiseEvent(PIObject * sender, const PIString & event, const T0 & v0 = T0()) {
for (int j = 0; j < sender->connections.size_s(); ++j) {
Connection & i(sender->connections[j]);
__Connection & i(sender->connections[j]);
if (i.event != event) continue;
if (i.performer) {
PIVector<PIVariant> vl;
if (i.args_count > 0) vl << PIVariant::fromValue(v0);
i.performer->postQueuedEvent(QueuedEvent(i.slot, i.dest, i.dest_o, sender, vl));
i.performer->postQueuedEvent(__QueuedEvent(i.slot, i.dest, i.dest_o, sender, vl));
} else {
if (sender->thread_safe_) i.dest_o->mutex_.lock();
i.dest_o->emitter_ = sender;
@@ -647,13 +647,13 @@ public:
template <typename T0, typename T1>
static void raiseEvent(PIObject * sender, const PIString & event, const T0 & v0 = T0(), const T1 & v1 = T1()) {
for (int j = 0; j < sender->connections.size_s(); ++j) {
Connection & i(sender->connections[j]);
__Connection & i(sender->connections[j]);
if (i.event != event) continue;
if (i.performer) {
PIVector<PIVariant> vl;
if (i.args_count > 0) vl << PIVariant::fromValue(v0);
if (i.args_count > 1) vl << PIVariant::fromValue(v1);
i.performer->postQueuedEvent(QueuedEvent(i.slot, i.dest, i.dest_o, sender, vl));
i.performer->postQueuedEvent(__QueuedEvent(i.slot, i.dest, i.dest_o, sender, vl));
} else {
if (sender->thread_safe_) i.dest_o->mutex_.lock();
i.dest_o->emitter_ = sender;
@@ -670,14 +670,14 @@ public:
template <typename T0, typename T1, typename T2>
static void raiseEvent(PIObject * sender, const PIString & event, const T0 & v0 = T0(), const T1 & v1 = T1(), const T2 & v2 = T2()) {
for (int j = 0; j < sender->connections.size_s(); ++j) {
Connection & i(sender->connections[j]);
__Connection & i(sender->connections[j]);
if (i.event != event) continue;
if (i.performer) {
PIVector<PIVariant> vl;
if (i.args_count > 0) vl << PIVariant::fromValue(v0);
if (i.args_count > 1) vl << PIVariant::fromValue(v1);
if (i.args_count > 2) vl << PIVariant::fromValue(v2);
i.performer->postQueuedEvent(QueuedEvent(i.slot, i.dest, i.dest_o, sender, vl));
i.performer->postQueuedEvent(__QueuedEvent(i.slot, i.dest, i.dest_o, sender, vl));
} else {
if (sender->thread_safe_) i.dest_o->mutex_.lock();
i.dest_o->emitter_ = sender;
@@ -695,7 +695,7 @@ public:
template <typename T0, typename T1, typename T2, typename T3>
static void raiseEvent(PIObject * sender, const PIString & event, const T0 & v0 = T0(), const T1 & v1 = T1(), const T2 & v2 = T2(), const T3 & v3 = T3()) {
for (int j = 0; j < sender->connections.size_s(); ++j) {
Connection & i(sender->connections[j]);
__Connection & i(sender->connections[j]);
if (i.event != event) continue;
if (i.performer) {
PIVector<PIVariant> vl;
@@ -703,7 +703,7 @@ public:
if (i.args_count > 1) vl << PIVariant::fromValue(v1);
if (i.args_count > 2) vl << PIVariant::fromValue(v2);
if (i.args_count > 3) vl << PIVariant::fromValue(v3);
i.performer->postQueuedEvent(QueuedEvent(i.slot, i.dest, i.dest_o, sender, vl));
i.performer->postQueuedEvent(__QueuedEvent(i.slot, i.dest, i.dest_o, sender, vl));
} else {
if (sender->thread_safe_) i.dest_o->mutex_.lock();
i.dest_o->emitter_ = sender;
@@ -847,8 +847,8 @@ protected:
//! \}
private:
struct Connection {
Connection(void * sl = 0, void * si = 0, const PIString & e = PIString(), PIObject * d_o = 0, void * d = 0, int ac = 0, PIObject * p = 0) {
struct __Connection {
__Connection(void * sl = 0, void * si = 0, const PIString & e = PIString(), PIObject * d_o = 0, void * d = 0, int ac = 0, PIObject * p = 0) {
slot = sl;
signal = si;
event = e;
@@ -865,8 +865,8 @@ private:
void * dest;
int args_count;
};
struct QueuedEvent {
QueuedEvent(void * sl = 0, void * d = 0, PIObject * d_o = 0, PIObject * s = 0, const PIVector<PIVariant> & v = PIVector<PIVariant>()) {
struct __QueuedEvent {
__QueuedEvent(void * sl = 0, void * d = 0, PIObject * d_o = 0, PIObject * s = 0, const PIVector<PIVariant> & v = PIVector<PIVariant>()) {
slot = sl;
dest = d;
dest_o = d_o;
@@ -885,17 +885,17 @@ private:
PIVector<__MetaFunc> findEH(const PIString & name) const;
__MetaFunc methodEH(const void * addr) const;
void updateConnectors();
void postQueuedEvent(const QueuedEvent & e);
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);
PIVector<Connection> connections;
PIVector<__Connection> connections;
PIMap<PIString, PIVariant> properties_;
PISet<PIObject * > connectors;
PIVector<QueuedEvent> events_queue;
PIVector<__QueuedEvent> events_queue;
PIMutex mutex_, mutex_connect, mutex_queue;
PIObject * emitter_;
bool thread_safe_, proc_event_queue;