qwert_e Posted January 11, 2019 Posted January 11, 2019 (edited) from docs: Quote Ptr<PropertyParameter> getParameterPtr( int id ) Returns a property parameter by its ID. Arguments int id - Property parameter ID. Return value Property parameter smart pointer, if it exists; otherwise, nullptr. As getNumParameters function deprecated, and i want to iterate through all parameters of my property, i go as: for (int i = 0; property->getParameterPtr(i); i++) { when i reaches 15 if logs into console: Property::getParameterPtr(): can't get parameter with id 15 in property "xxx_xxx" and it is not nullptr, as it said in docs. How can i handle that? UPD: found way to get count of parameters through getNumChildren() at root parameter, but question about nullptr still actual. Edited January 11, 2019 by qwert_e
alexander Posted January 14, 2019 Posted January 14, 2019 Hi qwert_e, Yes, there is a mistake. getParameterPtr() never returns nullptr. It always returns a PropertyParameter object, but the isExist() method may return 0. And, you can't iterate through all of your parameters by one loop. Only through recursive function: PropertyParameterPtr root_parameter = property->getParameterPtr(); std::function<void(const PropertyParameterPtr &)> recursive_func = [&, this](const PropertyParameterPtr &p) { for (int i = 0; i < p->getNumChildren(); i++) { PropertyParameterPtr child = p->getChild(i); // do something... recursive_func(child); } }; recursive_func(root_parameter); Best regards, Alexander 2
Amerio.Stephane Posted January 14, 2019 Posted January 14, 2019 I think this code sample should definitively be in the doc :)
fox Posted January 14, 2019 Posted January 14, 2019 Hi Amerio, The mistake will be fixed and code samples will be added shortly. We're sorry for the inconvenience caused! Thank you!
Recommended Posts