blob: 1c4e09bfeafe2543054532719b493bba5bfece7b [file] [log] [blame]
<html><head><META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>4.4.2.&nbsp;Create Rule</title><link href="style.css" rel="stylesheet" type="text/css"><meta content="DocBook XSL Stylesheets V1.72.0" name="generator"><link rel="start" href="index.html" title="The VIATRA2 Model Transformation Framework"><link rel="up" href="sec_ASMModelManipulationRules.html" title="4.4.&nbsp;Model Manipulation Rules"><link rel="prev" href="def_ModelManipulationRule.html" title="4.4.1.&nbsp;Model Manipulation Rule"><link rel="next" href="def_DeleteRule.html" title="4.4.3.&nbsp;Delete Rule"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table summary="Navigation header" width="100%"><tr><th align="center" colspan="3">4.4.2.&nbsp;Create Rule</th></tr><tr><td align="left" width="20%"><a accesskey="p" href="def_ModelManipulationRule.html">Prev</a>&nbsp;</td><th align="center" width="60%">4.4.&nbsp;Model Manipulation Rules</th><td align="right" width="20%">&nbsp;<a accesskey="n" href="def_DeleteRule.html">Next</a></td></tr></table><hr></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="def_CreateRule"></a>4.4.2.&nbsp;Create Rule</h4></div></div></div><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip: Description"><tr><td valign="top" align="center" rowspan="2" width="25"><img alt="[Tip]" src="images/tip.png"></td><th align="left"><a name="def_CreateRule_Description"></a>Description</th></tr><tr><td valign="top" align="left"><p>
The <span class="strong"><strong>create rule</strong></span><a name="N11B97" class="indexterm"></a> can be used for model element or
relationship creation.
</p></td></tr></table></div><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important: Syntax"><tr><td valign="top" align="center" rowspan="2" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left"><a name="def_CreateRule_Syntax"></a>Syntax</th></tr><tr><td valign="top" align="left"><pre class="programlisting">
CreateRuleAST ::= <span class="token">new</span> <span class="token">(</span> CreateModelElementAST <span class="token">)</span> <span class="token">;</span>
| <span class="token">new</span> <span class="token">(</span> CreateRelationshipAST <span class="token">)</span> <span class="token">;</span>
CreateModelElementAST ::= QualifiedTypeNameAST <span class="token">(</span> VariableRefAST <span class="token">)</span> InConstraintOptAST
| QualifiedTypeNameAST <span class="token">(</span> VariableRefAST <span class="token">,</span> ArithmeticTermAST <span class="token">,</span> ArithmeticTermAST <span class="token">)</span>
InConstraintOptAST ::= $empty | <span class="token">in</span> ArithmeticTermAST
CreateRelationshipAST ::= <span class="token">supertypeOf</span> TwoParametersAST
| <span class="token">subtypeOf</span> TwoParametersAST
| <span class="token">typeOf</span> TwoParametersAST
| <span class="token">instanceOf</span> TwoParametersAST
TwoParametersAST ::= <span class="token">(</span> <a href="def_ArithmeticTerm.html" title="5.3.1.&nbsp;Arithmetic Term">ArithmeticTermAST</a> <span class="token">,</span> <a href="def_ArithmeticTerm.html" title="5.3.1.&nbsp;Arithmetic Term">ArithmeticTermAST</a> <span class="token">)</span>
</pre></td></tr></table></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note: Semantics"><tr><td valign="top" align="center" rowspan="2" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"><a name="def_CreateRule_Semantics"></a>Semantics</th></tr><tr><td valign="top" align="left"><p>
When an <span class="emphasis"><em>entity</em></span> is being created
</p><div class="itemizedlist"><ul type="disc"><li><p>it will be the instance of the specified type (<a href="def_ModelElementName.html" title="5.7.1.&nbsp;Model Element Name">qualified type name</a>),
</p></li><li><p>it will be contained either by the entity determined by the
<a href="def_ArithmeticTerm.html" title="5.3.1.&nbsp;Arithmetic Term">term</a> if the <code class="computeroutput">in</code> branch is present or by the
<code class="computeroutput">root</code> element of the model space by default, and
</p></li><li><p>a reference to it will be stored in the <a href="def_Variable.html" title="5.7.2.&nbsp;Variable">variable reference</a>.
</p></li></ul></div><p>
When a <span class="emphasis"><em>relation</em></span> is being created
</p><div class="itemizedlist"><ul type="disc"><li><p>it will be the instance of the specified type (<a href="def_ModelElementName.html" title="5.7.1.&nbsp;Model Element Name">qualified type name</a>),
</p></li><li><p>it will point from the <span class="strong"><strong>source</strong></span> model element (identified by the second
<a href="def_Variable.html" title="5.7.2.&nbsp;Variable">variable reference</a>) to the
<span class="strong"><strong>target</strong></span> model element (identified by the third <a href="def_Variable.html" title="5.7.2.&nbsp;Variable">variable reference</a>), and
</p></li><li><p>a reference to it will be stored in the <a href="def_Variable.html" title="5.7.2.&nbsp;Variable">variable reference</a>.
</p></li></ul></div><p>
If the variable is already bound when the <span class="strong"><strong>create rule</strong></span> is called
its value will be overwritten.
</p><p>
When a <a href="def_Relationship.html" title="2.2.3.&nbsp;Relationships">relationship</a> is being created
<div class="itemizedlist"><ul type="disc"><li><p><span class="emphasis"><em>supertypeOf</em></span>: the first <a href="def_ArithmeticTerm.html" title="5.3.1.&nbsp;Arithmetic Term">term</a>
identifies the supertype, and the second <a href="def_ArithmeticTerm.html" title="5.3.1.&nbsp;Arithmetic Term">term</a> identifies the subtype.
</p></li><li><p><span class="emphasis"><em>subtypeOf</em></span>: the first <a href="def_ArithmeticTerm.html" title="5.3.1.&nbsp;Arithmetic Term">term</a>
identifies the subtype, and the second <a href="def_ArithmeticTerm.html" title="5.3.1.&nbsp;Arithmetic Term">term</a> identifies the supertype.
</p></li><li><p><span class="emphasis"><em>typeOf</em></span>: the first <a href="def_ArithmeticTerm.html" title="5.3.1.&nbsp;Arithmetic Term">term</a>
identifies the type of the model element, and the second <a href="def_ArithmeticTerm.html" title="5.3.1.&nbsp;Arithmetic Term">term</a> identifies the instance.
</p></li><li><p><span class="emphasis"><em>instanceOf</em></span>: the first <a href="def_ArithmeticTerm.html" title="5.3.1.&nbsp;Arithmetic Term">term</a>
identifies the instance element, and the second <a href="def_ArithmeticTerm.html" title="5.3.1.&nbsp;Arithmetic Term">term</a> identifies the type.
</p></li></ul></div>
</p></td></tr></table></div><div class="highlights"><a name="def_CreateRule_DefinedIn"></a><p><b>Defined In:&nbsp;</b>
<a href="def_ModelManipulationRule.html" title="4.4.1.&nbsp;Model Manipulation Rule">model manipulation rule</a>
</p></div></div><div class="navfooter"><hr><table summary="Navigation footer" width="100%"><tr><td align="left" width="40%"><a accesskey="p" href="def_ModelManipulationRule.html">Prev</a>&nbsp;</td><td align="center" width="20%"><a accesskey="u" href="sec_ASMModelManipulationRules.html">Up</a></td><td align="right" width="40%">&nbsp;<a accesskey="n" href="def_DeleteRule.html">Next</a></td></tr><tr><td valign="top" align="left" width="40%">4.4.1.&nbsp;Model Manipulation Rule&nbsp;</td><td align="center" width="20%"><a accesskey="h" href="index.html">Home</a></td><td valign="top" align="right" width="40%">&nbsp;4.4.3.&nbsp;Delete Rule</td></tr></table></div></body></html>