structure <name> {,<user_class>} {,<system_class>} { <data-block> }
Define an identifier structure (class).
<name>
The name of the structure or class.
<user_class>
The name of an existing class from which to derive the new class.
The new class will inherit methods and properties from this class.
<system_class>
The name of a system type (class) from which to derive the new class.
The new class will inherit methods and properties from this class.
Not all system types can be inherited from.
<data_block>
A data block defining the member elements of the new class.
XML characteristics, see here.
Multiple command lines, each of the form:
{<qual>} <type> { <element>{[<num>]} { = <value> } }
where:
<qual>
If included, may be one or more of the qualifying words
static, heritage,
private, protected
or public.
<type>
The identifier type.
<element>
The element name, unique for the structure. This is optional, see Notes
below.
<num>
The array dimension if the element is an array (may be omitted from variable-length
arrays).
<value>
A class value for the element. When an object of this structure class is
created, its element <element> will
be assigned the value <value>. This
will remain its value until changed by an object member assignment. Only
non-array elements can have a class value and only when <type>
is one of the following:
blob, channel, epointer, filter, group, layer, menupane, numeric, panel, point, projection, string, time, treenode, window, procedure/function
Values for members of type filter must be single-line definitions.
In addition, system callbacks for the class can be defined within the block. These are of the form:
<callback> = <value>
where:
<callback>
One of the following:
create - the class constructor
delete - the class destructor
ebrowse - the entity browse callback (entity derivations only)
autotext - the auto-annotate procedure (entity derivations only).
<value>
The execution meat of the callback.
Once defined, the class <name> may be used as a command to create an object of the structure type <name>.
The structure definition must have application scope, but occurrences of the structure can have any scope, or may be restricted by any classes it is derived from.
When a class with one or more graphic elements is required, the class should inherit from the system class entity. This is equivalent to declaring the class via the deprecated commands gstructure or compound.
Within the <data_block>:
<element> and <num> may be omitted when <type> is another class of structure. In such cases the members of <type> are copied into the new structure and given the same element names.
The qualifying word "static" defines an element to be a class value with the same value for all instances of <name>. Defining elements as static can result in considerable savings of object storage.
Note: for static functions and procedures, the behavior is different to that of static member functions in Java/C++. All functions and procedures, whether static or otherwise, have an implicit first parameter which is an instance of the class. If this is not used (e.g. in a function which simulates Java/C++ behavior) then it should be declared in the function something like args me=generic, and passed to the function by a caller as null.The qualifying word "heritage" defines an element to be available to child structures. For example, if an element named "t" of a structure is declared heritage, then object.child.child.t is equivalent to object.t.
When the structure class is used to marshal xml input/output, xml characteristics may be applied to the class and to individual class members by means of additional switches. See here for details.
When a class inherits from a system class, a member element is created automatically to access an object value, e.g. for a class which inherits from string a member .string of type string is made available. This value for an object of the class can usually be accessed just by reference to the object name as well as to its element, e.g.
class ~test.thing_t,string { # ... define some members }~test.thing_t myobj # The next 2 lines are equivalent myobj = 'String Value' myobj.string = 'String Value'
Define a simple class.
class ~admin.person_t { string name string address[4] numeric tel_no }
Create an occurrence (object) of the class.
~admin.person_t manager
Fill in some of its details.
manager.name = 'Ari van Essen' manager.tel_no = 7658787
Define 2 other classes, each extending the simple class.
class ~admin.male_t,~admin.person_t { numeric shirt_size }class ~admin.female_t,~admin.person_t { numeric dress_size }
Commands: |
|
Identifiers: |
scope (atable) |
Structures: |