![]() |
![]() |
![]() |
![]() |
![]() |
Working with Classes
This section describes how Classes are handled graphically.
The class symbol is a graphical syntax for defining SDL data structures, instead of writing textual newtype definitions. It is allowed in every diagram where textual data definitions are allowed.
When analyzing the SDL specification, class symbols are translated to standard textual newtype definitions, that are used as input to the analyzer.
It is important to notice that, in a diagram, all class symbols with the same class name are treated as if they were a single, merged class. Thus two classes, both named "a_class" but defining two separate operators, would be the same as a single class named "a_class", defining both operators.
While attributes and operators may be defined and edited in the SDL Editor directly, they may also be edited in the Browse&Edit Class dialog, see Browse & Edit Class Dialog.
The complete definition of all classes may be viewed in the Browse&Edit Class dialog, but also, in SDL/PR form, in the Class information dialog. The Class Information dialog may also be used for traversing among the classes that define the SDL/PR code, see Class Information.
Both the Browse&Edit Class dialog and the Class Information dialog present the aggregate of all graphical class symbols with the same class name.
Class Information
The complete class may be presented in textual (SDL/PR) form. This is done in the read-only Class information dialog.
The dialog can be started from the Windows menu, and will also be started automatically in response to a Show symbol request concerning a class, e.g Show Error from the Organizer Log. Since the sum of all class symbols with the same name is a single class, some information may be duplicated. The PR-representation of an error is shown in the class information dialog, and it will be possible to navigate to the symbol(s) that generated the PR-code.
- Next Symbol shows the next symbol described by the PR code line on which the cursor is placed. The number within brackets shows the total number symbols in the current SDL diagram that that are described by this line. If a line does not refer to any particular symbol, Next Symbol shows the next symbol belonging to the current class. Each time Next Symbol is clicked, the next symbol that is described by the current line is shown.
- Edit Class will show the Browse & Edit Class dialog for the current class.
If the cursor is moved to another line in the text area, the Next Symbol button is updated.
Browse & Edit Class Dialog
The Browse & Edit Class dialog is opened when you select Class... from the Edit menu. The dialog allows inspection of classes in the SDL diagram.
A class is defined as the union of attributes and operators in the class symbols, and the purpose of the Browse & Edit Class dialog is to display this union and ensure consistency when editing this combined information.
The Browse & Edit Class dialog is a modal dialog, which is divided into two parts. The browsing functionality is placed at the top part of the dialog, where all classes in the diagram, and all occurrences of each class, are listed in two drop-down menus. Below, in the editing part, the name of the class, its attributes and all its operators are listed.
The Browse & Edit Class dialog is available when a single class symbol is selected, unless the class name contains incorrect syntax.
Browse
In the topmost part of the Browse & Edit Class dialog, you can browse all class symbols within the current diagram.
Edit
In the lower part of the Browse & Edit Class dialog, you can edit the name, attributes and operators of a class. Any changes will propagate into all class symbols of this class within the SDL diagram. The attributes and operators will be presented in a list. This list contains parsed information, derived from the texts in the class symbols. If a particular text contains syntax errors, attributes and operators contained in the same text might be missing from this list.
The Scope Label
The Scope label is a non-editable text field, indicating which SDL diagram the Browse & Edit Class dialog operates on.
The Classes Drop-Down Menu
The Classes drop-down menu lists all classes within the current SDL diagram. When a class is selected from this menu, its attributes and operators are displayed in the editing part of the dialog.
The Show Symbol in Option Menu
A class can be represented by several class symbols. The Show Symbol in drop-down menu lists the name of all pages with occurrences of the current class (the current class is displayed in the Classes drop-down menu). By selecting a page name in this menu, the corresponding page will be shown in the work area.
The Class Name Field
The Class Name field is an editable text field, containing the name of the class being edited.
When the OK button is clicked, changes to the Class Name field update all occurrences of the class name in all class symbols, within the current SDL diagram.
The External Check Box
The External check box is checked when a class is externally defined. This means that no PR code will be generated for this class.
When the OK button is clicked, changes to the External check box update all occurrences of the external flag, in all relevant class symbols using the current class name, within the current SDL diagram.
The Attributes and Operators Buttons
The Attributes and Operators buttons are used to select the contents of the attributes/operators list. Clicking Attributes will list all attributes defined for the selected class, while clicking Operators will list all operators.
The Attributes/Operators List
The Attributes/Operators list lists all attributes or all operators defined for the selected class.
The Clear Button
The Clear button is used to remove the attribute or operator currently selected in the Attributes/Operators list.
When the `OK' button is clicked, the selected attribute or operator is removed from all relevant class symbols with the current class name, within the current SDL diagram.
The Name Field
The Name text field contains the name of the attribute or operator currently selected in the Attributes/Operators list, if any.
When the OK button is clicked, changes to the definition of the attribute or operator are applied to all relevant class symbols with the current class name, within the current SDL diagram
The Parameters Field
The Parameters field is an editable text field, containing the parameters of a class operator. It is only editable when an operator is selected in the Attributes/Operators list.
When the OK button is clicked, changes to the parameter list are applied to the definition of that operator in all relevant class symbols with the current class name, within the current SDL diagram.
The Sort/Returnsort Field
The Sort/Returnsort field is an editable text field that is editable only when an attribute or an operator is selected in the Attributes/Operators list.
Depending on the selection, the field contains:
When the OK button is clicked, the sort of the selected attribute, or the return sort of the selected operator, is updated in all relevant class symbols with the current class name, within the current SDL diagram.
The Body Code Text
The Body Code field is a text field, containing the body code of a class operator. It is only editable when an operator is selected in the Attributes/Operators list.
The declaration part of the body code is automatically generated, and all code should be added between the two comments indicating start and end of the user defined part, respectively. The comments themselves should never be edited. For example, the operator myOp:Boolean; will have the following default declaration:
operator myOp returns Boolean {/* Start of user defined body code *//* End of user defined body code */}When the OK button is clicked, changes to the body code definition are applied to the operator in the class with the current class name, within the current SDL diagram.
The OK Button
The OK button closes the Browse & Edit Class dialog, and updates all appropriate class symbols in the current SDL diagram.
No changes are made in the diagram until the OK button is clicked. This makes it possible to specify several changes in the dialog and disregard them later, by clicking the Cancel button.
All values are syntactically checked, so it is not possible to add syntax errors to your classes by using the Browse & Edit Class dialog. This might make it impossible to delete syntactically incorrect text from class symbols using the Browse & Edit Class dialog, since the dialog relies on information obtained by parsing the relevant symbol text compartments. A syntactically incorrect text must then be corrected by editing individual symbols.
Once the OK button is clicked, changes cannot be undone.
The Cancel Button
The Cancel button will close the Browse & Edit Class dialog and discard any changes specified in the dialog.
Syntax and Definition of Class Symbols
Name
The syntax for the name field is <SDL_name>, where <SDL_name> is a name in accordance with the SDL lexical rules.
The above class symbol will generate the following newtype definition.
newtype Person
endnewtype;
newtype Ref_Person Ref(Person); endnewtype;
newtype Own_Person Own(Person); endnewtype;
newtype Oref_Person Oref(Person); endnewtype;The three pointertypes, Ref_Person, Own_Person and Oref_Person, are generated for use when creating associations and aggregations.
Attributes
The syntax for the attribute field is <name><sort><end>, where <name> and <sort> are names in accordance with the SDL lexical rules.
The above class symbol will generate the following newtype definition.
newtype Person struct
i Integer;
endnewtype;
newtype Ref_Person Ref(Person); endnewtype;
newtype Own_Person Own(Person); endnewtype;
newtype Oref_Person Oref(Person); endnewtype;Operators
The syntax for the operator field is <name>[`(`<par>{`,'<par>*')'][<returns><sort>]<end>
The above class symbol will generate the following newtype definition.
newtype Person
operators
op: Integer -> Integer;
endnewtype;
newtype Ref_Person Ref(Person); endnewtype;
newtype Own_Person Own(Person); endnewtype;
newtype Oref_Person Oref(Person); endnewtype;Syntax and Definition of Association Lines
The syntax for the role name of an association is [<name>][<constraint>], where <constraint> is in the format `{`name'}'.
Associations can be of a number of types, depending on the constraint:
- if there is no constraint, the type is Ref_<opposite_class_name>
- if the constraint is "own", the type is Own_<opposite_class_name>
- if the constraint is "oref", the type is Oref_<opposite_class_name>
- if there is a constraint, but not "own" or "oref", the type is <constraint_name>.
The above association will generate the following newtype definition.
newtype Company struct
e Ref_Employee;
endnewtype;
newtype Ref_Company Ref(Company); endnewtype;
newtype Own_Company Own(Company); endnewtype;
newtype Oref_Company Oref(Company); endnewtype;
newtype Employee
endnewtype;
newtype Ref_Employee Ref(Employee); endnewtype;
newtype Own_Employee Own(Employee); endnewtype;
newtype Oref_Employee Oref(Employee); endnewtype;Syntax and Definition of Aggregation Lines
The above aggregation will generate the following PR code.
newtype Company
a Ref_Division;
endnewtype;
newtype Ref_Company Ref(Company); endnewtype;
newtype Own_Company Own(Company); endnewtype;
newtype Oref_Company Oref(Company); endnewtype;
newtype Division
endnewtype;
newtype Ref_Division Ref(Division); endnewtype;
newtype Own_Division Own(Division); endnewtype;
newtype Oref_Division Oref(Division); endnewtype;
http://www.ibm.com/rational |
![]() |
![]() |
![]() |
![]() |