QtModeling: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
=Qt Modeling=
[toc align_right="yes" depth="2"]


The Qt Modeling add-on module aims at providing basic model-driven features, such as the definition, storage, and manipulation of <span class="caps">MOF</span>/UML-based models as well as supporting new user-defined languages.
= Qt Modeling =


=Rationale=
The Qt Modeling add-on module aims at providing basic model-driven features, such as the definition, storage, and manipulation of MOF/UML-based models as well as supporting new user-defined languages.
 
= Rationale =


Qt Modeling Framework rationale has been driven by the following desired properties:
Qt Modeling Framework rationale has been driven by the following desired properties:


* We should support automatic code generation as much as possible. Only 8.17% of <span class="caps">UML</span> 2.4.1 meta-model properties are declared as ‘derived’ (and not derived unions), which prevent automatic code generation. For those properties, the [http://www.omg.org/spec/UML/2.4.1/Infrastructure/PDF specification] ''[omg.org]'' provide the guidelines for implementation but maybe some of them could be automatically derived from their [http://www.omg.org/spec/OCL/ <span class="caps">OCL</span>] ''[omg.org]'' specifications. QtMof and QtUml libraries already provides a mapping from <span class="caps">UML</span> to Qt5 by first generating a more Qt-ish representation of a <span class="caps">UML</span> model ([https://qt.gitorious.org/qt/qtmodeling/blobs/master/scripts/normative-xmi/xmi2qt.xq XQuery-based xmi to qtxmi conversion] ''[qt.gitorious.org]'') and then generating source code from a couple of [https://qt.gitorious.org/qt/qtmodeling/trees/master/scripts/templates well-design templates] ''[qt.gitorious.org]''. Such infrastructure has successfully been used to generate the initial skeletons of QtMof and QtUml and can also be used to convert user-defined <span class="caps">UML</span> models into Qt5 source code. As a consequence, we hopefully end up with a faithful implementation of OMG’s standardized meta-models.
* We should support automatic code generation as much as possible. Only 8.17% of UML 2.4.1 meta-model properties are declared as ‘derived’ (and not derived unions), which prevent automatic code generation. For those properties, the &quot;specification&amp;quot;:http://www.omg.org/spec/UML/2.4.1/Infrastructure/PDF provide the guidelines for implementation but maybe some of them could be automatically derived from their &quot;OCL&amp;quot;:http://www.omg.org/spec/OCL/ specifications. QtMof and QtUml libraries already provides a mapping from UML to Qt5 by first generating a more Qt-ish representation of a UML model (&quot;XQuery-based xmi to qtxmi conversion&amp;quot;:https://qt.gitorious.org/qt/qtmodeling/blobs/master/scripts/normative-xmi/xmi2qt.xq) and then generating source code from a couple of &quot;well-design templates&amp;quot;:https://qt.gitorious.org/qt/qtmodeling/trees/master/scripts/templates. Such infrastructure has successfully been used to generate the initial skeletons of QtMof and QtUml and can also be used to convert user-defined UML models into Qt5 source code. As a consequence, we hopefully end up with a faithful implementation of OMG’s standardized meta-models.
* We should leverage the development of [https://qt.gitorious.org/qt/qtmodeling/trees/master/examples/uml/qtumleditor meta-model-agnostic tools] ''[qt.gitorious.org]'' for editing, analysing, and converting any <span class="caps">MOF</span>-based model. By having no compile-time commitments with any specific <span class="caps">MOF</span>-based meta-model, such tool would be also able to handle other <span class="caps">MOF</span>-based meta-models (such as [http://www.omg.org/spec/CWM/ <span class="caps">CWM</span>] ''[omg.org]'') or even user-defined meta-models.<br /> QtMof and QtUml should provide a powerful modeling notation for early analysis of <span class="caps">MOF</span>-based models. A number of preset scripts for checking well-formed rules should be available and specific scripts may be defined by the user. <span class="caps">OCL</span> is a potential candidate as script language, but XQuery or even QtScript can also be considered. That would make possible, for example, analysis of conformance to architectural styles/patterns, continuously integrated models, and so on.
* We should leverage the development of &quot;meta-model-agnostic tools&amp;quot;:https://qt.gitorious.org/qt/qtmodeling/trees/master/examples/uml/qtumleditor for editing, analysing, and converting any MOF-based model. By having no compile-time commitments with any specific MOF-based meta-model, such tool would be also able to handle other MOF-based meta-models (such as &quot;CWM&amp;quot;:http://www.omg.org/spec/CWM/) or even user-defined meta-models.<br />QtMof and QtUml should provide a powerful modeling notation for early analysis of MOF-based models. A number of preset scripts for checking well-formed rules should be available and specific scripts may be defined by the user. OCL is a potential candidate as script language, but XQuery or even QtScript can also be considered. That would make possible, for example, analysis of conformance to architectural styles/patterns, continuously integrated models, and so on.
* A flexible mechanism for mapping of models into middleware/framework-specific artifacts should also be provided. A uml2qt mapping is already in place, but new ones should be easily defined.
* A flexible mechanism for mapping of models into middleware/framework-specific artifacts should also be provided. A uml2qt mapping is already in place, but new ones should be easily defined.
* High adherence to <span class="caps">OMG</span> standards. That includes avoiding unjustified proprietary extensions. We should consider [http://www.omg.org/spec/DD/ Diagram Definition] ''[omg.org]'' specification when exporting/importing diagrams. [http://www.omg.org/spec/UML/2.5/Beta1/ <span class="caps">UML</span> 2.5] ''[omg.org]'' is on beta stage. [http://www.omg.org/spec/QVT/ <span class="caps">QVT</span>] ''[omg.org]'' could also be supported in the future.
* High adherence to OMG standards. That includes avoiding unjustified proprietary extensions. We should consider &quot;Diagram Definition&amp;quot;:http://www.omg.org/spec/DD/ specification when exporting/importing diagrams. &quot;UML 2.5&amp;quot;:http://www.omg.org/spec/UML/2.5/Beta1/ is on beta stage. &quot;QVT&amp;quot;:http://www.omg.org/spec/QVT/ could also be supported in the future.


=Current Status=
= Current Status =


The following features are already supported in Qt Modeling:
The following features are already supported in Qt Modeling:


* <span class="caps">UML</span> 2.4.1 meta-model implementation
* UML 2.4.1 meta-model implementation
* <span class="caps">MOF</span> 2.4.1 meta-model implementation
* MOF 2.4.1 meta-model implementation
* QtUmlEditor: model-agnostic (plugin-based) editor with full capabilities for model creation and <span class="caps">XMI</span> serialization
* QtUmlEditor: model-agnostic (plugin-based) editor with full capabilities for model creation and XMI serialization
* Programmatic model manipulation via QtScript
* Programmatic model manipulation via QtScript


=Roadmap=
= Roadmap =


Expected features (probably not in first Qt Modeling release) include:
Expected features (probably not in first Qt Modeling release) include:


* Refactoring for wrappedobjects-free implementation of meta-models
* Refactoring for wrappedobjects-free implementation of meta-models
* <span class="caps">OCL</span> parser
* OCL parser
* <span class="caps">QML</span>-based (extensible plugin-based) concrete syntax
* QML-based (extensible plugin-based) concrete syntax
* Enhanced code-generation architecture
* Enhanced code-generation architecture


=Basic Usage=
= Basic Usage =
 
To link against the Qt Uml module, add this line to the project file:<br /><code><br />QT += uml<br /></code><br />Include the required headers:<br /><code><br />#include &lt;QtUml/QUmlModel&amp;gt;<br />#include &lt;QtUml/QUmlPackage&amp;gt;<br />#include &lt;QtUml/QUmlPrimitiveType&amp;gt;<br />#include &lt;QtUml/QUmlEnumeration&amp;gt;<br /></code><br />And then you can programmatically create your models:<br /><code><br />QWrappedObjectPointer&amp;lt;QModel&amp;gt; model = new QModel;<br />model-&gt;setName(&quot;MyModel&amp;quot;);
 
QWrappedObjectPointer&amp;lt;QPackage&amp;gt; package = new QPackage;<br />package-&gt;setName(&quot;Package1&amp;quot;);
 
QWrappedObjectPointer&amp;lt;QPrimitiveType&amp;gt; primitiveType = new QPrimitiveType;<br />primitiveType-&gt;setName(&quot;String&amp;quot;);
 
QWrappedObjectPointer&amp;lt;QEnumeration&amp;gt; enumeration = new QEnumeration;<br />enumeration-&gt;setName(&quot;DirectionKind&amp;quot;);<br />QWrappedObjectPointer&amp;lt;QEnumerationLiteral&amp;gt; directionIn = new QEnumerationLiteral;<br />directionIn-&gt;setName(&quot;DirectionIn&amp;quot;);<br />enumeration-&gt;addOwnedLiteral(directionIn);
 
QWrappedObjectPointer&amp;lt;QClass&amp;gt; class_ = new QClass;<br />class_<s>&gt;setName(&quot;Student&amp;quot;);<br />class_</s>&gt;setAbstract(false);
 
package-&gt;addOwnedType(enumeration);<br />package-&gt;addOwnedType(class_);
 
model-&gt;addPackagedElement(package);<br />model-&gt;addOwnedType(primitiveType);
 
// query model or perform 'well-formed/sanity/architectural conformance' checks
 
delete model.data();<br /></code><br />Maybe do some XMI serialization:<br /><code><br />QFile file&amp;amp;#40;&quot;test.xmi&amp;quot;&amp;#41;;
 
if (!file.open(QFile::WriteOnly | QFile::Text)) {<br /> qDebug() &lt;&lt; &quot;Cannot write file !&quot;;<br /> return 1;<br />}


To link against the Qt Uml module, add this line to the project file:<br /> Include the required headers:<br /> And then you can programmatically create your models:<br /> Maybe do some <span class="caps">XMI</span> serialization:<br />
QXmiWriter writer(model);<br />if (writer.writeFile&amp;amp;#40;&amp;file&amp;amp;#41;)<br /> qDebug() &lt;&lt; &quot;XMI file saved !&quot;;<br />else<br /> qDebug() &lt;&lt; &quot;Error when writing XMI file !&quot;;<br />file.close();<br /></code>


=Projects using Qt Modeling=
= Projects using Qt Modeling =


Qt Modeling has been motivated by and constitutes the basic model-driven platform for the [http://duse.sf.net DuSE-MT] ''[duse.sf.net]'' project. DuSE is a flexible and extensible approach for architectural design spaces based on [http://www.omg.org/spec/MOF/ <span class="caps">MOF</span>] ''[omg.org]'' (Meta Object Facility) and [http://www.omg.org/spec/UML/ <span class="caps">UML</span>] ''[omg.org]'' (Unified Modeling Language) technologies. DuSE defines a model-based meta-architecture which includes: i) a self-adaptation design space representation; ii) changes to be enacted in target system’s original model when navigating through the design space; iii) <span class="caps">OCL</span> rules which define valid variation points in each dimension; and iv) a set of metrics to guide architects during design trade-off analysis.
Qt Modeling has been motivated by and constitutes the basic model-driven platform for the &quot;DuSE-MT&amp;quot;:http://duse.sf.net project. DuSE is a flexible and extensible approach for architectural design spaces based on &quot;MOF&amp;quot;:http://www.omg.org/spec/MOF/ (Meta Object Facility) and &quot;UML&amp;quot;:http://www.omg.org/spec/UML/ (Unified Modeling Language) technologies. DuSE defines a model-based meta-architecture which includes: i) a self-adaptation design space representation; ii) changes to be enacted in target system’s original model when navigating through the design space; iii) OCL rules which define valid variation points in each dimension; and iv) a set of metrics to guide architects during design trade-off analysis.


DuSE is a research project and an open source initiative carried out at [http://www.ufba.br/ Federal University of Bahia] ''[ufba.br]'' (<span class="caps">UFB</span>a) and [http://www.ifba.edu.br/ Federal Institute of Education, Science and Technology of Bahia] ''[ifba.edu.br]'' (<span class="caps">IFB</span>a). The developers of DuSE are contributors of <span class="caps">KDE</span> / Qt Project and members of the [http://www.lasid.ufba.br/ Distributed Systems Laboratory] ''[lasid.ufba.br]'' (LaSiD), a research center created in 1995 and that has performing researchs in the fields of Distributed Systems, Fault Tolerance, Real-Time, Mobile Agents, and Mechatronic Systems.
DuSE is a research project and an open source initiative carried out at &quot;Federal University of Bahia&amp;quot;:http://www.ufba.br/ (UFBa) and &quot;Federal Institute of Education, Science and Technology of Bahia&amp;quot;:http://www.ifba.edu.br/ (IFBa). The developers of DuSE are contributors of KDE / Qt Project and members of the &quot;Distributed Systems Laboratory&amp;quot;:http://www.lasid.ufba.br/ (LaSiD), a research center created in 1995 and that has performing researchs in the fields of Distributed Systems, Fault Tolerance, Real-Time, Mobile Agents, and Mechatronic Systems.


[http://dusearchitects.files.wordpress.com/2013/03/duse-mt.png [[Image:duse-mt.png|DuSE-MT]]] ''[dusearchitects.files.wordpress.com]''
&quot;[[Image:http://dusearchitects.files.wordpress.com/2013/03/duse-mt.png?w=584&amp;h=318|DuSE-MT]]&quot;:http://dusearchitects.files.wordpress.com/2013/03/duse-mt.png


DuSE-MT integrates DuSE’s design spaces meta-model, algorithms, and mechanisms into an extensible and user-friendly supporting tool. DuSE-MT defines a flexible architecture which enables the use of connector plugins for system identification in a range of platforms. Each connector plugin enables the probing of target systems developed for that specific platform, gathering input/output relationships between system’s controlled/measured parameters and allowing off-line and on-line system identification.
DuSE-MT integrates DuSE’s design spaces meta-model, algorithms, and mechanisms into an extensible and user-friendly supporting tool. DuSE-MT defines a flexible architecture which enables the use of connector plugins for system identification in a range of platforms. Each connector plugin enables the probing of target systems developed for that specific platform, gathering input/output relationships between system’s controlled/measured parameters and allowing off-line and on-line system identification.


=Contribute !=
= Contribute ! =


All contributions are pretty welcome as usual. All development is done through [[Setting up Gerrit|Gerrit]] ''[wiki.qt.io]''. Therefore, those wishing to be involved in the development process must have a Qt developer account. More information about the registration process and development can be found [[Code Reviews|here]] ''[wiki.qt.io]''.
All contributions are pretty welcome as usual. All development is done through &quot;Gerrit&amp;quot;:http://wiki.qt.io/Setting_up_Gerrit. Therefore, those wishing to be involved in the development process must have a Qt developer account. More information about the registration process and development can be found &quot;here&amp;quot;:http://wiki.qt.io/Code_Reviews.


For those of you who want just trying it out, simply clone the Qt Modeling repository:<br /> and run the usual qmake/make recipe from a Qt5 installation.
For those of you who want just trying it out, simply clone the Qt Modeling repository:<br /><code><br />git clone git://gitorious.org/qt/qtmodeling.git<br /></code>

Revision as of 09:06, 24 February 2015

[toc align_right="yes&quot; depth="2&quot;]

Qt Modeling

The Qt Modeling add-on module aims at providing basic model-driven features, such as the definition, storage, and manipulation of MOF/UML-based models as well as supporting new user-defined languages.

Rationale

Qt Modeling Framework rationale has been driven by the following desired properties:

  • We should support automatic code generation as much as possible. Only 8.17% of UML 2.4.1 meta-model properties are declared as ‘derived’ (and not derived unions), which prevent automatic code generation. For those properties, the "specification&quot;:http://www.omg.org/spec/UML/2.4.1/Infrastructure/PDF provide the guidelines for implementation but maybe some of them could be automatically derived from their "OCL&quot;:http://www.omg.org/spec/OCL/ specifications. QtMof and QtUml libraries already provides a mapping from UML to Qt5 by first generating a more Qt-ish representation of a UML model ("XQuery-based xmi to qtxmi conversion&quot;:https://qt.gitorious.org/qt/qtmodeling/blobs/master/scripts/normative-xmi/xmi2qt.xq) and then generating source code from a couple of "well-design templates&quot;:https://qt.gitorious.org/qt/qtmodeling/trees/master/scripts/templates. Such infrastructure has successfully been used to generate the initial skeletons of QtMof and QtUml and can also be used to convert user-defined UML models into Qt5 source code. As a consequence, we hopefully end up with a faithful implementation of OMG’s standardized meta-models.
  • We should leverage the development of "meta-model-agnostic tools&quot;:https://qt.gitorious.org/qt/qtmodeling/trees/master/examples/uml/qtumleditor for editing, analysing, and converting any MOF-based model. By having no compile-time commitments with any specific MOF-based meta-model, such tool would be also able to handle other MOF-based meta-models (such as "CWM&quot;:http://www.omg.org/spec/CWM/) or even user-defined meta-models.
    QtMof and QtUml should provide a powerful modeling notation for early analysis of MOF-based models. A number of preset scripts for checking well-formed rules should be available and specific scripts may be defined by the user. OCL is a potential candidate as script language, but XQuery or even QtScript can also be considered. That would make possible, for example, analysis of conformance to architectural styles/patterns, continuously integrated models, and so on.
  • A flexible mechanism for mapping of models into middleware/framework-specific artifacts should also be provided. A uml2qt mapping is already in place, but new ones should be easily defined.
  • High adherence to OMG standards. That includes avoiding unjustified proprietary extensions. We should consider "Diagram Definition&quot;:http://www.omg.org/spec/DD/ specification when exporting/importing diagrams. "UML 2.5&quot;:http://www.omg.org/spec/UML/2.5/Beta1/ is on beta stage. "QVT&quot;:http://www.omg.org/spec/QVT/ could also be supported in the future.

Current Status

The following features are already supported in Qt Modeling:

  • UML 2.4.1 meta-model implementation
  • MOF 2.4.1 meta-model implementation
  • QtUmlEditor: model-agnostic (plugin-based) editor with full capabilities for model creation and XMI serialization
  • Programmatic model manipulation via QtScript

Roadmap

Expected features (probably not in first Qt Modeling release) include:

  • Refactoring for wrappedobjects-free implementation of meta-models
  • OCL parser
  • QML-based (extensible plugin-based) concrete syntax
  • Enhanced code-generation architecture

Basic Usage

To link against the Qt Uml module, add this line to the project file:

<br />QT += uml<br />


Include the required headers:

<br />#include &lt;QtUml/QUmlModel&amp;gt;<br />#include &lt;QtUml/QUmlPackage&amp;gt;<br />#include &lt;QtUml/QUmlPrimitiveType&amp;gt;<br />#include &lt;QtUml/QUmlEnumeration&amp;gt;<br />


And then you can programmatically create your models:

<br />QWrappedObjectPointer&amp;lt;QModel&amp;gt; model = new QModel;<br />model-&gt;setName(&quot;MyModel&amp;quot;);

QWrappedObjectPointer&amp;lt;QPackage&amp;gt; package = new QPackage;<br />package-&gt;setName(&quot;Package1&amp;quot;);

QWrappedObjectPointer&amp;lt;QPrimitiveType&amp;gt; primitiveType = new QPrimitiveType;<br />primitiveType-&gt;setName(&quot;String&amp;quot;);

QWrappedObjectPointer&amp;lt;QEnumeration&amp;gt; enumeration = new QEnumeration;<br />enumeration-&gt;setName(&quot;DirectionKind&amp;quot;);<br />QWrappedObjectPointer&amp;lt;QEnumerationLiteral&amp;gt; directionIn = new QEnumerationLiteral;<br />directionIn-&gt;setName(&quot;DirectionIn&amp;quot;);<br />enumeration-&gt;addOwnedLiteral(directionIn);

QWrappedObjectPointer&amp;lt;QClass&amp;gt; class_ = new QClass;<br />class_<s>&gt;setName(&quot;Student&amp;quot;);<br />class_</s>&gt;setAbstract(false);

package-&gt;addOwnedType(enumeration);<br />package-&gt;addOwnedType(class_);

model-&gt;addPackagedElement(package);<br />model-&gt;addOwnedType(primitiveType);

// query model or perform 'well-formed/sanity/architectural conformance' checks

delete model.data();<br />


Maybe do some XMI serialization:

<br />QFile file&amp;amp;#40;&quot;test.xmi&amp;quot;&amp;#41;;

if (!file.open(QFile::WriteOnly | QFile::Text)) {<br /> qDebug() &lt;&lt; &quot;Cannot write file !&quot;;<br /> return 1;<br />}

QXmiWriter writer(model);<br />if (writer.writeFile&amp;amp;#40;&amp;file&amp;amp;#41;)<br /> qDebug() &lt;&lt; &quot;XMI file saved !&quot;;<br />else<br /> qDebug() &lt;&lt; &quot;Error when writing XMI file !&quot;;<br />file.close();<br />

Projects using Qt Modeling

Qt Modeling has been motivated by and constitutes the basic model-driven platform for the "DuSE-MT&quot;:http://duse.sf.net project. DuSE is a flexible and extensible approach for architectural design spaces based on "MOF&quot;:http://www.omg.org/spec/MOF/ (Meta Object Facility) and "UML&quot;:http://www.omg.org/spec/UML/ (Unified Modeling Language) technologies. DuSE defines a model-based meta-architecture which includes: i) a self-adaptation design space representation; ii) changes to be enacted in target system’s original model when navigating through the design space; iii) OCL rules which define valid variation points in each dimension; and iv) a set of metrics to guide architects during design trade-off analysis.

DuSE is a research project and an open source initiative carried out at "Federal University of Bahia&quot;:http://www.ufba.br/ (UFBa) and "Federal Institute of Education, Science and Technology of Bahia&quot;:http://www.ifba.edu.br/ (IFBa). The developers of DuSE are contributors of KDE / Qt Project and members of the "Distributed Systems Laboratory&quot;:http://www.lasid.ufba.br/ (LaSiD), a research center created in 1995 and that has performing researchs in the fields of Distributed Systems, Fault Tolerance, Real-Time, Mobile Agents, and Mechatronic Systems.

"DuSE-MT":duse-mt.png

DuSE-MT integrates DuSE’s design spaces meta-model, algorithms, and mechanisms into an extensible and user-friendly supporting tool. DuSE-MT defines a flexible architecture which enables the use of connector plugins for system identification in a range of platforms. Each connector plugin enables the probing of target systems developed for that specific platform, gathering input/output relationships between system’s controlled/measured parameters and allowing off-line and on-line system identification.

Contribute !

All contributions are pretty welcome as usual. All development is done through "Gerrit&quot;:http://wiki.qt.io/Setting_up_Gerrit. Therefore, those wishing to be involved in the development process must have a Qt developer account. More information about the registration process and development can be found "here&quot;:http://wiki.qt.io/Code_Reviews.

For those of you who want just trying it out, simply clone the Qt Modeling repository:

<br />git clone git://gitorious.org/qt/qtmodeling.git<br />