Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » QVT-OML » Pass a type as an argument
Pass a type as an argument [message #1273604] Thu, 20 March 2014 08:50 Go to next message
Denis Nikiforov is currently offline Denis Nikiforov
Messages: 59
Registered: August 2013
Member
Hi!

Is it possible to pass a type as an argument to a mapping or query? Something like this:

modeltype ECORE uses 'http://www.eclipse.org/emf/2002/Ecore';

query ExprSingle::addParens(type : ECORE::EClass) : ExprSingle =
    if self.oclIsKindOf(type) then
        self
    else
        object ParenthesizedExpr { expr := self }
    endif;
Re: Pass a type as an argument [message #1273633 is a reply to message #1273604] Thu, 20 March 2014 09:41 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 4093
Registered: July 2009
Senior Member
Hi

Type arguments are under-specified in OCL at present, but should be
sorted out in OCL 2.5; the Pivot OCL supports a Metaclass(T) analoguous
to Java's Class<T>.

For Classic OCL and consequently QVTo, you will need to use EMF for
reflective operation, so self.eClass().isSuperTypeOf(...)

Regards

Ed Willink

On 20/03/2014 08:50, Denis Nikiforov wrote:
> Hi!
>
> Is it possible to pass a type as an argument to a mapping or query?
> Something like this:
>
> modeltype ECORE uses 'http://www.eclipse.org/emf/2002/Ecore';
>
> query ExprSingle::addParens(type : ECORE::EClass) : ExprSingle =
> if self.oclIsKindOf(type) then
> self
> else
> object ParenthesizedExpr { expr := self }
> endif;
Previous Topic:Swapping out EvaluationVisitor to add instrumentation (dependency injection...?)
Next Topic:Change in Helper/Mapping behaviour from QVTO 3.2.2 to 3.3.0
Goto Forum:
  


Current Time: Thu Oct 23 04:39:45 GMT 2014

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

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