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