Quiq/ImagePool/Directory.pm

filter: Statementstmt 47.8% 22 / 46 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 63.6% 7 / 11 Podpod 100% 4 / 4 totaltotal 39.2% 33 / 84 CC 8 SCAR 28.1
CC
8
Cov
35%
sequence
42.0
images
12.0
new
2.0
CRAP 16.6
« Quiq/Confluence/Client.pm ↑ Summary Quiq/Ssh.pm »
1 # -----------------------------------------------------------------------------
2  
3 =encoding utf8
4  
5 =head1 NAME
6  
7 Quiq::ImagePool::Directory - Unterverzeichnis eines Image-Pool
8  
9 =head1 BASE CLASS
10  
11 L<Quiq::Hash>
12  
13 =cut
14  
15 # -----------------------------------------------------------------------------
16  
17 package Quiq::ImagePool::Directory;
18 2 ▶use base qw/Quiq::Hash/;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 2 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 2 our $VERSION = '1.240';
25  
26 2 ▶use Quiq::TimeLapse::Directory;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 2 ▶use Quiq::Option;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 2 ▶use Quiq::ImagePool::Sequence;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 # -----------------------------------------------------------------------------
31  
32 =head1 METHODS
33  
34 =head2 Konstruktor
35  
36 =head3 new() - Instantiiere Directory-Objekt
37  
38 =head4 Synopsis
39  
40 $dir = $class->new($path);
41  
42 =head4 Arguments
43  
44 =over 4
45  
46 =item path
47  
48 Verzeichnis-Pfad.
49  
50 =back
51  
52 =cut
53  
54 # -----------------------------------------------------------------------------
55  
56 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
57 0 my ($class,$path) = @_;
58  
59 0 return $class->SUPER::new(
60 path => $path,
61 imageList => Quiq::TimeLapse::Directory->new("$path/img"),
62 sequenceH => {},
63 );
64 }
65  
66 # -----------------------------------------------------------------------------
67  
68 =head2 Sequenzen
69  
70 =head3 sequence() - Lookup Sequence-Objekt nach Name
71  
72 =head4 Synopsis
73  
74 $seq = $dir->sequence($name,@opt);
75  
76 =head4 Arguments
77  
78 =over 4
79  
80 =item $name
81  
82 Name der Sequenz.
83  
84 =back
85  
86 =head4 Options
87  
88 =over 4
89  
90 =item -sloppy => $bool (Default: 0)
91  
92 Liefere undef, wenn die Sequenz-Datei nicht existiert oder
93 keinen Range definiert.
94  
95 =back
96  
97 =head4 Description
98  
99 Liefere das Sequenz-Objekt mit Name $name. Das Objekt wird
100 gecached. Existiert das Verzeichnis nicht, wird eine Exception
101 geworfen, es sei denn, die Option -sloppy ist gesetzt.
102  
103 =cut
104  
105 # -----------------------------------------------------------------------------
106  
107 0 ▶sub sequence {
Subroutine sequence: not called CC=6 SCAR=37.4
Pod documented
108 0 my $self = shift;
109 0 my $name = shift;
110 # @_: @opt
111  
112 0 ▶ return $self->{'sequenceH'}->{$name} //= do {
Condition0%0/3
$self->{"sequenceH"}{$name} //= do { my $sloppy = 0; "Quiq::Option"->extract(\@_, "-sloppy", \$sloppy); my $seq; my $file = sprintf("%s/seq/%s.def", $self->path, $name); if (not -e $file and $sloppy) { (); } else { my $lst = $self->imageList; $seq = "Quiq::ImagePool::Sequence"->new($file, $lst); if ($seq->count == 0 and $sloppy) { $seq = undef; } ; } ; $seq }
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"sequenceH"}{$name} //= do { my $sloppy = 0; "Quiq::Option"->extract(\@_, "-sloppy", \$sloppy); my $seq; my $file = sprintf("%s/seq/%s.def", $self->path, $name); if (not -e $file and $sloppy) { (); } else { my $lst = $self->imageList; $seq = "Quiq::ImagePool::Sequence"->new($file, $lst); if ($seq->count == 0 and $sloppy) { $seq = undef; } ; } ; $seq }
$self->{"sequenceH"}{$name} do { my $sloppy = 0; "Quiq::Option"->extract(\@_, "-sloppy", \$sloppy); my $seq; my $file = sprintf("%s/seq/%s.def", $self->path, $name); if (not -e $file and $sloppy) { (); } else { my $lst = $self->imageList; $seq = "Quiq::ImagePool::Sequence"->new($file, $lst); if ($seq->count == 0 and $sloppy) { $seq = undef; } ; } ; $seq }
Truth table0%0/3
A //= B
A= $self->{"sequenceH"}{$name}B= do { my $sloppy = 0; "Quiq::Option"->extract(\@_, "-sloppy", \$sloppy); my $seq; my $file = sprintf("%s/seq/%s.def", $self->path, $name); if (not -e $file and $sloppy) { (); } else { my $lst = $self->imageList; $seq = "Quiq::ImagePool::Sequence"->new($file, $lst); if ($seq->count == 0 and $sloppy) { $seq = undef; } ; } ; $seq }
ABresult
1X1
011
000
113 # Optionen
114  
115 0 my $sloppy = 0;
116  
117 0 Quiq::Option->extract(\@_,
118 -sloppy=>\$sloppy,
119 );
120  
121 0 my $seq;
122 0 my $file = sprintf '%s/seq/%s.def',$self->path,$name;
123 0 ▶ if (!-e $file && $sloppy) {
Branch: 1 branch
BranchTrueFalseTotal
if (not -e $file and $sloppy) { } 0 0 0
Condition0%0/3
not -e $file and $sloppy
!ll&&!rl&&r
000
MC/DC0%0/2
not -e $file and $sloppy
not -e $file $sloppy
Truth table0%0/3
not(A) and B
A= not -e $fileB= $sloppy
ABresult
0X0
100
111
124 # nichts tun
125 }
126 else {
127 0 my $lst = $self->imageList;
128 0 $seq = Quiq::ImagePool::Sequence->new($file,$lst);
129 0 ▶ if ($seq->count == 0 && $sloppy) {
Branch: 1 branch
BranchTrueFalseTotal
if ($seq->count == 0 and $sloppy) 0 0 0
Condition0%0/3
$seq->count == 0 and $sloppy
!ll&&!rl&&r
000
MC/DC0%0/2
$seq->count == 0 and $sloppy
$seq->count == 0 $sloppy
Truth table0%0/3
A and B
A= $seq->count == 0B= $sloppy
ABresult
0X0
100
111
130 0 $seq = undef;
131 }
132 }
133 0 $seq;
134 };
135 }
136  
137 # -----------------------------------------------------------------------------
138  
139 =head2 Bilder
140  
141 =head3 images() - Liste von Bildern aus dem Verzeichnis
142  
143 =head4 Synopsis
144  
145 @images|$imageA = $dir->images($key);
146  
147 =head4 Description
148  
149 Liefere die Bild-Teilmenge $key. Der Schlüssel $key kann die
150 Ausprägungen annehmen:
151  
152 =over 2
153  
154 =item *
155  
156 nicht agegeben oder leer
157  
158 =item *
159  
160 Sequenz-Bezeichner SEQUENCE
161  
162 =item *
163  
164 Range-Bezeichner SEQUENCE/RANGE
165  
166 =back
167  
168 =cut
169  
170 # -----------------------------------------------------------------------------
171  
172 0 ▶sub images {
Subroutine images: not called CC=3 SCAR=24.8
Pod documented
173 0 my ($self,$key) = @_;
174  
175 0 ▶ if (!$key) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($key) 0 0 0
176 0 ▶ if (my $seq = $self->sequence('default',-sloppy=>1)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $seq = $self->sequence("default", "-sloppy", 1)) 0 0 0
177 # Wenn eine nicht-leere Default-Sequenz existiert,
178 # liefern wir deren Bilder
179 0 return $seq->images;
180 }
181 # andernfalls liefern wir alle Bilder des Verzeichnisses
182 0 return $self->imageList->images;
183 }
184  
185 # Liefere die Bilder der Sequenz oder des Range
186  
187 0 my ($sequence,$range) = split m|/|,$key;
188 0 return $self->sequence($sequence)->images($range);
189 }
190  
191 # -----------------------------------------------------------------------------
192  
193 =head3 image() - Lookup Bild-Objekt nach Bild-Nummer
194  
195 =head4 Synopsis
196  
197 $img = $dir->image($n);
198  
199 =cut
200  
201 # -----------------------------------------------------------------------------
202  
203 0 ▶sub image {
Subroutine image: not called CC=1 SCAR=6.9
Pod documented
204 0 my ($self,$n) = @_;
205 0 return $self->imageList->image($n);
206 }
207  
208 # -----------------------------------------------------------------------------
209  
210 =head1 VERSION
211  
212 1.240
213  
214 =head1 AUTHOR
215  
216 Frank Seitz, L<http://fseitz.de/>
217  
218 =head1 COPYRIGHT
219  
220 Copyright (C) 2026 Frank Seitz
221  
222 =head1 LICENSE
223  
224 This code is free software; you can redistribute it and/or modify
225 it under the same terms as Perl itself.
226  
227 =cut
228  
229 # -----------------------------------------------------------------------------
230  
231 2 1;
232  
233 # eof
« Quiq/Confluence/Client.pm ↑ Summary Quiq/Ssh.pm »