FITS.h

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

Generated on Thu Jun 28 11:49:08 2007 for CCfits by  doxygen 1.4.7