// SWIG interface for heasp library. Based on heasp.h, pha.h, phaII.h, rmf.h, rmft.h, 
// arf.h, arfII.h, grouping.h table.h

%module heasp

%{
#include <fstream>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <sstream>
#include <string>
#include <stdexcept>
#include <ctime>
#include <valarray>
#include <vector>

#include <CCfits/CCfits>

#include "../heasp.h"
#include "../pha.h"
#include "../phaII.h"
#include "../rmf.h"
#include "../rmft.h"
#include "../arf.h"
#include "../arfII.h"
#include "../grouping.h"
#include "../table.h"

// using heasp namespace
using namespace heasp;
%}

// define Integer and Real

typedef int Integer;
typedef double Real;

// and helpful to have definitions of some vector and valarray quantities

typedef std::valarray<Real> RealArray;
typedef std::vector<Real> RealVector;
typedef std::vector<Integer> IntegerVector;
typedef std::vector<std::string> StringVector;

// set up error statuses

enum{OK, NoSuchFile, NoData, NoChannelData, NoStatError, CannotCreate,
     NoEnergLo, NoEnergHi, NoSpecresp, NoEboundsExt, NoEmin, NoEmax,
     NoMatrixExt, NoNgrp, NoFchan, NoNchan, NoMatrix, CannotCreateMatrixExt,
     CannotCreateEboundsExt, InconsistentGrouping, InconsistentEnergies,
     InconsistentChannels, InconsistentUnits, UnknownXUnits, UnknownYUnits,
     InconsistentNumelt, InconsistentNumgrp, InconsistentNumTableParams,
     TableParamValueOutsideRange, VectorIndexOutsideRange, InconsistentKeywordValues,
     CannotCopyColumn, CannotWriteMatrix, InconsistentTableFilter,
     NoChannels, InconsistentChannelMin, InconsistentFChan, InconsistentNChan};

const std::string SPerrorNames[] =
  {"OK", "NoSuchFile", "NoData", "NoChannelData", "NoStatError", "CannotCreate",
   "NoEnergLo", "NoEnergHi", "NoSpecresp", "NoEboundsExt", "NoEmin", "NoEmax",
   "NoMatrixExt", "NoNgrp", "NoFchan", "NoNchan", "NoMatrix", "CannotCreateMatrixExt",
   "CannotCreateEboundsExt", "InconsistentGrouping", "InconsistentEnergies",
   "InconsistentChannels", "InconsistentUnits", "UnknownXUnits", "UnknownYUnits",
   "InconsistentNumelt", "InconsistentNumgrp", "InconsistentNumTableParams",
   "TableParamValueOutsideRange", "VectorIndexOutsideRange",
   "InconsistentKeywordValues", "CannotCopyColumn", "CannotWriteMatrix",
   "InconsistentTableFilter", "NoChannels", "InconsistentChannelMin",
   "InconsistentFChan", "InconsistentNChan"};

// the error message stack

static StringVector SPerrorStack;

static const Real FUZZY = 1.0e-6;

static const std::string BlankStr = " ";

// SWIG and numpy includes

%include "config.i"

// *************************************************************************
// Class definitions for pha object

// python renames
%rename(__iadd__) pha::operator+=;
%rename(__imul__) pha::operator*=;

%include "../pha.h"

// *************************************************************************
// Class definitions for phaII object

%include "../phaII.h"


// *************************************************************************
// Class definitions for rmf object

// python renames
%rename(__iadd__) rmf::operator+=;
%rename(__imul__) rmf::operator*=;

%include "../rmf.h"

// *************************************************************************
// Class definitions for ResponseMatrixTranspose object

%include "../rmft.h"

// *************************************************************************
// Class definitions for arf object

// python renames
%rename(__iadd__) arf::operator+=;

%include "../arf.h"

// *************************************************************************
// Definition of the arfII object. Just a wrap-up for a vector array of arf objects

%include "../arfII.h"

// *************************************************************************
// class definition for grouping class. Useful for setting grouping arrays and binning
// both spectra and responses.

%include "../grouping.h"

// *************************************************************************
// class definitions for table classes

%include "../table.h"



