| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Algorithm::LSH::Base; | 
| 2 | 5 |  |  | 5 |  | 26 | use strict; | 
|  | 5 |  |  |  |  | 8 |  | 
|  | 5 |  |  |  |  | 145 |  | 
| 3 | 5 |  |  | 5 |  | 31 | use warnings; | 
|  | 5 |  |  |  |  | 9 |  | 
|  | 5 |  |  |  |  | 125 |  | 
| 4 | 5 |  |  | 5 |  | 22 | use base qw( Class::Accessor::Fast Class::Data::Inheritable); | 
|  | 5 |  |  |  |  | 8 |  | 
|  | 5 |  |  |  |  | 4470 |  | 
| 5 | 5 |  |  | 5 |  | 23398 | use Carp; | 
|  | 5 |  |  |  |  | 12 |  | 
|  | 5 |  |  |  |  | 856 |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | __PACKAGE__->mk_accessors($_) for qw( context d L k ); | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | sub new { | 
| 10 | 18 |  |  | 18 | 1 | 52 | my $class = shift; | 
| 11 | 18 |  |  |  |  | 165 | my $self = $class->SUPER::new( {@_} ); | 
| 12 | 18 |  |  |  |  | 261 | return $self; | 
| 13 |  |  |  |  |  |  | } | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | sub mk_virtual_methods { | 
| 16 | 7 |  |  | 7 | 1 | 17 | my $class = shift; | 
| 17 | 7 |  |  |  |  | 15 | foreach my $method (@_) { | 
| 18 | 7 |  |  |  |  | 17 | my $slot = "${class}::${method}"; | 
| 19 |  |  |  |  |  |  | { | 
| 20 | 5 |  |  | 5 |  | 25 | no strict 'refs'; | 
|  | 5 |  |  |  |  | 6 |  | 
|  | 5 |  |  |  |  | 931 |  | 
|  | 7 |  |  |  |  | 17 |  | 
| 21 | 7 |  |  |  |  | 51 | *{$slot} = sub { | 
| 22 | 1 |  |  | 1 |  | 237 | Carp::croak( ref( $_[0] ) . "::${method} is not overridden" ); | 
| 23 |  |  |  |  |  |  | } | 
| 24 | 7 |  |  |  |  | 38 | } | 
| 25 |  |  |  |  |  |  | } | 
| 26 | 7 |  |  |  |  | 31 | return (); | 
| 27 |  |  |  |  |  |  | } | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | sub _check_parameters { | 
| 30 | 9 |  |  | 9 |  | 17 | my $self = shift; | 
| 31 | 9 |  |  |  |  | 23 | for my $param ( 'd', 'L', 'k' ) { | 
| 32 | 27 | 50 |  |  |  | 319 | unless ( $self->$param ) { | 
| 33 | 0 |  |  |  |  | 0 | croak( | 
| 34 |  |  |  |  |  |  | "ERROR: cannot create object [ new() method had to parameter '$param' is necessary ]" | 
| 35 |  |  |  |  |  |  | ); | 
| 36 |  |  |  |  |  |  | } | 
| 37 |  |  |  |  |  |  | } | 
| 38 | 9 | 50 |  |  |  | 72 | if ( $self->k > $self->d ) { | 
| 39 | 0 |  |  |  |  |  | croak( | 
| 40 |  |  |  |  |  |  | "ERROR: cannot create object [ parameter 'k' must be smaller than parameter 'd' ]" | 
| 41 |  |  |  |  |  |  | ); | 
| 42 |  |  |  |  |  |  | } | 
| 43 |  |  |  |  |  |  | } | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | 1; | 
| 46 |  |  |  |  |  |  | __END__ |