git-svn-id: svn://db.shs.com.ru/pip@842 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -91,6 +91,16 @@ PIObject::~PIObject() {
|
|||||||
piDisconnect(this);
|
piDisconnect(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PIMap<PIString, PIVariant> PIObject::properties() const {
|
||||||
|
PIMap<PIString, PIVariant> ret;
|
||||||
|
piForeachC (PropertyHash p, properties_)
|
||||||
|
ret[p.second.first] = p.second.second;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool PIObject::execute(const PIString & method, const PIVector<PIVariant> & vl) {
|
bool PIObject::execute(const PIString & method, const PIVector<PIVariant> & vl) {
|
||||||
if (method.isEmpty()) return false;
|
if (method.isEmpty()) return false;
|
||||||
@@ -533,9 +543,9 @@ void PIObject::dump(const PIString & line_prefix) const {
|
|||||||
PICout(PICoutManipulators::AddNewLine) << line_prefix << " properties {";
|
PICout(PICoutManipulators::AddNewLine) << line_prefix << " properties {";
|
||||||
PICout(PICoutManipulators::AddNewLine) << line_prefix << " count: " << properties_.size_s();
|
PICout(PICoutManipulators::AddNewLine) << line_prefix << " count: " << properties_.size_s();
|
||||||
//printf("dump %d properties\n", properties_.size());
|
//printf("dump %d properties\n", properties_.size());
|
||||||
piForeachC (Property p, properties_)
|
piForeachC (PropertyHash p, properties_)
|
||||||
if (p.first != "name")
|
if (p.first != PIString("name").hash())
|
||||||
PICout(PICoutManipulators::AddNewLine) << line_prefix << " " << p.first << ": " << p.second;
|
PICout(PICoutManipulators::AddNewLine) << line_prefix << " " << p.second.first << ": " << p.second.second;
|
||||||
//printf("dump %d properties ok\n", properties_.size());
|
//printf("dump %d properties ok\n", properties_.size());
|
||||||
PICout(PICoutManipulators::AddNewLine) << line_prefix << " }";
|
PICout(PICoutManipulators::AddNewLine) << line_prefix << " }";
|
||||||
PICout(PICoutManipulators::AddNewLine) << line_prefix << " methods {";
|
PICout(PICoutManipulators::AddNewLine) << line_prefix << " methods {";
|
||||||
|
|||||||
@@ -530,21 +530,21 @@ public:
|
|||||||
void setDebug(bool debug) {setProperty(PIStringAscii("debug"), debug);}
|
void setDebug(bool debug) {setProperty(PIStringAscii("debug"), debug);}
|
||||||
|
|
||||||
//! Returns properties of the object
|
//! Returns properties of the object
|
||||||
const PIMap<PIString, PIVariant> & properties() const {return properties_;}
|
PIMap<PIString, PIVariant> properties() const;
|
||||||
|
|
||||||
//! Returns properties count of the object
|
//! Returns properties count of the object
|
||||||
int propertiesCount() const {return properties_.size_s();}
|
int propertiesCount() const {return properties_.size_s();}
|
||||||
|
|
||||||
//! Returns property with name "name"
|
//! Returns property with name "name"
|
||||||
PIVariant property(const PIString & name) const {if (!properties_.contains(name)) return PIVariant(); return properties_.value(name);}
|
PIVariant property(const PIString & name) const {return properties_.value(name.hash(), Property(PIString(), PIVariant())).second;}
|
||||||
PIVariant property(const char * name) const {return property(PIStringAscii(name));}
|
PIVariant property(const char * name) const {return property(PIStringAscii(name));}
|
||||||
|
|
||||||
//! Set property with name "name" to "value". If there is no such property in object it will be added
|
//! 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; propertyChanged(name);}
|
void setProperty(const PIString & name, const PIVariant & value) {properties_[name.hash()] = Property(name, value); propertyChanged(name);}
|
||||||
void setProperty(const char * name, const PIVariant & value) {setProperty(PIStringAscii(name), value);}
|
void setProperty(const char * name, const PIVariant & value) {setProperty(PIStringAscii(name), value);}
|
||||||
|
|
||||||
//! Returns if property with name "name" exists
|
//! Returns if property with name "name" exists
|
||||||
bool isPropertyExists(const PIString & name) const {return properties_.contains(name);}
|
bool isPropertyExists(const PIString & name) const {return properties_.contains(name.hash());}
|
||||||
bool isPropertyExists(const char * name) const {return isPropertyExists(PIStringAscii(name));}
|
bool isPropertyExists(const char * name) const {return isPropertyExists(PIStringAscii(name));}
|
||||||
|
|
||||||
void setThreadSafe(bool yes) {thread_safe_ = yes;}
|
void setThreadSafe(bool yes) {thread_safe_ = yes;}
|
||||||
@@ -840,6 +840,7 @@ private:
|
|||||||
PIVector<PIVariant> values;
|
PIVector<PIVariant> values;
|
||||||
};
|
};
|
||||||
typedef PIPair<PIString, PIVariant> Property;
|
typedef PIPair<PIString, PIVariant> Property;
|
||||||
|
typedef PIPair<uint, PIPair<PIString, PIVariant> > PropertyHash;
|
||||||
|
|
||||||
bool findSuitableMethodV(const PIString & method, int args, int & ret_args, __MetaFunc & ret);
|
bool findSuitableMethodV(const PIString & method, int args, int & ret_args, __MetaFunc & ret);
|
||||||
PIVector<__MetaFunc> findEH(const PIString & name) const;
|
PIVector<__MetaFunc> findEH(const PIString & name) const;
|
||||||
@@ -855,7 +856,7 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
PIVector<__Connection> connections;
|
PIVector<__Connection> connections;
|
||||||
PIMap<PIString, PIVariant> properties_;
|
PIMap<uint, PIPair<PIString, PIVariant> > properties_;
|
||||||
PISet<PIObject * > connectors;
|
PISet<PIObject * > connectors;
|
||||||
PIVector<__QueuedEvent> events_queue;
|
PIVector<__QueuedEvent> events_queue;
|
||||||
PIMutex mutex_, mutex_connect, mutex_queue;
|
PIMutex mutex_, mutex_connect, mutex_queue;
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ PIVector<PIIntrospection::ObjectInfo> PIIntrospection::getObjects() {
|
|||||||
for (int i = 0; i < ao.size_s(); ++i) {
|
for (int i = 0; i < ao.size_s(); ++i) {
|
||||||
ret[i].classname = PIStringAscii(ao[i]->className());
|
ret[i].classname = PIStringAscii(ao[i]->className());
|
||||||
ret[i].name = ao[i]->name();
|
ret[i].name = ao[i]->name();
|
||||||
ret[i].properties = ao[i]->properties_;
|
ret[i].properties = ao[i]->properties();
|
||||||
ret[i].parents = ao[i]->scopeList();
|
ret[i].parents = ao[i]->scopeList();
|
||||||
ao[i]->mutex_queue.lock();
|
ao[i]->mutex_queue.lock();
|
||||||
ret[i].queued_events = ao[i]->events_queue.size_s();
|
ret[i].queued_events = ao[i]->events_queue.size_s();
|
||||||
|
|||||||
Reference in New Issue
Block a user