Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » A general question about derived features in EMF
A general question about derived features in EMF [message #1338630] Wed, 07 May 2014 09:51 Go to next message
Emre T is currently offline Emre TFriend
Messages: 119
Registered: April 2013
Senior Member
In EMF, one can define derived attributes or references for or between model elements, which are then computed from the actual state of the EMF model instances, based on the loaded resources etc. I find it very interesting to bind complex or fragmented models together. But in this case EMF lets the generated model code for such features simply empty and expects the user to implement the logic and mark the generated empty code signature then as "generated NOT".

Unfortunately, there are not a lot of materials regarding this scenario. I find the EMF-IncQuery a powerful tool in this matter. There are also an EMF Recipe for a Notifier for derived attributes and an example of how to use Feature Maps, which is from 2004. Also using OCL for derivation seems to be a possibility, though I am not so sure whether OCL acts as a setter for the values of the derived features directly, or only validates the value after the value is set by another mean?

So my general question would be, what the best practice is for implementing the getters for derived attributes or references? If my question should be vague, I can definitely narrow it to be precise. Smile

Thanks a lot!
Re: A general question about derived features in EMF [message #1338706 is a reply to message #1338630] Wed, 07 May 2014 10:38 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
On 07/05/2014 10:52, Emre T wrote:
> Also using OCL for derivation seems to be a possibility, though I am
> not so sure whether OCL acts as a setter for the values of the derived
> features directly, or only validates the value after the value is set
> by another mean?
You don't need to know. A derived value can never be set. OCL just
computes it. Whether it is cached for re-use or not is an implementation
detail.

In general it cannot be cached because some input to the derived
computation may have changed.

If you're really worried about performance you can use the OCL Impact
Analyzer of the IncQuery RETE network to detect changes and so avoid
redundant computation.

Regards

Ed Willink
Re: A general question about derived features in EMF [message #1338733 is a reply to message #1338706] Wed, 07 May 2014 10:50 Go to previous message
Emre T is currently offline Emre TFriend
Messages: 119
Registered: April 2013
Senior Member
Hello Ed,

thanks for the quick reply.

I guess I have used the word "set" wrong. Thats what you sad was what I meant. I need the values of derived references or attributes "computed" based on the actual state of the instances of the model, especially in cases where there are fragmented model instances (referencing each other in different ways) are loaded into one instance.

I have no issues right now with performance. It is just about getting the values of derived references computed. And I guess OCL is capable of doing this.

In this case the following question I have posted to OCL-forum solves itself.

http://www.eclipse.org/forums/index.php/t/736928/

Again thanks a lot!
Previous Topic:[Texo] create code depending on a user defined annotation
Next Topic:Multiple reference to one EObject
Goto Forum:
  


Current Time: Sat Apr 27 01:04:48 GMT 2024

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

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

Back to the top