File Coverage

blib/lib/Lab/MultiChannelInstrument/DeviceCache.pm
Criterion Covered Total %
statement 11 29 37.9
branch 0 6 0.0
condition n/a
subroutine 4 11 36.3
pod n/a
total 15 46 32.6


line stmt bran cond sub pod time code
1             package Lab::MultiChannelInstrument::DeviceCache;
2             #ABSTRACT: Multi-channel instrument device cache
3             $Lab::MultiChannelInstrument::DeviceCache::VERSION = '3.880';
4 1     1   4008 use v5.20;
  1         4  
5              
6 1     1   7 use warnings;
  1         2  
  1         26  
7 1     1   5 use strict;
  1         3  
  1         30  
8              
9             require Tie::Hash;
10 1     1   7 use List::MoreUtils qw{ any };
  1         5  
  1         9  
11              
12              
13             our @ISA = 'Tie::ExtraHash';
14              
15             sub TIEHASH {
16 0     0     my $class = shift;
17 0           my $storage = bless [ {}, @_ ], $class;
18 0           return $storage;
19             }
20              
21             sub STORE {
22 0     0     $_[0][0]{ $_[1] } = $_[2];
23 0 0   0     if ( any { $_[1] eq $_ } @{ $_[0][1]->{multichannel_shared_cache} } ) {
  0            
  0            
24 0           $_[0][1]->device_cache( { $_[1] => $_[2] } );
25             }
26             }
27              
28             sub FETCH {
29              
30 0 0   0     if ( any { $_[1] eq $_ } @{ $_[0][1]->{multichannel_shared_cache} } ) {
  0     0      
  0            
31 0           return $_[0][1]->device_cache( $_[1] );
32             }
33             else {
34 0           return $_[0][0]{ $_[1] };
35             }
36             }
37              
38             sub EXISTS {
39 0 0   0     if ( any { $_[1] eq $_ } @{ $_[0][1]->{multichannel_shared_cache} } ) {
  0     0      
  0            
40 0           return exists $_[0][1]->{device_cache}->{ $_[1] };
41             }
42 0           return exists $_[0][0]->{ $_[1] };
43             }
44              
45             1;
46              
47             __END__
48              
49             =pod
50              
51             =encoding UTF-8
52              
53             =head1 NAME
54              
55             Lab::MultiChannelInstrument::DeviceCache - Multi-channel instrument device cache
56              
57             =head1 VERSION
58              
59             version 3.880
60              
61             =head1 COPYRIGHT AND LICENSE
62              
63             This software is copyright (c) 2023 by the Lab::Measurement team; in detail:
64              
65             Copyright 2016 Simon Reinhardt
66             2017 Andreas K. Huettel
67             2020 Andreas K. Huettel
68              
69              
70             This is free software; you can redistribute it and/or modify it under
71             the same terms as the Perl 5 programming language system itself.
72              
73             =cut