line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# Graph::Writer - perl base class for Graph file format writers |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
package Graph::Writer; |
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
640
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
57
|
|
7
|
2
|
|
|
2
|
|
7
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
61
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '2.07'; |
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
933
|
use IO::File; |
|
2
|
|
|
|
|
15083
|
|
|
2
|
|
|
|
|
519
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#======================================================================= |
14
|
|
|
|
|
|
|
# |
15
|
|
|
|
|
|
|
# new () - constructor |
16
|
|
|
|
|
|
|
# |
17
|
|
|
|
|
|
|
# Create an instance of a Graph writer. This will not be invoked |
18
|
|
|
|
|
|
|
# directly on this class, but will be inherited by writers for |
19
|
|
|
|
|
|
|
# specific formats. |
20
|
|
|
|
|
|
|
# |
21
|
|
|
|
|
|
|
#======================================================================= |
22
|
|
|
|
|
|
|
sub new |
23
|
|
|
|
|
|
|
{ |
24
|
6
|
|
|
6
|
1
|
1385
|
my $class = shift; |
25
|
|
|
|
|
|
|
|
26
|
6
|
100
|
|
|
|
20
|
die "don't create an instance of $class!\n" if $class eq __PACKAGE__; |
27
|
|
|
|
|
|
|
|
28
|
5
|
|
|
|
|
11
|
my $self = bless {}, $class; |
29
|
|
|
|
|
|
|
|
30
|
5
|
|
|
|
|
21
|
$self->_init(@_); |
31
|
|
|
|
|
|
|
|
32
|
5
|
|
|
|
|
10
|
return $self; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
#======================================================================= |
36
|
|
|
|
|
|
|
# |
37
|
|
|
|
|
|
|
# _init() - initialise instance |
38
|
|
|
|
|
|
|
# |
39
|
|
|
|
|
|
|
# This is for any instance-specific initialisation. The idea is that |
40
|
|
|
|
|
|
|
# a sub-class will define an _init() method if it needs one. |
41
|
|
|
|
|
|
|
# For future compatibility the class-specific method should invoke |
42
|
|
|
|
|
|
|
# this. |
43
|
|
|
|
|
|
|
# |
44
|
|
|
|
|
|
|
#======================================================================= |
45
|
|
|
|
|
|
|
sub _init |
46
|
5
|
|
|
5
|
|
7
|
{ |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
#======================================================================= |
51
|
|
|
|
|
|
|
# |
52
|
|
|
|
|
|
|
# write_graph() - write the specified graph to the specified file (handle) |
53
|
|
|
|
|
|
|
# |
54
|
|
|
|
|
|
|
# This is the public method that will be invoked to write a graph. |
55
|
|
|
|
|
|
|
# The file can be specified either as a filename, or a filehandle. |
56
|
|
|
|
|
|
|
# |
57
|
|
|
|
|
|
|
#======================================================================= |
58
|
|
|
|
|
|
|
sub write_graph |
59
|
|
|
|
|
|
|
{ |
60
|
5
|
|
|
5
|
1
|
49
|
my $self = shift; |
61
|
5
|
|
|
|
|
7
|
my $graph = shift; |
62
|
5
|
|
|
|
|
6
|
my $filename = shift; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
5
|
50
|
|
|
|
7
|
if (ref $filename) |
66
|
|
|
|
|
|
|
{ |
67
|
0
|
|
|
|
|
0
|
$self->_write_graph($graph, $filename); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
else |
70
|
|
|
|
|
|
|
{ |
71
|
5
|
|
|
|
|
28
|
my $FILE = IO::File->new("> $filename"); |
72
|
5
|
50
|
|
|
|
469
|
if (not defined $FILE) |
73
|
|
|
|
|
|
|
{ |
74
|
0
|
|
|
|
|
0
|
warn "couldn't write to $filename: $!\n"; |
75
|
0
|
|
|
|
|
0
|
return 0; |
76
|
|
|
|
|
|
|
} |
77
|
5
|
|
|
|
|
24
|
$self->_write_graph($graph, $FILE); |
78
|
5
|
|
|
|
|
21
|
$FILE->close(); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
5
|
|
|
|
|
224
|
return 1; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
__END__ |