/usr/share/titan/help/info/template.html is in eclipse-titan 6.3.1-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | <!--
Copyright (c) 2000-2017 Ericsson Telecom AB
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
Contributors:
Baji, Laszlo
Balasko, Jeno
Csorba, Mate
Farkas, Laszlo
Gecse, Roland
Szabados, Kristof
Szabo, Janos Zoltan – initial implementation
-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Language" content="en-us">
<title>template</title>
</head>
<body bgcolor="#DAD3C5" vlink="#0094D2" link="#003258">
<table align="left" border="0" cellspacing="0" cellpadding="0" valign=top>
<tr>
<td width=105 height=40><a href="https://projects.eclipse.org/projects/tools.titan"><img src="../images/titan_transparent.gif" border=0 width=105 height=40 align="left" alt="Titan"></a></td>
</tr>
</table>
<table border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td><a href="../titan_main.html" alt="contents"><img border="0" src="../images/ao.jpg" width="53" height="40"></a></td>
<td><a href="../titan_index.html" alt="index"><img border="0" src="../images/up.jpg" width="53" height="40"></a></td>
<td><a href="system.html" alt="previous"><img border="0" src="../images/left.jpg" width="53" height="40"></a></td>
<td><a href="testcase.html" alt="next"><img border="0" src="../images/right.jpg" width="53" height="40"></a></td>
</tr>
</table>
<p><br clear="all">
</p>
<hr>
<h1>template</h1>
<hr align="left" width="75%">
<p>The keyword is a homonym. It is used to...
<ol>
<li>specify a set of values to be sent or received (<a href="#Templates">see below</a>);</li>
<li>extend the range of allowed parameters (<a href="function.html#template">see here</a> <a href="#Example 3">and here</a>).</li>
</ol>
<p>Related keywords:</p>
<ul>
<li><a href="modifies.html"><b><font face="Courier New" color="#003258" size="4">modifies</font></b></a> (sense 1)</li>
<li><a href="complement.html"><b><font face="Courier New" color="#003258" size="4">complement</font></b></a> (sense 1)</li>
<li><a href="ifpresent.html"><b><font face="Courier New" color="#003258" size="4">ifpresent</font></b></a> (sense 1)</li>
<li><a href="sizeof.html"><b><font face="Courier New" color="#003258" size="4">sizeof</font></b></a> (sense 1)</li>
<li><a href="subset.html"><b><font face="Courier New" color="#003258" size="4">subset</font></b></a> (sense 1)</li>
<li><a href="superset.html"><b><font face="Courier New" color="#003258" size="4">superset</font></b></a> (sense 1)</li>
<li><a href="pattern.html"><b><font face="Courier New" color="#003258" size="4">pattern</font></b></a>
<li><a href="permutation.html"><b><font face="Courier New" color="#003258" size="4">permutation</font></b></a> (sense 1)</li>
<li><a href="function.html"><b><font face="Courier New" color="#003258" size="4">function</font></b></a> (sense 2)</li>
</ul>
<hr align="left" width="75%">
<p>1. <a name="Templates">Templates</a> are used either to test whether a set of received values matches the template specification or to transmit a set of distinct values.
<ul>
<li>Templates used to receive messages have the advantage that all valid message variants may be described in a single template. When a message arrives, the program can decide whether it is a
valid one or not. This procedure is called matching.</li>
<p>
<li>Templates used to send messages are advantageous because they can be parameterized, thus, reused. All fields of these templates must have a determined value at the point when a message is
sent using them. These templates may be used to receive messages as well, but only when all fields of the expected message are fixed and known beforehand.</li>
</p>
</ul>
<hr align="left" width="50%">
<div align="center">
<center>
<table border="0" width="90%" bgcolor="#FFB599" cellpadding="4">
<tr>
<td width="100%">
<h3 align="center"><font face="Courier New" color="#003258" size="5"><b>template</b></font> <i>type identifier </i>[<i> formal_parameter_list</i> ] [<font face="Courier New" color="#003258"
size="5"><b> modifies</b></font> <i>base_template_identifier</i> ] := <i>body </i></h3>
</td>
</tr>
</table>
</center>
</div>
<ul>
<li>
<p><i>type</i> specifies the legal set of values of the template. In case of structured types it also determines the fields of the template.</p>
</li>
<li>
<p><i>identifier</i> is a name used to refer to the template. Must begin with a letter, may contain letters, numbers and
underscore characters. According to the Naming convention, the prefix <b>t_</b> or <b>tr_</b> is recommended. The former one is used denote a
specific value the template used with sending operations, whereas the latter one is used to denote a receiving template including field matching.</p>
</li>
<li>
<p><i> formal_parameter_list</i> provides the list of the parameters of the template. The formal parameters themselves can be templates or values. (In the first case, the keyword is used in
sense 2., <a href="#Example 3">see example</a>) These optional parameters may be used to alter the template at every invocation.</p>
</li>
<li>
<p><font face="Courier New"><b>modifies</b></font> denotes a <a href="#Example 4">derived template</a> where only some of the fields of the original template are changed.</p>
</li>
<li>
<p><i>base_template_identifier</i> identifies the parent template some of the field of which are modified. Both templates have the same fields.</p>
</li>
<li>
<p><i>body</i> lists the permitted values for each field: constants, matching expressions, templates or parameter references shall be assigned to each field of a template. The matching
mechanisms are elucidated in detail in Annex B of the standard. Below, abundant examples are given as illustrations.</p>
</li>
</ul>
<hr align="left" width="50%">
<p>Examples:</p>
<ol>
<li><a href="#parametrized">Parameterized value list template</a></li>
<li><a href="#Example 2">Value range template, parameterized with a template parameter</a></li>
<li><a href="#Example 3">Complemented value list template</a></li>
<li><a href="#ifpresent">Matching not omitted optional fields only</a></li>
<li><a href="#subset">Excluding a field with superfluous elements</a></li>
<li><a href="#superset">Excluding a field with missing elements</a></li>
<li><a href="#Example 7">Character pattern matching</a></li>
<li><a href="#Example 4">Modified template</a></li>
</ol>
<hr align="left" width="50%">
<p><a name="parametrized">Example</a> 1 (parameterized value list template):
<p><font face="Courier New">type record MyMessageType {<br>
<blockquote>integer field1 optional,<br>
charstring field2,<br>
boolean field3<br>
}</blockquote>
<p>template MyMessageType tr_MyTemplate (boolean pl_param) := {<br>
<blockquote>field1 := ?,<br>
field2 := (âBâ, âOâ, âQâ),<br>
field3 := pl_param<br>
}</blockquote>
</font>
<p>First, we define a record (MyMessageType) containing three fields, the first one being optional. The type of the template will be the one just defined. The template we'll define is called
tr_MyTemplate. In the template name prefix, 't' stands for 'template' and 'r' for receiving.<br>
The template accepts the following messages: the first field must be present, but its content is don't care. The second field may have the value B, O or Q. The value of the last field must be in
function of the parameter pl_param either true or false.<br>
The template can be used for receiving only, because it contains an undefined field (the first one).</p>
<hr align="left" width="25%">
<p><a name="Example 2">Example 2</a> (value range template, parameterized with a template parameter):
<p><font face="Courier New">type record MujMessageType {<br>
<blockquote>integer field1 optional,<br>
charstring field2,<br>
float field3<br>
}</blockquote>
<p>template MujMessageType tr_MujTemplate (template integer pl_parametr) := {<br>
<blockquote>field1 := pl_parametr,<br>
field2 := (âCâ .. âXâ),<br>
field3 := (1.0 .. 1.37)<br>
}</blockquote>
</font>
<p>First, we define a record (MujMessageType) containing three fields, the first one being optional. The type of the template will be the one just defined. The template we'll define is called
tr_MujTemplate.<br>
The template accepts the following messages: the first field is determined by the parameter pl_parametr. When the actual value of the parameter gives a value or a range, the field must have the
same value or range. When the parameter contains an asterisk, the field may be absent. When the parameter holds a question mark, the field must be present, but its content is don't care. The second
field may have any value from the series C, D, E, and so on to X included. The value of the last field must be between 1.0 and 1.37.<br>
The template can be used for receiving only, because it contains an undefined field (the first one).</p>
<hr align="left" width="25%">
<p><a name="Example 3">Example 3</a> (complemented value list template):
<p><font face="Courier New">type record MiaMessageType {<br>
<blockquote>float field1 optional,<br>
charstring field2,<br>
integer field3<br>
}</blockquote>
<p>template MiaMessageType tr_MiaTemplate := {<br>
<blockquote>field1 := *,<br>
field2 := complement (âCâ, "L", âXâ),<br>
field3 := (1 .. infinity)<br>
}</blockquote>
</font>
<p>First, we define a record (MiaMessageType) containing three fields, the first one being optional. The type of the template will be the one just defined. The template we'll define is called
tr_MiaTemplate.<br>
The template accepts the following messages: the first field may be either absent or present, in either case its content is don't care. The second field may have any value except the capital letters
C, L, and X. The value of the last field must be greater than 1.</p>
<hr align="left" width="25%">
<p><a name="ifpresent">Example 4</a> (matching not omitted optional fields only):
<p><font face="Courier New">type record MonMessageType {<br>
<blockquote>float field1 optional<br>
}</blockquote>
<p>template MonMessageType tr_MonTemplate := {<br>
<blockquote>field1 := (1.0 .. 1.99, 2.71) ifpresent<br>
}</blockquote>
</font>
<p>First, we define a record (MonMessageType) containing an optional field. The type of the template will be the one just defined. The template we'll define is called tr_MonTemplate.<br>
The template accepts the following messages: the first field may be either absent or present. If it is present, its value must either fit in the range 1.0 .. 1.99 or equal 2.71.</p>
<hr align="left" width="25%">
<p><a name="subset">Example 5</a> (excluding a field with superfluous elements):
<p><font face="Courier New">type set of integer MeinMessageType;</font>
<p><font face="Courier New"> template MeinMessageType tr_MeinTemplate := subset { 1, 2, 3 };</font>
<p>The template matches the sets {1,3,1,2} and {1,3} but does not match {4,3,2} and {0,1,2,3,4}. (In the latter sets there are superfluous elements, like 0 or 4)</p>
<hr align="left" width="25%">
<p><a name="superset">Example 6</a> (excluding a field with missing elements):
<p><font face="Courier New">type set of integer MeenMessageType;</font>
<p><font face="Courier New"> template MeenMessageType tr_MeenTemplate := superset { 1, 2, 3 };</font>
<p>The template matches the sets {1,3,1,2} and {0,1,2,3,4} but does not match {1,3} and {4,3,2}. (In the latter sets there are missing elements, like 2 or 1)</p>
<hr align="left" width="25%">
<p><a name="Example 7">Example 7</a>: (character pattern matching)</p>
<p><font face="Courier New">template charstring tr_AzulejoTemplate:= pattern "ab?\?xyz*";</font>
<p>The template tr_AzulejoTemplate would match any character string which consists of the characters 'ab', followed by a single arbitrary character, followed by the characters '?xyz', followed by
any number of any characters.</p>
<hr align="left" width="25%">
<p><a name="Example 4">Example 8</a> (modified template):
<p><font face="Courier New">// Parent template:<br>
template MyMsgType t_MyMessage1 := {<br>
<blockquote>field1 := 123,<br>
field2 := true<br>
}</p>
</blockquote>
// modified template:
<br>
template MyMsgType t_MyMessage2 modifies t_MyMessage1 :={
<br>
<blockquote>field2 := false<br>
}
</p>
</blockquote>
</font>
<p>The modified template (t_MyMessage2) has the same structure (the same fields) as the parent template (t_MyMessage1). The first field has the same value as specified in the parent template, but
the second one has a new value assigned (false).
<hr align="left" width="25%">
<hr align="left" width="25%">
<p><a HREF="../info/BNF.html#templatedef">BNF definition</a> of <font face="Courier New"> template</font> (sense 1)<br>
<a HREF="BNF.html#formaltemplatepar">BNF definition</a> of <font face="Courier New"> template</font> (sense 2)</p>
</body>
</html>
|