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