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