Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [QVTo] global variables for transformation(How to set, instantiate, etc. global variables to used as additional input parameter for a transformation)
[QVTo] global variables for transformation [message #539426] Thu, 10 June 2010 12:59 Go to next message
C. Kopf is currently offline C. Kopf
Messages: 37
Registered: November 2009
Member
Hi @all:

I need to do a switch case in my transformation. Something like, if x:= true do ttransformation xyz else tranformation xyz'

due to the fact that in my case the differences between xyz and xyz' are pretty small I want to use an additional input parameter of boolean for my transformation.

I did not find a lot of information about global variables in QVTo at all. just the following:

Quote:

transformation UmlCleaning(inout umlmodel:UML14)
extends MyUmlFacilities(UML14),
access MathUtils;
var allSuper : Set(Class); // a global variable
main () {
allSuper := umlmodel.objectsOfType(Class)->collect(i|i.getAllBaseClasses());
// ....
}


(taken from QVT Specification 2.0 chapter 8.1.3)

so I tried the following:

transformation Arsep2Tsp(in arsep : ARSEP, out tsp : TSP);

var complMode_ : Boolean;

main() { 
	complMode_ := true;
	// ...
}


this does not work anyway.

So does anybody know how to use global variables?
Or even better: how to use additional parameters for a transformation?

Thanks!

Chris
Re: [QVTo] global variables for transformation [message #539472 is a reply to message #539426] Thu, 10 June 2010 17:18 Go to previous messageGo to next message
Sergey Boyko is currently offline Sergey Boyko
Messages: 162
Registered: July 2009
Senior Member
Hi C. Kopf ,

Please, consider using configuration properties.
For example, declaring configuration property of boolean in
transformation like follows:

modeltype ECORE uses "http://www.eclipse.org/emf/2002/Ecore";
transformation Ecore2Ecore(in input : ECORE, out output : ECORE);

configuration property myFlag : Boolean;

main() {
// here we can use myFlag ..
if (myFlag) then {
} endif;
}

Configuration properties appear in separate "Configuration" tab in QVTo
launch configuration so might be assumed as addition parameters to
transformation.

Regards,
Sergey.


C. Kopf wrote:
> Hi @all:
>
> I need to do a switch case in my transformation. Something like, if x:=
> true do ttransformation xyz else tranformation xyz'
>
> due to the fact that in my case the differences between xyz and xyz' are
> pretty small I want to use an additional input parameter of boolean for
> my transformation.
>
> I did not find a lot of information about global variables in QVTo at
> all. just the following:
>
> Quote:
>> transformation UmlCleaning(inout umlmodel:UML14)
>> extends MyUmlFacilities(UML14),
>> access MathUtils;
>> var allSuper : Set(Class); // a global variable
>> main () {
>> allSuper :=
>> umlmodel.objectsOfType(Class)->collect(i|i.getAllBaseClasses());
>> // ....
>> }
>
> (taken from QVT Specification 2.0 chapter 8.1.3)
>
> so I tried the following:
>
>
> transformation Arsep2Tsp(in arsep : ARSEP, out tsp : TSP);
>
> var complMode_ : Boolean;
>
> main() { complMode_ := true;
> // ...
> }
>
>
> this does not work anyway.
>
> So does anybody know how to use global variables?
> Or even better: how to use additional parameters for a transformation?
>
> Thanks!
>
> Chris
Re: [QVTo] global variables for transformation [message #540219 is a reply to message #539426] Tue, 15 June 2010 08:35 Go to previous messageGo to next message
C. Kopf is currently offline C. Kopf
Messages: 37
Registered: November 2009
Member
Thanks a lot Sergey,

I used a property as a work around, configuration property is just what I looked for. Thanks!
Re: [QVTo] global variables for transformation [message #543260 is a reply to message #539426] Mon, 28 June 2010 16:33 Go to previous message
Oliver is currently offline Oliver
Messages: 13
Registered: January 2010
Location: Germany
Junior Member
Hi!

Is there a way to define a global variable that can access from all operations of a transformation? I've tried
var myRegistry : Dict(String, Integer);
after the transformation header. This doesn't work (syntax error). I've also tried
property myRegistry : Dict(String, Integer)
and it's doesn't work too (collection not implemented error). I don't know the difference between a variable and a property but a property was the only way to define something globally Smile

ciao
Olli
Previous Topic:how to access a tagged value of a stereotype??
Next Topic:How does ATl deal with many source models in the normal execution mode
Goto Forum:
  


Current Time: Mon Jul 28 18:32:41 EDT 2014

Powered by FUDForum. Page generated in 0.03451 seconds