Ignore:
Timestamp:
2008-08-15T15:30:17+12:00 (16 years ago)
Author:
davidb
Message:

Introduced new merge_inheritance function, useful in a plugin constructor where it is known that later methods will access fields from *multiple* $self super-classes created in the constructor

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/perllib/plugins/BasePlugin.pm

    r16767 r16821  
    214214}
    215215
     216sub merge_inheritance
     217{
     218    my $self = {};
     219    my @child_selfs = @_;
     220
     221    foreach my $child_self (@child_selfs) {
     222    foreach my $key (keys %$child_self) {
     223        if (defined $self->{$key}) {
     224        if ($self->{$key} ne $child_self->{$key}) {
     225#           print STDERR "Warning: Conflicting value in multiple inheritance for '$key'\n";
     226#           print STDERR "Existing stored value = $self->{$key}\n";
     227#           print STDERR "New (child) value     = $child_self->{$key}\n";
     228#           print STDERR "Keeping existing value\n";
     229            # Existing value seems to be option specified in collect.cfg
     230
     231            ### $self->{$key} = $child_self->{$key};
     232           
     233        }
     234        else {
     235##          print STDERR "****Info: Value $self->{$key} for $key already defined through multiple inheritance as the same value\n";
     236        }
     237
     238        }
     239        else {
     240        $self->{$key} = $child_self->{$key};
     241        }
     242    }
     243    }
     244
     245    return $self;   
     246}
     247
    216248# initialize BasePlugin options
    217249# if init() is overridden in a sub-class, remember to call BasePlugin::init()
     
    249281    my $self = shift (@_);
    250282    my ($pluginfo, $base_dir, $processor, $maxdocs) = @_;
     283
     284    # Save base_dir for use in file cache
     285    # Would be more logical to do this in MediaConverter, but
     286    # it's begin method doesn't appear to be called (29/6/08)
     287    $self->{'base_dir'} = $base_dir;
    251288}
    252289
     
    848885   
    849886    my ($process_status,$doc_obj) = $self->read_into_doc_obj(@_);
    850    
     887
    851888    if ((defined $process_status) && ($process_status == 1)) {
    852889
Note: See TracChangeset for help on using the changeset viewer.