Basic code generation concepts CG::Event::SerializeBase $Name::serialize(theStrStream); If you defined an event VoiceAlarm with two arguments, severity and priority , and VoiceAlarm inherits from Alarm , the resulting code for the template would be as follows: strstream & VoiceAlarm::serialize(strstream & theStrStream) { Alarm::serialize(theStrStream); theStrStream theStrStream return theStrStream; } The same process is done for the unserialize part. Customize Code Generation with Stereotypes Stereotypes allow extension of the UML metamodel by “typing” different model elements. Certain stereotypes are predefined in the UML, others might be user-defined.
Rational Rhapsody properties are name-value pairs that allow, among other things, customization of code generation. Property settings can be applied to a stereotype, and when that stereotype is applied to a model element, the properties for the stereotype are transferred onto the model element. For more information on stereotypes, see Stereotypes . A stereotype is typically defined as part of a profile, which is a special package primarily containing stereotypes and tags. For more information on profiles, see Profiles .
Example of Using Stereotypes to Customize Code Generation A Rational Rhapsody project has a Whole and Part class and uses an ordered container ( OMList ) to keep track of the Part objects. For this project, you create a profile called CustomCG and define an stereotype called OrderedContainer. You make the OrderedContainer stereotype only applicable to AssociationEnd elements. For the OrderedContainer stereotype, you set the CG::Relation::Ordered property to Checked . For the AssociationEnd, you set the stereotype to be OrderedContainer. When you generate code, you will see that OMList is used. 968 User Guide