FITS.h

00001 //      This is version 1.6 release dated Nov 2006
00002 //      Astrophysics Science Division,
00003 //      NASA/ Goddard Space Flight Center
00004 //      HEASARC
00005 //      http://heasarc.gsfc.nasa.gov
00006 //      e-mail: ccfits@legacy.gsfc.nasa.gov
00007 //
00008 //      Original author: Ben Dorman, L3-Communications EER Systems Inc.
00009 
00010 #ifndef FITS_H
00011 #define FITS_H 1
00012 
00013 // exception
00014 #include <exception>
00015 // string
00016 #include <string>
00017 // map
00018 #include <map>
00019 // ExtHDU
00020 #include "ExtHDU.h"
00021 // HDUCreator
00022 #include "HDUCreator.h"
00023 // FitsError
00024 #include "FitsError.h"
00025 
00026 namespace CCfits {
00027   class FITSBase;
00028   class PHDU;
00029   class Table;
00030 
00031 } // namespace CCfits
00032 //class PHDU;
00033 extern "C"
00034 {
00035 #       include <sys/stat.h>
00036 }           
00037 #include <memory>
00038 
00039 
00040 namespace CCfits {
00630   //    ! The FITS object class. Contains a primary HDU and Extensions indexed by name.
00631 
00632 
00633 
00634   class FITS 
00635   {
00636 
00637     public:
00638 
00639 
00640 
00641       class NoSuchHDU : public FitsException  //## Inherits: <unnamed>%396C90CB0236
00642       {
00643         public:
00644             NoSuchHDU (const String& diag, bool silent = true);
00645 
00646         protected:
00647         private:
00648         private: //## implementation
00649       };
00650 
00651 
00652 
00653       class OperationNotSupported : public FitsException  //## Inherits: <unnamed>%39806C7600D5
00654       {
00655         public:
00656             OperationNotSupported (const String& msg, bool silent = true);
00657 
00658         protected:
00659         private:
00660         private: //## implementation
00661       };
00662 
00663 
00664 
00665       class CantOpen : public FitsException  //## Inherits: <unnamed>%39C8EB1D02C0
00666       {
00667         public:
00668             CantOpen (const String& diag, bool silent = true);
00669 
00670         protected:
00671         private:
00672         private: //## implementation
00673       };
00674 
00675 
00676 
00677       struct CantCreate : public FitsException  //## Inherits: <unnamed>%39C8EB10020B
00678       {
00679             CantCreate (const String& diag, bool silent = false);
00680 
00681         public:
00682         protected:
00683         private:
00684         private: //## implementation
00685       };
00686         FITS (const String &name, RWmode mode = Read, bool readDataFlag = false, const std::vector<String>& primaryKeys = std::vector<String>());
00687         //      Open a file and read a specified HDU.
00688         //
00689         //      Optional parameter allows the reading of specified primary HDU keys.
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         //      Read data from a set of specified HDUs. keywords can only be specified for the primary here.
00692         //      The code will call a different constructor for the case where keywords are required for
00693         //      the extensions.
00694         FITS (const String &name, RWmode mode, const std::vector<String>& hduNames, bool readDataFlag = false, const std::vector<String>& primaryKey = std::vector<String>());
00695         //      Initialize a new FITS file object with the primary from a
00696         //      different file.
00697         FITS (const String& fileName, const FITS& source);
00698         //      Fully general FITS HDU reader. May read any part of fits file by
00699         //      supplying HDU names and version numbers, and optionally
00700         //      the data read flag.
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         //      Writing constructor. Takes a name and information to create an empty
00703         //      Primary HDU which can then be filled with calls to HDU methods.
00704         FITS (const String& name, int bitpix, int naxis, long *naxes);
00705         //      Open a file and read a specified HDU.
00706         //
00707         //      Optional parameter allows the reading of specified primary HDU keys.
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         //      Open a file and read a HDU that contains  specified
00710         //      search keywords with [optional] specified values
00711         //      (sometimes one just wants to know that the keyword is present).
00712         //
00713         //      Optional parameters allows the reading of specified primary HDU keys and specified keywords in
00714         //      the HDU of interest.
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         //      Read keys and data from a single ExtHDU in the file.
00721         void read (const String &hduName, bool readDataFlag = false, const std::vector<String> &keys = std::vector<String>(), int version = 1);
00722         //      Read multiple ExtHDUs. If the version number needs to be specified then one must call a
00723         //      different method.
00724         void read (const std::vector<String> &hduNames, bool readDataFlag = false);
00725         //      Read selected data from multiple ExtHDUs
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         //      Read keys and data from a single ExtHDU in the file.
00736         void read (int hduIndex,        // Construct and Read HDU specified by number. One can add further HDUs by number using
00737                 // the HDUCreator factory.
00738         bool readDataFlag = false, const std::vector<String> &keys = std::vector<String>());
00739         //      ! add a new Table extension to a FITS object
00740         Table* addTable (const String& hduName, int rows,       // ! Number of rows in new table. Mandatory
00741         const std::vector<String>& columnName = std::vector<String>(),  // ! Optional set of column names for new table
00742         const std::vector<String>& columnFmt = std::vector<String>(),   // ! Column formats for column units. Mandatory if columnName is specified
00743         const std::vector<String>& columnUnit = std::vector<String>(),  // ! Column formats for column units. Optional
00744         HduType type = BinaryTbl, int version = 1);
00745         //      ! add a new ImageExt (image extension) to the FITS object. A "writing" method.
00746         ExtHDU* addImage (const String& hduName, int bpix, std::vector<long>& naxes, int version = 1);
00747         //      Force destruction of the FITS object. Essentially
00748         //      is a manual destructor call.
00749         void destroy () throw ();
00750         void flush ();
00751         const String& currentExtensionName () const;
00752         //      Open a file and read a HDU that contains  specified
00753         //      search keywords with [optional] specified values
00754         //      (sometimes one just wants to know that the keyword is present).
00755         //
00756         //      Optional parameters allows the reading of specified primary HDU keys and specified keywords in
00757         //      the HDU of interest.
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       // Additional Public Declarations
00778 
00779     protected:
00780       // Additional Protected Declarations
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         //      read the primary HDU. Read the image if
00789         //      readDataFlag is true.
00790         void read (bool readDataFlag = false, const std::vector<String>& keys = std::vector<String>());
00791         void open (RWmode mode = Read);
00792         //      Create returns true if a new file was created or an
00793         //      existing file overwritten, false if appending.
00794         //
00795         //
00796         //      It throws exception CantCreate or CantOpen if either fails.
00797         bool create ();
00798         //      Close the fits file.
00799         //
00800         //      Called in destructors so must not throw.
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       // Additional Private Declarations
00815 
00816     private: //## implementation
00817       // Data Members for Class Attributes
00818         static bool s_verboseMode;
00819 
00820       // Data Members for Associations
00821         FITSBase* m_FITSImpl;
00822 
00823       // Additional Implementation Declarations
00824       friend fitsfile* HDU::fitsPointer() const;
00825       friend void HDU::makeThisCurrent() const;
00826   };
00827 
00828   // Class CCfits::FITS::NoSuchHDU 
00829 
00830   // Class CCfits::FITS::OperationNotSupported 
00831 
00832   // Class CCfits::FITS::CantOpen 
00833 
00834   // Class CCfits::FITS::CantCreate 
00835 
00836   // Class CCfits::FITS 
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 } // namespace CCfits
00861 
00862 
00863 #endif

Generated on Fri Nov 3 17:09:05 2006 for CCfits by  doxygen 1.4.7