Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Feaure request: Inerface not extending EObject(New option for not extending EObjec needed)
Feaure request: Inerface not extending EObject [message #1780820] Sun, 28 January 2018 19:50 Go to next message
Veselin Markov is currently offline Veselin MarkovFriend
Messages: 15
Registered: February 2012
Junior Member
I was wandering if it is possible to implement a new genmodel option, so that one can define an interface that doesn't extend EObject?
In my case I wanted to implement the visitor pattern for my model and defined a visitor interface - later I notices that it extends EObject and I must implement all the methods instead of only that what I defined.
Re: Feaure request: Inerface not extending EObject [message #1780822 is a reply to message #1780820] Sun, 28 January 2018 22:03 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The RootExtendsInterface option should do this for you. There is also a RootImplementsInterface option for further flexibility.

Regards

Ed Willink
Re: Feaure request: Inerface not extending EObject [message #1780840 is a reply to message #1780822] Mon, 29 January 2018 07:39 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
You should probably write interfaces that you intend to implement directly by hand rather than have EMF generate them because EMF will generally assume that for any instance of modeled EClass that the underlying implementation objects will be EObjects. You can use an EClass to wrap it so you can make modeled classes implement that interface. But as Ed W suggests, you can set the Root Extends Interface to the empty string, but that affects all your generated interfaces, not just this visitor interface. And it that will make the utilities of the framework less convenient to use, because they all take EObject arguments and your interfaces won't include that, so you'll have to cast.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Feaure request: Inerface not extending EObject [message #1780857 is a reply to message #1780840] Mon, 29 January 2018 10:12 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

I missed the 'visitor' clue.

You may find http://git.eclipse.org/c/ocl/org.eclipse.ocl.git/tree/examples/org.eclipse.ocl.examples.build/src/org/eclipse/ocl/examples/build/xtend/GenerateVisitorsXtend.xtend and related files helpful. They auto-generate a family of visitors that are extensible to multiple packages.

You can see examples of base visitors at http://git.eclipse.org/c/ocl/org.eclipse.ocl.git/tree/plugins/org.eclipse.ocl.pivot/emf-gen/org/eclipse/ocl/pivot/util
and derived visitors at http://git.eclipse.org/c/mmt/org.eclipse.qvtd.git/tree/plugins/org.eclipse.qvtd.pivot.qvtbase/emf-gen/org/eclipse/qvtd/pivot/qvtbase/util

The generator is parameterized by GenModel GenAnnotations that are described at http://help.eclipse.org/oxygen/topic/org.eclipse.ocl.doc/help/BuildingtheOCLProject.html?cp=74_8

Regards

Ed Willink
Re: Feaure request: Inerface not extending EObject [message #1780865 is a reply to message #1780857] Mon, 29 January 2018 11:16 Go to previous messageGo to next message
Veselin Markov is currently offline Veselin MarkovFriend
Messages: 15
Registered: February 2012
Junior Member
Hello,

thanks for the replies. I did find the Root Extends Interface but that's not working for me, as it removes the EObject interface from all generated classes. Thanks for the links, I'll take a look :)
Re: Feaure request: Inerface not extending EObject [message #1780875 is a reply to message #1780840] Mon, 29 January 2018 13:11 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Ed Merks wrote on Mon, 29 January 2018 08:39
You should probably write interfaces that you intend to implement directly by hand [...]


And model an EDataType that wraps that interface, so that you can use it in your model, for example in EParameters of EOperations:

<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="my" nsURI="http://my" nsPrefix="my">
  <eClassifiers xsi:type="ecore:EDataType" name="Visitor" instanceClassName="com.foo.bar.Visitor"
      serializable="false"/>
  <eClassifiers xsi:type="ecore:EClass" name="Node">
    <eOperations name="accept">
      <eParameters name="visitor" eType="#//Visitor"/>
    </eOperations>
  </eClassifiers>
</ecore:EPackage>


Previous Topic:[Validation]
Next Topic:How do I define a nillable element in XSD schema for ecore XML model plugin
Goto Forum:
  


Current Time: Sat Apr 20 01:43:20 GMT 2024

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

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

Back to the top