package Util::HEAdas;
##############################################################################
#
# DESCRIPTION: This sub-class adds HEAdas environment initialization
#
# HISTORY
# HISTORY: $Log: HEAdas.pm,v $
# HISTORY: Revision 1.2 2006/08/01 20:35:34 apsop
# HISTORY: Add in CVS history indicator.
# HISTORY:
# HISTORY: 1.0 -> 1.1 2001-03-05
# HISTORY: Modified the way the PATH and LD_LIBRARY_PATH environment variables
# HISTORY: are set to make the more robust.
# HISTORY:
# HISTORY: 1.1 -> 2.0 2002-04-18
# HISTORY: Made this a subclass of ParfileTool to better handle FTOOLS
# HISTORY: and HEAdas, not to mention PseudoFtools.
# HISTORY:
# HISTORY: 2.0 -> 2.1 2004-02-11
# HISTORY: The environment method now returns a reference to a hash
# HISTORY:
# HISTORY: 2.1 -> 2.2 2004-03-09
# HISTORY: Moved HEADASNOQUERY environment variable to ParfileTool.pm
#
# VERSION: 2.2
#
##############################################################################
use Util::ParfileTool;
@ISA=("Util::ParfileTool");
use strict;
my $INSTALL_DIR;
my @BINS=();
my @LIBS=();
my $SYSPFILES;
my %ENVIRONMENT=();
my %SCRIPT_ENVIRONMENT=();
my $VERSION;
#########################################################################
#
#########################################################################
sub new {
my $self=shift;
my $tool=shift;
$self->SUPER::new($tool,$SYSPFILES, \@BINS, \@LIBS);
} # end of constructor
######################
# ACCESSORS:
######################
########################################################################
# Returns a hash of environment variables which must
# be set before running this tool
########################################################################
sub environment {
my $self=shift;
if($self->{IS_SCRIPT} ) { return {%{$self->SUPER::environment()}, %ENVIRONMENT, %SCRIPT_ENVIRONMENT}; }
else { return {%{$self->SUPER::environment()}, %ENVIRONMENT}; }
} # end of environment method
####################################################################
# This method does all the initialization for this class, given
# the name of the machine-specific instalation directory.
# Note this method must be called after the corresponding method is called
# for the Ftools.
####################################################################
sub install_dir {
my $self=shift;
if(@_) {
$INSTALL_DIR=shift;
#####################################################
# set the executable directories and
# the parfile directory
#####################################################
@BINS=("$INSTALL_DIR/bin", '/bin');
@LIBS=("$INSTALL_DIR/lib");
$SYSPFILES = "$INSTALL_DIR/syspfiles";
##########################################
# parse the version name
##########################################
($VERSION) = $INSTALL_DIR =~ m|/\w*\.([^/]*)/|;
#####################################################
# Set the environment variables
#####################################################
$ENVIRONMENT{HEADAS}=$INSTALL_DIR;
$ENVIRONMENT{HEADASOUTPUT}="stdout";
$ENVIRONMENT{HEADASERROR }="stderr";
$ENVIRONMENT{HEADASPROMPT}="/dev/null";
#####################################################
# special stuff for scripts
#####################################################
$SCRIPT_ENVIRONMENT{PERLLIB} = "$INSTALL_DIR/lib/perl";
$SCRIPT_ENVIRONMENT{PER5LLIB} = "$INSTALL_DIR/lib/perl";
$SCRIPT_ENVIRONMENT{PATH} = join (":", (@BINS, @{Util::Ftool::BINS})) .
$ENV{PATH};
}
return $INSTALL_DIR;
}
##############################################################
# returns the version of the package being used.
# Note this version name is derived by parsing the name
# of the instalation directory.
############################################################
sub version {
my $self=shift;
return $VERSION;
}
####################################################
# assemble the error message.
# Override the generic message to specify "FTOOL"
####################################################
sub error_message {
my $self=shift;
my $message="Error from HEAdas Task $self->{COMMAND} - ".
"exit status $self->{STATUS}";
return $message;
}
sub DESTROY {
my $self = shift;
# check for an overridden destructor...
$self->SUPER::DESTROY if $self->can("SUPER::DESTROY");
}
1;