openframeworks / openframeworks/openFrameworks
ofParameterGroup contains(string name) if parameter changed name.
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 10.4k
- Forks
- 2.6k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 9
Description
Hi everyone.
Playing with ofParameterGroups I found an issue with ofParameterGroup::contains(...)
https://github.com/openframeworks/openFrameworks/blob/5453d35ae88022d2c09f47d3beb9a57c1e87a65d/libs/openFrameworks/types/ofParameterGroup.cpp#L422-L424 it also applies in all places where std::map<std::string,std::size_t> parametersIndex; is used.
The issue pops up when you change the name of a parameter that is already inside the parameterGroup. The name changes of the parameter changes, but the name in parametersIndex does, not and so we cannot find our parameter inside the parameterGroup. Because the parameterIndex map is only created when adding parameters, and only modified when removing, the only workaround for this is to remove the element from the group, changing the name, and adding it again. With that changing the order of the elements in the group.
As ofParameter has a public method of ::setName(), this case should be considered right?
As there is no event fired by the ofParameter when the name is changed, I think the best solution is to get rid of parametersIndex and search the parameters vector directly so we get the updated name every time we make the request.
Eduard
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with ofParameterGroup::contains(...) in libs/openFrameworks/types/ofParameterGroup.cpp and inspect parametersIndex in libs/openFrameworks/types/ofParameter.h. Trace how ofParameter::setName() affects a parameter already in a group, then determine how contains can reflect the updated name without changing the group's element order. Done means renamed parameters remain discoverable through the group.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100