Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [XCore] Overriding implementation of a super class feature in a subclass
[XCore] Overriding implementation of a super class feature in a subclass [message #891648] Mon, 25 June 2012 12:04 Go to next message
Roland Tepp is currently offline Roland TeppFriend
Messages: 36
Registered: July 2009
Member
Hi,

I have a legacy model I want to model (I am using XCore for this) in EMF.

Basically the legacy model is a table that has tons of columns. Most of
these columns are only filled if the "type" column has a certain value.

I decided to model this table using class inheritance with one base
class for common features and a subclass for each type of the entity
with the additional features relevant to the particular type defined
inside this subclass.

I would also like to provide the abstract "type" feature in the base
class that would return the value of the "type" column of the table.

Essentially the value of the Type feature would be constant for a
particular subclass, but I can not specify an override for a feature
(xcore reports an error when I try to specify a field that is already
defined for a superclass)

What are my options in this case? Can this be done?
Re: [XCore] Overriding implementation of a super class feature in a subclass [message #891722 is a reply to message #891648] Mon, 25 June 2012 15:38 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Roland,

Comments below.

On 25/06/2012 2:04 PM, Roland Tepp wrote:
> Hi,
>
> I have a legacy model I want to model (I am using XCore for this) in EMF.
>
> Basically the legacy model is a table that has tons of columns. Most
> of these columns are only filled if the "type" column has a certain
> value.
>
> I decided to model this table using class inheritance with one base
> class for common features and a subclass for each type of the entity
> with the additional features relevant to the particular type defined
> inside this subclass.
>
> I would also like to provide the abstract "type" feature in the base
> class that would return the value of the "type" column of the table.
And it must be a feature, i.e., an operation won't suffice?
>
> Essentially the value of the Type feature would be constant for a
> particular subclass, but I can not specify an override for a feature
> (xcore reports an error when I try to specify a field that is already
> defined for a superclass)
You should be able to define an operation that has the same name as the
accessor method for the feature.
>
> What are my options in this case? Can this be done?


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [XCore] Overriding implementation of a super class feature in a subclass [message #891883 is a reply to message #891722] Tue, 26 June 2012 12:28 Go to previous messageGo to next message
Roland Tepp is currently offline Roland TeppFriend
Messages: 36
Registered: July 2009
Member
Thanks Ed for quick reply,

My comments below as well:

25.06.2012 18:38, Ed Merks kirjutas:
>> I would also like to provide the abstract "type" feature in the base
>> class that would return the value of the "type" column of the table.
> And it must be a feature, i.e., an operation won't suffice?

I suppose, an operation would do just as well... Feature would simply
"look better" in this context.

>> Essentially the value of the Type feature would be constant for a
>> particular subclass, but I can not specify an override for a feature
>> (xcore reports an error when I try to specify a field that is already
>> defined for a superclass)
> You should be able to define an operation that has the same name as the
> accessor method for the feature.

Okay, so let me confirm that I understand it correctly:

I can define:

enum Type {
ONE
TWO
THREE
...
}

abstract class Base {
...
derived transient readonly Type ^type
...
}

class One extends Base {
...
op Type getType(){
return Type::ONE
}
...
}
etc.

It looks like a hackish solution, but it seems to work well enough.
Thanks :)


Roland
Re: [XCore] Overriding implementation of a super class feature in a subclass [message #891885 is a reply to message #891883] Tue, 26 June 2012 12:33 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Roland,

Yes, that's the idea.


On 26/06/2012 2:28 PM, Roland Tepp wrote:
> Thanks Ed for quick reply,
>
> My comments below as well:
>
> 25.06.2012 18:38, Ed Merks kirjutas:
>>> I would also like to provide the abstract "type" feature in the base
>>> class that would return the value of the "type" column of the table.
>> And it must be a feature, i.e., an operation won't suffice?
>
> I suppose, an operation would do just as well... Feature would simply
> "look better" in this context.
>
>>> Essentially the value of the Type feature would be constant for a
>>> particular subclass, but I can not specify an override for a feature
>>> (xcore reports an error when I try to specify a field that is already
>>> defined for a superclass)
>> You should be able to define an operation that has the same name as the
>> accessor method for the feature.
>
> Okay, so let me confirm that I understand it correctly:
>
> I can define:
>
> enum Type {
> ONE
> TWO
> THREE
> ...
> }
>
> abstract class Base {
> ...
> derived transient readonly Type ^type
> ...
> }
>
> class One extends Base {
> ...
> op Type getType(){
> return Type::ONE
> }
> ...
> }
> etc.
>
> It looks like a hackish solution, but it seems to work well enough.
> Thanks :)
>
>
> Roland


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Read-only resource in resourceset
Next Topic:EMap and resolved keys
Goto Forum:
  


Current Time: Thu Apr 25 06:07:02 GMT 2024

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

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

Back to the top