ibm Rational Rhapsody 7.5 — User-Defined Attributes and Operations

Basic code generation concepts User-Defined Attributes and Operations In this section, all operations and attribute data members are defined. The code in this section is a direct translation of class operations and attributes. You control it by adding or removing operations and attributes from the model. For example: //// User explicit entries //// public : //## operation op1 () // Annotation for the operation void op1 (); // Definition of an operation protected : // Attributes: //## attribute attr1 // Annotation for an attribute attrType1 attr1 ; // Definition of an attribute //// User implicit entries //// public : // Constructors and destructors:

class (OMThread* thread = theMainThread); virtual ~ class (); // Generated destructor Generating Code for Static Attributes When you generate code for a static attribute, the initial value entered is generated into a statement that initializes the static attribute outside the class constructor. Consider the following initial values for three static attributes: When you generate code, these values cause the following statements to be generated in the specification file A.h : //------------------------------------------------- // A.h //------------------------------------------------- class A { //// User explicit entries //// protected:

//## attribute attr3 static OMString attr3; //## attribute attr1 static int attr1; //## attribute attr2 static OMBoolean attr2; ... }; 934 User Guide Attribute Type Value attr1 int 5 attr2 OMBoolean true attr3 OMString “Shalom”