23.06.2014 - PICodeParser, PICodeInfo, PIConnection, new binary "pip_cmg"

This commit is contained in:
peri4
2014-06-23 21:08:27 +04:00
parent 2e5e75c4c4
commit 15a20d40ac
56 changed files with 10315 additions and 760 deletions

View File

@@ -26,6 +26,7 @@
#define PIOBJECT_H
#include "pivariant.h"
#include "pimutex.h"
#ifdef DOXYGEN
@@ -258,7 +259,7 @@ public:
PIVariant property(const PIString & name) const {if (!properties_.contains(name)) return PIVariant(); return properties_.value(name);}
//! Set property with name "name" to "value". If there is no such property in object it will be added
void setProperty(const PIString & name, const PIVariant & value) {properties_[name] = value;}
void setProperty(const PIString & name, const PIVariant & value) {properties_[name] = value; propertyChanged(name);}
//! Returns if property with name "name" exists
bool isPropertyExists(const PIString & name) const {return properties_.contains(name);}
@@ -373,7 +374,11 @@ public:
for (int j = 0; j < sender->connections.size_s(); ++j) {
Connection & i(sender->connections[j]);
if (i.event != event) continue;
((PIObject*)(i.dest))->mutex_.lock();
((PIObject*)(i.dest))->emitter_ = sender;
((void(*)(void * ))i.slot)(i.dest);
((PIObject*)(i.dest))->emitter_ = 0;
((PIObject*)(i.dest))->mutex_.unlock();
}
}
template <typename T0>
@@ -381,7 +386,11 @@ public:
for (int j = 0; j < sender->connections.size_s(); ++j) {
Connection & i(sender->connections[j]);
if (i.event != event) continue;
((PIObject*)(i.dest))->mutex_.lock();
((PIObject*)(i.dest))->emitter_ = sender;
((void(*)(void * , T0))i.slot)(i.dest, v0);
((PIObject*)(i.dest))->emitter_ = 0;
((PIObject*)(i.dest))->mutex_.unlock();
}
}
template <typename T0, typename T1>
@@ -389,7 +398,11 @@ public:
for (int j = 0; j < sender->connections.size_s(); ++j) {
Connection & i(sender->connections[j]);
if (i.event != event) continue;
((PIObject*)(i.dest))->mutex_.lock();
((PIObject*)(i.dest))->emitter_ = sender;
((void(*)(void * , T0, T1))i.slot)(i.dest, v0, v1);
((PIObject*)(i.dest))->emitter_ = 0;
((PIObject*)(i.dest))->mutex_.unlock();
}
}
template <typename T0, typename T1, typename T2>
@@ -397,7 +410,11 @@ public:
for (int j = 0; j < sender->connections.size_s(); ++j) {
Connection & i(sender->connections[j]);
if (i.event != event) continue;
((PIObject*)(i.dest))->mutex_.lock();
((PIObject*)(i.dest))->emitter_ = sender;
((void(*)(void * , T0, T1, T2))i.slot)(i.dest, v0, v1, v2);
((PIObject*)(i.dest))->emitter_ = 0;
((PIObject*)(i.dest))->mutex_.unlock();
}
}
template <typename T0, typename T1, typename T2, typename T3>
@@ -405,7 +422,11 @@ public:
for (int j = 0; j < sender->connections.size_s(); ++j) {
Connection & i(sender->connections[j]);
if (i.event != event) continue;
((PIObject*)(i.dest))->mutex_.lock();
((PIObject*)(i.dest))->emitter_ = sender;
((void(*)(void * , T0, T1, T2, T3))i.slot)(i.dest, v0, v1, v2, v3);
((PIObject*)(i.dest))->emitter_ = 0;
((PIObject*)(i.dest))->mutex_.unlock();
}
}
/*
@@ -476,7 +497,7 @@ public:
raiseEvent<T0, T1, T2, T3>(name,dest , v0, v1, v2, v3);
}
//! Returns PIObject* with name "name" or 0, if there is no objects found
//! Returns PIObject* with name "name" or 0, if there is no object found
static PIObject * findByName(const PIString & name) {
piForeach (PIObject * i, PIObject::objects) {
if (i->name() != name) continue;
@@ -486,6 +507,12 @@ public:
};
protected:
//! Returns PIObject* which has raised an event. This value is correct only in definition of some event handler
PIObject * emitter() const {return emitter_;}
//! Virtual function executes after property with name "name" has been changed
virtual void propertyChanged(const PIString & name) {}
private:
struct Connection {
@@ -500,6 +527,8 @@ private:
PIMap<PIString, PIVariant> properties_;
static PIVector<PIObject * > objects;
PIMutex mutex_;
PIObject * emitter_;
};