###########################################################################
#
# Base plugin for other plugins that don't inherit (directly or indirectly)
# from BasePlugin
#
# A component of the Greenstone digital library software
# from the New Zealand Digital Library Project at the 
# University of Waikato, New Zealand.
#
# Copyright (C) 2008 New Zealand Digital Library Project
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
###########################################################################
package AbstractPlugin;

use PrintInfo;

use strict;
no strict 'subs';

sub BEGIN {
    @AbstractPlugin::ISA = ( 'PrintInfo' );
}

my $arguments = [];


my $options = { 'name'     => "AbstractPlugin",
		'desc'     => "{AbstractPlugin.desc}",
		'abstract' => "yes",
		'inherits' => "yes",
		'args'     => $arguments };


sub new 
{
    my $class = shift (@_);
    my ($pluginlist,$inputargs,$hashArgOptLists) = @_;
    my $plugin_name = (defined $pluginlist->[0]) ? $pluginlist->[0] : $class;

    if ($plugin_name eq $class) {
	push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
	push(@{$hashArgOptLists->{"OptList"}},$options);
    }

    my $self = new PrintInfo($pluginlist, $inputargs, $hashArgOptLists);


    $self->{'num_processed'} = 0;
    $self->{'num_not_processed'} = 0;
    $self->{'num_blocked'} = 0;
    $self->{'num_archives'} = 0;

    return bless $self, $class;
}


# here are some more methods which we want at a lower level that BasePlugin.
# but should we have a new class for these?
# Rec and Arc plugs use these
sub set_incremental {
    my $self = shift(@_);
    my ($incremental) = @_;

    $self->{'incremental'} = $incremental;
}

# called once, at the start of processing
sub init {
    my $self = shift (@_);
    my ($verbosity, $outhandle, $failhandle) = @_;

    # verbosity is passed through from the processor
    $self->{'verbosity'} = $verbosity;

    # as are the outhandle and failhandle
    $self->{'outhandle'} = $outhandle if defined $outhandle;
    $self->{'failhandle'} = $failhandle;

}

# called at the beginning of each plugin pass (import has one, buildin has many)
sub begin {
    my $self = shift (@_);
    my ($pluginfo, $base_dir, $processor, $maxdocs) = @_;

}

# called at the end of each plugin pass
sub end {
    my ($self) = shift (@_);

}

# called once, after all passes have finished
sub deinit {
    my ($self) = @_;

}

sub compile_stats {

}

sub metadata_read {
    return undef;
}

sub file_block_read {
    return undef;
}

