[gme-users] enum attribute values in ocl constraints
Matthew J. Emerson
mjemerson at isis.vanderbilt.edu
Tue Jun 21 17:17:08 CDT 2005
I need to write an ocl constraint which essentially says, "If the enum attribute X of the context class has value Y, then enum attribute M of the context class must have value N".
I know how to do this in most cases. The constraint would look like this:
(self.X = #Y) implies (self.M = #N)
But, it doesn't really work value Y contains whitespace. For instance, suppose the value I need to check for is "Foo Bar":
(self.X = #Foo Bar) implies (self.M = #N)
The ocl parser can't understand this because of the whitespace. So, I performed a little experiment to figure out how the parser would like the value to be formated. I wrote the following constraint:
let testVal = self.X in false
When I check the constraint in a model where the value of X for a particular object is "Foo Bar", then I can look at the value of testVal in the constraint violation window and see how the parser is formating the enum value "Foo Bar". Unfortunately, what I got was:
testVal ocl::Enumeration{#Foo Bar}
Since I already determined that the above formatting for the enum value wouldn't be accepted by the parser as input, my experiment didn't help me.
So, how am I supposed to write this constraint? I'd like to write something like
(self.X = #[Foo Bar]) implies (self.M = #N)
or
(self.X = #"Foo Bar") implies (self.M = #N)
or even
(self.X = ocl::Enumeration("Foo Bar")) implies (self.M = #N)
But the parser doesn't like any of these (and the last one causes an emergency exception which crashes GME. Unfortunately, I can't find any GME documentation or existing examples which cover this case. Anyone know what to do?
More information about the gme-users
mailing list