| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package GraphViz::Diagram::ClassDiagram::Class; |
|
2
|
|
|
|
|
|
|
#_{ use |
|
3
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
32
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
21
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
50
|
|
|
7
|
1
|
|
|
1
|
|
6
|
use GraphViz::Diagram::ClassDiagram; |
|
|
1
|
|
|
|
|
8
|
|
|
|
1
|
|
|
|
|
33
|
|
|
8
|
|
|
|
|
|
|
#_} |
|
9
|
1
|
|
|
1
|
|
7
|
use GraphViz::Diagram::ClassDiagram; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
26
|
|
|
10
|
1
|
|
|
1
|
|
428
|
use GraphViz::Diagram::ClassDiagram::Method; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
40
|
|
|
11
|
1
|
|
|
1
|
|
576
|
use GraphViz::Diagram::ClassDiagram::Node_; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use GraphViz::Diagram::ClassDiagram::Attribute; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = $GraphViz::Diagram::ClassDiagram::VERSION; |
|
15
|
|
|
|
|
|
|
our @ISA = qw(GraphViz::Diagram::ClassDiagram::Node_); |
|
16
|
|
|
|
|
|
|
#_{ POD: Name |
|
17
|
|
|
|
|
|
|
=head1 NAME |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
C: A class that represents classes. |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=encoding utf8 |
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $graph = GraphViz::Diagram::ClassDiagram->new(…); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $class = $graph->class("ClassName"); |
|
27
|
|
|
|
|
|
|
… |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
|
30
|
|
|
|
|
|
|
#_} |
|
31
|
|
|
|
|
|
|
#_{ POD: Methods |
|
32
|
|
|
|
|
|
|
=head1 METHODS |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
|
35
|
|
|
|
|
|
|
#_} |
|
36
|
|
|
|
|
|
|
sub new { #_{ |
|
37
|
|
|
|
|
|
|
#_{ POD |
|
38
|
|
|
|
|
|
|
=head2 new |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
C should not be directly called by the user. Instead, he should |
|
41
|
|
|
|
|
|
|
call C<< $graph->class(…) >> |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut |
|
44
|
|
|
|
|
|
|
#_} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my $class = shift; |
|
48
|
|
|
|
|
|
|
my $class_name = shift; |
|
49
|
|
|
|
|
|
|
my $class_diagram = shift; # The class diagram on which this class should be drawn |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# my $opts = shift // {}; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
croak "Class - new, class=$class instead GraphViz::Diagram::ClassDiagram::Class" unless $class eq 'GraphViz::Diagram::ClassDiagram::Class'; |
|
54
|
|
|
|
|
|
|
croak "Class - new, class_name=$class_name instead of a string" if ref $class_name; |
|
55
|
|
|
|
|
|
|
croak "Class - new, class_diagram=$class_diagram instead of GraphViz::Diagram::ClassDiagram" unless ref $class_diagram eq 'GraphViz::Diagram::ClassDiagram'; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my $self = $class->GraphViz::Diagram::ClassDiagram::Node_::new($class_name, $class_diagram); |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
$self->{class_elements} = []; |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
return $self; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
} #_} |
|
64
|
|
|
|
|
|
|
sub file { #_{ |
|
65
|
|
|
|
|
|
|
#_{ POD |
|
66
|
|
|
|
|
|
|
=head2 file |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
|
69
|
|
|
|
|
|
|
#_} |
|
70
|
|
|
|
|
|
|
my $self = shift; |
|
71
|
|
|
|
|
|
|
my $file = shift; |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
$self->{file} = $file; |
|
74
|
|
|
|
|
|
|
return $self; |
|
75
|
|
|
|
|
|
|
} #_} |
|
76
|
|
|
|
|
|
|
sub comment { #_{ |
|
77
|
|
|
|
|
|
|
#_{ POD |
|
78
|
|
|
|
|
|
|
=head2 comment |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
|
81
|
|
|
|
|
|
|
#_} |
|
82
|
|
|
|
|
|
|
my $self = shift; |
|
83
|
|
|
|
|
|
|
my $comment = shift; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
push @{$self->{comments}}, $comment; |
|
86
|
|
|
|
|
|
|
return $self; |
|
87
|
|
|
|
|
|
|
} #_} |
|
88
|
|
|
|
|
|
|
sub method { #_{ |
|
89
|
|
|
|
|
|
|
#_{ POD |
|
90
|
|
|
|
|
|
|
=head2 method |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=cut |
|
93
|
|
|
|
|
|
|
#_} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
my $self = shift; |
|
96
|
|
|
|
|
|
|
my $ident = shift; |
|
97
|
|
|
|
|
|
|
my $opts = shift; |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
my $method = GraphViz::Diagram::ClassDiagram::Method->new($self, $ident, $opts); |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
push @{$self->{class_elements}}, $method; |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
return $method; |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
} #_} |
|
106
|
|
|
|
|
|
|
sub attribute { #_{ |
|
107
|
|
|
|
|
|
|
#_{ POD |
|
108
|
|
|
|
|
|
|
=head2 attribute |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
|
111
|
|
|
|
|
|
|
#_} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
my $self = shift; |
|
114
|
|
|
|
|
|
|
my $ident = shift; |
|
115
|
|
|
|
|
|
|
my $opts = shift; |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
my $method = GraphViz::Diagram::ClassDiagram::Attribute->new($self, $ident, $opts); |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
croak "Class - attribute: $method is not a GraphViz::Diagram::ClassDiagram::Attribute" unless ref $method eq 'GraphViz::Diagram::ClassDiagram::Attribute'; |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
push @{$self->{class_elements}}, $method; |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
return $method; |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
} #_} |
|
126
|
|
|
|
|
|
|
sub inherits_from { #_{ |
|
127
|
|
|
|
|
|
|
#_{ POD |
|
128
|
|
|
|
|
|
|
=head2 new |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
my $class_base = $class_diagram->class("CBase"); |
|
131
|
|
|
|
|
|
|
my $class_derv = $class_diagram->class("CDerived"); |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
$class_derv -> inherits_from($class_base); |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
# Multiple base classes |
|
136
|
|
|
|
|
|
|
$class_xyz -> inherits_from($class_abc, $class_def, $class_ghi); |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=cut |
|
139
|
|
|
|
|
|
|
#_} |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
my $self = shift; |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
for my $base_class (@_) { |
|
144
|
|
|
|
|
|
|
croak "GraphViz::Diagram::ClassDiagram::Class - inherits_from base_class $base_class is not a GraphViz::Diagram::ClassDiagram::Class" unless $base_class->isa('GraphViz::Diagram::ClassDiagram::Class'); |
|
145
|
|
|
|
|
|
|
$self->{class_diagram}->inheritance($base_class, $self); |
|
146
|
|
|
|
|
|
|
} |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
} #_} |
|
149
|
|
|
|
|
|
|
sub render { #_{ |
|
150
|
|
|
|
|
|
|
#_{ POD |
|
151
|
|
|
|
|
|
|
=head2 render |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Renders the html for the Class. Should not be called by the user, it's called |
|
154
|
|
|
|
|
|
|
by L. |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=cut |
|
157
|
|
|
|
|
|
|
#_} |
|
158
|
|
|
|
|
|
|
my $self = shift; |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
my $colspan_max= colspan_(); |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
my $border_below = " $colspan_max border='4' sides='b'"; |
|
163
|
|
|
|
|
|
|
my $border_etc = ''; |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
if (! $self->{file} and ! @{$self->{comments}}) { |
|
166
|
|
|
|
|
|
|
$border_etc = $border_below; |
|
167
|
|
|
|
|
|
|
} |
|
168
|
|
|
|
|
|
|
else { |
|
169
|
|
|
|
|
|
|
$border_etc = " border='0' $colspan_max"; |
|
170
|
|
|
|
|
|
|
} |
|
171
|
|
|
|
|
|
|
my $tr_class_name = " |
| $self->{name} |
";
|
172
|
|
|
|
|
|
|
my $tr_file=''; |
|
173
|
|
|
|
|
|
|
my $tr_comments=''; |
|
174
|
|
|
|
|
|
|
my $tr_class_elems=''; |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
if ($self->{file}) { #_{ |
|
177
|
|
|
|
|
|
|
if (! $self->{file} and ! @{$self->{comments}}) { |
|
178
|
|
|
|
|
|
|
$border_etc = $border_below |
|
179
|
|
|
|
|
|
|
} |
|
180
|
|
|
|
|
|
|
else { |
|
181
|
|
|
|
|
|
|
$border_etc = " border='0' $colspan_max"; |
|
182
|
|
|
|
|
|
|
} |
|
183
|
|
|
|
|
|
|
$tr_comments .= " |
| $self->{file} |
";
|
184
|
|
|
|
|
|
|
} #_} |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
my $color_comment = GraphViz::Diagram::ClassDiagram::color_comment(); |
|
187
|
|
|
|
|
|
|
my $comment_cnt = 0; |
|
188
|
|
|
|
|
|
|
for my $comment (@{$self->{comments}}) { #_{ |
|
189
|
|
|
|
|
|
|
$comment_cnt ++; |
|
190
|
|
|
|
|
|
|
if ($comment_cnt == @{$self->{comments}}) { |
|
191
|
|
|
|
|
|
|
$border_etc = $border_below; |
|
192
|
|
|
|
|
|
|
} |
|
193
|
|
|
|
|
|
|
else { |
|
194
|
|
|
|
|
|
|
$border_etc = " border='0' $colspan_max"; |
|
195
|
|
|
|
|
|
|
} |
|
196
|
|
|
|
|
|
|
$tr_comments .= " |
| $comment |
";
|
197
|
|
|
|
|
|
|
} #_} |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
my $first_row = 1; |
|
200
|
|
|
|
|
|
|
for my $class_elem (@{$self->{class_elements}}) { #_{ |
|
201
|
|
|
|
|
|
|
$tr_class_elems .= $class_elem->tr($first_row) . "\n"; |
|
202
|
|
|
|
|
|
|
$first_row = 0; |
|
203
|
|
|
|
|
|
|
} #_} |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
$self->label({html=> |
|
206
|
|
|
|
|
|
|
"" |
|
212
|
|
|
|
|
|
|
}); |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
} #_} |
|
215
|
|
|
|
|
|
|
sub connector_for_links { #_{ |
|
216
|
|
|
|
|
|
|
#_{ POD |
|
217
|
|
|
|
|
|
|
=head2 connector_for_links |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
Returns an L that can be used in L C<< -> C>. |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=cut |
|
222
|
|
|
|
|
|
|
#_} |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
my $self = shift; |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
# croak "class_node is not defined. Was render' alread called?" unless $self->{class_node}; |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
return $self;#->{class_node}; |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
} #_} |
|
231
|
|
|
|
|
|
|
sub colspan_ { #_{ |
|
232
|
|
|
|
|
|
|
#_{ POD |
|
233
|
|
|
|
|
|
|
=head2 colspan_ |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
A private static method. Returns the necessary C for C<< | >>'s that are to span the entire table. |
|
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=cut |
|
238
|
|
|
|
|
|
|
#_} |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
return "colspan='2'"; |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
} #_} |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
'tq84'; |