################################################################################
#      writer: Dan Tsafrir (dants AT cs DOT huji DOT ac DOT il)
# description: Some global variables ("constants") that are used throughout.
################################################################################
package ConversionConfig;
use strict;
use warnings;


################################################################################
# THE EXPORTED STUFF:
################################################################################
use Exporter;
our @ISA       = qw(Exporter);
our @EXPORT    = 
    qw(%CONFIG %SWF_COL2INDEX %SWF_COL2INDEX0 @SWF_COLS $SWF_COLNUM); 
our $VERSION   = 1;


################################################################################
# The "constants":
################################################################################

# the conversion configuration (filled by ParseArgv::parse_argv() which parses
# the command line args given to pbs2swf).
our %CONFIG = ();

# the SWF structure: from column name to its position
our %SWF_COL2INDEX = 
    (
     'job'        =>  1,        # a counter field, starting from 1
     'submit'     =>  2,        # seconds. submittal time
     'wait'       =>  3,        # seconds. diff between submit and begin to run
     'runtime'    =>  4,        # seconds. end-time minus start-time
     'proc_used'  =>  5,        # number of allocated processors
     'cpu_used'   =>  6,        # seconds. user+system. avg over procs
     'mem_used'   =>  7,        # KB. avg over procs.
     'proc_req'   =>  8,        # requested number of processors
     'cpu_req'    =>  9,        # seconds. user runtime estimate. "req runtime"
     'mem_req'    => 10,        # KB. avg over procs.
     'status'     => 11,        # 1=success, 0=failure, 5=canceled
     'uid'        => 12,        # user id
     'gid'        => 13,        # group id
     'executable' => 14,        # [1,2..n] n = app# appearing in log
     'queue'      => 15,        # [1,2..n] n = queue# in the system
     'partition'  => 16,        # [1,2..n] n = partition# in the systems
     'prev_jobs'  => 17,        # cur job will start only after ...
     'think_time' => 18,        # seconds should elapse between termination of 
     # preceding job and submittal of this one
     );

# same as %SWF_COL2INDEX, but indexes start at 0
our %SWF_COL2INDEX0 = map {$_ => $SWF_COL2INDEX{$_}-1} keys %SWF_COL2INDEX;

# ordered keys of %SWF_COL2INDEX
our @SWF_COLS = sort( { $SWF_COL2INDEX{$a}<=>$SWF_COL2INDEX{$b} } 
		      keys(%SWF_COL2INDEX) );

# number of SWF fields
our $SWF_COLNUM = scalar(@SWF_COLS);

# sanity
foreach my $field (keys %SWF_COL2INDEX) {
    $SWF_COL2INDEX{$field} == $SWF_COL2INDEX0{$field} + 1
        or die "bug";
}

# dtor.
#sub DESTROY {}
1;

################################################################################
#                                   EOF
################################################################################
