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