Norm Kirchner Posted March 28, 2007 Report Share Posted March 28, 2007 I have about 25 dynamic events being registered to an event structure which look like this http://forums.lavag.org/index.php?act=attach&type=post&id=5317 If I were to do a registration of only 1 item and that items object class was LVObject, When I fired the event and passed a child class to the event, would the object wire (of LVObject class)returned within the event structure properly dynamic dispatch to the appropritate class? I know if you cast a child class to a parent, the childs data is retained, but will it dispatch to the child method rather than the parent? -Norm http://forums.lavag.org/index.php?act=attach&type=post&id=5318 Quote Link to comment
Jim Kring Posted March 28, 2007 Report Share Posted March 28, 2007 QUOTE(njkirchner @ Mar 27 2007, 02:26 PM) I have about 25 dynamic events being registered to an event structure which look like thisIf I were to do a registration of only 1 item and that items object class was LVObject, When I fired the event and passed a child class to the event, would the object wire (of LVObject class)returned within the event structure properly dynamic dispatch to the appropritate class? I know if you cast a child class to a parent, the childs data is retained, but will it dispatch to the child method rather than the parent? -Norm First off, just as an FYI, you can pass a cluster (or clusters of clusters) into the Register for Events node and the events will be available as a nested tree. You don't need to pass each user event reference into the Register for Events node. Second, yes, the dispatch should work fine. Quote Link to comment
Norm Kirchner Posted March 28, 2007 Author Report Share Posted March 28, 2007 QUOTE(Jim Kring @ Mar 27 2007, 05:32 PM) First off, just as an FYI, you can pass a cluster (or clusters of clusters) into the Register for Events node and the events will be available as a nested tree. You don't need to pass each user event reference into the Register for Events node. The problem with this is you still have a bundle node w/ 25 elements. That aside, thanks for confirming my question. -Norm Quote Link to comment
Jim Kring Posted March 29, 2007 Report Share Posted March 29, 2007 QUOTE(njkirchner @ Mar 27 2007, 03:37 PM) The problem with this is you still have a bundle node w/ 25 elements. That aside, thanks for confirming my question. -Norm > The problem with this is you still have a bundle node w/ 25 elements. Not if your events are already in the same cluster. I just wasn't sure if you knew this. I've seen people unbundle events and wire each event, seperately, into the Register for Events node -- so, it's worth mentioning. I'll be writing a blog article about this, soon. Quote Link to comment
Aristos Queue Posted March 29, 2007 Report Share Posted March 29, 2007 QUOTE(njkirchner @ Mar 27 2007, 04:26 PM) I know if you cast a child class to a parent, the childs data is retained, but will it dispatch to the child method rather than the parent? Yes. Data traveling on a class wire will always dispatch to the class of the data, not the class of the wire. That is the very definition of dynamic dispatching. The classic demo: Drop a constant of Parent and a constant of a Child. Drop a Build Array. Wire both constants to the build array. You get an array of Parent. Wire that to the border of a For Loop (indexing tunnel) and wire the inside to a dynamic dispatch subVI. Run the VI and watch as the first iteration calls the Parent version and the second iteration calls the Child version. 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.