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