Using LabVIEW Classes and Interfaces in an Application

LabVIEW classes and interfaces are user-defined data types. LabVIEW class and interface developers create and distribute these data types. The LabVIEW class or interface user does not need to know how to create a LabVIEW class or interface, but rather how to use the data type a class or interface defines in an application, what information is available to them in debugging code that uses LabVIEW classes or interfaces, and how a new version of the LabVIEW class or interface might affect the application the programmer has built.

Creating an Instance of a Class or Interface

The LabVIEW class or interface does not need to be in the project. You can add the LabVIEW class or interface to the palette so you can easily find and drag the class or interface to the block diagram or front panel window. To create an instance of the LabVIEW class or interface you receive or create, place the class library file (.lvclass) as a control or constant on the front panel or block diagram on which you want to use it. You can use a LabVIEW user-defined data type similarly to other LabVIEW data types.

Using the Class Browser window, you can place member VIs of the LabVIEW class or interface on the block diagram.

Coercing LabVIEW Classes and Interfaces

LabVIEW coerces classes and interfaces to the nearest common parent class or interface with the following rules:

Using Context Help and Probes with Locked LabVIEW Classes or Interfaces

The LabVIEW class or interface developer may lock the LabVIEW class or interface when he or she distributes the class or interface. If the LabVIEW class or interface developer locks the LabVIEW class or interface, the Context Help window only displays the data type of the class or interface and the description of the class if the developer provides one. LabVIEW also only displays the data type of the class or interface in the generic probe on a locked class or interface. You can create a non-member custom probe for a LabVIEW class or interface, however the non-member custom probe only can display the public interface of the class or interface. The LabVIEW class or interface developer also can set a custom default probe for the class or interface to provide specialized class or interface information for debugging. Work with the LabVIEW class or interface developer to provide the appropriate amount of documentation or probe information necessary for working with the LabVIEW class or interface.

Dynamic Dispatch VIs

Some member VIs of a LabVIEW class or interface can be dynamic dispatching. Dynamic dispatch methods are similar to polymorphic VIs. Where polymorphic VIs decide which VI to call depending upon the data type you wire to it, dynamic dispatch methods wait until run time to decide which member VI in the class hierarchy to call depending on the data that arrives at the input. Because a LabVIEW class or interface wire can carry data of its own type or data of any child type, LabVIEW determines which member VI in the class hierarchy to execute at run time. You can double-click dynamic dispatch member VI on the block diagram to view the particular VI that is on the block diagram. To view the other dynamic dispatch member VIs in the class hierarchy, you must view each individual VI in the class hierarchy.

Mutating Data

Tracking the version number of the LabVIEW class or interface is beneficial to LabVIEW class users who develop applications using LabVIEW classes or interfaces. For example, you have a LabVIEW class in an application that uses an unsigned 32-bit integer in the private data control of the class. A LabVIEW class developer can send you a version of the LabVIEW class that changes the numeric control in the private data control to a double-precision floating-point number. Because LabVIEW tracks version changes and knows how to flatten and unflatten data on all LabVIEW classes, you can replace the old version of the LabVIEW class with the new version and run the program without making changes to it.

Note��If you try to unflatten data from a future version of a LabVIEW class, LabVIEW returns an error. For example, this error might occur if you have data with a version number of 1.0.0.3 but the LabVIEW class in memory is version 1.0.0.2.