| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
###################################################################### |
|
2
|
|
|
|
|
|
|
# Copyright (c)2010-2011, David L. Armstrong. |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# P4::OO::_Base.pm |
|
5
|
|
|
|
|
|
|
# |
|
6
|
|
|
|
|
|
|
# See COPYRIGHT AND LICENSE section in pod text below for usage |
|
7
|
|
|
|
|
|
|
# and distribution rights. |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
###################################################################### |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
P4::OO::_Base - Base class for all P4::OO objects |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use base 'P4::OO::_Base'; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
P4::OO::_Base functions only as a base class, providing the following: |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head2 Attribute Handling |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
_getAttr(), _setAttr(), _delAttr(), _listAttrs() |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head2 Option Handling |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
_argsToHash() |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 Exception handling and basic hierarchy |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Exceptions are provided by the P4::OO::_Error decorator. |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
###################################################################### |
|
39
|
|
|
|
|
|
|
# Package Initialization |
|
40
|
|
|
|
|
|
|
# |
|
41
|
|
|
|
|
|
|
package P4::OO::_Base; |
|
42
|
|
|
|
|
|
|
our $VERSION = '0.00_02'; |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# Import exception methods and hierarchy |
|
45
|
28
|
|
|
28
|
|
76381
|
use P4::OO::_Error; |
|
|
28
|
|
|
|
|
101
|
|
|
|
28
|
|
|
|
|
3033
|
|
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# Standard Stuff |
|
48
|
28
|
|
|
28
|
|
336
|
use strict; |
|
|
28
|
|
|
|
|
54
|
|
|
|
28
|
|
|
|
|
868
|
|
|
49
|
28
|
|
|
28
|
|
155
|
use warnings; |
|
|
28
|
|
|
|
|
57
|
|
|
|
28
|
|
|
|
|
25973
|
|
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# For _uniqueID() |
|
52
|
|
|
|
|
|
|
require Scalar::Util; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
###################################################################### |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
###################################################################### |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
###################################################################### |
|
64
|
|
|
|
|
|
|
sub new |
|
65
|
|
|
|
|
|
|
{ |
|
66
|
37
|
|
|
37
|
0
|
23275
|
my $proto = shift; |
|
67
|
37
|
|
33
|
|
|
753
|
my $class = ref( $proto ) || $proto; |
|
68
|
|
|
|
|
|
|
|
|
69
|
37
|
|
|
|
|
97
|
my $self = {}; |
|
70
|
37
|
|
|
|
|
114
|
bless( $self, $class ); |
|
71
|
|
|
|
|
|
|
|
|
72
|
37
|
|
|
|
|
216
|
my $subName = ( caller( 0 ) )[3]; |
|
73
|
37
|
|
|
|
|
1075
|
$self->{'_objAttrs'} = $self->_argsToHash( $subName, @_ ); |
|
74
|
|
|
|
|
|
|
|
|
75
|
37
|
|
|
|
|
131
|
return( $self ); |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
###################################################################### |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 METHODS |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
###################################################################### |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 query |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
PURPOSE: |
|
90
|
|
|
|
|
|
|
Helper method that allows all subclass objects to query Perforce. |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
PARAMETERS/RETURNS/THROWS: |
|
93
|
|
|
|
|
|
|
See Documentation for P4::OO::_Connection for details |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
###################################################################### |
|
98
|
|
|
|
|
|
|
sub query |
|
99
|
|
|
|
|
|
|
{ |
|
100
|
0
|
|
|
0
|
1
|
0
|
my $self = shift(); |
|
101
|
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
0
|
my $p4Conn = $self->_getP4Connection(); |
|
103
|
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
0
|
return( $p4Conn->query( @_ ) ); |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub _uniqueID |
|
109
|
|
|
|
|
|
|
{ |
|
110
|
14
|
|
|
14
|
|
18
|
my $self = shift(); |
|
111
|
|
|
|
|
|
|
|
|
112
|
14
|
|
|
|
|
45
|
return( Scalar::Util::refaddr( $self ) ); |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub _printDebug |
|
117
|
|
|
|
|
|
|
{ |
|
118
|
0
|
|
|
0
|
|
0
|
my $self = shift(); |
|
119
|
|
|
|
|
|
|
|
|
120
|
0
|
0
|
0
|
|
|
0
|
if( ( $self->_getAttr( 'debugFlag' ) ) |
|
121
|
|
|
|
|
|
|
|| ( $ENV{'P4OO_DEBUG'} ) ) |
|
122
|
|
|
|
|
|
|
{ |
|
123
|
0
|
|
|
|
|
0
|
foreach my $debugLine ( @_ ) |
|
124
|
|
|
|
|
|
|
{ |
|
125
|
0
|
|
|
|
|
0
|
chomp( $debugLine ); |
|
126
|
0
|
|
|
|
|
0
|
print "DEBUG: $debugLine\n"; |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub _getAttr |
|
133
|
|
|
|
|
|
|
{ |
|
134
|
21
|
|
|
21
|
|
1057
|
return( $_[0]->{'_objAttrs'}->{$_[1]} ); |
|
135
|
|
|
|
|
|
|
} |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub _setAttr |
|
139
|
|
|
|
|
|
|
{ |
|
140
|
10
|
|
|
10
|
|
47
|
return( $_[0]->{'_objAttrs'}->{$_[1]} = $_[2] ); |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub _setAttrs |
|
144
|
|
|
|
|
|
|
{ |
|
145
|
0
|
|
|
0
|
|
0
|
my $self = shift(); |
|
146
|
0
|
|
|
|
|
0
|
my $subName = ( caller( 0 ) )[3]; |
|
147
|
0
|
|
|
|
|
0
|
my $argsHash = $self->_argsToHash( $subName, @_ ); |
|
148
|
|
|
|
|
|
|
|
|
149
|
0
|
|
|
|
|
0
|
return( map { $self->{'_objAttrs'}->{$_} = $argsHash->{$_} } ( keys( %{$argsHash} ) ) ); |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
150
|
|
|
|
|
|
|
} |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub _delAttr |
|
153
|
|
|
|
|
|
|
{ |
|
154
|
0
|
|
|
0
|
|
0
|
return( delete( $_[0]->{'_objAttrs'}->{$_[1]} ) ); |
|
155
|
|
|
|
|
|
|
} |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub _listAttrs |
|
159
|
|
|
|
|
|
|
{ |
|
160
|
0
|
|
|
0
|
|
0
|
return( keys( %{$_[0]->{'_objAttrs'}} ) ); |
|
|
0
|
|
|
|
|
0
|
|
|
161
|
|
|
|
|
|
|
} |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
###################################################################### |
|
165
|
|
|
|
|
|
|
# _argsToHash |
|
166
|
|
|
|
|
|
|
# |
|
167
|
|
|
|
|
|
|
# _argsToHash takes the arguments passed in and constructs a hash |
|
168
|
|
|
|
|
|
|
# of name/value pairs from them, returning a reference to the hash. |
|
169
|
|
|
|
|
|
|
# |
|
170
|
|
|
|
|
|
|
# This is a helper method intended to make it simple for functions |
|
171
|
|
|
|
|
|
|
# to accept name/value pair arguments in a consistent and easy way. |
|
172
|
|
|
|
|
|
|
# |
|
173
|
|
|
|
|
|
|
# If the same name is specified more than once when called in a list |
|
174
|
|
|
|
|
|
|
# or ARRAYref form, the resulting value will be an ARRAYref of the |
|
175
|
|
|
|
|
|
|
# values. |
|
176
|
|
|
|
|
|
|
# |
|
177
|
|
|
|
|
|
|
# Values are preserved as-is, so any reference values are simply |
|
178
|
|
|
|
|
|
|
# copied, not dereferenced in any way. |
|
179
|
|
|
|
|
|
|
# |
|
180
|
|
|
|
|
|
|
# This method expects to be called on an object, not a class, and |
|
181
|
|
|
|
|
|
|
# may try to recurse on itself, so an object inheriting this method |
|
182
|
|
|
|
|
|
|
# must be used. No object state is changed in this method. |
|
183
|
|
|
|
|
|
|
# |
|
184
|
|
|
|
|
|
|
# For more helpful exceptions, the first argument required is the |
|
185
|
|
|
|
|
|
|
# name of the caller, and will be used in the exception text. |
|
186
|
|
|
|
|
|
|
# |
|
187
|
|
|
|
|
|
|
# Each of these will return the same result: |
|
188
|
|
|
|
|
|
|
# $self->_argsToHash( $callerName, 'name1', 'value1', 'name2', 'value2' ); |
|
189
|
|
|
|
|
|
|
# $self->_argsToHash( $callerName, [ 'name1', 'value1', 'name2', 'value2' ] ); |
|
190
|
|
|
|
|
|
|
# $self->_argsToHash( $callerName, { 'name1' => 'value1', 'name2' => 'value2' } ); |
|
191
|
|
|
|
|
|
|
# |
|
192
|
|
|
|
|
|
|
###################################################################### |
|
193
|
|
|
|
|
|
|
sub _argsToHash |
|
194
|
|
|
|
|
|
|
{ |
|
195
|
45
|
|
|
45
|
|
7636
|
my $self = shift(); |
|
196
|
45
|
|
|
|
|
115
|
my( $caller, @argsIn ) = @_; |
|
197
|
|
|
|
|
|
|
|
|
198
|
45
|
|
|
|
|
92
|
my $argsHashOut = {}; |
|
199
|
|
|
|
|
|
|
|
|
200
|
45
|
100
|
|
|
|
264
|
if( scalar( @argsIn ) == 0 ) |
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
{ |
|
202
|
|
|
|
|
|
|
# Nothing to see here... |
|
203
|
33
|
|
|
|
|
319
|
return( $argsHashOut ); |
|
204
|
|
|
|
|
|
|
} |
|
205
|
|
|
|
|
|
|
elsif( scalar( @argsIn ) % 2 == 0 ) |
|
206
|
|
|
|
|
|
|
{ |
|
207
|
|
|
|
|
|
|
# Even number of args, so must be a list call - process duplicates |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
# Keep track of args first seen as ARRAYrefs so we do break them down |
|
210
|
10
|
|
|
|
|
17
|
my $arrayRefsSeen = {}; |
|
211
|
|
|
|
|
|
|
|
|
212
|
10
|
|
|
|
|
31
|
while( scalar( @argsIn ) ) |
|
213
|
|
|
|
|
|
|
{ |
|
214
|
18
|
|
|
|
|
26
|
my $name = shift( @argsIn ); |
|
215
|
18
|
|
|
|
|
84
|
my $value = shift( @argsIn ); |
|
216
|
|
|
|
|
|
|
|
|
217
|
18
|
100
|
|
|
|
45
|
if( exists( $argsHashOut->{$name} ) ) |
|
218
|
|
|
|
|
|
|
{ |
|
219
|
4
|
100
|
|
|
|
9
|
if( exists( $arrayRefsSeen->{$name} ) ) |
|
220
|
|
|
|
|
|
|
{ |
|
221
|
|
|
|
|
|
|
# We saw it first as an ARRAYref, so we just make a new ref. |
|
222
|
1
|
|
|
|
|
4
|
$argsHashOut->{$name} = [ $argsHashOut->{$name}, $value ]; |
|
223
|
1
|
|
|
|
|
5
|
delete( $arrayRefsSeen->{$name} ); |
|
224
|
|
|
|
|
|
|
} |
|
225
|
|
|
|
|
|
|
else |
|
226
|
|
|
|
|
|
|
{ |
|
227
|
|
|
|
|
|
|
# We've seen it before, and maybe more than once! |
|
228
|
3
|
100
|
|
|
|
11
|
if( UNIVERSAL::isa( $argsHashOut->{$name}, "ARRAY" ) ) |
|
229
|
|
|
|
|
|
|
{ |
|
230
|
1
|
|
|
|
|
3
|
push( @{$argsHashOut->{$name}}, $value ); |
|
|
1
|
|
|
|
|
6
|
|
|
231
|
|
|
|
|
|
|
} |
|
232
|
|
|
|
|
|
|
else |
|
233
|
|
|
|
|
|
|
{ |
|
234
|
2
|
|
|
|
|
8
|
$argsHashOut->{$name} = [ $argsHashOut->{$name}, $value ]; |
|
235
|
|
|
|
|
|
|
} |
|
236
|
|
|
|
|
|
|
} |
|
237
|
|
|
|
|
|
|
} |
|
238
|
|
|
|
|
|
|
else |
|
239
|
|
|
|
|
|
|
{ |
|
240
|
14
|
|
|
|
|
31
|
$argsHashOut->{$name} = $value; |
|
241
|
|
|
|
|
|
|
|
|
242
|
14
|
100
|
|
|
|
86
|
if( UNIVERSAL::isa( $value, "ARRAY" ) ) |
|
243
|
|
|
|
|
|
|
{ |
|
244
|
1
|
|
|
|
|
4
|
$arrayRefsSeen->{$name} = 1; |
|
245
|
|
|
|
|
|
|
} |
|
246
|
|
|
|
|
|
|
} |
|
247
|
|
|
|
|
|
|
} |
|
248
|
|
|
|
|
|
|
} |
|
249
|
|
|
|
|
|
|
elsif( scalar( @argsIn ) == 1 ) |
|
250
|
|
|
|
|
|
|
{ |
|
251
|
2
|
100
|
|
|
|
11
|
if( UNIVERSAL::isa( $argsIn[0], "ARRAY" ) ) |
|
|
|
50
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
{ |
|
253
|
|
|
|
|
|
|
# Called with ARRAYref, so just call self recurively with deref |
|
254
|
1
|
|
|
|
|
4
|
return( $self->_argsToHash( $caller, @{$argsIn[0]} ) ); |
|
|
1
|
|
|
|
|
22
|
|
|
255
|
|
|
|
|
|
|
} |
|
256
|
|
|
|
|
|
|
elsif( UNIVERSAL::isa( $argsIn[0], "HASH" ) ) |
|
257
|
|
|
|
|
|
|
{ |
|
258
|
|
|
|
|
|
|
# For now we'll copy it, but could be bad for performance... |
|
259
|
1
|
|
|
|
|
2
|
%{$argsHashOut} = %{$argsIn[0]}; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
4
|
|
|
260
|
|
|
|
|
|
|
} |
|
261
|
|
|
|
|
|
|
} |
|
262
|
|
|
|
|
|
|
else |
|
263
|
|
|
|
|
|
|
{ |
|
264
|
0
|
|
|
|
|
0
|
throw E_Fatal "$caller: Invalid arguments.\n"; |
|
265
|
|
|
|
|
|
|
} |
|
266
|
|
|
|
|
|
|
|
|
267
|
11
|
|
|
|
|
49
|
return( $argsHashOut ); |
|
268
|
|
|
|
|
|
|
} |
|
269
|
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
###################################################################### |
|
272
|
|
|
|
|
|
|
# Standard authorship and copyright for documentation |
|
273
|
|
|
|
|
|
|
# |
|
274
|
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
=head1 AUTHOR |
|
276
|
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
David L. Armstrong |
|
278
|
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
280
|
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
P4::OO::_Base is Copyright (c)2010-2011, David L. Armstrong. |
|
282
|
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or |
|
284
|
|
|
|
|
|
|
modify it under the same terms as Perl itself, either Perl |
|
285
|
|
|
|
|
|
|
version 5.8.8 or, at your option, any later version of Perl 5 |
|
286
|
|
|
|
|
|
|
you may have available. |
|
287
|
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
=head1 SUPPORT AND WARRANTY |
|
289
|
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
This program is distributed in the hope that it will be |
|
291
|
|
|
|
|
|
|
useful, but it is provided "as is" and without any expressed |
|
292
|
|
|
|
|
|
|
or implied warranties. |
|
293
|
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
=cut |
|
295
|
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
1; |