// $Header: https://oberon.oapd.inaf.it/shins/trunk/shins/src/data_mgr/fitsFileI.hpp 3652 2021-05-21 10:34:10Z depa $

#ifndef __FITSFILEI_HPP__
#define __FITSFILEI_HPP__

#include <string>
#include <algorithm>

#include <boost/filesystem.hpp>
#include <boost/python.hpp>

#include <Ice/Ice.h>
#include <IceUtil/Optional.h>

#include <Nice/Log.h>

#include <fitsio.h>
#include "dataManager.h"

using namespace sharknir;
namespace py = boost::python;
namespace bt = boost;


class fitsFileI : public dataManager::fitsFile
{
private:
std::string m_curFilenameSHINS;
std::string m_curFilenameSASHA;
public:
fitsFileI(int argc, char*argv[]);
~fitsFileI();

Ice::Int createEmptyFile(const std::string& _inFilename,
                         const IceUtil::Optional<std::string>& _instrumentMode,
                         std::string& _outFilename,
                         const Ice::Current&);

  Ice::Int createEmptyAndPopulateHeader(const std::string& _inFilename,
                                        Ice::Int _bitpix, Ice::Int _naxis,
                                        const sharknir::SeqLong& _naxes,
                                        const Ice::Current&);

  Ice::Int printFITS(const std::string& _key,
                   const std::string& _value,
                   const IceUtil::Optional<std::string>& _comment,
                   const IceUtil::Optional<std::string>& _filename,
                   const Ice::Current&);

Ice::Int printFITSMultipleKeys(const sharknir::SeqString& _seqKey,
                               const sharknir::SeqString& _seqValue,
                               const sharknir::SeqString& _seqComment,
                               const IceUtil::Optional<std::string>& _filename,
                               const Ice::Current&);

Ice::Int mergeHeaders(const IceUtil::Optional<std::string>& _filenameSASHA,
                      const IceUtil::Optional<std::string>& _filenameSHINS,
                      const Ice::Current&);

Ice::Int populateWithData(const IceUtil::Optional<std::string>& _filenameSASHA,
                          const IceUtil::Optional<std::string>& _filenameSHINS,
                          const Ice::Current&);
Ice::Int fitsToArchive(const IceUtil::Optional<std::string>& _filenameSASHA,
                       const Ice::Current&);

std::string getCurrentFilenameSHINS(const Ice::Current&);
std::string getCurrentFilenameSASHA(const Ice::Current&);
Ice::Int setCurrentFilenameSASHA(const std::string& _filename, const Ice::Current&);

  std::string saveSASHABLOB(Ice::Byte BLOBptrAddress, const IceUtil::Optional<int>& counter, const Ice::Current&);
};

typedef IceUtil::Handle<fitsFileI> fitsFileIPtr;

#endif
