Chapter 4 Managing Profiles
A generated file uses templates defined in metaclasses. The first template you have to define is on messages. The role of this template is to evaluate the message sequence number and to provide the name of the sender, the name of the message, and the name of the receiver for each message in the diagram.
The syntax for defining this template is the following:
.set_value(_tabs, "", new) .foreach_part(%SequenceNumber%, '.') .set_value(_tabs, " %_tabs%") .next %_tabs%%SequenceNumber%) %Sender.ShortDescription% sends message "%Name%" to %Receiver.ShortDescription%
The first part of the template aims at creating indentation according to the sequence number of the message. The macro foreach_parts loops on the sequence numbers:
.foreach_part(%SequenceNumber%, '.') .set_value(_tabs, " %_tabs%")
It browses each sequence number, and whenever a dot is found, it adds 3 empty spaces automatically for indentation. This calculates the _tab variable, which is later used to create the correct indentation based on the sequence numbering.
The last line contains the actual generated text of the template: for each sequence number, the appropriate tab value is created, followed by the name of the sender (short description), the text "sends message", then the name of the message, the text "to", and the name of the receiver.
To define a template used for generation:
.set_value(_tabs, "", new) .foreach_part(%SequenceNumber%, '.') .if (%Separator% == ".") .set_value(_tabs, " "%_tabs%) .endif .next %_tabs%%SequenceNumber%) %Sender.ShortDescription% sends message "%Name%" to %Receiver.ShortDescription%
Copyright (C) 2005. Sybase Inc. All rights reserved. |