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

#ifndef IPPTOPSPS_BATCH_H
#define IPPTOPSPS_BATCH_H

#include <libxml/parser.h>
#include <libxml/tree.h>

#include <psmodules.h>
#include <dvo_util.h>

#include "FitsGenerator.h"
#include "Fits.h"
#include "InitData.h"
#include "Logger.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 implement print()
  */
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
    Fits *fitsOut;                 // output FITS file
    pmConfig* pmconfig;            // pmConfig
    dvoConfig* dvoConfig;          // dvo database
    FitsGenerator* fitsGenerator;  // FitsGenerator object
    InitData* initData;            // InitData object
    char todaysDate[20];           // today's date
    int exitCode;                  // ps exit code
    bool testMode;                 // test mode boolean
    Logger* logger;                // Logger object 

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

    // destructor
    void (*destroy)();

} Batch;

// public functions
bool new_Batch(Logger* logger, 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 
