3
3
#
4
4
#(c) Mark Strembeck
5
5
#
6
- # Most UML models/diagrams are essentially graphs (e.g.
6
+ # Most UML models/diagrams are essentially graphs (e.g.
7
7
# activity diagrams, class diagrams, state machines, etc.).
8
8
# UML2::Graph is a convenience package to provide a basic
9
- # graph structure for other UML2 packages. Therefore,
9
+ # graph structure for other UML2 packages. Therefore,
10
10
# UML2::Graph instances are not intended to exist as
11
11
# standalone objects, but provide the base structure
12
12
# for packages that define actual UML2 models.
@@ -21,9 +21,8 @@ package require MSXOLIB
21
21
22
22
namespace eval ::UML2 {
23
23
24
- Object ::UML2::resultobjects
25
24
26
- Class Graph -slots {
25
+ Class create Graph -slots {
27
26
::msxolib::SingleValued name
28
27
::msxolib::OrderedSet valid_node_types
29
28
::msxolib::OrderedSet valid_edge_types
@@ -38,10 +37,11 @@ Graph instproc init args {
38
37
39
38
Graph instproc addNode {type {name ""}} {
40
39
if {![my isValidNodeType $type]} {
41
- return [::msxolib::FunctionResult [::xotcl::Object autoname result] -success 0\
40
+ return [::msxolib::FunctionResult create [::xotcl::Object autoname result] -success 0\
42
41
-comment "[my info class] [self] [self proc] FAILED, << $type >> is not a valid node type\
43
- for [my info class]."]
44
- }
42
+ for [my info class]."]
43
+
44
+ }
45
45
if {$name eq ""} {
46
46
set new [$type [::xotcl::Object autoname [self]::nodes::[string tolower [namespace tail $type]]]]
47
47
$new name [namespace tail $new]
@@ -51,15 +51,16 @@ Graph instproc addNode {type {name ""}} {
51
51
set new [$type [::xotcl::Object autoname [self]::nodes::[string tolower [namespace tail $type]]]]
52
52
$new name $name
53
53
} else {
54
- return [::msxolib::FunctionResult [::xotcl::Object autoname ::UML2::resultobjects::result] -success 0\
54
+ return [::msxolib::FunctionResult create [::xotcl::Object autoname ::UML2::resultobjects::result] -success 0\
55
55
-comment "[my info class] [self] [self proc] FAILED, $type with name << $name >>\
56
56
already exists in [my info class] << [my name] >>."]
57
- }
57
+
58
+ }
58
59
}
59
60
$new owning_graph [self]
60
61
# here [string tolower [namespace tail $type]] determines an array name
61
62
my set [string tolower [namespace tail $type]]([$new name]) $new
62
- return [::msxolib::FunctionResult [::xotcl::Object autoname ::UML2::resultobjects::result] -success 1\
63
+ return [::msxolib::FunctionResult create [::xotcl::Object autoname ::UML2::resultobjects::result] -success 1\
63
64
-object_name [$new name] -object_reference $new\
64
65
-comment "[my info class] [self] [self proc], successfully added $type << [$new name] >>\
65
66
to [my info class] << [my name] >>."]
@@ -74,20 +75,20 @@ Graph instproc isValidNodeType {type} {
74
75
75
76
Graph instproc addEdge {edgeType fromType from toType to {name ""}} {
76
77
if {![my isValidEdgeType $edgeType]} {
77
- return [::msxolib::FunctionResult [::xotcl::Object autoname ::UML2::resultobjects::result] -success 0\
78
+ return [::msxolib::FunctionResult create [::xotcl::Object autoname ::UML2::resultobjects::result] -success 0\
78
79
-comment "[my info class] [self] [self proc] FAILED, << $edgeType >> is not a valid edge type\
79
80
for [my info class]."]
80
81
}
81
82
foreach t "$fromType $toType" n "$from $to" {
82
83
if {![my existNode $t $n]} {
83
- return [::msxolib::FunctionResult [::xotcl::Object autoname ::UML2::resultobjects::result] -success 0\
84
+ return [::msxolib::FunctionResult create [::xotcl::Object autoname ::UML2::resultobjects::result] -success 0\
84
85
-comment "[my info class] [self] [self proc] FAILED, $t node << $n >> does not exist\
85
86
in [my info class] << [my name] >>."]
86
87
}
87
88
}
88
89
set constructioncheck [my checkGraphConstructionRules $edgeType $fromType $from $toType $to]
89
- if {![$constructioncheck success]} {
90
- return $constructioncheck
90
+ if {![$constructioncheck success]} {
91
+ return $constructioncheck
91
92
}
92
93
if {$name eq ""} {
93
94
set new [$edgeType [::xotcl::Object autoname [self]::edges::[string tolower [namespace tail $edgeType]]]]
@@ -98,7 +99,7 @@ Graph instproc addEdge {edgeType fromType from toType to {name ""}} {
98
99
set new [$edgeType [::xotcl::Object autoname [self]::edges::[string tolower [namespace tail $edgeType]]]]
99
100
$new name $name
100
101
} else {
101
- return [::msxolib::FunctionResult [::xotcl::Object autoname ::UML2::resultobjects::result] -success 0\
102
+ return [::msxolib::FunctionResult create [::xotcl::Object autoname ::UML2::resultobjects::result] -success 0\
102
103
-comment "[my info class] [self] [self proc] FAILED, $edgeType with name << $name >>\
103
104
already exists in [my info class] << [my name] >>."]
104
105
}
@@ -112,14 +113,14 @@ Graph instproc addEdge {edgeType fromType from toType to {name ""}} {
112
113
my set [string tolower [namespace tail $edgeType]]([$new name]) $new
113
114
[my getFQON $fromType $from] outgoing add $new
114
115
[my getFQON $toType $to] incoming add $new
115
- return [::msxolib::FunctionResult [::xotcl::Object autoname ::UML2::resultobjects::result] -success 1\
116
+ return [::msxolib::FunctionResult create [::xotcl::Object autoname ::UML2::resultobjects::result] -success 1\
116
117
-object_name [$new name] -object_reference $new\
117
118
-comment "[my info class] [self] [self proc], successfully added $edgeType << [$new name] >>\
118
119
to [my info class] << [my name] >>."]
119
120
}
120
121
121
122
Graph instproc checkGraphConstructionRules {edgeType fromType from toType to} {
122
- return [::msxolib::FunctionResult [::xotcl::Object autoname ::UML2::resultobjects::result] -success 1\
123
+ return [::msxolib::FunctionResult create [::xotcl::Object autoname ::UML2::resultobjects::result] -success 1\
123
124
-comment "[my info class] [self] [self proc], no specific construction rules for [my info class] graphs."]
124
125
}
125
126
@@ -158,16 +159,16 @@ Graph instproc getFQON {type name} {
158
159
return ""
159
160
}
160
161
161
- Class Graph::Node -slots {
162
+ Class create Graph::Node -slots {
162
163
::msxolib::SingleValued name
163
164
::msxolib::SingleValued owning_graph
164
165
}
165
- Class Graph::Node::SingleIn -slots {::msxolib::SingleValued incoming}
166
- Class Graph::Node::SingleOut -slots {::msxolib::SingleValued outgoing}
167
- Class Graph::Node::MultiIn -slots {::msxolib::OrderedSet incoming}
168
- Class Graph::Node::MultiOut -slots {::msxolib::OrderedSet outgoing}
166
+ Class create Graph::Node::SingleIn -slots {::msxolib::SingleValued incoming}
167
+ Class create Graph::Node::SingleOut -slots {::msxolib::SingleValued outgoing}
168
+ Class create Graph::Node::MultiIn -slots {::msxolib::OrderedSet incoming}
169
+ Class create Graph::Node::MultiOut -slots {::msxolib::OrderedSet outgoing}
169
170
170
- Class Graph::Edge -slots {
171
+ Class create Graph::Edge -slots {
171
172
::msxolib::SingleValued name
172
173
::msxolib::SingleValued source
173
174
::msxolib::SingleValued target
@@ -180,4 +181,4 @@ Class Graph::Edge -slots {
180
181
181
182
182
183
}
183
- # ::UML2 namespace ends here
184
+ # ::UML2 namespace ends here
0 commit comments