=head1 NAME

  CFX5::Job - Compatibility module

=head1 SYNOPSIS

  # make a new object for a new job
  $job = new CFX5::Job;

=head1 DESCRIPTION

Provides methods that were in the old CFX5::Job module
Most of these call the corresponding CFX5::Configuration method directly

=cut

package CFX5::Job;

use strict;

use CFX5::PathManip qw(fullpath);
use CFX5::Simulation::Configuration;

use base 'CFX5::Simulation';

use Carp;

=head2 CONSTRUCTORS

=head3 new

  $job=new CFX5::Job();

Creates a new job object.
This is simply a Simulation object with a single configuration.

=cut

sub new {
  my $class = shift;
  my $self = {
             };
  bless $self, $class;

  $self->SUPER::initialise();
  $self->init();
  
  return $self;
}

sub init {
  my $self=shift;
  # Use dummy values for the configuration ID step
  my $configid = 1;
  my $configstep = 0;
  $self->add_configuration($configid, $configstep, "Default");
  $self->createConfig($configid, $configstep);
  $self->singleconfig(1);
  $self->{currentconfig} = $configid;
}

=head2 METHODS

Functions to provide compatibility with the old Job methods

=cut

sub text_command {
  my $self = shift;
  return $self->config_object()->text_command(@_);
}

sub deffile {
  my $self = shift;
  return $self->config_object()->deffile(@_);
}

sub read_def_ccl {
  my $self = shift;
  return $self->config_object()->read_def_ccl(@_);
}

sub read_ccl {
  my $self = shift;
  return $self->config_object()->read_ccl(@_);
}

sub get_current_ccl {
  my $self = shift;
  return $self->config_object()->get_current_ccl(@_);
}

sub name {
  my $self = shift;
  return $self->config_object()->name(@_);
}

sub fullname {
  my $self = shift;
  return $self->config_object()->fullname(@_);
}

sub ChooseName {
  my $self = shift;
  # To emulate the old CFX5::Job method, the name uses the full path
  my $fullname = fullpath($self->config_object()->ChooseName(@_));
  $self->fullname($fullname);;
  return $fullname;
}

sub StartOutFile {
  my $self = shift;
  return $self->config_object()->StartOutFile(@_);
}

sub rundir {
  my $self = shift;
  return $self->config_object()->rundir(@_);
}

sub rundir_obj {
  my $self = shift;
  return $self->config_object()->rundir_obj(@_);
}

sub OutFileHeader {
  my $self = shift;
  return $self->config_object()->OutFileHeader(@_);
}

sub outobj {
  my $self = shift;
  return $self->config_object()->outobj(@_);
}

sub TidyupRun {
  my $self = shift;
  return $self->config_object()->TidyupRun(@_);
}

sub HaveFile {
  my $self = shift;
  return $self->config_object()->HaveFile(@_);
}

sub read_ccl_parm {
  my $self = shift;
  return $self->config_object()->read_ccl_parm(@_);
}

sub ccl_api_obj {
  my $self = shift;
  return $self->config_object()->ccl_api_obj(@_);
}

sub flow_name {
  my $self = shift;
  if (@_) {
    $self->config_object()->{settings}->{flow_name} = shift;
  } else {
    return $self->config_object()->flow_name();
  }
}

1;
