As you can see the default definitions depend on the type of the relation and the multiplicity, of course these defaults are modifiable through the generation settings.
ÕýÈçÄãËù¼ûµ½µÄ£¬Ä¬Èϵ͍ÒåÒÀÀµÓÚ¹ØÁªµÄÀàÐͺ͹ØÁªµÄÖØÊý£¬µ±È»ÕâЩĬÈÏÖµ¿Éͨ¹ýgeneration settings ½øÐÐÐ޸ġ£
The way a UML stereotype is projected for each language is also modifiable through the generation settings, as you can see above and below vector produces vector in C++ Vector in Java and sequence in IDL :
UMLµÄ·¶ÐÍÏà¶ÔÓÚ¸÷ÓïÑÔÀ´Ëµ¶¼ÊÇÆÁ±ÎµÄ£¨±£»¤µÄ£©£¬ÆäʵÏÖ¿ÉÒÔͨ¹ýgeneration settings ½øÐÐÐ޸ġ£ÏÂÃæÄã¿É¼ûµ½£¬UMLÖÐvector ÔÚC++ÖвúÉúÒ»¸öÏòÁ¿Vector£¬¶øÔÚIDLÖвúÉúÐòÁÐsequence¡£
- 37 -
Press the button Ok and look at the diagram : °´OK°´Å¥£¬¿´Í¼£º
- 38 -
Because the relation is now bi-directional this one appears in the browser in C1 and Administrator (I mark them in the browser : they are red).
ÒòΪ£¬ÏÖÔÚ¹ØÁªÊÇË«ÏòµÄ£¬ÔÚä¯ÀÀÆ÷ÖÐC1 and Administrator Öж¼¿É¼ûµ½´Ë¹ØÁª¡££¨ÎÒ½«ËüÃDZê¼ÇΪºìÉ«£©
Define struct, union, typedef, enum¶¨Òå½á¹¹¡¢ÁªºÏ¡¢ÀàÐͶ¨Ò壨typedef£©£¬Ã¶¾Ù
To define a C++ or IDL struct use the class stereotype struct, and edit the class using the Default declaration button on the desired language(s). In Java a struct is implemented through a standard class, of course the projection of a class stereotype from UML to a given language may be set through the generation settings, look at the dialog already shown below and read the reference manual.
Òª¶¨ÒåÒ»¸öC++»òISDLµÄstruc£¬Ê¹ÓÃÀà·¶ÐÍ struct , ʹÓÃDefault declaration °´Å¥£¬Õë¶ÔÏà¹ØµÄÓïÑÔ±à¼Àà¡£ÔÚJava ÖеÄstruct ÊÇͨ¹ýÒ»¸ö±ê×¼µÄÀàÀ´ÊµÏֵ쬵±È»ÔÚUMLµÄÀà·¶Ð͵½¸ø¶¨µÄÓïÑÔµÄÓ³Éä¿ÉÒÔͨ¹ýÉèÖÃgeneration settingsÀ´Íê³É£¬Çë¿´ÏÂÃæµÄ¶Ô»°¿ò£¬²¢²ÎÔIJο¼Êֲᡣ
To define a C++ or IDL union use the class stereotype union as for a struct. Òª¶¨ÒåÒ»¸öC++»òIDLµÄÁªºÏ£¬Õë¶ÔClass ʹÓÃUnion ·¶ÐÍ£º
To define for instance the C++ typedef T which is a pointer to a C1 : create the class T, and draw a dependency from T to C1
ÀýÈçÒªÔÚC++Öж¨Òåtypedef T£¬ËüÊÇÖ¸ÏòC1µÄÒ»¸öÖ¸Õ룺´´½¨ÀàT£¬»æÖÆÒ»¸ö´ÓTµ½C1
- 39 -
µÄÒÀÀµ¹ØÏµ¡£
Edit the class and set the stereotype to typedef : the dialog is changed to indicate a base type, thanks to the dependency this one is set to C1, but you may change it . Go in the C++ tab :
±à¼´ËÀàT£¬ÉèÖÃÆä·¶ÐÍΪtypedef£º¶Ô»°¿òÖз¢Éú¸Ä±äÖ¸ÏòÆä»ùÀàÐÍ¡£ תµ½C++±êÇ©£º
Of course the dependency in not mandatory, for instance to define typedef int turlututu µ±È»£¬ÒÀÀµÐÔ²»ÊÇÇ¿ÖÆµÄ£¬ÀýÈç¿ÉÒÔ¶¨Òå typedef int turlututu Add a '*' between ${type} and ${name} : ÔÚ$(type)ºÍ$(name)Ö®¼ä‰ˆ¼ÓÒ»¸ö¡¯*¡¯ £º
- 40 -