FITS.h

00001 //   Read the documentation to learn more about C++ code generator
00002 //   versioning.
00003 //      This is version 2.1 release dated Nov 2008
00004 //      Astrophysics Science Division,
00005 //      NASA/ Goddard Space Flight Center
00006 //      HEASARC
00007 //      http://heasarc.gsfc.nasa.gov
00008 //      e-mail: ccfits@legacy.gsfc.nasa.gov
00009 //
00010 //      Original author: Ben Dorman
00011 
00012 #ifndef FITS_H
00013 #define FITS_H 1
00014 
00015 // map
00016 #include <map>
00017 // string
00018 #include <string>
00019 // exception
00020 #include <exception>
00021 // ExtHDU
00022 #include "ExtHDU.h"
00023 // HDUCreator
00024 #include "HDUCreator.h"
00025 // FitsError
00026 #include "FitsError.h"
00027 
00028 namespace CCfits {
00029   class FITSBase;
00030   class PHDU;
00031   class Table;
00032 
00033 } // namespace CCfits
00034 //class PHDU;
00035 extern "C"
00036 {
00037 #       include <sys/stat.h>
00038 }           
00039 #include <memory>
00040 
00041 
00042 namespace CCfits {
00658   //    ! The FITS object class. Contains a primary HDU and Extensions indexed by name.
00659 
00660 
00661 
00662   class FITS 
00663   {
00664 
00665     public:
00666 
00667 
00668 
00669       class NoSuchHDU : public FitsException  //## Inherits: <unnamed>%396C90CB0236
00670       {
00671         public:
00672             NoSuchHDU (const String& diag, bool silent = true);
00673 
00674         protected:
00675         private:
00676         private: //## implementation
00677       };
00678 
00679 
00680 
00681       class OperationNotSupported : public FitsException  //## Inherits: <unnamed>%39806C7600D5
00682       {
00683         public:
00684             OperationNotSupported (const String& msg, bool silent = true);
00685 
00686         protected:
00687         private:
00688         private: //## implementation
00689       };
00690 
00691 
00692 
00693       class CantOpen : public FitsException  //## Inherits: <unnamed>%39C8EB1D02C0
00694       {
00695         public:
00696             CantOpen (const String& diag, bool silent = true);
00697 
00698         protected:
00699         private:
00700         private: //## implementation
00701       };
00702 
00703 
00704 
00705       struct CantCreate : public FitsException  //## Inherits: <unnamed>%39C8EB10020B
00706       {
00707             CantCreate (const String& diag, bool silent = false);
00708 
00709         public:
00710         protected:
00711         private:
00712         private: //## implementation
00713       };
00714         FITS (const String &name, RWmode mode = Read, bool readDataFlag = false, const std::vector<String>& primaryKeys = std::vector<String>());
00715         //      Open a file and read a specified HDU.
00716         //
00717         //      Optional parameter allows the reading of specified primary HDU keys.
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         //      Read data from a set of specified HDUs. keywords can only be specified for the primary here.
00720         //      The code will call a different constructor for the case where keywords are required for
00721         //      the extensions.
00722         FITS (const String &name, RWmode mode, const std::vector<String>& hduNames, bool readDataFlag = false, const std::vector<String>& primaryKey = std::vector<String>());
00723         //      Initialize a new FITS file object with the primary from a
00724         //      different file.
00725         FITS (const String& fileName, const FITS& source);
00726         //      Fully general FITS HDU reader. May read any part of fits file by
00727         //      supplying HDU names and version numbers, and optionally
00728         //      the data read flag.
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         //      Writing constructor. Takes a name and information to create an empty
00731         //      Primary HDU which can then be filled with calls to HDU methods.
00732         FITS (const String& name, int bitpix, int naxis, long *naxes);
00733         //      Open a file and read a specified HDU.
00734         //
00735         //      Optional parameter allows the reading of specified primary HDU keys.
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         //      Open a file and read a HDU that contains  specified
00738         //      search keywords with [optional] specified values
00739         //      (sometimes one just wants to know that the keyword is present).
00740         //
00741         //      Optional parameters allows the reading of specified primary HDU keys and specified keywords in
00742         //      the HDU of interest.
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         //      Read keys and data from a single ExtHDU in the file.
00749         void read (const String &hduName, bool readDataFlag = false, const std::vector<String> &keys = std::vector<String>(), int version = 1);
00750         //      Read multiple ExtHDUs. If the version number needs to be specified then one must call a
00751         //      different method.
00752         void read (const std::vector<String> &hduNames, bool readDataFlag = false);
00753         //      Read selected data from multiple ExtHDUs
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         //      Read keys and data from a single ExtHDU in the file.
00756         void read (int hduIndex,        // Construct and Read HDU specified by number. One can add further HDUs by number using
00757                 // the HDUCreator factory.
00758         bool readDataFlag = false, const std::vector<String> &keys = std::vector<String>());
00759         //      Open a file and read a HDU that contains  specified
00760         //      search keywords with [optional] specified values
00761         //      (sometimes one just wants to know that the keyword is present).
00762         //
00763         //      Optional parameters allows the reading of specified primary HDU keys and specified keywords in
00764         //      the HDU of interest.
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         //      ! add a new Table extension to a FITS object
00775         Table* addTable (const String& hduName, int rows,       // ! Number of rows in new table. Mandatory
00776         const std::vector<String>& columnName = std::vector<String>(),  // ! Optional set of column names for new table
00777         const std::vector<String>& columnFmt = std::vector<String>(),   // ! Column formats for column units. Mandatory if columnName is specified
00778         const std::vector<String>& columnUnit = std::vector<String>(),  // ! Column formats for column units. Optional
00779         HduType type = BinaryTbl, int version = 1);
00780         //      ! add a new ImageExt (image extension) to the FITS object. A "writing" method.
00781         ExtHDU* addImage (const String& hduName, int bpix, std::vector<long>& naxes, int version = 1);
00782         //      Force destruction of the FITS object. Essentially
00783         //      is a manual destructor call.
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       // Additional Public Declarations
00806 
00807     protected:
00808       // Additional Protected Declarations
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         //      read the primary HDU. Read the image if
00817         //      readDataFlag is true.
00818         void read (bool readDataFlag = false, const std::vector<String>& keys = std::vector<String>());
00819         //      Returns index of current HDU where primary = 0.  (Extended file syntax may cause a shift to an
00820         //      extension.)
00821         int open (RWmode mode = Read);
00822         //      Create returns true if a new file was created or an
00823         //      existing file overwritten, false if appending.
00824         //
00825         //
00826         //      It throws exception CantCreate or CantOpen if either fails.
00827         bool create ();
00828         //      Close the fits file.
00829         //
00830         //      Called in destructors so must not throw.
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& extension ();
00839         String nameOfUnmapped (int hduNum) const;
00840         void cloneHeader (const ExtHDU& source);
00841 
00842       // Additional Private Declarations
00843 
00844     private: //## implementation
00845       // Data Members for Class Attributes
00846         static bool s_verboseMode;
00847 
00848       // Data Members for Associations
00849         FITSBase* m_FITSImpl;
00850 
00851       // Additional Implementation Declarations
00852       friend void HDU::makeThisCurrent() const;
00853   };
00854 
00855   // Class CCfits::FITS::NoSuchHDU 
00856 
00857   // Class CCfits::FITS::OperationNotSupported 
00858 
00859   // Class CCfits::FITS::CantOpen 
00860 
00861   // Class CCfits::FITS::CantCreate 
00862 
00863   // Class CCfits::FITS 
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 } // namespace CCfits
00888 
00889 
00890 #endif

Generated on Thu Nov 6 10:44:38 2008 for CCfits by  doxygen 1.5.4