Skip to main content


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 16:51 Go to next message
Hugo A. Garcia is currently offline Hugo A. GarciaFriend
Messages: 258
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 17:19 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
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


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [Xcore] Using the same field name in subclasses [message #1081014 is a reply to message #1081004] Tue, 06 August 2013 17:35 Go to previous messageGo to next message
Hugo A. Garcia is currently offline Hugo A. GarciaFriend
Messages: 258
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 17:56 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
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


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:EMF: Force load as a given type
Next Topic:EMF and XML: list serialization
Goto Forum:
  


Current Time: Tue Apr 16 18:27:23 GMT 2024

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

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

Back to the top