PIObject Property const char *
This commit is contained in:
@@ -113,7 +113,7 @@ public:
|
||||
|
||||
//! \~english Returns object name
|
||||
//! \~russian Возвращает имя объекта
|
||||
PIString name() const {return property(PIStringAscii("name")).toString();}
|
||||
PIString name() const {return property("name").toString();}
|
||||
|
||||
//! \~english Returns object class name
|
||||
//! \~russian Возвращает имя класса объекта
|
||||
@@ -131,17 +131,16 @@ public:
|
||||
|
||||
//! \~english Return if \a piCoutObj of this object is active
|
||||
//! \~russian Возвращает включен ли вывод \a piCoutObj для этого объекта
|
||||
bool debug() const {return property(PIStringAscii("debug")).toBool();}
|
||||
bool debug() const {return property("debug").toBool();}
|
||||
|
||||
|
||||
//! \~english Set object name
|
||||
//! \~russian Устанавливает имя объекта
|
||||
void setName(const PIString & name) {setProperty(PIStringAscii("name"), name);}
|
||||
void setName(const char * name) {setName(PIStringAscii(name));}
|
||||
|
||||
void setName(const PIString & name) {setProperty("name", name);}
|
||||
|
||||
//! \~english Set object \a piCoutObj active
|
||||
//! \~russian Включает или отключает вывод \a piCoutObj для этого объекта
|
||||
void setDebug(bool debug) {setProperty(PIStringAscii("debug"), debug);}
|
||||
void setDebug(bool debug) {setProperty("debug", debug);}
|
||||
|
||||
//! \~english Returns properties of the object
|
||||
//! \~russian Возвращает словарь свойств объекта
|
||||
@@ -153,18 +152,15 @@ public:
|
||||
|
||||
//! \~english Returns property with name "name"
|
||||
//! \~russian Возвращает свойство объекта по имени "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 properties_.value(piHashData((const uchar *)name, strlen(name)), Property(nullptr, PIVariant())).second;}
|
||||
|
||||
//! \~english Set property with name "name" to "value". If there is no such property in object it will be added
|
||||
//! \~russian Устанавливает у объекта свойство по имени "name" в "value". Если такого свойства нет, оно добавляется
|
||||
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) {properties_[piHashData((const uchar *)name, strlen(name))] = Property(name, value); propertyChanged(name);}
|
||||
|
||||
//! \~english Returns if property with name "name" exists
|
||||
//! \~russian Возвращает присутствует ли свойство по имени "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 properties_.contains(piHashData((const uchar *)name, strlen(name)));}
|
||||
|
||||
void setThreadSafe(bool yes) {thread_safe_ = yes;}
|
||||
bool isThreadSafe() const {return thread_safe_;}
|
||||
@@ -520,7 +516,7 @@ protected:
|
||||
|
||||
//! \~english Virtual function executes after property with name "name" has been changed
|
||||
//! \~russian Виртуальная функция, вызывается после изменения любого свойства.
|
||||
virtual void propertyChanged(const PIString & name) {}
|
||||
virtual void propertyChanged(const char * name) {}
|
||||
|
||||
EVENT1(deleted, PIObject *, o)
|
||||
|
||||
@@ -569,8 +565,8 @@ private:
|
||||
PRIVATE_DECLARATION(PIP_EXPORT)
|
||||
};
|
||||
|
||||
typedef PIPair<PIString, PIVariant> Property;
|
||||
typedef PIPair<uint, PIPair<PIString, PIVariant> > PropertyHash;
|
||||
typedef PIPair<const char *, PIVariant> Property;
|
||||
typedef PIPair<uint, Property > PropertyHash;
|
||||
|
||||
bool findSuitableMethodV(const PIString & method, int args, int & ret_args, __MetaFunc & ret);
|
||||
PIVector<__MetaFunc> findEH(const PIString & name) const;
|
||||
@@ -591,7 +587,7 @@ private:
|
||||
|
||||
|
||||
PIVector<Connection> connections;
|
||||
PIMap<uint, PIPair<PIString, PIVariant> > properties_;
|
||||
PIMap<uint, Property> properties_;
|
||||
PISet<PIObject * > connectors;
|
||||
PIVector<__QueuedEvent> events_queue;
|
||||
PIMutex mutex_, mutex_connect, mutex_queue;
|
||||
|
||||
Reference in New Issue
Block a user