Jump to content

Dynamic Event Registration Using Objects


Recommended Posts

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

Link to comment

QUOTE(njkirchner @ Mar 27 2007, 02:26 PM)

I have about 25 dynamic events being registered to an event structure which look like this

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

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.

Link to comment

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

Link to comment

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.

Link to comment

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.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.