11-30-2020 01:59 PM
I like using free software libraries in C with the Call Library Function Node, I'm currently programming the LibXML2 interface. With it, I have DLL pointers to docs, nodes, elements, etcetera, defined as Magic cookies to locations in the DLL memory space.
When I create strict typedefs for nodes and docs, LabView allows me to wire a doc magic cookie to a node magic cookie (or pointer, and visa-versa) and only indicates an intrinsic cast. Is there a way to define a reference or unsigned 32 typedef that yield a broken wire instead of allowing it with the red dot of intrinsic casting?
11-30-2020 04:31 PM
If they are the same data type and just different type definitions, there's no way to 100% prevent type definitions from casting to each other.
You could instead create a LabVIEW class for each of the different types of pointer. With classes, the internal data is protected and only members of a class can unbundle the integer pointer that you'd put inside of them. You would even get the ability to define a custom wire type so you would have different wires going on your block diagrams instead of the same 1-width blue wire going everywhere.
You could even add some inheritance. For instance, a document is also a top-level node, so if you have one inherit from the other you can have it so that any VI that accepts a Node pointer also accepts a Document pointer.
12-01-2020 07:46 AM
Thanks, good answer.
It hurts my head to think of a document getting inheritance from the node object since, due to the hierarchical nature of XML, is upside down thinking.
In general, the document includes a top level node and DtD stuff, it's not a slam dunk inheritance, but I see your point.