| 1 | # | ||||||||||||||||||||||||||||
| 2 | # @author Bodo (Hugo) Barwich | ||||||||||||||||||||||||||||
| 3 | # @version 2026-01-29 | ||||||||||||||||||||||||||||
| 4 | # @package Object::Meta | ||||||||||||||||||||||||||||
| 5 | # @subpackage lib/Object/Meta/File/List.pm | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | # This Module defines Classes to manage Data in an indexed List | ||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||
| 9 | #--------------------------------- | ||||||||||||||||||||||||||||
| 10 | # Requirements: | ||||||||||||||||||||||||||||
| 11 | # | ||||||||||||||||||||||||||||
| 12 | #--------------------------------- | ||||||||||||||||||||||||||||
| 13 | # Features: | ||||||||||||||||||||||||||||
| 14 | # | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | #============================================================================== | ||||||||||||||||||||||||||||
| 17 | # The Object::Meta::File::List Package | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | =head1 NAME | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | Object::Meta::File::List - Library to index C<Object::Meta::File> instances by | ||||||||||||||||||||||||||||
| 22 | their C<name> field. | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | =cut | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | package Object::Meta::File::List; | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | #---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 29 | #Dependencies | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 2 | ▶ | use parent 'Object::Meta::Named::List'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 2 | ▶ | use Scalar::Util 'blessed'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | C<Object::Meta::File::List> implements a class which indexes C<Object::Meta::File> | ||||||||||||||||||||||||||||
| 38 | instances by their C<name> field. It works exactly like the C<Object::Meta::Named::List> | ||||||||||||||||||||||||||||
| 39 | class. | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | Additionally a C<hash> meta data field will be created for indexation and lookup. | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | The C<hash> meta data field is used to lookup entries. | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | =cut | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | #---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 48 | #Constructors | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | #---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 51 | #Administration Methods | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | =head1 METHODS | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | =head2 Administration Methods | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | =head3 Add ( [ C<Object::Meta::File> | DATA ] ) | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | This works like C<Object::Meta::List::Add()> only that it handles | ||||||||||||||||||||||||||||
| 60 | C<Object::Meta::File> instances. | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | If no parameter is given it creates an empty instance of C<Object::Meta::File> | ||||||||||||||||||||||||||||
| 63 | and adds it to the list | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | B<Parameters:> | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | =over 4 | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | =item C<Object::Meta::File> | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | An instance of C<Object::Meta::File> to be added to the list. | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | =item C<DATA> | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | A hash with data to create an instance of C<Object::Meta::File> and add it to the list. | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | =back | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | B<Returns:> C<Object::Meta::File> - The object which was created or added. | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | See L<Method C<Object::Meta::Named::List::Add()>|Object::Meta::Named::List/"Add ( [ C<Object::Meta::Named> | DATA ] )"> | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | See L<Method C<Object::Meta::List::Add()>|Object::Meta::List/"Add ( [ C<Object::Meta> | DATA ] )"> | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | =cut | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 3 | ▶ | sub Add { | ||||||||||||||||||||||||||
|
Subroutine
Add: called CC=6 SCAR=20.5
Pod
documented
| |||||||||||||||||||||||||||||
| 88 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 89 | 3 | my $mtaety = undef; | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 3 | ▶ | if ( scalar(@_) > 0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 92 | 3 | ▶ | if ( defined blessed $_[0] ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | 3 | $mtaety = $_[0]; | |||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | else #Parameter is not an Object | ||||||||||||||||||||||||||||
| 96 | { | ||||||||||||||||||||||||||||
| 97 | # Create the new Object::Meta::File object from the given parameters | ||||||||||||||||||||||||||||
| 98 | 0 | $mtaety = Object::Meta::File->new(@_); | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 3 | ▶ | if ( defined $mtaety && !$mtaety->isa('Object::Meta::File') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $mtaety and not $mtaety->isa("Object::Meta::File")
MC/DC0%0/2
defined $mtaety and not $mtaety->isa("Object::Meta::File")
defined $mtaety
not $mtaety->isa("Object::Meta::File")
Truth table33%1/3
A and not(B)
A= defined $mtaetyB= not $mtaety->isa("Object::Meta::File")
| |||||||||||||||||||||||||||||
| 103 | 0 | $mtaety = undef; | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 3 | ▶ | $mtaety = Object::Meta::File->new unless ( defined $mtaety ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | #Execute the Base Logic | ||||||||||||||||||||||||||||
| 109 | 3 | $self->SUPER::Add($mtaety); | |||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 3 | return $mtaety; | |||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 2 | return 1; | |||||||||||||||||||||||||||