HDUCreator.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 HDUCREATOR_H
00011 #define HDUCREATOR_H 1
00012 
00013 // typeinfo
00014 #include <typeinfo>
00015 // valarray
00016 #include <valarray>
00017 // string
00018 #include <string>
00019 // vector
00020 #include <vector>
00021 // CCfitsHeader
00022 #include "CCfits.h"
00023 // FitsError
00024 #include "FitsError.h"
00025 
00026 namespace CCfits {
00027   class FITSBase;
00028   class HDU;
00029   class PHDU;
00030   class ExtHDU;
00031 
00032 } // namespace CCfits
00033 
00034 
00035 namespace CCfits {
00036 
00037 
00038 
00039   class HDUCreator 
00040   {
00041 
00042     public:
00043         HDUCreator (FITSBase* p);
00044         ~HDUCreator();
00045 
00046         //      Read a specified HDU from given fitsfile and
00047         //      return a pointer to it.
00048         HDU * getHdu (const String& hduName, bool readDataFlag = false, const std::vector<String> &keys = std::vector<String>(), bool primary = false, int version = 1);
00049         PHDU * createImage (int bitpix, long naxis, const std::vector<long>& naxes);
00050         void reset ();
00051         HDU * Make (const String& hduName, bool readDataFlag, const std::vector<String> &keys, bool primary, int version);
00052         HDU* createTable (const String &name, HduType xtype, int rows, const std::vector<String>& colName, const std::vector<String> colFmt, const std::vector<String> colUnit, int version);
00053         //      Read a specified HDU from given fitsfile and
00054         //      return a pointer to it.
00055         //
00056         //      With no arguments this reads the PrimaryHDU.
00057         HDU * getHdu (int index = 0, bool readDataFlag = false, const std::vector<String> &keys = std::vector<String>());
00058         ExtHDU * createImage (const String &name, int bitpix, long naxis, const std::vector<long>& naxes, int version);
00059 
00060       // Additional Public Declarations
00061 
00062     protected:
00063       // Additional Protected Declarations
00064 
00065     private:
00066         PHDU * MakeImage (int bpix, int naxis, const std::vector<long>& naxes);
00067         HDU* MakeTable (const String &name, HduType xtype, int rows, const std::vector<String>& colName, const std::vector<String>& colFmt, const std::vector<String>& colUnit, int version);
00068         HDU * Make (int index, bool readDataFlag, const std::vector<String> &keys);
00069         ExtHDU * MakeImage (const String &name, int bpix, long naxis, const std::vector<long>& naxes, int version);
00070         void getScaling (long& type, double& zero, double& scale, long& unscaledType) const;
00071         void parent (FITSBase* value);
00072 
00073       // Data Members for Class Attributes
00074         HDU *m_hdu;
00075 
00076       // Additional Private Declarations
00077 
00078     private: //## implementation
00079       // Data Members for Associations
00080         FITSBase* m_parent;
00081 
00082       // Additional Implementation Declarations
00083 
00084   };
00085 
00086   // Class CCfits::HDUCreator 
00087 
00088   inline HDU * HDUCreator::getHdu (const String& hduName, bool readDataFlag, const std::vector<String> &keys, bool primary, int version)
00089   {
00091   if ( m_hdu == 0 ) m_hdu = Make(hduName,readDataFlag,keys,primary,version);
00092   return m_hdu;
00093   }
00094 
00095   inline void HDUCreator::reset ()
00096   {
00097   m_hdu = 0;
00098   }
00099 
00100   inline HDU* HDUCreator::createTable (const String &name, HduType xtype, int rows, const std::vector<String>& colName, const std::vector<String> colFmt, const std::vector<String> colUnit, int version)
00101   {
00103         if (m_hdu == 0) m_hdu = MakeTable(name,xtype,rows,colName,colFmt,colUnit,version);
00104         return m_hdu;
00105   }
00106 
00107   inline HDU * HDUCreator::getHdu (int index, bool readDataFlag, const std::vector<String> &keys)
00108   {
00110   if ( m_hdu == 0 ) m_hdu = Make(index,readDataFlag,keys);
00111   return m_hdu;
00112   }
00113 
00114   inline void HDUCreator::parent (FITSBase* value)
00115   {
00116     m_parent = value;
00117   }
00118 
00119 } // namespace CCfits
00120 
00121 
00122 #endif

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