#if !defined( _IOAFITSHEADER_H )
#define _IOAFITSHEADER_H

#include "ImageFileFormat.h"

// FITS file header
class IoAFITSHeader
{
public:
    IoAFITSHeader( )
    {
        Clear( );
        
        m_SIMPLE = TRUE;
        m_BITPIX = 16;
        m_NAXIS  = 2;
        m_BZERO  = 32768.0;
        m_BSCALE = 1.0;
        m_EXTEND = TRUE;
    }

    void Clear( ) { ::ZeroMemory( this, sizeof( IoAFITSHeader ) ); }

    static int Size( IoAImageFileFormat::ImageFileFormat FileFormat )
    {
        // Header size is always a multiple of 36 * 80 = 2880 bytes
        switch ( FileFormat )
        {
            case IoAImageFileFormat::FITSFormat:  return 2880;
            case IoAImageFileFormat::LuckyFormat: return 2880;

            default: return 0;
        }
    }

    void Set( const char *Name, int Value );

    int Encode( char *FITSHeader, IoAImageFileFormat::ImageFileFormat FileFormat );
    int Decode( const char *FITSHeader );

    int Parse( const char *FITSHeader ) { return Decode( FITSHeader ); }  // old style decode

    int IsValid( ) const { return m_Valid; }

    int    m_SIMPLE;
    int    m_BITPIX;
    int    m_NAXIS;
    int    m_NAXIS1;
    int    m_NAXIS2;
    int    m_EXTEND;
    double m_BZERO;
    double m_BSCALE;
    int    m_FRAMETIM;
    int    m_CAMERAID;
    int    m_FRAMENUM;
    int    m_LC_FORMT;
    int    m_LC_CBITS;
    int    m_LC_UBITS;
    int    m_LC_OFFST;
    int    m_LCL_ZERO;
    int    m_CPUCLKHI;
    int    m_CPUCLKLO;
    int    m_DMABUFID;

private:
    int m_Valid;
};

#endif

