CLASS-DEFINITION.
CLASS-DEFINITION.
Item-configuration attribute determines which configurations are in effect for this class. These configurations apply only to the definition itself, not to instances of the class that it defines. Instance configurations are described under Specifying Instance Configurations. For a description of configuration clauses, see Chapter 7, Configurations.
Providing a Class Name
Use the Class-name attribute to specify the name of the class. You can use any symbol that is not already in use. You cannot use a G2 reserved word, or any symbol that denotes a G2 data type. Once specified, the class name appears below the definitions's icon:
![]() |
The class naming convention in G2 is to use hyphens to separate words in a class name. You can use another allowable G2 character, such as an underscore (_), if you wish.
Note: All class names must be unique within your KB. A class name cannot conflict with another class name even if the definition is of a different type. For instance, you cannot create a CLASS-DEFINITION and an OBJECT-DEFINITION with the same class name.
You must complete both the Class-name and Direct-superior-classes attributes of your definition before G2 considers the definition complete and adds it to the class hierarchy and the menu structure. Until you complete both of those attributes, a definition displays INCOMPLETE in its Notes attribute, as shown in the partial definition that follows:
![]() |
Specifying the Superior Class(es)
The Direct-superior-classes attribute determines the name of one or more direct superior classes for the new class. any foundation-class in the Text Editor displays a list of all system-defined and user-defined classes (other than mixins) that can be inherited. Entering Direct Superior Classes
Providing one or more extensible direct superior classes (along with a valid class name) adds the new class to the class hierarchy. When a class exists within the class hierarchy, it inherits attributes from all of its superior classes. Note that you cannot:
If you are creating a class with multiple inheritance (more than one direct superior class), the name of the direct superior class you enter first is significant. The first class in the list is the primary direct superior class. All other direct superior classes are secondary superior classes.
Some restrictions on multiple inheritance must be observed, as described under Illegal Patterns of Multiple Inheritance.
Specifying Direct Superiors Before Creating Their Definitions
You can enter the names of direct superior classes before you have defined them. Specifying a definition with one or more direct superior classes that are not defined, however, does not add the new class to the hierarchy. It merely provides a means for you to create definitions prior to creating all of the required direct superior classes. Notes attribute of the class that names the missing superior includes an INCOMPLETE message such as:
![]() |
Using Mixin Classes
You can use some classes, called mixin classes, with one or more other direct superior classes to add specific properties to a subclass. To use a mixin class, define a class whose Direct-superior-classes attribute includes one or more of the following mixins:
GFI-DATA-SERVICE
GSI-DATA-SERVICE
GSI-MESSAGE-SERVICES
G2-TO-G2-DATA-SERVICE
G2-METER-DATA-SERVICE
UNIQUE-IDENTIFICATION
GSI-MESSAGE-SERVICE and UNIQUE-IDENTIFICATION can be mixed in with any class. The other mixins shown can be used only with subclasses of VARIABLE. Mixin classes add the following system-defined attributes to a subclass:
Specifying Instance Configurations
The Instance-configuration attribute specifies the configuration statements for all instances or subclasses of a definition. These configurations apply only to instances of the defined class, not to the definition itself. Definition configurations are described under Specifying the Item Configuration. For a description of configuration clauses, see Chapter 7, Configurations.
For instance, you may want to configure all instances of a class so that they do not include the
Delete menu option. To do this, you could enter the instance configuration as shown here in a partial definition:
![]() |
Determining the Class Inheritance Path
The Class-inheritance-path attribute specifies the inheritance path from the class you are defining to ITEM. For details, see Class-inheritance-path Attribute and Multiple Inheritance and Class Inheritance Paths.
G2 completes this attribute as soon as you enter one or more direct superior classes and close the edit for the
Direct-superior-classes attribute. You cannot edit the value of the Class-inheritance-path attribute.Class-inheritance-path attribute, the direct superior classes you specify must already exist and the inheritance you specify must be valid. Determining the Initializable System Attributes
The Initializable-system-attributes attribute lists the names of all in initializable attributes that the class definition inherits from the system-defined class(es) in its list of direct superiors. This display is read-only, and appears as soon as you specify one or more legal direct superiors as the value of a class definition's Direct-superior-classes attribute. The default value is none. PROCEDURE subclass:
![]() |
Techniques for providing default values for initializable system attributes are described under Specifying Default Values for Inherited Attributes.
Determining the Inherited User-Defined Attributes
The Inherited-attributes attribute lists the user-defined attributes that the class inherits from its superior classes. This display is read-only, and appears as soon as you specify one or more legal direct superiors as the value of a definition's Direct-superior-classes attribute. The default value is none.
Defining and Initializing Class-Specific Attributes
The Class-specific-attributes attribute defines all user-defined attributes that are specific to the class you are creating. The value of an attribute can be a value or an item. The default value of this attribute is none. none when they appear in instances and can contain a value of any G2 type when you complete them.
is a/an
is an instance of
is given by a/an
initially is
has values
with an index clause. The next sections describe each kind of attribute expression.
temperature;
maximum-height
initially is phrase. For example:
past-time initially is 10 minutes;
operator-reading initially is cool;
set-up-message initially is "The beginning of this is:";
number-of-plants-online initially is 10;
temp initially is sequence (5, 6, 7);
dim initially is structure (length: 767, height: 45387);
list-of-messages initially is an instance of a g2-list;
temperature initially is given by a float-variable
initially is phrase with:
True
False
given by phrase, followed by a variable or parameter class
OBJECT
is a and initially is phrases. For example:
temperature is a float, initially is 98.6;
maximum-height is an integer, initially is 12;
temp is a sequence, initially is sequence (6, 7, 8);
dim is a structure, initially is structure (length: 767, height: 45387)
is a phrase. For example:
temperature is a float;
maximum-height is an integer
dim is a structure
item-or-value, symbol, value, truth-value, quantity, integer, float, text, structure, or sequence.Specifying an attribute with a specific type constrains the attribute value to be of that type when:
Attribute-initializations to provide an attribute value. See Specifying Default Values for Inherited Attributes.
initially is phrase such as this:
temperature is a float, initially is 0.0;
maximum-height is an integer, initially is 0
| Attribute type | Default value |
|---|---|
float
|
0.0
|
integer
|
0
|
item-or-value
|
0.0
|
quantity
|
0.0
|
sequence
|
sequence ( )
|
structure
|
structure ( )
|
symbol
|
G2
|
text
|
""
|
truth-value
|
true
|
value
|
0.0
|
Defining an Attribute as an Object Instance
You can specify an attribute whose value is an instance of any object class, including a variable or parameter class, by using the is an instance of phrase:
attribute-name is an instance of a[n] class-name
heat-sensor is an instance of a thermometer
initially is an instance of phrase that instantiates the specified class:
inner-pressure is an instance of a float-variable, initially is an instance of a float-variable;
initially is an instance of phrase that specifies the default value as a more specific class than the type of the attribute requires:
outer-pressure is an instance of a quantitative-parameter, initially is an instance of an integer-parameter
SPECIAL-PRESSURE object, whose Inner-pressure attribute is given by a float-variable. The variable is shown in the object attribute table as asterisks (****), because it has no value. Clicking in the value of that attribute and choosing subtable displays the attribute table of the variable. You can specify the value of an attribute to be an instance of the class that defines the attribute. To prevent an infinite regress, G2 limits the depth to 20 items when you instantiate such a class. The value of the attribute in the most deeply nested instance is
none.
![]() |
Defining an Attribute for Implied Symbolic Reference
Specify an attribute that is to be used with an implied symbolic reference as follows:
pc-operating-system has values windows/nt or windows31, initially is windows/nt
has values phrase in expressions that imply an attribute. For example, using the example above for the PC class, once instances of the class exist, you could use an implied attribute reference such as:
if PC is windows/nt
pc-operating-system attribute. The statement specifies the class and a value, rather than an attribute name. From this statement, G2 infers that the expression refers to the pc-operating-system attribute, because it is the only attribute that can have the specified value.
with an index clause:
temp initially is 98, with an index
While the Text Editor does not prevent you from entering the
with an index clause after any attribute, you can index only attributes that are:
integer, text, symbol, or truth-value
integer-, text-, symbolic-, or logical-parameter
Specifying Default Values for Inherited Attributes
The Attribute-initializations attribute lets you set default values for all user-defined attributes and many system-defined attributes. System-defined attributes are part of each class in the hierarchy. You cannot change or delete them. Some system-defined attributes, like Notes and Names, appear in every G2 item. Overriding Default Values of Inherited User-Defined Attributes
The Inherited-attributes attribute lists the user-defined attributes that a class inherits from its superior classes. Each of these already has an inherited default value. Using the Attribute-initialization attribute, you can override the inherited default value of any inherited user-defined attribute.
To specify a default value for an inherited user-defined attribute:
Enter:
initially is default-value
Attribute-initializations. Separate consecutive initializations with a semicolon (;).
As part of the capability to create and complete definitions in bottom-up order, G2 allows you to specify user-defined attribute initializations for currently non-existent inherited attributes. When such an initialization exists, the definition's
Notes attribute displays a message such as the following:
![]() |
Specifying Default Values of Initializable System-Defined Attributes
The Initializable-system-attributes attribute lists the names of all initializable attributes that the definition inherits from the system-defined class(es) in its list of direct superiors. Each of these already has an inherited default value. Using the Attribute-initialization attribute, you can override the default value of any initializable system-defined attribute. array-length and the element-type for an array definition in Attribute-initializations. These two attributes appear on the attribute table of an array.
To specify a default value for an initializable system-defined attribute:
Enter:
procedure specifies default values for the initializable system attributes tracing-and-breakpoints and default-procedure-priority:
![]() |
Initializations of inherited user-defined attributes and initializable system-defined attributes can be intermixed as desired. Separate the adjacent initializations with a semicolon (;). Be careful not to confuse the different grammars of the two types of initialization.