From c6bed4c4f51cbef7121704da27b6de156e718a79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=8B=D1=87=D0=BA=D0=BE=D0=B2=20=D0=90=D0=BD=D0=B4?= =?UTF-8?q?=D1=80=D0=B5=D0=B9?= Date: Mon, 12 Aug 2019 13:37:47 +0000 Subject: [PATCH] git-svn-id: svn://db.shs.com.ru/pip@842 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5 --- src_main/core/piobject.cpp | 16 +++++++++++++--- src_main/core/piobject.h | 11 ++++++----- .../introspection/piintrospection_server_p.cpp | 2 +- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src_main/core/piobject.cpp b/src_main/core/piobject.cpp index b332e164..66d9fccb 100755 --- a/src_main/core/piobject.cpp +++ b/src_main/core/piobject.cpp @@ -91,6 +91,16 @@ PIObject::~PIObject() { piDisconnect(this); } +PIMap PIObject::properties() const { + PIMap ret; + piForeachC (PropertyHash p, properties_) + ret[p.second.first] = p.second.second; + return ret; +} + + + + bool PIObject::execute(const PIString & method, const PIVector & vl) { 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 << " count: " << properties_.size_s(); //printf("dump %d properties\n", properties_.size()); - piForeachC (Property p, properties_) - if (p.first != "name") - PICout(PICoutManipulators::AddNewLine) << line_prefix << " " << p.first << ": " << p.second; + piForeachC (PropertyHash p, properties_) + if (p.first != PIString("name").hash()) + PICout(PICoutManipulators::AddNewLine) << line_prefix << " " << p.second.first << ": " << p.second.second; //printf("dump %d properties ok\n", properties_.size()); PICout(PICoutManipulators::AddNewLine) << line_prefix << " }"; PICout(PICoutManipulators::AddNewLine) << line_prefix << " methods {"; diff --git a/src_main/core/piobject.h b/src_main/core/piobject.h index 5aa6903e..9a309a07 100755 --- a/src_main/core/piobject.h +++ b/src_main/core/piobject.h @@ -530,21 +530,21 @@ public: void setDebug(bool debug) {setProperty(PIStringAscii("debug"), debug);} //! Returns properties of the object - const PIMap & properties() const {return properties_;} + PIMap properties() const; //! Returns properties count of the object int propertiesCount() const {return properties_.size_s();} //! 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));} //! 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);} //! 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));} void setThreadSafe(bool yes) {thread_safe_ = yes;} @@ -840,6 +840,7 @@ private: PIVector values; }; typedef PIPair Property; + typedef PIPair > PropertyHash; bool findSuitableMethodV(const PIString & method, int args, int & ret_args, __MetaFunc & ret); PIVector<__MetaFunc> findEH(const PIString & name) const; @@ -855,7 +856,7 @@ private: PIVector<__Connection> connections; - PIMap properties_; + PIMap > properties_; PISet connectors; PIVector<__QueuedEvent> events_queue; PIMutex mutex_, mutex_connect, mutex_queue; diff --git a/src_main/introspection/piintrospection_server_p.cpp b/src_main/introspection/piintrospection_server_p.cpp index 0ca40c38..ca34a98f 100644 --- a/src_main/introspection/piintrospection_server_p.cpp +++ b/src_main/introspection/piintrospection_server_p.cpp @@ -75,7 +75,7 @@ PIVector PIIntrospection::getObjects() { for (int i = 0; i < ao.size_s(); ++i) { ret[i].classname = PIStringAscii(ao[i]->className()); ret[i].name = ao[i]->name(); - ret[i].properties = ao[i]->properties_; + ret[i].properties = ao[i]->properties(); ret[i].parents = ao[i]->scopeList(); ao[i]->mutex_queue.lock(); ret[i].queued_events = ao[i]->events_queue.size_s();