line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# vim:ts=4 sw=4
|
2
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
3
|
|
|
|
|
|
|
# Name : Class::STL::Trace.pm
|
4
|
|
|
|
|
|
|
# Created : 12 May 2006
|
5
|
|
|
|
|
|
|
# Author : Mario Gaffiero (gaffie)
|
6
|
|
|
|
|
|
|
#
|
7
|
|
|
|
|
|
|
# Copyright 2006-2007 Mario Gaffiero.
|
8
|
|
|
|
|
|
|
#
|
9
|
|
|
|
|
|
|
# This file is part of Class::STL::Containers(TM).
|
10
|
|
|
|
|
|
|
#
|
11
|
|
|
|
|
|
|
# Class::STL::Containers is free software; you can redistribute it and/or modify
|
12
|
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
13
|
|
|
|
|
|
|
# the Free Software Foundation; version 2 of the License.
|
14
|
|
|
|
|
|
|
#
|
15
|
|
|
|
|
|
|
# Class::STL::Containers is distributed in the hope that it will be useful,
|
16
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18
|
|
|
|
|
|
|
# GNU General Public License for more details.
|
19
|
|
|
|
|
|
|
#
|
20
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
21
|
|
|
|
|
|
|
# along with Class::STL::Containers; if not, write to the Free Software
|
22
|
|
|
|
|
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
23
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
24
|
|
|
|
|
|
|
# Modification History
|
25
|
|
|
|
|
|
|
# When Version Who What
|
26
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
27
|
|
|
|
|
|
|
# TO DO:
|
28
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
29
|
|
|
|
|
|
|
package Class::STL::Trace;
|
30
|
|
|
|
|
|
|
require 5.005_62;
|
31
|
7
|
|
|
7
|
|
37
|
use strict;
|
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
447
|
|
32
|
7
|
|
|
7
|
|
37
|
use warnings;
|
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
317
|
|
33
|
7
|
|
|
7
|
|
36
|
use vars qw($VERSION $BUILD);
|
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
655
|
|
34
|
|
|
|
|
|
|
$VERSION = '0.24';
|
35
|
|
|
|
|
|
|
$BUILD = 'Saturday May 6 23:08:34 GMT 2006';
|
36
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
37
|
|
|
|
|
|
|
{
|
38
|
|
|
|
|
|
|
package Class::STL::Trace; # Singleton
|
39
|
7
|
|
|
7
|
|
37
|
use UNIVERSAL qw(isa can);
|
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
37
|
|
40
|
7
|
|
|
7
|
|
3610
|
use Carp qw(confess);
|
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
1907
|
|
41
|
|
|
|
|
|
|
sub new {
|
42
|
357
|
|
|
357
|
0
|
507
|
our $__class_stl_trace;
|
43
|
357
|
100
|
|
|
|
6497
|
return $__class_stl_trace if (defined($__class_stl_trace));
|
44
|
7
|
|
|
7
|
|
46
|
use vars qw(@ISA);
|
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
3228
|
|
45
|
7
|
|
|
|
|
17
|
my $proto = shift;
|
46
|
7
|
|
33
|
|
|
46
|
my $class = ref($proto) || $proto;
|
47
|
7
|
50
|
|
|
|
48
|
$__class_stl_trace = int(@ISA) ? $class->SUPER::new(@_) : {};
|
48
|
7
|
|
|
|
|
24
|
bless($__class_stl_trace, $class);
|
49
|
7
|
|
|
|
|
33
|
$__class_stl_trace->members_init(@_);
|
50
|
7
|
|
|
|
|
35
|
return $__class_stl_trace;
|
51
|
|
|
|
|
|
|
}
|
52
|
|
|
|
|
|
|
sub filename {
|
53
|
7
|
|
|
7
|
0
|
24
|
my $self = shift;
|
54
|
7
|
50
|
|
|
|
99
|
$self->{Class_STL_Trace}->{FILENAME} = shift if (@_);
|
55
|
7
|
|
|
|
|
31
|
return $self->{Class_STL_Trace}->{FILENAME};
|
56
|
|
|
|
|
|
|
}
|
57
|
|
|
|
|
|
|
sub trace_level {
|
58
|
7
|
|
|
7
|
0
|
15
|
my $self = shift;
|
59
|
7
|
50
|
|
|
|
32
|
$self->{Class_STL_Trace}->{TRACE_LEVEL} = shift if (@_);
|
60
|
7
|
|
|
|
|
16
|
return $self->{Class_STL_Trace}->{TRACE_LEVEL};
|
61
|
|
|
|
|
|
|
}
|
62
|
|
|
|
|
|
|
sub debug_on {
|
63
|
364
|
|
|
364
|
0
|
647
|
my $self = shift;
|
64
|
364
|
100
|
|
|
|
857
|
$self->{Class_STL_Trace}->{DEBUG_ON} = shift if (@_);
|
65
|
364
|
|
|
|
|
1922
|
return $self->{Class_STL_Trace}->{DEBUG_ON};
|
66
|
|
|
|
|
|
|
}
|
67
|
|
|
|
|
|
|
sub print {
|
68
|
0
|
|
|
0
|
0
|
0
|
my $self = shift;
|
69
|
0
|
|
0
|
|
|
0
|
my $caller = shift || '';
|
70
|
0
|
|
|
|
|
0
|
open(DEBUG, ">>@{[ $self->filename() ]}");
|
|
0
|
|
|
|
|
0
|
|
71
|
0
|
|
|
|
|
0
|
print DEBUG "# $caller\n"; # !!! need to get this as arg to print !!!
|
72
|
0
|
|
|
|
|
0
|
print DEBUG @_, "\n";
|
73
|
0
|
|
|
|
|
0
|
close(DEBUG);
|
74
|
|
|
|
|
|
|
}
|
75
|
|
|
|
|
|
|
sub members_init {
|
76
|
7
|
|
|
7
|
0
|
16
|
my $self = shift;
|
77
|
7
|
|
|
7
|
|
45
|
use vars qw(@ISA);
|
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
3010
|
|
78
|
7
|
50
|
33
|
|
|
38
|
if (int(@ISA) && (caller())[0] ne __PACKAGE__) {
|
79
|
0
|
|
|
|
|
0
|
$self->SUPER::members_init(@_);
|
80
|
|
|
|
|
|
|
}
|
81
|
7
|
|
|
|
|
12
|
my @p;
|
82
|
7
|
50
|
|
|
|
25
|
while (@_) { my $p=shift; push(@p, $p, shift) if (!ref($p)); }
|
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
44
|
|
83
|
7
|
|
|
|
|
28
|
my %p = @p;
|
84
|
7
|
50
|
|
|
|
165
|
$self->filename(exists($p{'filename'}) ? $p{'filename'} : "class_stl_dump$$");
|
85
|
7
|
50
|
|
|
|
39
|
$self->trace_level(exists($p{'trace_level'}) ? $p{'trace_level'} : '0');
|
86
|
7
|
50
|
|
|
|
50
|
$self->debug_on(exists($p{'debug_on'}) ? $p{'debug_on'} : '0');
|
87
|
|
|
|
|
|
|
}
|
88
|
|
|
|
|
|
|
sub member_print {
|
89
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
90
|
0
|
|
0
|
|
|
|
my $delim = shift || '|';
|
91
|
0
|
|
|
|
|
|
return join("$delim",
|
92
|
0
|
0
|
|
|
|
|
"debug_on=@{[ defined($self->debug_on()) ? $self->debug_on() : 'NULL' ]}",
|
93
|
0
|
0
|
|
|
|
|
"filename=@{[ defined($self->filename()) ? $self->filename() : 'NULL' ]}",
|
94
|
0
|
0
|
|
|
|
|
"trace_level=@{[ defined($self->trace_level()) ? $self->trace_level() : 'NULL' ]}",
|
95
|
|
|
|
|
|
|
);
|
96
|
|
|
|
|
|
|
}
|
97
|
|
|
|
|
|
|
sub members_local { # static function
|
98
|
|
|
|
|
|
|
return {
|
99
|
0
|
|
|
0
|
0
|
|
debug_on=>[ '0', '' ],
|
100
|
|
|
|
|
|
|
filename=>[ "class_stl_dump$$", '' ],
|
101
|
|
|
|
|
|
|
trace_level=>[ '0', '' ],
|
102
|
|
|
|
|
|
|
};
|
103
|
|
|
|
|
|
|
}
|
104
|
|
|
|
|
|
|
sub members {
|
105
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
106
|
7
|
|
|
7
|
|
38
|
use vars qw(@ISA);
|
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
1196
|
|
107
|
0
|
0
|
|
|
|
|
my $super = (int(@ISA)) ? $self->SUPER::members() : {};
|
108
|
0
|
0
|
|
|
|
|
return keys(%$super)
|
109
|
|
|
|
|
|
|
? {
|
110
|
|
|
|
|
|
|
%$super,
|
111
|
|
|
|
|
|
|
debug_on=>[ '0', '' ],
|
112
|
|
|
|
|
|
|
filename=>[ "class_stl_dump$$", '' ],
|
113
|
|
|
|
|
|
|
trace_level=>[ '0', '' ]
|
114
|
|
|
|
|
|
|
}
|
115
|
|
|
|
|
|
|
: {
|
116
|
|
|
|
|
|
|
debug_on=>[ '0', '' ],
|
117
|
|
|
|
|
|
|
filename=>[ "class_stl_dump$$", '' ],
|
118
|
|
|
|
|
|
|
trace_level=>[ '0', '' ]
|
119
|
|
|
|
|
|
|
};
|
120
|
|
|
|
|
|
|
}
|
121
|
|
|
|
|
|
|
sub swap {
|
122
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
123
|
0
|
|
|
|
|
|
my $other = shift;
|
124
|
7
|
|
|
7
|
|
41
|
use vars qw(@ISA);
|
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
1473
|
|
125
|
0
|
|
|
|
|
|
my $tmp = $self->clone();
|
126
|
0
|
0
|
|
|
|
|
$self->SUPER::swap($other) if (int(@ISA));
|
127
|
0
|
|
|
|
|
|
$self->filename($other->filename());
|
128
|
0
|
|
|
|
|
|
$self->trace_level($other->trace_level());
|
129
|
0
|
|
|
|
|
|
$self->debug_on($other->debug_on());
|
130
|
0
|
|
|
|
|
|
$other->filename($tmp->filename());
|
131
|
0
|
|
|
|
|
|
$other->trace_level($tmp->trace_level());
|
132
|
0
|
|
|
|
|
|
$other->debug_on($tmp->debug_on());
|
133
|
|
|
|
|
|
|
}
|
134
|
|
|
|
|
|
|
sub clone {
|
135
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
136
|
7
|
|
|
7
|
|
34
|
use vars qw(@ISA);
|
|
7
|
|
|
|
|
24
|
|
|
7
|
|
|
|
|
1128
|
|
137
|
0
|
0
|
|
|
|
|
my $clone = int(@ISA) ? $self->SUPER::clone() : $self->new();
|
138
|
0
|
|
|
|
|
|
$clone->filename($self->filename());
|
139
|
0
|
|
|
|
|
|
$clone->trace_level($self->trace_level());
|
140
|
0
|
|
|
|
|
|
$clone->debug_on($self->debug_on());
|
141
|
0
|
|
|
|
|
|
return $clone;
|
142
|
|
|
|
|
|
|
}
|
143
|
|
|
|
|
|
|
}
|
144
|
|
|
|
|
|
|
1;
|