source: gsdl/trunk/perllib/plugins/AbstractPlugin.pm@ 17026

Last change on this file since 17026 was 17026, checked in by kjdon, 16 years ago

OID generation modifications: OIDtype and OIDmetadata options now available for plugins as well as import. OIDtype for plugins defaults to auto - if set to auto, then use the values from import. All plugins now call self->add_OID instead of doc_obj->set_OID. This sets the doc_obj OIDtype so that doesn't need to be donein other places any more. all plugins have the get_oid_hash_type method - normally returns hash_on_file, but can be overridden to return hash_on_ga_xml for those plugins that don't want hashing on file (MP3,OggVorbis...)

  • Property svn:executable set to *
File size: 3.2 KB
Line 
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###########################################################################
27package AbstractPlugin;
28
29use PrintInfo;
30
31use strict;
32no strict 'subs';
33
34sub BEGIN {
35 @AbstractPlugin::ISA = ( 'PrintInfo' );
36}
37
38my $arguments = [];
39
40
41my $options = { 'name' => "AbstractPlugin",
42 'desc' => "{AbstractPlugin.desc}",
43 'abstract' => "yes",
44 'inherits' => "yes",
45 'args' => $arguments };
46
47
48sub 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
74sub set_incremental {
75 my $self = shift(@_);
76 my ($incremental) = @_;
77
78 $self->{'incremental'} = $incremental;
79}
80
81# called once, at the start of processing
82sub 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
95# called at the beginning of each plugin pass (import has one, buildin has many)
96sub begin {
97 my $self = shift (@_);
98 my ($pluginfo, $base_dir, $processor, $maxdocs) = @_;
99
100}
101
102# called at the end of each plugin pass
103sub end {
104 my ($self) = shift (@_);
105
106}
107
108# called once, after all passes have finished
109sub deinit {
110 my ($self) = @_;
111
112}
113
114sub compile_stats {
115
116}
117
118sub metadata_read {
119 return undef;
120}
121
122sub file_block_read {
123 return undef;
124}
125
Note: See TracBrowser for help on using the repository browser.