blob: 5e47e2b5bfe94e82b72e99af37fd3063d97115ef [file] [log] [blame]
<?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd-->
<html xmlns="http://www.w3.org/1999/xhtml"
>
<head><title>Annotations</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="generator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)" />
<meta name="originator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)" />
<!-- xhtml,3,next,html -->
<meta name="src" content="etrice-doc.tex" />
<meta name="date" content="2015-07-03 15:56:00" />
<link rel="stylesheet" type="text/css" href="etrice-doc.css" />
</head><body
>
<!--l. 1--><div class="crosslinks"><p class="noindent">[<a
href="etrice-docse22.html" >next</a>] [<a
href="etrice-docse20.html" >prev</a>] [<a
href="etrice-docse20.html#tailetrice-docse20.html" >prev-tail</a>] [<a
href="#tailetrice-docse21.html">tail</a>] [<a
href="etrice-docch6.html#etrice-docse21.html" >up</a>] </p></div>
<h3 class="sectionHead"><span class="titlemark">6.4 </span> <a
id="x29-1760004"></a>Annotations</h3>
<!--l. 3--><p class="noindent" >In eTrice it is possible to use annotations similar to Java annotations. Annotation types can be defined together with their
targets and other properties and later they can be used.
</p><!--l. 7--><p class="noindent" >Annotations can be processed by the code generator to influence its behavior.
<a
id="x29-176001r241"></a>
</p>
<h4 class="subsectionHead"><span class="titlemark">6.4.1 </span> <a
id="x29-1770001"></a>Annotation Type Definitions</h4>
<!--l. 11--><p class="noindent" >Examples of such definitions can be found in the files <span
class="ec-lmtt-10">Annotations.room </span>which are part of the modellibs. They contain
definitions of annotations that are recognized by the generator of the associated language.
</p><!--l. 14--><p class="noindent" >Consider e.g. the annotations definitions for Java
</p>
<!--l. 16--><div class="lstinputlisting">
<a
id="x29-177001"></a>
<span
class="ec-lmtt-9">&#x00A0;</span><br /><span class="label"><a
id="x29-177002r1"></a></span><span
class="ec-lmssbx-10x-x-90">RoomModel</span><span
class="ec-lmtt-9">&#x00A0;</span><span
class="ec-lmtt-9">room</span><span
class="ec-lmtt-9">.</span><span
class="ec-lmtt-9">basic</span><span
class="ec-lmtt-9">.</span><span
class="ec-lmtt-9">annotations</span><span
class="ec-lmtt-9">&#x00A0;</span><span
class="ec-lmtt-9">{</span><span
class="ec-lmtt-9">&#x00A0;</span><br /><span class="label"><a
id="x29-177003r2"></a></span><span
class="ec-lmtt-9">&#x00A0;</span><br /><span class="label"><a
id="x29-177004r3"></a></span><span
class="ec-lmtt-9">&#x00A0;</span><span
class="ec-lmssbx-10x-x-90">AnnotationType</span><span
class="ec-lmtt-9">&#x00A0;</span><span
class="ec-lmtt-9">BehaviorManual</span><span
class="ec-lmtt-9">&#x00A0;</span><span
class="ec-lmtt-9">{</span><span
class="ec-lmtt-9">&#x00A0;</span><br /><span class="label"><a
id="x29-177005r4"></a></span><span
class="ec-lmtt-9">&#x00A0;</span><span
class="ec-lmtt-9">&#x00A0;</span><span
class="ec-lmtt-9">&#x00A0;</span><span
class="ec-lmssbx-10x-x-90">target</span><span
class="ec-lmtt-9">&#x00A0;</span><span
class="ec-lmtt-9">=</span><span
class="ec-lmtt-9">&#x00A0;</span><span
class="ec-lmssbx-10x-x-90">ActorBehavior</span><span
class="ec-lmtt-9">&#x00A0;</span><br /><span class="label"><a
id="x29-177006r5"></a></span><span
class="ec-lmtt-9">&#x00A0;</span><span
class="ec-lmtt-9">}</span><span
class="ec-lmtt-9">&#x00A0;</span><br /><span class="label"><a
id="x29-177007r6"></a></span><span
class="ec-lmtt-9">&#x00A0;</span><br /><span class="label"><a
id="x29-177008r7"></a></span><span
class="ec-lmtt-9">&#x00A0;</span><span
class="ec-lmssbx-10x-x-90">AnnotationType</span><span
class="ec-lmtt-9">&#x00A0;</span><span
class="ec-lmtt-9">ActorBaseClass</span><span
class="ec-lmtt-9">&#x00A0;</span><span
class="ec-lmtt-9">{</span><span
class="ec-lmtt-9">&#x00A0;</span><br /><span class="label"><a
id="x29-177009r8"></a></span><span
class="ec-lmtt-9">&#x00A0;</span><span
class="ec-lmtt-9">&#x00A0;</span><span
class="ec-lmtt-9">&#x00A0;</span><span
class="ec-lmssbx-10x-x-90">target</span><span
class="ec-lmtt-9">&#x00A0;</span><span
class="ec-lmtt-9">=</span><span
class="ec-lmtt-9">&#x00A0;</span><span
class="ec-lmssbx-10x-x-90">ActorClass</span><span
class="ec-lmtt-9">&#x00A0;</span><br /><span class="label"><a
id="x29-177010r9"></a></span><span
class="ec-lmtt-9">&#x00A0;</span><span
class="ec-lmtt-9">&#x00A0;</span><span
class="ec-lmtt-9">&#x00A0;</span><span
class="ec-lmssbx-10x-x-90">mandatory</span><span
class="ec-lmtt-9">&#x00A0;</span><span
class="ec-lmssbx-10x-x-90">attribute</span><span
class="ec-lmtt-9">&#x00A0;</span><span
class="ec-lmtt-9">class</span><span
class="ec-lmtt-9">:</span><span
class="ec-lmtt-9">&#x00A0;</span><span
class="ec-lmssbx-10x-x-90">ptCharacter</span><span
class="ec-lmtt-9">&#x00A0;</span><br /><span class="label"><a
id="x29-177011r10"></a></span><span
class="ec-lmtt-9">&#x00A0;</span><span
class="ec-lmtt-9">&#x00A0;</span><span
class="ec-lmtt-9">&#x00A0;</span><span
class="ec-lmssbx-10x-x-90">mandatory</span><span
class="ec-lmtt-9">&#x00A0;</span><span
class="ec-lmssbx-10x-x-90">attribute</span><span
class="ec-lmtt-9">&#x00A0;</span><span
class="ec-lmtt-9">package</span><span
class="ec-lmtt-9">:</span><span
class="ec-lmtt-9">&#x00A0;</span><span
class="ec-lmssbx-10x-x-90">ptCharacter</span><span
class="ec-lmtt-9">&#x00A0;</span><br /><span class="label"><a
id="x29-177012r11"></a></span><span
class="ec-lmtt-9">&#x00A0;</span><span
class="ec-lmtt-9">}</span><span
class="ec-lmtt-9">&#x00A0;</span><br /><span class="label"><a
id="x29-177013r12"></a></span><span
class="ec-lmtt-9">&#x00A0;</span><br /><span class="label"><a
id="x29-177014r13"></a></span><span
class="ec-lmtt-9">}</span>
</div>
<!--l. 18--><p class="noindent" >Here we find two definitions. The meaning of those annotations will be explained later in section <a
href="#x29-1780002">6.4.2<!--tex4ht:ref: sec:predef_annotations --></a> about "<a
href="#x29-1780002">Usage and
Effect of the Pre-defined Annotations<!--tex4ht:ref: sec:predef_annotations --></a>".
</p><!--l. 21--><p class="noindent" >The annotation type definition defines a target where the annotation is allowed to be used. This can be one
of
</p>
<ul class="itemize1">
<li class="itemize">DataClass
</li>
<li class="itemize">ActorClass
</li>
<li class="itemize">ActorBehavior
</li>
<li class="itemize">ProtocolClass
</li>
<li class="itemize">CompoundProtocolClass
</li>
<li class="itemize">SubSystemClass
</li>
<li class="itemize">LogicalSystem</li></ul>
<!--l. 34--><p class="noindent" >Attributes can be added as needed and qualified as mandatory or optional. Attributes have a type (similar as the
PrimitiveType but with the understanding that ptChar is a string). Another attribute type is enum with an explicit list of
allowed enum literals.
<a
id="x29-177015r243"></a>
</p>
<h4 class="subsectionHead"><span class="titlemark">6.4.2 </span> <a
id="x29-1780002"></a>Usage and Effect of the Pre-defined Annotations</h4>
<!--l. 42--><p class="noindent" >The eTrice generators currently implement two annotations.
<a
id="Q1-29-246"></a>
</p>
<h5 class="likesubsubsectionHead"><a
id="x29-1790002"></a>BehaviorManual</h5>
<!--l. 46--><p class="noindent" >This annotation has no attribute. If specified the code generator won&#8217;t generate a state machine but part of the interface and
methods of an actor class.
</p><!--l. 49--><p class="noindent" ><span
class="ec-lmssbx-10">Java</span>
</p><!--l. 51--><p class="noindent" >An abstract base class <span
class="ec-lmtt-10">Abstract&#x003C;ActorClassName&#x003E; </span>is generated which contains ports, SAPs and attributes as members.
The <span
class="ec-lmtt-10">receiveEvent() </span>method is dispatching to distinct methods per pair of interface item (port or SAP) and message
coming in from this interface item. The user has to sub class the abstract base class and may override the generated methods
as needed.
</p><!--l. 56--><p class="noindent" ><span
class="ec-lmssbx-10">C</span>
</p><!--l. 58--><p class="noindent" >The generator is only generating a public header file and is leaving its implementation to the user.
<a
id="Q1-29-248"></a>
</p>
<h5 class="likesubsubsectionHead"><a
id="x29-1800002"></a>ActorBaseClass</h5>
<!--l. 62--><p class="noindent" >This annotation is defined for Java only. It tells the generator that the generated actor class should inherit from the specified
base class (mandatory string parameters class and package).
</p><!--l. 65--><p class="noindent" >If the actor class is modeled as having another actor base class then the annotation has no effect.
</p>
<!--l. 1--><div class="crosslinks"><p class="noindent">[<a
href="etrice-docse22.html" >next</a>] [<a
href="etrice-docse20.html" >prev</a>] [<a
href="etrice-docse20.html#tailetrice-docse20.html" >prev-tail</a>] [<a
href="etrice-docse21.html" >front</a>] [<a
href="etrice-docch6.html#etrice-docse21.html" >up</a>] </p></div>
<!--l. 1--><p class="noindent" ><a
id="tailetrice-docse21.html"></a></p>
</body></html>