/** @file ippToPsps.h
 *
 *  @brief Batch
 *
 *  @ingroup ippToPsps
 *
 *  @author IfA
 *  Copyright 2009 Institute for Astronomy, University of Hawaii
 */

#ifndef IPPTOPSPS_BATCH_H
#define IPPTOPSPS_BATCH_H

#include <psmodules.h>
#include <dvo_util.h>
#include "ippToPspsConfig.h"
#include <libxml/parser.h>
#include <libxml/tree.h>

/**
  Abstract base class for all batches. Known subclasses are:

  - InitBatch
  - DetectionBatch
  - StackBatch

  All subclasses need to implement the run() method and may need to implenent print() and/or init()
  */
typedef struct Batch {

    // fields
    char surveyType[10];        // the survey type, eg 3PI, MD01, STS, SSS
    int8_t surveyID;            // survey ID
    char fitsInPath[1000];      // path to FITS input
    char resultsPath[1000];     // path to results file
    xmlDocPtr resultsXmlDoc;    // pointer to XML document for results
    uint16_t numOfInputFiles;   // number of input files
    char** inputFiles;          // array of input file names
    char fitsOutFile[100];      // FITS output filename
    char fitsOutPath[1000];     // path to FITS output
    fitsfile *fitsOut;          // output FITS file
    char configsDir[500];       // path to IPP/PSPS mapping file
    pmConfig* pmconfig;         // pmConfig
    dvoConfig* dvoConfig;       // dvo database
    IppToPspsConfig* config;    // config structure
    char todaysDate[20];        // today's date
    int exitCode;               // ps exit code

    // methods
    bool (*parseArguments)();
    bool (*init)();
    int (*run)();
    void (*print)();
    bool (*gotResultsPath)(); 
    bool (*gotFitsInPath)();
    bool (*gotFitsOutPath)();
    bool (*gotConfig)();
    bool (*gotSurveyType)(); 
    void (*destroy)();

} Batch;

// public functions
bool new_Batch(Batch *this);

void ippToPsps_VersionPrint(void);

bool getFlux(
        const float exposureTime, 
        const float magnitude, 
        float* flux, 
        const float magnitudeErr, 
        float* fluxErr);

# endif // IPPTOPSPS_BATCH_H 
