diff --git a/src_main/core/pipropertystorage.h b/src_main/core/pipropertystorage.h index 09486278..4a055346 100644 --- a/src_main/core/pipropertystorage.h +++ b/src_main/core/pipropertystorage.h @@ -30,7 +30,7 @@ /** * @brief Key-value storage, based on PIVector with PIPropertyStorage::Property elements. Each element in vector * contains unique name and you can identify property by name with propertyValueByName(), propertyByName(). - * You can add property using addProperty(). + * You can add property using addProperty(const Property&), addProperty(const PIString&, const PIVariant&, const PIString&, int). */ class PIPropertyStorage { public: @@ -42,14 +42,23 @@ public: struct Property { Property(const PIString & n = PIString(), const PIString & c = PIString(), const PIVariant & v = PIVariant(), int f = 0): name(n), comment(c), value(v), flags(f) {} + bool toBool() const {return value.toBool();} int toInt() const {return value.toInt();} float toFloat() const {return value.toFloat();} double toDouble() const {return value.toDouble();} PIString toString() const {return value.toString();} + + /*! Uniqueue id of property */ PIString name; + + /*! Optional description of property */ PIString comment; + + /*! Custom value of property */ PIVariant value; + + /*! Abstract flags which may be used for user needs */ int flags; }; @@ -81,7 +90,18 @@ public: const PIPropertyStorage & propertyStorage() const {return *this;} bool isPropertyExists(const PIString & _name) const; void clearProperties() {props.clear();} + + /** + * @brief Add property if name isn't present in storage, otherwrise update existing property with same name. + * + * @param p to copy in storage + */ void addProperty(const Property & p); + + /** + * @brief First of all construct Property with method params. After then add property if name isn't present + * in storage, otherwrise update existing property with same name. + */ void addProperty(const PIString & _name, const PIVariant & _def_value, const PIString & _comment = PIString(), int _flags = 0) {addProperty(Property(_name, _comment, _def_value, _flags));} void removeProperty(const PIString & _name); void removePropertiesByFlag(int flag);