1 |
############################################ |
2 |
# |
3 |
# $Id: Result.pm,v 1.1 2002/10/10 03:43:53 cvsjoko Exp $ |
4 |
# |
5 |
# $Log: Result.pm,v $ |
6 |
# Revision 1.1 2002/10/10 03:43:53 cvsjoko |
7 |
# + new |
8 |
# |
9 |
# |
10 |
############################################ |
11 |
|
12 |
package Data::Storage::Result::Abstract; |
13 |
|
14 |
use strict; |
15 |
use warnings; |
16 |
|
17 |
use Data::Dumper; |
18 |
|
19 |
# get logger instance |
20 |
my $logger = Log::Dispatch::Config->instance; |
21 |
|
22 |
sub new { |
23 |
my $invocant = shift; |
24 |
my $class = ref($invocant) || $invocant; |
25 |
my $self = { type => $invocant, @_ }; |
26 |
bless $self, $class; |
27 |
return $self; |
28 |
} |
29 |
|
30 |
sub AUTOLOAD { |
31 |
my $self = shift; |
32 |
our $AUTOLOAD; |
33 |
return if $AUTOLOAD =~ m/::DESTROY$/; |
34 |
|
35 |
# find out methodname |
36 |
my $methodname = $AUTOLOAD; |
37 |
$methodname =~ s/^.*:://; |
38 |
|
39 |
# test for RESULTHANDLE |
40 |
if (!$self->{RESULTHANDLE}) { |
41 |
$logger->error( __PACKAGE__ . ": " . "RESULTHANDLE is undefined while trying to execute method \"$methodname\"" ); |
42 |
return; |
43 |
} |
44 |
|
45 |
# dispatch method-call to COREHANDLE |
46 |
if ($self->{RESULTHANDLE}->can($methodname) || $self->{RESULTHANDLE}->can("AUTOLOAD")) { |
47 |
#$logger->debug( __PACKAGE__ . "->" . $methodname . "(@_)" ); |
48 |
$self->{RESULTHANDLE}->$methodname(@_); |
49 |
} |
50 |
|
51 |
} |
52 |
|
53 |
sub _abstract_function { |
54 |
my $self = shift; |
55 |
my $fName = shift; |
56 |
my $class = ref($self); |
57 |
$logger->error( __PACKAGE__ . ": function \"$fName\" is an abstract method, please implement it in \"$class\""); |
58 |
#exit; |
59 |
} |
60 |
|
61 |
# ==================================================== |
62 |
# CONCRETE METHOD DUMMIES (croaking via "$logger" by calling "_abstract_function") |
63 |
# ==================================================== |
64 |
|
65 |
sub getNextEntry { |
66 |
my $self = shift; |
67 |
$self->_abstract_function('getNextEntry'); |
68 |
} |
69 |
|
70 |
sub getStatus { |
71 |
my $self = shift; |
72 |
$self->_abstract_function('getStatus'); |
73 |
} |
74 |
|
75 |
1; |