jon_mcbee Posted March 7, 2013 Report Share Posted March 7, 2013 Is it possible to call the oldest ancestors implementation of a dynamic dispatch VI? Lets say that I have an inheritance hierarchy where the oldest ancestor is called DUT and has three abstract dynamic dispatch methods (to be overridden and not extended by children): Read Torque, Read Trip, Read Serial Number. DUT has a child class called Mindbender3000, and Mindbender3000 overrides all of the parent dynamic dispatch methods: Read Torque, Read Trip, and Read Serial Number. Somewhere down the road an upgrade is made to the Mindbender3000 product, and Mindbender5000 is born. The upgrade incorporated two main improvements, a clock was added to the new hardware that we can now query using a Read Clock method, and the ability to Read Trip was removed from the device. To account for these changes, a new abstract dynamic dispatch method is added to the DUT class, Read Clock, and a child class of MindBender3000 is created, named Mindbender5000. Mindbender5000 uses its parents implementation of the Read Torque, and Read Serial Number override methods, and overrides the DUT classes dynamic dispatch method for Read Clock. Ideally, Mindbender5000 would use the DUT classes implementation of the Read Trip method, as it is abstract and doesn't really do anything. However, because Mindbender 3000 has already overridden the Read Trip method, the Mindbender5000 product wants to use its implementation. Is there a way to call DUTs Read Trip dynamic dispatch method from the Mindbender5000 class? Lets assume that DUT has other children that need to be able to override these dynamic dispatch methods, including the new Read Clock method. Thanks! Quote Link to comment
LogMAN Posted March 8, 2013 Report Share Posted March 8, 2013 Well I guess you could cast your class to a more generic class (within the 'Read Trip' implementation of the child) and then call the parent class implementation of your 'Read Trip' method. Quote Link to comment
mje Posted March 8, 2013 Report Share Posted March 8, 2013 Well I guess you could cast your class to a more generic class (within the 'Read Trip' implementation of the child) and then call the parent class implementation of your 'Read Trip' method. No. Calling a dynamic dispatch will always call the most specific implementation of the method available for an object regardless of the wire type, so casting the wire to a more generic class does not change the VI which gets called at run-time. The only way to call a parent implementation of a dynamic dispatch if from within the method itself via the Call Parent Method primitive, at which point the next most specific implementation gets called. There's no way to skip implementations by design. Quote Link to comment
MikaelH Posted March 10, 2013 Report Share Posted March 10, 2013 You should not need to call the base ancestor's implementation, if there is a sub class you inherit from that overrides a base class method you should call that. If you don't think that is right, you should not inherit from the sub class but instead inherit from the base class. 1 Quote Link to comment
LogMAN Posted March 11, 2013 Report Share Posted March 11, 2013 No. Calling a dynamic dispatch will always call the most specific implementation of the method available for an object regardless of the wire type, so casting the wire to a more generic class does not change the VI which gets called at run-time. The only way to call a parent implementation of a dynamic dispatch if from within the method itself via the Call Parent Method primitive, at which point the next most specific implementation gets called. There's no way to skip implementations by design. You're right. Should have tested it... Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.