-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Make Model class visitable #4902
Conversation
This has no impact, so I'll merge without review in 5 days. |
include/AutomatableModel.h
Outdated
Target* dcast(bool doThrow = false) | ||
{ | ||
DCastVisitor<Target> vis; accept(vis); | ||
if(doThrow && !vis.result) Q_ASSERT(false); |
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.
Could you provide an example where the cast fails?
Also, please use if (
instead of if(
.
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.
For example, you have an AutomatableModel*
pointing to a ComboBoxModel
or IntModel
, but try converting the pointer to FloatModel*
(using FloatModel
for the Target
parameter). Should I add this to the comment?
Notes to self: Document doThrow
, and correct the current statement that nullptr
is only returned if !doThrow
. And add something like see non const version
.
* document `dcast` * make `dcast` not only cast exact, but also upwards * add `dcast` test * rename `dcast` -> `dynamicCast`
I just added review commits. The old There's also a test now documenting how it works. |
Check whether returned pointers from the cast are equal to the original pointers, rather than just checking wether they are not `nullptr`.
I'm not sure if it's worth handling this, but |
I don't think it's necessary now. Currently, I only need this to handle widgets of different types, like knobs, LEDs, ComboBoxes, for dialogs with LADSPA or Lv2 ports. |
Make Model class visitable
This makes the different
AutomatableModel
s visitable and adds a visitor based cast function for cleaner code and more type safety. Currently only used in the Lv2 branch, but it's a generic feature.