Jump to content

How to check if a class is an interface or a concrete?


bjustice

Recommended Posts

I ran into a situation where I need to return the class hierarchy of an object as a concrete object array.  (If you are curious, this is used in the BlueSerialization toolkit)

The following code snippet demonstrates how I accomplished this.
Unfortunately, I just discovered that this algorithm doesn't work if a class also inherits from an interface class.  (My algorithm here assumes that a class can only inherit from 1 other class.)

Naturally, my immediate question is this:

Is there a graceful NI primitive or mechanism for determining if a given object is an interface class or a concrete class?

If yes, then I could just filter out interface classes in my code here and move on with life.

image.png.7dc7c473f113e271b24d40e42cd4be86.png

 

I did find the "Get LabVIEW Class Parent and Member VI information VI.  But, I can't get this VI to work recursively.  On the 2nd loop iteration, this NI primitive returns that results for a base LabVIEW object even though the wire probe shows this as not being a base LabVIEW object.

image.png.57003127745ac439b88bd8a1437a97b0.png

 

Get Class Hierarchy.vi

Link to comment

BlueSerialization is currently LabVIEW 2020.

hmm... okay.  How bulletproof do you think your VI might be?  Would LabVIEW ever be "smart" enough to not load a classes' *.ctl file into memory if it was blank or something like that?  Or perhaps drop it from a build if it were blank?

If you think this is pretty bulletproof, I'll just use this and push a patch to the BlueSerialization library.

I am already cacheing the results, so speed is probably not a huge issue.

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.