It would be nice if we had a C++ like class template functionality for LabView classes.
Templates are a powerful concept. Being able to provide the type of control in a class at edit time would allow users to create reusable classes, like data structures. It would be nice if we had a way to select a control and make it part of a template, so that we could pass the data type of that control in at edit time without changing the base definition of the class, and thus be able to reuse the class in several instances and never have to rewrite any code.
A great example would be the node of a tree. If we were to have 2 classes Tree.lvclass & TreeNode.lvclass. Assume that the Tree class contains an array of nodes and VIs to add, remove, insert, and recurse the nodes in the array. Assume that a node contains a numeric which is the index in the tree array to its parent and an array of numerics which are the indexes into the array of the nodes children. We also need a control in the node that stores our data. We will call it data, and it will be of type LogData.lvclass.
The tree works well and great for children of LogData.lvclass, but if we decide we now also need a tree to hold FilterData, we can't just swap out LogData.lvclass for FilterData.lvclass in the TreeNode.lvclass. Because then we wouldn't be able to put LogData classes into our tree node anymore.
Class Templates would allow us to tell the TreeNode Class that the type of the control data can be changed at edit time, and in fact is worthless unless we give it a type. Thus we can create several instances of the Tree class and feed the desired type down into the TreeNode, and we can in fact have 2 different trees containing to different types of data, while still reusing the same Tree code.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.