FITS.h

00001 //   Read the documentation to learn more about C++ code generator
00002 //   versioning.
00003 //      This is version 2.0 release dated Jan 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 // exception
00016 #include <exception>
00017 // map
00018 #include <map>
00019 // string
00020 #include <string>
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 {
00643   //    ! The FITS object class. Contains a primary HDU and Extensions indexed by name.
00644 
00645 
00646 
00647   class FITS 
00648   {
00649 
00650     public:
00651 
00652 
00653 
00654       class NoSuchHDU : public FitsException  //## Inherits: <unnamed>%396C90CB0236
00655       {
00656         public:
00657             NoSuchHDU (const String& diag, bool silent = true);
00658 
00659         protected:
00660         private:
00661         private: //## implementation
00662       };
00663 
00664 
00665 
00666       class OperationNotSupported : public FitsException  //## Inherits: <unnamed>%39806C7600D5
00667       {
00668         public:
00669             OperationNotSupported (const String& msg, bool silent = true);
00670 
00671         protected:
00672         private:
00673         private: //## implementation
00674       };
00675 
00676 
00677 
00678       class CantOpen : public FitsException  //## Inherits: <unnamed>%39C8EB1D02C0
00679       {
00680         public:
00681             CantOpen (const String& diag, bool silent = true);
00682 
00683         protected:
00684         private:
00685         private: //## implementation
00686       };
00687 
00688 
00689 
00690       struct CantCreate : public FitsException  //## Inherits: <unnamed>%39C8EB10020B
00691       {
00692             CantCreate (const String& diag, bool silent = false);
00693 
00694         public:
00695         protected:
00696         private:
00697         private: //## implementation
00698       };
00699         FITS (const String &name, RWmode mode = Read, bool readDataFlag = false, const std::vector<String>& primaryKeys = std::vector<String>());
00700         //      Open a file and read a specified HDU.
00701         //
00702         //      Optional parameter allows the reading of specified primary HDU keys.
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         //      Read data from a set of specified HDUs. keywords can only be specified for the primary here.
00705         //      The code will call a different constructor for the case where keywords are required for
00706         //      the extensions.
00707         FITS (const String &name, RWmode mode, const std::vector<String>& hduNames, bool readDataFlag = false, const std::vector<String>& primaryKey = std::vector<String>());
00708         //      Initialize a new FITS file object with the primary from a
00709         //      different file.
00710         FITS (const String& fileName, const FITS& source);
00711         //      Fully general FITS HDU reader. May read any part of fits file by
00712         //      supplying HDU names and version numbers, and optionally
00713         //      the data read flag.
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         //      Writing constructor. Takes a name and information to create an empty
00716         //      Primary HDU which can then be filled with calls to HDU methods.
00717         FITS (const String& name, int bitpix, int naxis, long *naxes);
00718         //      Open a file and read a specified HDU.
00719         //
00720         //      Optional parameter allows the reading of specified primary HDU keys.
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         //      Open a file and read a HDU that contains  specified
00723         //      search keywords with [optional] specified values
00724         //      (sometimes one just wants to know that the keyword is present).
00725         //
00726         //      Optional parameters allows the reading of specified primary HDU keys and specified keywords in
00727         //      the HDU of interest.
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         //      Read keys and data from a single ExtHDU in the file.
00734         void read (const String &hduName, bool readDataFlag = false, const std::vector<String> &keys = std::vector<String>(), int version = 1);
00735         //      Read multiple ExtHDUs. If the version number needs to be specified then one must call a
00736         //      different method.
00737         void read (const std::vector<String> &hduNames, bool readDataFlag = false);
00738         //      Read selected data from multiple ExtHDUs
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         //      Read keys and data from a single ExtHDU in the file.
00741         void read (int hduIndex,        // Construct and Read HDU specified by number. One can add further HDUs by number using
00742                 // the HDUCreator factory.
00743         bool readDataFlag = false, const std::vector<String> &keys = std::vector<String>());
00744         //      Open a file and read a HDU that contains  specified
00745         //      search keywords with [optional] specified values
00746         //      (sometimes one just wants to know that the keyword is present).
00747         //
00748         //      Optional parameters allows the reading of specified primary HDU keys and specified keywords in
00749         //      the HDU of interest.
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         //      ! add a new Table extension to a FITS object
00760         Table* addTable (const String& hduName, int rows,       // ! Number of rows in new table. Mandatory
00761         const std::vector<String>& columnName = std::vector<String>(),  // ! Optional set of column names for new table
00762         const std::vector<String>& columnFmt = std::vector<String>(),   // ! Column formats for column units. Mandatory if columnName is specified
00763         const std::vector<String>& columnUnit = std::vector<String>(),  // ! Column formats for column units. Optional
00764         HduType type = BinaryTbl, int version = 1);
00765         //      ! add a new ImageExt (image extension) to the FITS object. A "writing" method.
00766         ExtHDU* addImage (const String& hduName, int bpix, std::vector<long>& naxes, int version = 1);
00767         //      Force destruction of the FITS object. Essentially
00768         //      is a manual destructor call.
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       // Additional Public Declarations
00791 
00792     protected:
00793       // Additional Protected Declarations
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         //      read the primary HDU. Read the image if
00802         //      readDataFlag is true.
00803         void read (bool readDataFlag = false, const std::vector<String>& keys = std::vector<String>());
00804         void open (RWmode mode = Read);
00805         //      Create returns true if a new file was created or an
00806         //      existing file overwritten, false if appending.
00807         //
00808         //
00809         //      It throws exception CantCreate or CantOpen if either fails.
00810         bool create ();
00811         //      Close the fits file.
00812         //
00813         //      Called in destructors so must not throw.
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       // Additional Private Declarations
00826 
00827     private: //## implementation
00828       // Data Members for Class Attributes
00829         static bool s_verboseMode;
00830 
00831       // Data Members for Associations
00832         FITSBase* m_FITSImpl;
00833 
00834       // Additional Implementation Declarations
00835       friend void HDU::makeThisCurrent() const;
00836   };
00837 
00838   // Class CCfits::FITS::NoSuchHDU 
00839 
00840   // Class CCfits::FITS::OperationNotSupported 
00841 
00842   // Class CCfits::FITS::CantOpen 
00843 
00844   // Class CCfits::FITS::CantCreate 
00845 
00846   // Class CCfits::FITS 
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 } // namespace CCfits
00871 
00872 
00873 #endif

Generated on Tue Feb 5 11:26:56 2008 for CCfits by  doxygen 1.5.4