Class Code Structure Constructors and Destructors A default constructor and destructor are generated for each class. You can explicitly specify additional constructors, or override the default constructor or destructor by explicitly adding them to the model. For example: class :: class (OMThread* thread) { NOTIFY_CONSTRUCTOR(class, class(), 0, class_SERIALIZE); setThread(thread); initRelations(); }; If you are defining states, use initStatechart instead of initRelations : class ::~ class () { NOTIFY_DESTRUCTOR(~ class ); cleanUpRelations(); }; Similarly, if you are defining states, use cleanUpStatechart instead of cleanUpRelations .
Operations The following code pattern is created for every primitive (user-defined) operation: void class :: op1 () { NOTIFY_OPERATION(op1, op1(), 0, op1_SERIALIZE); // Instrumentation //#[ operation op1 () // Annotation // body of the operation as you entered //#] }; Accessors and Mutators for Attributes and Relations Accessors and mutators are automatically generated for each attribute and relation of the class. Their contents and generation can be controlled by setting relation and attribute properties. For example:
attr1Type class ::get attr1 ()const { return attr1 ; }; void class ::set attr1 ( attr1type p) { attr1 = p; }; OMIterator rclass * class ::getIts rclass ()const { OMIterator rclass * iter(its rclass ); return iter; }; void Referee::_addIts Rclass ( Class * p_Class) { NOTIFY_RELATION_ITEM_ADDED(“itsRClass”,p_Class, Rational Rhapsody 939