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

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

plugin overhaul: BasPlug has been split into several base plugins: PrintInfo just does the printing for pluginfo.pl, and does the argument parsing in the constructor. All plugins and supporting extractors etc inherit directly or indirectly from this. AbstractPlugin adds a few methods to this, is used by Directory and ArchivesInf plugins. These are not really plugins so can we remove them? anyway, not sure if AbstractPlugin will live for very long. BasePlugin is a proper base plugin, has read and read_into_doc_obj methods. It does nothing with reading in the file or textcat stuff. Makes a basic doc obj and adds some metadata. It also handles all the blocking stuff, associate ext stuff etc. Binary plugins can implement the process method to do file specific stuff. AutoExtractMetadata inherits BasePlugin and adds automatic metadata extraction using hte new Extractor plugins. ReadTextFile is the equivalent in functionality to the old BasPlug - does lang and encoding extraction, and reading in the file. It inherits from AutoExtractMetadata. If your file type is binary and will have no text, then inherit from BasePlugin. If its binary but ends up with text (eg using convert_to) then inherit from AutoExtractMetadata. If your file is a text type file, then inherit from ReadTextFile.

  • Property svn:executable set to *
File size: 1.7 KB
Line 
1package AbstractPlugin;
2
3use PrintInfo;
4
5use strict;
6no strict 'subs';
7
8sub BEGIN {
9 @AbstractPlugin::ISA = ( 'PrintInfo' );
10}
11
12my $arguments = [];
13
14
15my $options = { 'name' => "AbstractPlugin",
16 'desc' => "{AbstractPlugin.desc}",
17 'abstract' => "yes",
18 'inherits' => "yes",
19 'args' => $arguments };
20
21
22sub new
23{
24 my $class = shift (@_);
25 my ($pluginlist,$inputargs,$hashArgOptLists) = @_;
26 my $plugin_name = (defined $pluginlist->[0]) ? $pluginlist->[0] : $class;
27
28 if ($plugin_name eq $class) {
29 push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
30 push(@{$hashArgOptLists->{"OptList"}},$options);
31 }
32
33 my $self = new PrintInfo($pluginlist, $inputargs, $hashArgOptLists);
34
35
36 $self->{'num_processed'} = 0;
37 $self->{'num_not_processed'} = 0;
38 $self->{'num_blocked'} = 0;
39 $self->{'num_archives'} = 0;
40
41 return bless $self, $class;
42}
43
44
45# here are some more methods which we want at a lower level that BasePlugin.
46# but should we have a new class for these?
47# Rec and Arc plugs use these
48sub set_incremental {
49 my $self = shift(@_);
50 my ($incremental) = @_;
51
52 $self->{'incremental'} = $incremental;
53}
54
55sub init {
56 my $self = shift (@_);
57 my ($verbosity, $outhandle, $failhandle) = @_;
58
59 # verbosity is passed through from the processor
60 $self->{'verbosity'} = $verbosity;
61
62 # as are the outhandle and failhandle
63 $self->{'outhandle'} = $outhandle if defined $outhandle;
64 $self->{'failhandle'} = $failhandle;
65
66}
67
68sub begin {
69
70}
71
72sub end {
73
74}
75
76sub deinit {
77
78}
79
80sub compile_stats {
81
82}
83
84sub metadata_read {
85 return undef;
86}
87
Note: See TracBrowser for help on using the repository browser.