Use a G Type document with class functionality to define the fields and methods of a class. A class object on the diagram of a VI can have a specific value for each field and can perform each method on the class G Type document.
You cannot remove class functionality after you add it to a G Type document.
After you add class functionality to a G Type, the G Type document is split into two views:
- Data—The fields that apply to a class object on the diagram of a VI. The palette contains controls and indicators you can use to set the fields of the class.
- Member List—The list of methods that are a part of the class and have access to the fields on the Data view.
Compare the fields and methods of the class you want to create with that of other classes in your project to avoid duplicating code. If two classes in your program share the same fields and methods, consider merging the two classes into a single class.
Complete the following steps to create a class using a G Type document.
Add a G Type document to your project.
Open the G Type document.
On the Document tab, click Add class functionality.
To add a class field, add a control or indicator to the Data view of the class G Type document.
To add a class method, drag a file from the Project Files tab onto the Member List of the class G Type document or click Add member on the G Type document toolbar to select a template to use as a starting point.
|VI for data member access
||Create an interface that other parts of your program can use to read or write to a class field.
You can only create a VI for data member access if a control or indicator is present on the Data view of the class G Type document.
|VI from dynamic dispatch template
||Create a version of a VI specific to the class. The program chooses the version of the VI to execute at run time based on the object the VI input accepts.
|VI from static dispatch template
||Create a VI that has the same functionality for all class objects it accepts.
|VI for override
||Create a VI that overrides a method on the Member List of a parent class in your project.
The option to create a VI for override is available only when the Member List of the parent class contains a valid member VI to override.
||Create an empty VI for the class.
||Create a property that can use VIs you create to access fields on the Data view.