06-10-2016 09:32 AM - edited 06-10-2016 09:34 AM
i think you refer to the fact that P1 displays 0 as Object data after execution. That is expected behavior.
You call after the decrement an increment by calling "who_am_i.vi" of Base.......
EDIT: Also note that what you are doing has nothing to do with dynamic dispatching. Also, the m* VIs do not require dynamic dispatch in/output connectors.
EDIT 2: You can directly cast the variant to Base.lvclass. No obscure cast to LVObject and To More Specific necessary!
06-10-2016 09:47 AM - edited 06-10-2016 09:49 AM
I think you really have to understand what "dynamic dispatch" means in context of LVOOP:
The base class defines a basic function (VI) which can be overriden by child classes. In the calling code, the developer only uses VIs from the base class without caring about the *possible* child classes which will be included and called during execution.
During execution, the LV runtime evaluates the class of the object and, if present, calls the override of that specific child class. If no override is present, it will execute the base method of the parent.
EDIT: This is done per "static" call to parent class VIs configured for dynamic dispatch. This is NOT done for static dispatch VIs!
I *assume* what you are looking for:
The P1 class should also execute the m2 and m3, but from Base as P1 doesn't implement those.
The point is that the dynamic dispatching replaces dynamic vi calls for the developer and the other way round. So no "standard" call in LV => no dynamic dispatching.
That means that your main.vi would call all four m-VIs from the Base. In case of selection of P1, m1 and m4 would dispatch dynamically, m2 and m3 call into Base implementation.
06-10-2016 11:14 AM
Your assumption is spot on. I apologize if my careless use of terms caused confusion. I attached a revision of the same project that shows the difference between what I have that works, and what I'm trying to implement that doesn't work. So, is there a way in LabVIEW to load a list of base class methods from disk and dynamically dispatch plugin methods where they exist? Hopefully that's worded correctly, or close enough.
06-13-2016 12:47 AM
Scripting...My fears are I'll either reach a similar result, or that I'll spend a lot of time joining class data from scripted objects with the object already loaded in my application. Or both.
I'm not sure what you're afraid of here. The idea behind this is that you write code which will duplicate your working code and then run it. Since I'm guessing there's no way to do what you actually want, this seems like a reasonable option. I expect that if you were to base it on your existing code, it would basically require duplicating the frame N times (once for each m* VI), setting the value of each frame, then replacing the subVI with the correct VI. Seems easy enough, although I haven't verified that all the methods exist.
This still only answers the technical question of how to (sort of) do what you're asking, not whether it's the right thing to do or if there are better options.
06-13-2016 02:10 AM
[...]not whether it's the right thing to do or if there are better options.
I am not sure if there is a "right thing to do" at all in this context in LV.
Though i think that your suggestion is the closest to what makes sense.....and does the job.
As i said, LV has to call explicitly into VIs for dynamic dispatching. So the dynamic dispatch approach requires a caller for each method. Dynamic dispatching does not work if you call VIs by reference (as you encountered).
However, you could write your own dispatcher to check for present override VIs and "missing" ones. In case it is "missing", you reference to the parental version and in case it is present the child version. You still have the advantage of the "generic dynamic dispatching" in case you need it and of course: Call parent method and all other advantages why you'd might have chosen LVOOP.
In order to prevent misunderstandings:
Though that custom dispatcher might reflect your need of "dynamic dispatching" as you called it, from a LVOOP point of view, that should have another term. I recommed something like "custom dispatching".
06-13-2016 03:55 AM
I've been following this thread with interest.
Have I understood properly:
You have a base class with 300 Methods, M1 to M300. You want to be able to pass in a string to launch the respective method.
You don't want to have static links to each method on the BD of the VI doing the selection.
You want to be able to override any of these given methods in a child class but retain the selection by string method and have them also call the parent implementation.
To which extent do you really need dynamic dispatch because it sounds like you want to do your own version of that.