File::Comments::Plugin - Base class for all File::Comments plugins


File-Comments documentation Contained in the File-Comments distribution.

Index


Code Index:

NAME

Top

File::Comments::Plugin - Base class for all File::Comments plugins

SYNOPSIS

Top

    use File::Comments::Plugin;

DESCRIPTION

Top

File::Comments::Plugin is an abstract base class for all plugins in the File::Comments framework.

LEGALESE

Top

Copyright 2005 by Mike Schilli, all rights reserved. This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

Top

2005, Mike Schilli <cpan@perlmeister.com>


File-Comments documentation Contained in the File-Comments distribution.

###########################################
# File::Comments::Plugin -- 2005, Mike Schilli <cpan@perlmeister.com>
###########################################

###########################################
package File::Comments::Plugin;
###########################################

use strict;
use warnings;
use Log::Log4perl qw(:easy);

###########################################
sub new {
###########################################
    my($class, %options) = @_;

    my $self = {
        %options,
    };

    bless $self, $class;

    $self->init();

    return $self;
}

###########################################
sub applicable {
###########################################
    my($self, $target, $cold_call) = @_;

    if($cold_call) {
        DEBUG "", __PACKAGE__, " doesn't accept cold calls";
        return 0;
    }

    DEBUG "", __PACKAGE__, " accepts";
    return 1;
}

###########################################
sub comments {
###########################################
    die "Mandatory method comments() not defined in ", ref $_[0];
}

###########################################
sub init {
###########################################
    die "Mandatory method init() not defined in ", ref $_[0];
}

###########################################
sub register_suffix {
###########################################
    my($self, $suffix) = @_;
    
    $self->mothership()->register_suffix($suffix, $self);
}

###########################################
sub register_base {
###########################################
    my($self, $base) = @_;
    
    $self->mothership()->register_base($base, $self);
}

###########################################
sub mothership { return $_[0]->{mothership} }
###########################################

1;

__END__