02-12-2019 09:48 AM - edited 02-12-2019 09:54 AM
Suppose I have the following classes.
Class A:
Method 1 (dynamic dispatch)
Method 2 (dynamic dispatch)
Method 3 (static dispatch)
Class B: inherits from Class A
Method 1 (dynamic dispatch)
Method 2 (dynamic dispatch)
Method X (static dispatch)
When invoking the LabVIEW Class:All Methods Of LVClass, it returns fully qualified names of the Class A methods which have been overridden by Class B methods. Shouldn't it return the methods for the class specified and not its ancestor?
I can understand this behaviour for methods which don't have an override, i.e. Method 3., but not for ones which override it in the specified class.
Is this a bug? Are there any other methods that allow you to obtain all of the public methods of the child class at run-time?
Actual output:
Expected output:
Solved! Go to Solution.
02-12-2019 09:53 AM
I'm pretty sure that this isn't a bug. Your class B isn't used as object, but as class.
I recall that dynamic dispatching is a pure runtime behavior. That means that a class will always check the parental class(es) for methods before looking into its own methods. As a result, the All Methods of LVClass will return methods from ancestor down to children without checking for dynamic dispatch overrides....
02-12-2019 09:56 AM
@Norbert_B wrote:
I'm pretty sure that this isn't a bug. Your class B isn't used as object, but as class.
I recall that dynamic dispatching is a pure runtime behavior. That means that a class will always check the parental class(es) for methods before looking into its own methods. As a result, the All Methods of LVClass will return methods from ancestor down to children without checking for dynamic dispatch overrides....
Bugger 😞
02-12-2019 09:58 AM
Regarding your question on how to get a list of all methods of one specific class in your inheritance hierachy, i would check the property nodes "StaticMemberVIs" and "DynamicMemberVIs" you can find using the LVClassLibrary reference. This is more work (getting references, query names, ...) but should result in what you are looking for...
02-14-2019 07:58 AM
Thanks Norbert. I use these in a related function, but they are not run-time. However, at the moment the function that uses the list of methods doesn't need to be included in the executable, so this will suffice for now.