Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [QVTO] Temporary objects, removing objects and current limitations ?
[QVTO] Temporary objects, removing objects and current limitations ? [message #78281] Fri, 04 April 2008 13:42 Go to next message
Eclipse UserFriend
Originally posted by: yann.davin.gmail.com

Hi all,

I'm trying to build a little model merger with qvto.
I often want to create helpers that return a new model element without
adding it to the created transformed resource, but it seems that
when we use the 'object' function, the created element is automatically created inside
the resource, and it seems that is not possible to remove it.
When I try to set to null the reference to the created object,
it is moved at the top of the resource and not deleted from it.

So for the moment I've created Tuple which has a similar structure of the model element,
and I use it as return type of my helper, but it is not clean, and fastidious when the model is big,
I would like to know if there is better way at the current stage of the qvto implementation to create temporary model
elements, or to remove a element from the resource ?

example:
--simple model struct test
--Value
-- value : String

--Definition
-- name : Value

-- Is it possible to create objects without adding them to the created transformed resource ?
helper create():Value{
return object Value{value := 'test'}
-- created in the resource
--so i use tuple replacement
--helper create():Tuple(value : String) ...
}

-- Is it possible to remove a element from the resource ?
helper deleteName(inout d :Definition){
d.name := null; --elementA is moved to the top of the resource
}

Regards,

Yann
Re: [QVTO] Temporary objects, removing objects and current limitations ? [message #78297 is a reply to message #78281] Fri, 04 April 2008 14:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Alexander.Igdalov.borland.com

Hi Yann,

All the model objects created during a QVTO script execution must belong
to some model extent. These are defined in the transformation header,
for example:

transformation t(in a : ECORE, out b : ECORE, out fake : ECORE);
modeltype ECORE uses ecore('http://www.eclipse.org/emf/2002/Ecore');

Here 'a', 'b' and 'fake' are model extents used in the transformation.

Thus, creating model objects in nowhere is prohibited but you can a fake
out model extent and create your model element in it. To use your extent
you will probably need to explicitly refer to it. Use '@' symbol after
the type to do it, e.g.:

object ECORE::EPackage@fake {
name := 'runtime'
}

Note, that if you omit the extent reference:

object ECORE::EPackage {
name := 'runtime'
}

the QVT compiler will choose the first appropriate extent which is 'b'
in my sample.

HTH,
Alex.

yann davin wrote:
> Hi all,
>
> I'm trying to build a little model merger with qvto.
> I often want to create helpers that return a new model element without
> adding it to the created transformed resource, but it seems that
> when we use the 'object' function, the created element is automatically
> created inside
> the resource, and it seems that is not possible to remove it.
> When I try to set to null the reference to the created object,
> it is moved at the top of the resource and not deleted from it.
>
> So for the moment I've created Tuple which has a similar structure of
> the model element,
> and I use it as return type of my helper, but it is not clean, and
> fastidious when the model is big,
> I would like to know if there is better way at the current stage of the
> qvto implementation to create temporary model elements, or to remove a
> element from the resource ?
>
> example:
> --simple model struct test
> --Value
> -- value : String
>
> --Definition
> -- name : Value
>
> -- Is it possible to create objects without adding them to the created
> transformed resource ?
> helper create():Value{
> return object Value{value := 'test'}
> -- created in the resource
> --so i use tuple replacement
> --helper create():Tuple(value : String) ...
> }
>
> -- Is it possible to remove a element from the resource ?
> helper deleteName(inout d :Definition){
> d.name := null; --elementA is moved to the top of the resource
> }
>
> Regards,
>
> Yann
Re: [QVTO] Temporary objects, removing objects and current limitations ? [message #78312 is a reply to message #78281] Fri, 04 April 2008 15:00 Go to previous message
Radomil Dvorak is currently offline Radomil DvorakFriend
Messages: 249
Registered: July 2009
Senior Member
Hi David,

Since M6 build - coming this Monday, you can use =

Model::removeElement(Element) operation.
Though, it's in CVS HEAD already.

transformation t(in a : ECORE, out b : ECORE);

main() {
var p:=3D object EPackage {};
b.removeElement(p); -- deletes p and performs cleanup of all references=
=

to it
}


Perhaps, it might be also useful to use Element::clone(), deepclone() if=
=

you wish to
copy certain parts of your modified model and make some custom changes. =
=

The copy will
be instantiated in the out extent so you will be resonsible for unwanted=
=

objects explicit
deletion as well.

There is a concept of intermediate classes in QVTo, which are not suppos=
ed =

to be part of the
transformation result. But in this case you define a new class, internal=
=

to the transf,
while in your case you deal with a known metamodel.
FYI, itermediate classes not implemented yet, but should be coming soon =
=

;-).

Regards,
/Radek


On Fri, 04 Apr 2008 15:42:36 +0200, yann davin <yann.davin@gmail.com> =

wrote:

> Hi all,
>
> I'm trying to build a little model merger with qvto.
> I often want to create helpers that return a new model element without=

> adding it to the created transformed resource, but it seems that
> when we use the 'object' function, the created element is automaticall=
y =

> created inside
> the resource, and it seems that is not possible to remove it.
> When I try to set to null the reference to the created object,
> it is moved at the top of the resource and not deleted from it.
>
> So for the moment I've created Tuple which has a similar structure of =
=

> the model element,
> and I use it as return type of my helper, but it is not clean, and =

> fastidious when the model is big,
> I would like to know if there is better way at the current stage of th=
e =

> qvto implementation to create temporary model elements, or to remove a=
=

> element from the resource ?
>
> example:
> --simple model struct test
> --Value
> -- value : String
>
> --Definition
> -- name : Value
>
> -- Is it possible to create objects without adding them to the created=
=

> transformed resource ?
> helper create():Value{
> return object Value{value :=3D 'test'}
> -- created in the resource
> --so i use tuple replacement
> --helper create():Tuple(value : String) ...
> }
>
> -- Is it possible to remove a element from the resource ?
> helper deleteName(inout d :Definition){
> d.name :=3D null; --elementA is moved to the top of the resource
> }
>
> Regards,
>
> Yann



-- =

Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Previous Topic:[QVTO] Adding custom operations for primitive data types
Next Topic:[ATL] Get model's name
Goto Forum:
  


Current Time: Thu Apr 25 13:33:32 GMT 2024

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

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

Back to the top