comp.lang.ada
 help / color / mirror / Atom feed
From: "Hibou57 (Yannick Duchêne)" <yannick_duchene@yahoo.fr>
Subject: Re: Ada and UML
Date: Fri, 3 Sep 2010 06:18:38 -0700 (PDT)
Date: 2010-09-03T06:18:38-07:00	[thread overview]
Message-ID: <156c1bf7-8744-43a0-b620-017244d4763d@k17g2000prf.googlegroups.com> (raw)
In-Reply-To: op.vifvmexfule2fv@garhos

On 3 sep, 06:19, Yannick Duchêne (Hibou57) <yannick_duch...@yahoo.fr>
wrote:
> No, that is solved. You can do Ada with it

Here is a tiny example, just to show to people with curiosity. This
lack many and many things, this is just to show.

First, the Model to Text transformation. It is able to generate a
package with contained classes implemented as records whose full view
is private. Methods which are not of UML public visibility are
declared in the Ada package private part, the others, in the public
part. Generate the *.ads source only.


   <%metamodel http://www.eclipse.org/uml2/2.0.0/UML%>

   <%script type="uml.NamedElement" name="asTypeName" post="trim()"%>
   <%args(0).name%>_Type

   <%script type="uml.Operation" name="asParameterList"
post="trim()"%>
   Self : <%asTypeName(args(0).parent())%>
   <%if (eAllContents("Parameter")) {%>
      <%for (eAllContents("Parameter")) {%>
         <%if (!name.equalsIgnoreCase("return")) {%>
         ; <%name%> : <%asTypeName(type)%>
         <%}%>
      <%}%>
   <%}%>)

   <%script type="uml.Operation" name="asSignature" post="trim()"%>
   <%if (type == "") {%>
      procedure <%name%> (
      <%asParameterList(current)%>;
   <%}else{%>
      function <%name%> (
      <%asParameterList(current)%>
      return <%asTypeName(type)%>;
   <%}%>

   <%script type="uml.Package" name="Generator_1" file="<%name%>.ads"
%>

   package <%name%> is

      <%for (eAllContents("Class")) {%>
         type <%asTypeName(current)%> is private;

         <%for (eAllContents("Operation")) {%>
            <%if (visibility == "public") {%>
               <%asSignature(current)%>
            <%}%>
         <%}%>
      <%}%>

   private

      <%for (eAllContents("Class")) {%>
         type <%asTypeName(current)%> is record
            <%for (eAllContents("Property")) {%>
               <%name%> : <%asTypeName(type)%>;
            <%}%>
         end record; --  <%asTypeName(current)%>

         <%for (eAllContents("Operation")) {%>
            <%if (visibility != "public") {%>
               <%asSignature(current)%>
            <%}%>
         <%}%>
      <%}%>

   end <%name%>;




Then, a sample UML model it can be applied to (to access XML source of
a model, just access it as a text file):


   <?xml version="1.0" encoding="UTF-8"?>
   <uml:Model xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/
XMI/2.1" xmlns:uml="http://www.eclipse.org/uml2/3.0.0/UML"
xmi:id="_qb8akM37EdqwVrslYOdUDA">
     <packagedElement xmi:type="uml:Package"
xmi:id="_w8IxIM37EdqwVrslYOdUDA" name="Greetings">
       <ownedComment xmi:id="_c4EW8LcvEd-uHOxBOe6bQQ"
annotatedElement="_yjuScLcsEd-uHOxBOe6bQQ">
         <body>Your three cents here.</body>
       </ownedComment>
       <packagedElement xmi:type="uml:Class" xmi:id="_yjuScLcsEd-
uHOxBOe6bQQ" name="Greeting_Box" clientDependency="_fD-ewLc4Ed-
uHOxBOe6bQQ">
         <ownedAttribute xmi:id="_gbfysrc1Ed-uHOxBOe6bQQ"
name="Greating_Counter" visibility="package" type="_ImL_4Lc0Ed-
uHOxBOe6bQQ"/>
         <ownedOperation xmi:id="_pudakLcvEd-uHOxBOe6bQQ"
name="Say_Hi"/>
         <ownedOperation xmi:id="_m3Xp8rc1Ed-uHOxBOe6bQQ"
name="Set_Greeting_Counter">
           <ownedParameter xmi:id="_AFKIELc2Ed-uHOxBOe6bQQ"
name="Value" type="_ImL_4Lc0Ed-uHOxBOe6bQQ"/>
         </ownedOperation>
         <ownedOperation xmi:id="_P3XxsLc4Ed-uHOxBOe6bQQ"
name="Get_Greeting_Counter">
           <ownedParameter xmi:id="_lddJULc4Ed-uHOxBOe6bQQ"
name="return" type="_ImL_4Lc0Ed-uHOxBOe6bQQ" direction="return"/>
         </ownedOperation>
         <ownedOperation xmi:id="_NMRYMLdKEd--x_e0zw638A"
name="Have_A_Private_Time" visibility="private"/>
       </packagedElement>
       <packagedElement xmi:type="uml:PrimitiveType"
xmi:id="_ImL_4Lc0Ed-uHOxBOe6bQQ" name="Natural"/>
       <packagedElement xmi:type="uml:Dependency" xmi:id="_fD-ewLc4Ed-
uHOxBOe6bQQ" name="Dependency1" supplier="_ImL_4Lc0Ed-uHOxBOe6bQQ"
client="_yjuScLcsEd-uHOxBOe6bQQ"/>
     </packagedElement>
   </uml:Model>




Sample output. Note that I did not work the generated source
formating ; I know it's ugly.


   package Greetings is

         type Greeting_Box_Type is private;

               procedure Say_Hi (
      Self : Greeting_Box_Type
      );
               procedure Set_Greeting_Counter (
      Self : Greeting_Box_Type
            ; Value : Natural_Type
      );
               function Get_Greeting_Counter (
      Self : Greeting_Box_Type
      )
      return Natural_Type;

   private

         type Greeting_Box_Type is record
               Greating_Counter : Natural_Type;
         end record; --  Greeting_Box_Type

               procedure Have_A_Private_Time (
      Self : Greeting_Box_Type
      );

   end Greetings;


Has a taste of both ASIS (due to semantic access of an UML "source")
and XSLT (due to transform). Never seen like this before.

There may be provision to generate full source when an implementation
is a pure state machine. At least, this is able to generate a more or
less detailed skeleton, but with a better view on the overall types +
tagged + packages architecture/cooperation and probably more.

The limitation I feel: not as much easy and clean to access UML
diagrams semantic this way as it is to access Ada sources semantic
using ASIS. May be this is partly due to the script-like language
which is involved.


Well, any one can now push Ada in UML shops (or perhaps this is UML
pushing in an Ada shop, lol)


How does it work with HOOD ? Does it work the same way ?



  parent reply	other threads:[~2010-09-03 13:18 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-31 10:12 Ada and UML Yannick Duchêne (Hibou57)
2010-08-31 11:05 ` Yannick Duchêne (Hibou57)
2010-08-31 11:54   ` Yannick Duchêne (Hibou57)
2010-08-31 16:34     ` Matteo Bordin
2010-08-31 21:20       ` nobody
2010-09-02  0:19         ` Yannick Duchêne (Hibou57)
2010-09-02  6:14           ` Simon Wright
2010-09-02 20:33           ` nobody
2010-08-31 23:14       ` Yannick Duchêne (Hibou57)
2010-08-31 23:31         ` Yannick Duchêne (Hibou57)
2010-09-01  8:20         ` Matteo Bordin
2010-09-01 18:44           ` Simon Wright
2010-09-01 21:56             ` Simon Wright
2010-09-02  1:18             ` Yannick Duchêne (Hibou57)
2010-09-02 10:25               ` Brian Drummond
2010-09-02  0:43           ` Yannick Duchêne (Hibou57)
2010-09-02  7:50             ` Georg Bauhaus
2010-09-02 23:05               ` Yannick Duchêne (Hibou57)
2010-09-03  4:19                 ` Yannick Duchêne (Hibou57)
2010-09-03  6:54                   ` Matteo Bordin
2010-09-03 10:20                     ` Yannick Duchêne (Hibou57)
2010-09-03 11:33                       ` sjw
2010-09-03 13:18                   ` Hibou57 (Yannick Duchêne) [this message]
2010-09-03 16:14                     ` Matteo Bordin
2010-09-04 14:51                       ` Yannick Duchêne (Hibou57)
2010-09-06  9:21                         ` Matteo Bordin
2010-09-07 18:25                         ` Yannick Duchêne (Hibou57)
2010-09-03 16:16                     ` Matteo Bordin
2010-09-03 19:39                       ` Simon Wright
2010-08-31 18:25 ` Martin Krischik
2010-09-01  8:40   ` sjw
2010-09-02  0:22   ` Yannick Duchêne (Hibou57)
2010-09-02  4:48     ` J-P. Rosen
2010-09-02 10:34       ` Brian Drummond
2010-09-02 13:00         ` Robert A Duff
2010-09-02 13:24           ` Yannick Duchêne (Hibou57)
2010-09-10 20:13 ` Yannick Duchêne (Hibou57)
  -- strict thread matches above, loose matches on Subject: below --
2001-08-04  9:55 Paul Foster
2001-07-10 10:54 Death by analogy Part 2 (was Re: is ada dead?) Robert C. Leif, Ph.D.
2001-07-10 16:58 ` Al Christians
2001-07-10 18:39   ` Michael P. Card
2001-07-10 20:39     ` Al Christians
2001-07-10 21:11       ` Michael P. Card
2001-07-11  5:25         ` Ada and UML raj
2001-07-11  9:40           ` David C. Hoos, Sr.
2001-07-13 19:00           ` Nick Williams
2001-07-13 19:46             ` Ted Dennison
2001-07-17  8:25               ` David Humphris
2001-07-16  0:56             ` Ken Garlington
2001-07-17 18:59               ` Simon Wright
2001-07-23 14:38                 ` John Kern
2001-08-04  6:29                   ` Simon Wright
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox