00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef FITS_H
00011 #define FITS_H 1
00012
00013
00014 #include <exception>
00015
00016 #include <string>
00017
00018 #include <map>
00019
00020 #include "ExtHDU.h"
00021
00022 #include "HDUCreator.h"
00023
00024 #include "FitsError.h"
00025
00026 namespace CCfits {
00027 class FITSBase;
00028 class PHDU;
00029 class Table;
00030
00031 }
00032
00033 extern "C"
00034 {
00035 # include <sys/stat.h>
00036 }
00037 #include <memory>
00038
00039
00040 namespace CCfits {
00630
00631
00632
00633
00634 class FITS
00635 {
00636
00637 public:
00638
00639
00640
00641 class NoSuchHDU : public FitsException
00642 {
00643 public:
00644 NoSuchHDU (const String& diag, bool silent = true);
00645
00646 protected:
00647 private:
00648 private:
00649 };
00650
00651
00652
00653 class OperationNotSupported : public FitsException
00654 {
00655 public:
00656 OperationNotSupported (const String& msg, bool silent = true);
00657
00658 protected:
00659 private:
00660 private:
00661 };
00662
00663
00664
00665 class CantOpen : public FitsException
00666 {
00667 public:
00668 CantOpen (const String& diag, bool silent = true);
00669
00670 protected:
00671 private:
00672 private:
00673 };
00674
00675
00676
00677 struct CantCreate : public FitsException
00678 {
00679 CantCreate (const String& diag, bool silent = false);
00680
00681 public:
00682 protected:
00683 private:
00684 private:
00685 };
00686 FITS (const String &name, RWmode mode = Read, bool readDataFlag = false, const std::vector<String>& primaryKeys = std::vector<String>());
00687
00688
00689
00690 FITS (const String &name, RWmode mode, const string &hduName, bool readDataFlag = false, const std::vector<String>& hduKeys = std::vector<String>(), const std::vector<String>& primaryKey = std::vector<String>(), int version = 1);
00691
00692
00693
00694 FITS (const String &name, RWmode mode, const std::vector<String>& hduNames, bool readDataFlag = false, const std::vector<String>& primaryKey = std::vector<String>());
00695
00696
00697 FITS (const String& fileName, const FITS& source);
00698
00699
00700
00701 FITS (const String &name, RWmode mode, const std::vector<String>& hduNames, const std::vector<std::vector<String> >& hduKeys, bool readDataFlag = false, const std::vector<String>& primaryKeys = std::vector<String>(), const std::vector<int>& hduVersions = std::vector<int>());
00702
00703
00704 FITS (const String& name, int bitpix, int naxis, long *naxes);
00705
00706
00707
00708 FITS (const string &name, RWmode mode, int hduIndex, bool readDataFlag = false, const std::vector<String>& hduKeys = std::vector<String>(), const std::vector<String>& primaryKey = std::vector<String>());
00709
00710
00711
00712
00713
00714
00715 FITS (const String &name, RWmode mode, const std::vector<String>& searchKeys, const std::vector<String> &searchValues, bool readDataFlag = false, const std::vector<String>& hduKeys = std::vector<String>(), const std::vector<String>& primaryKey = std::vector<string>(), int version = 1);
00716 ~FITS();
00717
00718 static void clearErrors ();
00719 void deleteExtension (const String& doomed, int version = 1);
00720
00721 void read (const String &hduName, bool readDataFlag = false, const std::vector<String> &keys = std::vector<String>(), int version = 1);
00722
00723
00724 void read (const std::vector<String> &hduNames, bool readDataFlag = false);
00725
00726 void read (const std::vector<String> &hduNames, const std::vector<std::vector<String> > &keys, bool readDataFlag = false, const std::vector<int>& hduVersions = std::vector<int>());
00727 FITS * clone () const;
00728 const ExtHDU& extension (int i) const;
00729 ExtHDU& extension (int i);
00730 const ExtHDU& extension (const String& hduName, int version = 1) const;
00731 const PHDU& pHDU () const;
00732 PHDU& pHDU ();
00733 ExtHDU& extension (const String& hduName, int version = 1);
00734 friend std::ostream& operator << (std::ostream& s, const FITS& right);
00735
00736 void read (int hduIndex,
00737
00738 bool readDataFlag = false, const std::vector<String> &keys = std::vector<String>());
00739
00740 Table* addTable (const String& hduName, int rows,
00741 const std::vector<String>& columnName = std::vector<String>(),
00742 const std::vector<String>& columnFmt = std::vector<String>(),
00743 const std::vector<String>& columnUnit = std::vector<String>(),
00744 HduType type = BinaryTbl, int version = 1);
00745
00746 ExtHDU* addImage (const String& hduName, int bpix, std::vector<long>& naxes, int version = 1);
00747
00748
00749 void destroy () throw ();
00750 void flush ();
00751 const String& currentExtensionName () const;
00752
00753
00754
00755
00756
00757
00758 void read (const std::vector<String>& searchKeys, const std::vector<String> &searchValues, bool readDataFlag = false, const std::vector<String>& hduKeys = std::vector<String>(), int version = 1);
00759 const ExtMap& extension () const;
00760 void resetPosition ();
00761 void currentExtensionName (const String& extName);
00762 const String& name () const;
00763 void copy (const HDU& source);
00764 Table& filter (const String& expression, ExtHDU& inputTable, bool overwrite = true, bool readData = false);
00765 ExtHDU& currentExtension ();
00766 void deleteExtension (int doomed);
00767 void setCompressionType (int compType);
00768 void setTileDimensions (const std::vector<long>& tileSizes);
00769 void setNoiseBits (int noiseBits);
00770 int getCompressionType () const;
00771 void getTileDimensions (std::vector<long>& tileSizes) const;
00772 int getNoiseBits () const;
00773 static bool verboseMode ();
00774 static void setVerboseMode (bool value);
00775
00776 public:
00777
00778
00779 protected:
00780
00781
00782 private:
00783 FITS(const FITS &right);
00784 FITS & operator=(const FITS &right);
00785
00786 void unmapExtension (ExtHDU& doomed);
00787 int nextVersionNumber (const String& inputName) const;
00788
00789
00790 void read (bool readDataFlag = false, const std::vector<String>& keys = std::vector<String>());
00791 void open (RWmode mode = Read);
00792
00793
00794
00795
00796
00797 bool create ();
00798
00799
00800
00801 int close () throw ();
00802 std::ostream & put (std::ostream &s) const;
00803 fitsfile*& fitsPointer () const;
00804 ExtHDU& extbyVersion (const String& hduName, int version) const;
00805 void pHDU (PHDU* value);
00806 void readExtensions (bool readDataFlag = false);
00807 ExtHDU* addExtension (ExtHDU* ext);
00808 void swap (FITS& right);
00809 fitsfile*& fitsPointer ();
00810 ExtMap& extension ();
00811 String nameOfUnmapped (int hduNum) const;
00812 void cloneHeader (const ExtHDU& source);
00813
00814
00815
00816 private:
00817
00818 static bool s_verboseMode;
00819
00820
00821 FITSBase* m_FITSImpl;
00822
00823
00824 friend fitsfile* HDU::fitsPointer() const;
00825 friend void HDU::makeThisCurrent() const;
00826 };
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838 inline ExtHDU& FITS::extension (const String& hduName, int version)
00839 {
00840
00841 return extbyVersion(hduName,version);
00842 }
00843
00844 inline std::ostream& operator << (std::ostream& s, const FITS& right)
00845 {
00846
00847 return right.put(s);
00848 }
00849
00850 inline bool FITS::verboseMode ()
00851 {
00852 return s_verboseMode;
00853 }
00854
00855 inline void FITS::setVerboseMode (bool value)
00856 {
00857 s_verboseMode = value;
00858 }
00859
00860 }
00861
00862
00863 #endif