[16025] | 1 | ###########################################################################
|
---|
| 2 | #
|
---|
| 3 | # Base plugin for other plugins that don't inherit (directly or indirectly)
|
---|
| 4 | # from BasePlugin
|
---|
| 5 | #
|
---|
| 6 | # A component of the Greenstone digital library software
|
---|
| 7 | # from the New Zealand Digital Library Project at the
|
---|
| 8 | # University of Waikato, New Zealand.
|
---|
| 9 | #
|
---|
| 10 | # Copyright (C) 2008 New Zealand Digital Library Project
|
---|
| 11 | #
|
---|
| 12 | # This program is free software; you can redistribute it and/or modify
|
---|
| 13 | # it under the terms of the GNU General Public License as published by
|
---|
| 14 | # the Free Software Foundation; either version 2 of the License, or
|
---|
| 15 | # (at your option) any later version.
|
---|
| 16 | #
|
---|
| 17 | # This program is distributed in the hope that it will be useful,
|
---|
| 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 20 | # GNU General Public License for more details.
|
---|
| 21 | #
|
---|
| 22 | # You should have received a copy of the GNU General Public License
|
---|
| 23 | # along with this program; if not, write to the Free Software
|
---|
| 24 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 25 | #
|
---|
| 26 | ###########################################################################
|
---|
[15868] | 27 | package AbstractPlugin;
|
---|
| 28 |
|
---|
| 29 | use PrintInfo;
|
---|
| 30 |
|
---|
| 31 | use strict;
|
---|
| 32 | no strict 'subs';
|
---|
| 33 |
|
---|
| 34 | sub BEGIN {
|
---|
| 35 | @AbstractPlugin::ISA = ( 'PrintInfo' );
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | my $arguments = [];
|
---|
| 39 |
|
---|
| 40 |
|
---|
| 41 | my $options = { 'name' => "AbstractPlugin",
|
---|
| 42 | 'desc' => "{AbstractPlugin.desc}",
|
---|
| 43 | 'abstract' => "yes",
|
---|
| 44 | 'inherits' => "yes",
|
---|
| 45 | 'args' => $arguments };
|
---|
| 46 |
|
---|
| 47 |
|
---|
| 48 | sub new
|
---|
| 49 | {
|
---|
| 50 | my $class = shift (@_);
|
---|
| 51 | my ($pluginlist,$inputargs,$hashArgOptLists) = @_;
|
---|
| 52 | my $plugin_name = (defined $pluginlist->[0]) ? $pluginlist->[0] : $class;
|
---|
| 53 |
|
---|
| 54 | if ($plugin_name eq $class) {
|
---|
| 55 | push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
|
---|
| 56 | push(@{$hashArgOptLists->{"OptList"}},$options);
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 | my $self = new PrintInfo($pluginlist, $inputargs, $hashArgOptLists);
|
---|
| 60 |
|
---|
| 61 |
|
---|
| 62 | $self->{'num_processed'} = 0;
|
---|
| 63 | $self->{'num_not_processed'} = 0;
|
---|
| 64 | $self->{'num_blocked'} = 0;
|
---|
| 65 | $self->{'num_archives'} = 0;
|
---|
| 66 |
|
---|
| 67 | return bless $self, $class;
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 |
|
---|
| 71 | # here are some more methods which we want at a lower level that BasePlugin.
|
---|
| 72 | # but should we have a new class for these?
|
---|
| 73 | # Rec and Arc plugs use these
|
---|
| 74 | sub set_incremental {
|
---|
| 75 | my $self = shift(@_);
|
---|
| 76 | my ($incremental) = @_;
|
---|
| 77 |
|
---|
| 78 | $self->{'incremental'} = $incremental;
|
---|
| 79 | }
|
---|
| 80 |
|
---|
[17026] | 81 | # called once, at the start of processing
|
---|
[15868] | 82 | sub init {
|
---|
| 83 | my $self = shift (@_);
|
---|
| 84 | my ($verbosity, $outhandle, $failhandle) = @_;
|
---|
| 85 |
|
---|
| 86 | # verbosity is passed through from the processor
|
---|
| 87 | $self->{'verbosity'} = $verbosity;
|
---|
| 88 |
|
---|
| 89 | # as are the outhandle and failhandle
|
---|
| 90 | $self->{'outhandle'} = $outhandle if defined $outhandle;
|
---|
| 91 | $self->{'failhandle'} = $failhandle;
|
---|
| 92 |
|
---|
| 93 | }
|
---|
| 94 |
|
---|
[17026] | 95 | # called at the beginning of each plugin pass (import has one, buildin has many)
|
---|
[15868] | 96 | sub begin {
|
---|
[17026] | 97 | my $self = shift (@_);
|
---|
| 98 | my ($pluginfo, $base_dir, $processor, $maxdocs) = @_;
|
---|
[15868] | 99 |
|
---|
| 100 | }
|
---|
| 101 |
|
---|
[17026] | 102 | # called at the end of each plugin pass
|
---|
[15868] | 103 | sub end {
|
---|
[17026] | 104 | my ($self) = shift (@_);
|
---|
[15868] | 105 |
|
---|
| 106 | }
|
---|
| 107 |
|
---|
[17026] | 108 | # called once, after all passes have finished
|
---|
[15868] | 109 | sub deinit {
|
---|
[17026] | 110 | my ($self) = @_;
|
---|
[15868] | 111 |
|
---|
| 112 | }
|
---|
| 113 |
|
---|
| 114 | sub compile_stats {
|
---|
| 115 |
|
---|
| 116 | }
|
---|
| 117 |
|
---|
| 118 | sub metadata_read {
|
---|
| 119 | return undef;
|
---|
| 120 | }
|
---|
| 121 |
|
---|
[16388] | 122 | sub file_block_read {
|
---|
| 123 | return undef;
|
---|
| 124 | }
|
---|
| 125 |
|
---|