Setting an Enum Reference Value in the Subclasses [message #1742653] |
Tue, 06 September 2016 11:43 |
Eclipse User |
|
|
|
Hello,
I have a metamodel in ECore. In this metamodel, I have an enum declaration, say
tag_enum = {SC_A_tag = 1, SC_B_tag = 2 }.
And I have a parent EClass, PC_E; and two subclasses of it, SC_A and SC_B.
PC_E has an attribute tag of type tag_enum. This attribute needs o be set in the subclasses: All instances of SC_A, the value of tag is SC_A_tag (an a similar case goes for SC_B). Is there was way to fix this in the metamodel instead of pushing this to OCL or model instantiation?
Thanks.
|
|
|
|
|
Re: Setting an Enum Reference Value in the Subclasses [message #1742662 is a reply to message #1742659] |
Tue, 06 September 2016 13:09 |
Eclipse User |
|
|
|
1. Ed, actually I am trying to avoid OCL for doing this check. Instead of using operations like getters and setters, I prefer to set the attribute directly since the metamodel will be used as a data structure rather than having some dynamics like operations.
2. I see what you mean Erick and I agree with your point with the current setting of the question. Maybe, I should make it clear, these enum values are going to be processed later in some other setting. So, they don't actually serve the purpose of distinguishing the subclasses, rather keeping a constant data. If I don't present this data inside the metamodel (this is my question: How to do it properly?), then I have two options: (a) Set the correct values each time I create an instance of the metamodel, (b) Since these values will be useful in the later processing step, I can embedded them to the processing step; which conflicts with separation-of-concerns principle.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03041 seconds