Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [Xcore] Using the same field name in subclasses
[Xcore] Using the same field name in subclasses [message #1080991] Tue, 06 August 2013 12:51 Go to next message
Eclipse User is currently offline Eclipse User
Messages: 257
Registered: July 2009
Senior Member
Hi

I have:

class TaskContext {
....
refers InputPort [] inputPorts opposite parent
refers EventPort[] eventPorts opposite eventParent
refers OutputPort [] outputPorts opposite parent
....
}

where:

class InputPort
{
String [1] name
refers DataType dataType
refers TaskContext parent opposite inputPorts
}

class EventPort extends InputPort {
refers TaskContext eventParent opposite eventPorts
}

class OutputPort
{
String [1] name
refers DataType dataType
refers TaskContext parent opposite outputPorts
}

so...

I would like to have

class TaskContext {
....
refers EventPort[] eventPorts opposite parent
....
}


class EventPort extends InputPort {
refers TaskContext parent opposite eventPorts
}

BUT the editor complains that I cannot 'There may not be two features
named parent'

-H
Re: [Xcore] Using the same field name in subclasses [message #1081004 is a reply to message #1080991] Tue, 06 August 2013 13:19 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25747
Registered: July 2009
Senior Member
Hugo,

Comments below.

On 06/08/2013 6:51 PM, Hugo A. Garcia wrote:
> Hi
>
> I have:
>
> class TaskContext {
> ...
> refers InputPort [] inputPorts opposite parent
> refers EventPort[] eventPorts opposite eventParent
> refers OutputPort [] outputPorts opposite parent
> ...
> }
>
> where:
>
> class InputPort
> {
> String [1] name
> refers DataType dataType
> refers TaskContext parent opposite inputPorts
> }
>
> class EventPort extends InputPort {
> refers TaskContext eventParent opposite eventPorts
> }
>
> class OutputPort
> {
> String [1] name
> refers DataType dataType
> refers TaskContext parent opposite outputPorts
> }
>
> so...
>
> I would like to have
>
> class TaskContext {
> ...
> refers EventPort[] eventPorts opposite parent
> ...
> }
>
>
> class EventPort extends InputPort {
> refers TaskContext parent opposite eventPorts
> }
>
> BUT the editor complains that I cannot 'There may not be two features
> named parent'
No, you can't have that. An EventPort could be referenced by two
different TaskContexts, one via inputPorts and the other via
eventPorts. Opposites must be paired, and feature names must be unique...
>
> -H
Re: [Xcore] Using the same field name in subclasses [message #1081014 is a reply to message #1081004] Tue, 06 August 2013 13:35 Go to previous messageGo to next message
Eclipse User is currently offline Eclipse User
Messages: 257
Registered: July 2009
Senior Member
Comments at the bottom.

On 2013-08-06 19:19, Ed Merks wrote:
> Hugo,
>
> Comments below.
>
> On 06/08/2013 6:51 PM, Hugo A. Garcia wrote:
>> Hi
>>
>> I have:
>>
>> class TaskContext {
>> ...
>> refers InputPort [] inputPorts opposite parent
>> refers EventPort[] eventPorts opposite eventParent
>> refers OutputPort [] outputPorts opposite parent
>> ...
>> }
>>
>> where:
>>
>> class InputPort
>> {
>> String [1] name
>> refers DataType dataType
>> refers TaskContext parent opposite inputPorts
>> }
>>
>> class EventPort extends InputPort {
>> refers TaskContext eventParent opposite eventPorts
>> }
>>
>> class OutputPort
>> {
>> String [1] name
>> refers DataType dataType
>> refers TaskContext parent opposite outputPorts
>> }
>>
>> so...
>>
>> I would like to have
>>
>> class TaskContext {
>> ...
>> refers EventPort[] eventPorts opposite parent
>> ...
>> }
>>
>>
>> class EventPort extends InputPort {
>> refers TaskContext parent opposite eventPorts
>> }
>>
>> BUT the editor complains that I cannot 'There may not be two features
>> named parent'
> No, you can't have that. An EventPort could be referenced by two
> different TaskContexts, one via inputPorts and the other via
> eventPorts. Opposites must be paired, and feature names must be unique...
>>
>> -H
>

ok... so I go a make a bidirectional refers in EventPort so that it can
use 'parent' from its super type InputPort?

-H
Re: [Xcore] Using the same field name in subclasses [message #1081028 is a reply to message #1081014] Tue, 06 August 2013 13:56 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 25747
Registered: July 2009
Senior Member
Hugo,

Yes, the additional opposite feature you want to define in EventPort
must have a different name than "parent" which is used up by the super type.


On 06/08/2013 7:35 PM, Hugo A. Garcia wrote:
> Comments at the bottom.
>
> On 2013-08-06 19:19, Ed Merks wrote:
>> Hugo,
>>
>> Comments below.
>>
>> On 06/08/2013 6:51 PM, Hugo A. Garcia wrote:
>>> Hi
>>>
>>> I have:
>>>
>>> class TaskContext {
>>> ...
>>> refers InputPort [] inputPorts opposite parent
>>> refers EventPort[] eventPorts opposite eventParent
>>> refers OutputPort [] outputPorts opposite parent
>>> ...
>>> }
>>>
>>> where:
>>>
>>> class InputPort
>>> {
>>> String [1] name
>>> refers DataType dataType
>>> refers TaskContext parent opposite inputPorts
>>> }
>>>
>>> class EventPort extends InputPort {
>>> refers TaskContext eventParent opposite eventPorts
>>> }
>>>
>>> class OutputPort
>>> {
>>> String [1] name
>>> refers DataType dataType
>>> refers TaskContext parent opposite outputPorts
>>> }
>>>
>>> so...
>>>
>>> I would like to have
>>>
>>> class TaskContext {
>>> ...
>>> refers EventPort[] eventPorts opposite parent
>>> ...
>>> }
>>>
>>>
>>> class EventPort extends InputPort {
>>> refers TaskContext parent opposite eventPorts
>>> }
>>>
>>> BUT the editor complains that I cannot 'There may not be two features
>>> named parent'
>> No, you can't have that. An EventPort could be referenced by two
>> different TaskContexts, one via inputPorts and the other via
>> eventPorts. Opposites must be paired, and feature names must be
>> unique...
>>>
>>> -H
>>
>
> ok... so I go a make a bidirectional refers in EventPort so that it
> can use 'parent' from its super type InputPort?
>
> -H
Previous Topic:EMF: Force load as a given type
Next Topic:EMF and XML: list serialization
Goto Forum:
  


Current Time: Sun Apr 20 03:09:57 EDT 2014

Powered by FUDForum. Page generated in 0.01634 seconds