-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enable volatile params #623
Conversation
Pinging @brryan @pgrete @jdolence @nmsriram @forrestglines as people with stakes in this machinery and/or who wrote the original version |
small nomenclature suggestion: find-replace |
This is a good idea. |
done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I like this approach to be more specific.
The one additional change I'd like to see before approving is an update to the Update
function.
From a consistency point of view, I think that if we differentiate between mutable and non-mutable parameter, then Update
should also check if the parameter is mutable and otherwise throw an error.
src/interface/params.hpp
Outdated
myTypes_.emplace(make_pair(key, std::type_index(typeid(value)))); | ||
myMutable_[key] = make_mutable; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, is there a reason to use emplace
in one case and the direct assignment in the other case?
Also, I wonder, if it wouldn't be cleaner the only use one map (e.g., with a struct) instead of three, but that's probably a separate discussion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used assignment because it was easier. I don't know why the original was emplace
. I can copy that if it's preferred.
@pgrete take a look now. I added a check for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to go!
Codecov Report
@@ Coverage Diff @@
## develop #623 +/- ##
===========================================
+ Coverage 54.25% 54.28% +0.02%
===========================================
Files 125 125
Lines 13699 13701 +2
===========================================
+ Hits 7433 7438 +5
+ Misses 6266 6263 -3
Continue to review full report at Codecov.
|
PR Summary
This is motivated by @brryan 's comment in issue #621 . I modify
Params
to enable the user to tag a param as "volatile." The effect of this is that the user can optionally extract the non-const
pointer from theParams
object withGetVolatile
in theParams
object orVolatileParam
in theStateDescriptor
object. If the user attempts to extract a non-volatile param withGetVolatile
, a runtime error is raised.I thought about returning a non-
const
reference, but the pointer felt safer and more explicit, without being any more cumbersome really. On the other hand, returning a pointer withGetVolatile
means that the twoGet
methods return different types, which is a little weird. So I'd be open to returning a non-const
reference instead, if people would like that better.PR Checklist