commit 142e64b1abee978636e2291032f16e4dec10a29f
parent 4f0e35134bca913821ad7893a9e04fc224b0f8ec
Author: Morel BĂ©renger <berengermorel76@gmail.com>
Date: Fri, 27 Nov 2020 19:59:16 +0100
uml: implemented relations multiplicity
Diffstat:
2 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/uml b/uml
@@ -33,12 +33,24 @@ function fun( overload ) {
printf( "): %s %s\l", $2, overload );
}
-function relation( from, to, tail, head, label ) {
+function relation( from, to, tail, head, label, multiplicity ) {
printf( "%s -> %s [ dir = \"both\", arrowtail = \"%s\", arrowhead = \"%s\"", from, to, tail, head );
if( label != "" )
{
printf( ", label = \"%s\"", label );
}
+ if( multiplicity != "" )
+ {
+ if( multiplicity ~ /[0-9]*:[0-9n]*/ )
+ {
+ split( multiplicity, labels, ":" );
+ printf( ", taillabel = \"%s\", headlabel = \"%s\"", labels[1], labels[2] );
+ }
+ else
+ {
+ printf( ", taillabel = \"%s\", headlabel = \"%s\"", multiplicity, multiplicity );
+ }
+ }
}
function close_relation() {
@@ -124,25 +136,25 @@ $1 == "var" {
$1 == "inherit" {
end_class();
- relation( $2, $3, "none", "empty", "" );
+ relation( $2, $3, "none", "empty" );
close_relation();
}
$1 == "associate" {
end_class();
- relation( $2, $3, "none", "vee", $4 );
+ relation( $2, $3, "none", "vee", $4, $5 );
close_relation();
}
$1 == "aggreg" {
end_class();
- relation( $2, $3, "odiamond", "vee", $4 );
+ relation( $2, $3, "odiamond", "vee", $4, $5 );
close_relation();
}
$1 == "compose" {
end_class();
- relation( $2, $3, "diamond", "vee", $4 );
+ relation( $2, $3, "diamond", "vee", $4, $5 );
close_relation();
}
diff --git a/uml.README b/uml.README
@@ -101,6 +101,7 @@ Closes the current class.
Arg 1: "owner" class
Arg 2: target class
Arg 3: relation name
+Arg 4: optional multiplicity. Either a single val, or a min:max range.
==== aggreg ====
Defines an aggregation relation.
@@ -109,6 +110,7 @@ Closes the current class.
Arg 1: "owner" class
Arg 2: target class
Arg 3: relation name
+Arg 4: optional multiplicity. Either a single val, or a min:max range.
==== compose ====
Defines an composition relation.
@@ -117,6 +119,7 @@ Closes the current class.
Arg 1: "owner" class
Arg 2: target class
Arg 3: relation name
+Arg 4: optional multiplicity. Either a single val, or a min:max range.
==== depends ====
Defines a dependency relation.