EGL provides a variety of classifiers, each
of which is a category of types. The EGL documentation sometimes refers
to a classifier as a part type, but the word “type” in
that phrase means “kind” rather than “data type.”
If you are interested in understanding how the EGL generator works,
you can start by noting that each EGL part is an instance of a classifier.
In any case, be aware that the capabilities of a given classifier
are made available to your EGL code when you define or use a part
that is based on that classifier:
- You might define a part. For example, the EmployeeRecordType type
is in the category of Record classifiers, and the PromoteEmployee program
is in the category of Program classifiers.
- You might declare a field that is of a native type other than
a simple one. For example, if you declare a dictionary named myDictionary,
you have declared a variable of type Dictionary. In essence, the Dictionary
type is a part that is defined for you. The Dictionary type is in
the category of Class part types.
- You might use a native-type field that is defined for you. For
example, if you use the ColorKind.blue enumeration
value, you are referencing the ColorKind type. In essence, the ColorKind
type is a part that is defined for you. The part is static, which
implies that you do not declare a variable to use that part in your
EGL logic. The ColorKind type is in the category of Enumeration classifiers.
Each of the EGL parts that you develop has some or all of the following
characteristics, depending on the classifier:
- A header, which is always required. The header includes a name
and, in many cases, a stereotype.
- The end keyword, which is always required
to terminate the part.
- A set of members:
- Fields, each of which is based on either a native part of a user-defined
part.
- Functions, each of which is a logical unit that is equivalent
to a function or method in another language. However, functions do
not embed other functions.
- Constructors, each of which is a logical unit that creates an
instance of a reference type.
The members in a part are typically accessible in the same
part. However, if you declare a field, function, or constructor to
be private, the member is protected from
external access and can be accessed only within the same part. If
you do not declare a member to be private, it is said to be public.
One classifier is
Record. It enables you to define
a part with multiple fields. For example, you might use this classifier
to define a part named
CarPolicy:
Record CarPolicy type BasicRecord {}
thePolicyID STRING;
theCarCount NumberOfCars;
theDriverCount NumberofDrivers;
end
You can use a part such as
CarPolicy to declare
a variable named
myCarPolicy:
myCarPolicy CarPolicy;
The variable is called a record, and you can now assign data to
each of its fields:
myCarPolicy.thePolicyID = "ABC123";
myCarPolicy.theCarCount = 2;
myCarPolicy.theDriverCount = 2;
Another EGL classifier is
Program. You use this part
type to define a
static type, which is a unit that is
not the basis of a variable. For example, here is the program part
AssignPolicyValues:
Program AssignPolicyValues
myCarPolicy CarPolicy;
const CONSTANT_TWO INT = 2;
function main()
myCarPolicy.thePolicyID = "ABC123";
myCarPolicy.theCarCount = CONSTANT_TWO;
myCarPolicy.theDriverCount = CONSTANT_TWO;
end
end
The Program part AssignPolicyValues is a single
unit that embeds fields and functions. Those fields and functions
are program global, which means that they are accessible
from every function in the part.
Incidentally, the EGL documentation often drops the word “part”
when referring to a part that is based on a classifier other than
Record. For example, AssignPolicyValues is said to
be a “program” rather than a “Program part.”