[great-users] FW: [gme-users] How to use Guards with EnumAttributes

Attila Vizhanyo viza at isis.vanderbilt.edu
Tue Nov 29 09:45:09 CST 2005


 
Hi Tobias,
 
We have a great-users list, so please direct your great-related
questions to great-users at list.isis.vanderbilt.edu.
 
Enum attributes are represented as strings, but strings are represented
with the StringAttr type in UDM (the underlying data manipulation layer
in GReAT).
StringAttr defines a type conversion operator for string, but that must
be called explicitly (no implicit conversion to string in C++
expressions)
So to get this work, you will write:
            return ( ( std::string)person.maritalStatus()) == "single";
 
Since the conversion works implicitly for data initialization, you can
also write:
            std::string status= person.maritalStatus();
            return status == "single";
 
HTH,
Attila
 
 
-----Original Message-----
From: gme-users-bounces at list.isis.vanderbilt.edu
[mailto:gme-users-bounces at list.isis.vanderbilt.edu] On Behalf Of Tobias
Welp
Sent: Tuesday, November 29, 2005 9:15 AM
To: gme-users
Subject: [gme-users] How to use Guards with EnumAttributes
 
Hello,
 
Currently, Im trying to use GReAT in order to make a transformation.
 
I want a rule only to be executed if certain conditions are fulfilled.
>From the tutorial I learnt that this can be done by a guard.
Unfortunately, I have serious problems to express the condition.
 
The rule should be executed if a certain EnumAttribute of a Class has a
specific value. I tried to use
 
return (<className>.<EnumAttributeName>() == <Value>);
 
e.g. return (person.martialStatus() == "single");
 
This does not function, I get an error message.
 
I wondered if someone could tell me, what I have to do in order to
achieve my aim.
 
Regards,
 
Tobias
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://list.isis.vanderbilt.edu/pipermail/great-users/attachments/20051129/5ea0b866/attachment.htm


More information about the great-users mailing list