Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » QVT-OML » Possibility to generate Circular Referenced target model
Possibility to generate Circular Referenced target model [message #941147] Fri, 12 October 2012 08:45 Go to next message
Alexander Unsonamed is currently offline Alexander UnsonamedFriend
Messages: 10
Registered: October 2012
Junior Member
Is it possible to somehow handle Circular References?
My source model has circular references, and I'd like to have circular references in generated target model.

E.g.:
result.name := "Model";	
var box: Box := object Box {
	name := "Box node";
};
	
var subBox : Box := object Box {
	name := "SubBox";
};
	

result.root := box;				
box.children += subBox;	
subBox.children += box;		


So, I have Box with child of type Box. Thus I have possibility to create infinite nesting of boxes.
As a result of transformation, I have result object without any children.

If I remove the following statement:
subBox.children += box;

transformation works well, but I get predefined 1-level nesting.
Re: Possibility to generate Circular Referenced target model [message #941208 is a reply to message #941147] Fri, 12 October 2012 09:46 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4189
Registered: July 2009
Senior Member
Hi

It's certainly possible, but QVTo is only partially declarative so you
need to empathize with its imperative actions.

A circular loop cannot naturally be created in a single regular pass.

Rather than ensuring the referential validity of each loop step and
having a special loop closing step, I recommend what I usually find
necessary in QVTo; code in two passes.

Pass 1 creates the output as a tree, and populates an in2out Dict.
Pass 2 adds cross-references to the tree using the in2out Dict from pass 1.

[If you're clever/lucky you can use 'resolve' in place of the Doct, but
I find resolve hard to understand/debug in practice.]

Regards

Ed Willink


On 12/10/2012 09:45, Alexander Unsonamed wrote:
> Is it possible to somehow handle Circular References?
> My source model has circular references, and I'd like to have circular
> references in generated target model.
>
> E.g.:
>
> result.name := "Model";
> var box: Box := object Box {
> name := "Box node";
> };
>
> var subBox : Box := object Box {
> name := "SubBox";
> };
>
>
> result.root := box;
> box.children += subBox;
> subBox.children += box;
>
>
> So, I have Box with child of type Box. Thus I have possibility to
> create infinite nesting of boxes.
> As a result of transformation, I have result object without any children.
>
> If I remove the following statement:
>
> subBox.children += box;
>
> transformation works well, but I get predefined 1-level nesting.
Re: Possibility to generate Circular Referenced target model [message #944828 is a reply to message #941208] Mon, 15 October 2012 06:03 Go to previous messageGo to next message
Alexander Unsonamed is currently offline Alexander UnsonamedFriend
Messages: 10
Registered: October 2012
Junior Member
Quote:
Pass 1 creates the output as a tree, and populates an in2out Dict.
Pass 2 adds cross-references to the tree using the in2out Dict from pass 1.


Thanks for the comment, but I really don't understand what you meant by in2out Dict. What am I supposed to store in such a dictionary and why it cannot be created by one pass?
Can you supply me with the simplest example, it would be nice.
Thanks in advance.
Re: Possibility to generate Circular Referenced target model [message #944881 is a reply to message #944828] Mon, 15 October 2012 06:32 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4189
Registered: July 2009
Senior Member
Hi

Take the simplest of trees with links

A
B, link to C
C, link to B

This can be constructed in containment order
create A
create B
create C

then crossreferenced
assign B link to C
assign C link to B

since when assigning cross references all sources and targets exist.
Cannot be done in one pass.

If A, B, C result from a transformation on a, b, c then in2out Dict contains
a => A
b => B
c => C

Regards

Ed Willink



On 15/10/2012 07:03, Alexander Unsonamed wrote:
> Quote:
>> Pass 1 creates the output as a tree, and populates an in2out Dict.
>> Pass 2 adds cross-references to the tree using the in2out Dict from
>> pass 1.
>
>
> Thanks for the comment, but I really don't understand what you meant
> by in2out Dict. What am I supposed to store in such a dictionary and
> why it cannot be created by one pass?
> Can you supply me with the simplest example, it would be nice.
> Thanks in advance.
Previous Topic:Resolve EValues from a qvtotrace file
Next Topic:How to manually register blackbox units?
Goto Forum:
  


Current Time: Tue Dec 23 03:07:55 GMT 2014

Powered by FUDForum. Page generated in 0.06408 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software