Home » Modeling » EMF » indexed aggregations/associations
indexed aggregations/associations [message #416483] |
Tue, 05 February 2008 10:01 |
|
Hi
I'd like some of my association releations to be indexed, e.g., with a
map, so that they could be easily and efficiently searchable... however
they're implemented with EList... is there a solution for this?
I also noticed the HKey property, but this does not generate Java code,
only a @model in the generated javadoc...
thanks in advance
Lorenzo
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
|
Re: indexed aggregations/associations [message #416490 is a reply to message #416483] |
Tue, 05 February 2008 12:29 |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi, Lorenzo,
Do you mean, something like UML association-end qualifiers? Ecore doesn't
support that directly.
However, you can define a containment reference of some EObject type
extending EMap.Entry<K, V>. In this case, if the value is an EReference, I
think you should end up with an EMap<K, V> property that does what you
need, albeit with the overhead of an EObject for each entry.
HTH,
Christian
Lorenzo Bettini wrote:
> Hi
>
> I'd like some of my association releations to be indexed, e.g., with a
> map, so that they could be easily and efficiently searchable... however
> they're implemented with EList... is there a solution for this?
>
> I also noticed the HKey property, but this does not generate Java code,
> only a @model in the generated javadoc...
>
> thanks in advance
> Lorenzo
>
|
|
|
Re: indexed aggregations/associations [message #416504 is a reply to message #416490] |
Tue, 05 February 2008 20:03 |
|
Christian W. Damus wrote:
> Hi, Lorenzo,
>
> Do you mean, something like UML association-end qualifiers? Ecore doesn't
> support that directly.
>
Hi
I actually don't know about association-end qualifiers...
Let me explain my requirements with an example: I have a protocol class
that contains some protocol states, and I would like to search for a
specific state using its name (the key)
> However, you can define a containment reference of some EObject type
> extending EMap.Entry<K, V>. In this case, if the value is an EReference, I
> think you should end up with an EMap<K, V> property that does what you
> need, albeit with the overhead of an EObject for each entry.
>
mh... could you please provide an example or a link?
thanks in advance
Lorenzo
> HTH,
>
> Christian
>
>
> Lorenzo Bettini wrote:
>
>> Hi
>>
>> I'd like some of my association releations to be indexed, e.g., with a
>> map, so that they could be easily and efficiently searchable... however
>> they're implemented with EList... is there a solution for this?
>>
>> I also noticed the HKey property, but this does not generate Java code,
>> only a @model in the generated javadoc...
>>
>> thanks in advance
>> Lorenzo
>>
>
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
|
Re: indexed aggregations/associations [message #416510 is a reply to message #416490] |
Wed, 06 February 2008 02:05 |
Marcelo Paternostro Messages: 602 Registered: July 2009 |
Senior Member |
|
|
Hi Lorenzo,
An alternative to what Christian suggested would be for you to do it
yourself. You could, for example, override the did* (didAdd, didRemove,
didMove, ...) methods of the list returned by the getter to populate
your own map. This method could be exposed in the interface via an
operation or "directly" (adding the method manually).
That said, I believe the best solution would be for us to exploit the
EKeys information to generate such accessors for you (you would need to
set them in your model). If you are now curious ;-), check out these posts:
"EReference.eKeys" from 6/19/2007 10:09 AM
"about EReference.eKeys" from 6/4/2007 10:43 AM
"EReference.eKeys and code generation" from 6/15/2007 11:39 AM
The last one is not as "basic" as the first two, but actually mentions
the accessors you would like to have.
Cheers,
Marcelo.
Christian W. Damus wrote:
> Hi, Lorenzo,
>
> Do you mean, something like UML association-end qualifiers? Ecore doesn't
> support that directly.
>
> However, you can define a containment reference of some EObject type
> extending EMap.Entry<K, V>. In this case, if the value is an EReference, I
> think you should end up with an EMap<K, V> property that does what you
> need, albeit with the overhead of an EObject for each entry.
>
> HTH,
>
> Christian
>
>
> Lorenzo Bettini wrote:
>
>> Hi
>>
>> I'd like some of my association releations to be indexed, e.g., with a
>> map, so that they could be easily and efficiently searchable... however
>> they're implemented with EList... is there a solution for this?
>>
>> I also noticed the HKey property, but this does not generate Java code,
>> only a @model in the generated javadoc...
>>
>> thanks in advance
>> Lorenzo
>>
>
|
|
|
Goto Forum:
Current Time: Thu Apr 25 17:44:45 GMT 2024
Powered by FUDForum. Page generated in 0.02220 seconds
|