=head1 NAME

  CFX5::Parallel::Reqs::Base - Base for CFX-5 parallel requisites

=head1 DESCRIPTION

This is a base class for prerequisite modules from the CFX-5 parallel
runs.  It defines the interface to these modules, and some utility
functions.

A prerequisite is a prerequisite for the Start Command to be run.

=cut

package CFX5::Parallel::Reqs::Base;

use strict;

=head2 CONSTRUCTOR

=head3 new

You should not need to call the constructor yourself; CFX5::Parallel
will do it for you.

=cut

sub new {
  my $this=shift;
  my $class=ref($this) || $this;
  my $self={};
  bless $self, $class;
  $self->init(@_);
  $self;
}

sub init {
  my $self=shift;

  $self->{__PACKAGE__ . '::ppe'} = shift;
}

=head2 ACCESSORS

=head3 ppe

Returns the CFX5::Parallel object for the current run.

=cut

sub ppe {
  $_[0]->{__PACKAGE__ . '::ppe'};
}

=head2 INTERFACE

Derived modules can provide any or all of these functions, which are
called at different times in the run.

=head3 setup

Does whatever is necessary to provide this prerequisite.

  $req->setup($workdir);

The single argument is the working directory into which to place any
files created.

This call must be overridden by derived classes!

=cut

sub setup {
  my $self=shift;
  internal_error("Call to base-class setup method");
}

1;
