line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
###################################################################### |
2
|
|
|
|
|
|
|
# Copyright (c)2010-2011, David L. Armstrong. |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# P4:OO::_Set.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
|
|
|
|
|
|
|
=head1 SYNOPSIS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 DESCRIPTION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
###################################################################### |
21
|
|
|
|
|
|
|
# Package Initialization |
22
|
|
|
|
|
|
|
# |
23
|
|
|
|
|
|
|
package P4::OO::_Set; |
24
|
|
|
|
|
|
|
our $VERSION = '0.00_02'; |
25
|
12
|
|
|
12
|
|
31213
|
use base 'P4::OO'; |
|
12
|
|
|
|
|
21
|
|
|
12
|
|
|
|
|
6192
|
|
26
|
12
|
|
|
12
|
|
61
|
use strict; |
|
12
|
|
|
|
|
26
|
|
|
12
|
|
|
|
|
4557
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
###################################################################### |
30
|
|
|
|
|
|
|
# Globals |
31
|
|
|
|
|
|
|
# |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
###################################################################### |
35
|
|
|
|
|
|
|
# Methods |
36
|
|
|
|
|
|
|
# |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub addObjects |
40
|
|
|
|
|
|
|
{ |
41
|
7
|
|
|
7
|
0
|
482
|
my $self = shift(); |
42
|
7
|
|
|
|
|
20
|
my( @addObjects ) = @_; |
43
|
|
|
|
|
|
|
|
44
|
7
|
|
|
|
|
39
|
my $setHash = $self->_getAttr( '_setHash' ); |
45
|
7
|
|
|
|
|
23
|
my $setList = $self->_getAttr( '_setList' ); |
46
|
|
|
|
|
|
|
|
47
|
7
|
100
|
|
|
|
22
|
if( ! defined( $setHash ) ) |
48
|
|
|
|
|
|
|
{ |
49
|
4
|
|
|
|
|
28
|
$setHash = $self->_setAttr( '_setHash', {} ); |
50
|
4
|
|
|
|
|
17
|
$setList = $self->_setAttr( '_setList', [] ); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
7
|
|
|
|
|
35
|
my $addedCount = 0; |
54
|
|
|
|
|
|
|
|
55
|
7
|
|
|
|
|
17
|
foreach my $object ( @addObjects ) |
56
|
|
|
|
|
|
|
{ |
57
|
16
|
100
|
|
|
|
64
|
if( ! UNIVERSAL::isa( $object, "P4::OO" ) ) |
58
|
|
|
|
|
|
|
{ |
59
|
1
|
|
|
|
|
24
|
throw E_Fatal( __PACKAGE__ . " can only be used to store P4::OO objects.\n" ); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# If the object is a Set, dump the members of the Set onto the list instead |
63
|
|
|
|
|
|
|
#TODO - what about a Set of Sets? |
64
|
15
|
100
|
|
|
|
76
|
if( UNIVERSAL::isa( $object, 'P4::OO::_Set' ) ) |
65
|
|
|
|
|
|
|
{ |
66
|
1
|
|
|
|
|
5
|
push( @addObjects, $object->listObjects() ); |
67
|
1
|
|
|
|
|
4
|
next; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
14
|
|
|
|
|
49
|
my $objectID = $object->_uniqueID(); |
71
|
|
|
|
|
|
|
|
72
|
14
|
100
|
|
|
|
44
|
if( exists( $setHash->{$objectID} ) ) |
73
|
|
|
|
|
|
|
{ |
74
|
|
|
|
|
|
|
# ignore any objects we already have |
75
|
1
|
|
|
|
|
5
|
next; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
13
|
|
|
|
|
296
|
push( @{$setList}, $object ); |
|
13
|
|
|
|
|
26
|
|
79
|
13
|
|
|
|
|
30
|
$setHash->{$objectID} = $object; |
80
|
13
|
|
|
|
|
34
|
$addedCount++; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
6
|
|
|
|
|
135
|
return( $addedCount ); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub listObjects |
88
|
|
|
|
|
|
|
{ |
89
|
3
|
|
|
3
|
0
|
15
|
my $self = shift(); |
90
|
|
|
|
|
|
|
|
91
|
3
|
|
|
|
|
17
|
my $setList = $self->_getAttr( '_setList' ); |
92
|
3
|
100
|
|
|
|
11
|
if( ! defined( $setList ) ) |
93
|
|
|
|
|
|
|
{ |
94
|
1
|
|
|
|
|
3
|
$setList = []; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# Try to provide calling flexibility here... this might not be a good thing. |
98
|
3
|
|
|
|
|
5
|
return( @{$setList} ); |
|
3
|
|
|
|
|
20
|
|
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub listObjectIDs |
102
|
|
|
|
|
|
|
{ |
103
|
0
|
|
|
0
|
0
|
|
my $self = shift(); |
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
return( map { $_->_uniqueID() } ( $self->listObjects() ) ); |
|
0
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
###################################################################### |
110
|
|
|
|
|
|
|
# Standard authorship and copyright for documentation |
111
|
|
|
|
|
|
|
# |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 AUTHOR |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
David L. Armstrong |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
P4::OO::_Set is Copyright (c)2010-2011, David L. Armstrong. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or |
122
|
|
|
|
|
|
|
modify it under the same terms as Perl itself, either Perl |
123
|
|
|
|
|
|
|
version 5.8.8 or, at your option, any later version of Perl 5 |
124
|
|
|
|
|
|
|
you may have available. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 SUPPORT AND WARRANTY |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
This program is distributed in the hope that it will be |
129
|
|
|
|
|
|
|
useful, but it is provided "as is" and without any expressed |
130
|
|
|
|
|
|
|
or implied warranties. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=cut |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
1; |