PartialOrder/LRUCaching.pm

filter: Statementstmt 100% 23 / 23 Branchbran n/a Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 78.9% 30 / 38 CC 3 SCAR 7.6
CC
3
Cov
86%
new
3.3
BEGIN
1.0
BEGIN
1.0
CRAP 2.1
« PartialOrder/Caching.pm ↑ Summary PartialOrder.pm »
1 # -*- Mode: Perl -*-
2  
3 #
4 # Copyright (c) 2001, Bryan Jurish. All rights reserved.
5 #
6 # This package is free software. You may redistribute it
7 # and/or modify it under the same terms as Perl itself.
8 #
9  
10 ###############################################################
11 #
12 # File: Math::PartialOrder::LRUCaching.pm
13 # Author: Bryan Jurish <jurish@ling.uni-potsdam.de>
14 #
15 # Description: Math::PartialOrder class using hashrefs
16 # objects to store hierarchy information,
17 # caches inheritance- and operation-lookups
18 # using Tie::Cache.
19 #
20 ###############################################################
21  
22  
23 package Math::PartialOrder::LRUCaching;
24 # System modules
25 7 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 #require Exporter;
27 # 3rd party exstensions
28 7 ▶use Tie::Cache;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 # user extension modules
30 7 ▶use Math::PartialOrder::Caching qw($CACHE_KEY_SEP);
Subroutine BEGIN: called CC=1 SCAR=0.0
31 7 @ISA = qw(Math::PartialOrder::Caching);
32 7 @EXPORT = qw();
33 7 @EXPORT_OK = qw();
34  
35 ###############################################################
36 # Package-Globals
37 ###############################################################
38  
39 7 our $VERSION = 0.01;
40  
41 # $CACHE_KEY_SEP : imported from Math::PartialOrder::Caching
42 7 our $IN_CACHE_ATTRS = { MaxCount => 5000 };
43 7 our $OP_CACHE_ATTRS = { MaxCount => 5000 };
44  
45  
46 ###############################################################
47 # Initialization
48 # + object structure:
49 # {
50 # # --- INHERITED ---
51 # types => Set::Hashed
52 # root => scalar
53 # parents => { type1 => {p1a=>p1a,...}, ... }
54 # children => { type1 => {c1a=>c1a,...}, ... }
55 # attributes => { type1 => { attr1.1 => val1.1, ... }, ... }
56 # # --- NEW ---
57 # _incache => { 'type1,type2' => $has_anc_bool, ... }
58 # _opcache => { 'op,type1,type2' => \@results }
59 # }
60 ###############################################################
61  
62 #----------------------------------------------------------------------
63 # new( \%args )
64 # + initialization routine: returns the object
65 # + keys of \%args
66 # + inherited:
67 # root => $typ
68 # + new
69 # incache_attrs => \%attrs
70 # opcache_attrs => \%attrs
71 #----------------------------------------------------------------------
72 11 ▶sub new ($;$) {
Subroutine new: called CC=3 SCAR=11.8
Pod documented
73 11 my ($proto,$args) = @_;
74 11 my $self = $proto->SUPER::new($args);
75  
76 # tie up caches
77 11 ▶ tie %{$self->{incache}}, Tie::Cache, $args{incache_attrs}||$IN_CACHE_ATTRS;
Condition33%1/3
$args{'incache_attrs'} || $IN_CACHE_ATTRS
l!l&&r!l&&!r
0110
MC/DC0%0/2
$args{'incache_attrs'} || $IN_CACHE_ATTRS
$args{'incache_attrs'} $IN_CACHE_ATTRS
Truth table33%1/3
A || B
A= $args{'incache_attrs'}B= $IN_CACHE_ATTRS
ABresult
1X1
011
000
78 11 ▶ tie %{$self->{opcache}}, Tie::Cache, $args{opcache_attrs}||$OP_CACHE_ATTRS;
Condition33%1/3
$args{'opcache_attrs'} || $OP_CACHE_ATTRS
l!l&&r!l&&!r
0110
MC/DC0%0/2
$args{'opcache_attrs'} || $OP_CACHE_ATTRS
$args{'opcache_attrs'} $OP_CACHE_ATTRS
Truth table33%1/3
A || B
A= $args{'opcache_attrs'}B= $OP_CACHE_ATTRS
ABresult
1X1
011
000
79  
80 11 return $self;
81 }
82  
83  
84  
85 ###############################################################
86 # Hierarchy Maintainance: Type Operations
87 ###############################################################
88 #--------------------------------------------------------------
89 # types : inherited from Math::PartialOrder::Std
90  
91 #--------------------------------------------------------------
92 # add : inherited from Math::PartialOrder::Caching
93  
94 #--------------------------------------------------------------
95 # has_type : inherited from Math::PartialOrder::Std
96  
97 #--------------------------------------------------------------
98 # add_parents : inherited from Math::PartialOrder::Caching
99  
100 #--------------------------------------------------------------
101 # move : inherited from Math::PartialOrder::Caching
102  
103 #--------------------------------------------------------------
104 # remove : inherited from Math::PartialOrder::Caching
105  
106 #--------------------------------------------------------------
107 # parents : inherited from Math::PartialOrder::Std
108  
109 #--------------------------------------------------------------
110 # children : inherited from Math::PartialOrder::Std
111  
112 #--------------------------------------------------------------
113 # has_parent : inherited from Math::PartialOrder::Std
114  
115 #--------------------------------------------------------------
116 # has_child : inherited from Math::PartialOrder::Std
117  
118 #--------------------------------------------------------------
119 # has_ancestor : inherited from Math::PartialOrder::Caching
120  
121  
122 #--------------------------------------------------------------
123 # has_descendant : inherited from Math::PartialOrder::Caching
124  
125 #--------------------------------------------------------------
126 # get_attributes : inherited from Math::PartialOrder::Std
127  
128 #--------------------------------------------------------------
129 # get_attribute : inherited from Math::PartialOrder::Std
130  
131 #--------------------------------------------------------------
132 # set_attribute : inherited from Math::PartialOrder::Std
133  
134 #--------------------------------------------------------------
135 # assign : inherited from Math::PartialOrder::Caching
136  
137  
138 #--------------------------------------------------------------
139 # merge : inherited from Math::PartialOrder::Caching
140  
141 #--------------------------------------------------------------
142 # clear : inherited from Math::PartialOrder::Caching
143  
144 ###############################################################
145 # Additional Hierarchy Maintainence Operations
146 ###############################################################
147 #--------------------------------------------------------------
148 # ensure_types : inherited from Math::PartialOrder::Std
149  
150 #--------------------------------------------------------------
151 # _ancestors($type) => $hashref : inherited from Math::PartialOrder::Std
152  
153 #--------------------------------------------------------------
154 # _descendants($type) => $hashref : inherited from Math::PartialOrder::Std
155  
156 #--------------------------------------------------------------
157 # _minimize : inherited from Math::PartialOrder:Set
158  
159 #--------------------------------------------------------------
160 # _maximize : inherited from Math::PartialOrder:Set
161  
162  
163 ###############################################################
164 # Hierarchy Operations
165 ###############################################################
166  
167 #--------------------------------------------------------------
168 # _lub : inherited from Math::PartialOrder::Caching
169  
170 #--------------------------------------------------------------
171 # _glb : inherited from Math::PartialOrder::Caching
172  
173  
174 ###############################################################
175 # Hierarchy operation utilities
176 ###############################################################
177  
178 ###############################################################
179 # Accessors/manipulators
180 ###############################################################
181  
182 #--------------------------------------------------------------
183 # _types : inherited from Math::PartialOrder::Std
184  
185 #--------------------------------------------------------------
186 # _root, root : inherited from Math::PartialOrder::Caching
187  
188 #--------------------------------------------------------------
189 # _parents : inherited from Math::PartialOrder::Std
190  
191 #--------------------------------------------------------------
192 # _children : inherited from Math::PartialOrder::Std
193  
194 #--------------------------------------------------------------
195 # _attributes : inherited from Math::PartialOrder::Std
196  
197  
198 #--------------------------------------------------------------
199 # _incache : inherited from Math::PartialOrder::Caching
200 # _get_cached_in : inherited from Math::PartialOrder::Caching
201 # _set_cached_in : inherited from Math::PartialOrder::Caching
202  
203  
204 #--------------------------------------------------------------
205 # _opcache : inherited from Math::PartialOrder::Caching
206 # _get_cached_op : inherited from Math::PartialOrder::Caching
207 # _set_cached_op : inherited from Math::PartialOrder::Caching
208  
209  
210 #--------------------------------------------------------------
211 # _clear_cached, _clear_cache : inherited from Math::PartialOrder::Caching
212  
213  
214 7 1;
215 __END__
« PartialOrder/Caching.pm ↑ Summary PartialOrder.pm »