second mapping steals first one [message #1043373] |
Wed, 17 April 2013 12:12  |
Eclipse User |
|
|
|
Hello,
I want to transform a UML-Statechart into a Class diagramm:
modeltype UML uses "http://www.eclipse.org/uml2/4.0.0/UML";
transformation state2class(in stateM:UML,out classM:UML);
property curmainclass : UML::Class = null;
main()
{
stateM.objectsOfType(StateMachine)->map toPackage();
}
mapping StateMachine::toPackage() : UML::Package
{
name := self.name;
nestedPackage := self.region.map toPackage();
}
mapping Region::toPackage() : UML::Package
{
name := self.name;
var oberklasse = object Class {};
oberklasse.name := "State";
/*!1!*/
oberklasse.ownedOperation := self.transition.map transToOp();
ownedType += oberklasse;
curmainclass := oberklasse;
ownedType += self.subvertex.map toClass();
}
/* jeder Knoten wird in eine Klasse umgewandelt */
mapping Vertex::toClass() : UML::Class
{
name := self.name;
result.superClass += curmainclass;
/*!2!*/
result.ownedOperation += self.container.transition->select(t | t.target = self).map transToOp();
}
mapping Transition::transToOp() : UML::Operation
{
name := self.name;
}
In the output without /*!2!*/ the Class "State" has all the transitions as Operations.
Now /*!2!*/ generates Operations in the concrete State-classes, but there the operations in the Class "State" are missing.
Why ?
May a Mapping has a implicit relation and QVTo can generate only 1:1-Mappings ?
|
|
|
|
|
|
RE: Statecharts (was Re: second mapping steals first one) [message #1044065 is a reply to message #1043902] |
Thu, 18 April 2013 09:02  |
Eclipse User |
|
|
|
Hi
Direct M2T is easier when it's easier, but increasingly hard as the
problem gets more complex. Often difficult to re-use.
Since neither Java nor C++ has any StateMachine concepts, you will have
to realize them using Classes and operations, so you could consider
An M2M from: OO-with-states to OO-without-states
so that you can re-use an existing M2T for OO-without-states to code.
The M2M can be OO implementation language neutral and so re-useable.
If your target code is Java, then EMF code gen is viable for the
structure and OCL code gen for the behaviour.
Regards
Ed Willink
On 18/04/2013 09:42, Rudolf Weber wrote:
> General question for QvTo:
> Ok, I have now transformed a statechart-model to a classmodel.
> But the UML-Classmodel doesn't have the semantic to specify the
> operations.
> (I can't see it in the UML2.4.1 Infrastructure/Superstructure)
> (May in future an operation have a Action-Sequence as implementation)
> Generate code from the generated classes lacks information.
>
> QVto M2T like Acceleo
> So Statechart -------> Classmodell ---> Code seems not the practical
> way ?
>
> M2T
> Statechart -------------> Code
>
> seems simpler and better.
>
> Regards Rudolf Weber
|
|
|
Powered by
FUDForum. Page generated in 0.04655 seconds