00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef HDUCREATOR_H
00013 #define HDUCREATOR_H 1
00014
00015
00016 #include "FitsError.h"
00017
00018 #include <typeinfo>
00019
00020 #include "CCfits.h"
00021
00022 #include <string>
00023
00024 #include <valarray>
00025
00026 #include <vector>
00027
00028 namespace CCfits {
00029 class ExtHDU;
00030 class PHDU;
00031 class FITSBase;
00032 class HDU;
00033
00034 }
00035
00036
00037 namespace CCfits {
00038
00039
00040
00041 class HDUCreator
00042 {
00043
00044 public:
00045 HDUCreator (FITSBase* p);
00046 ~HDUCreator();
00047
00048
00049
00050 HDU * getHdu (const String& hduName, bool readDataFlag = false, const std::vector<String> &keys = std::vector<String>(), bool primary = false, int version = 1);
00051 PHDU * createImage (int bitpix, long naxis, const std::vector<long>& naxes);
00052 void reset ();
00053 HDU * Make (const String& hduName, bool readDataFlag, const std::vector<String> &keys, bool primary, int version);
00054 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);
00055
00056
00057
00058
00059 HDU * getHdu (int index = 0, bool readDataFlag = false, const std::vector<String> &keys = std::vector<String>());
00060 ExtHDU * createImage (const String &name, int bitpix, long naxis, const std::vector<long>& naxes, int version);
00061
00062
00063
00064 protected:
00065
00066
00067 private:
00068 PHDU * MakeImage (int bpix, int naxis, const std::vector<long>& naxes);
00069 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);
00070 HDU * Make (int index, bool readDataFlag, const std::vector<String> &keys);
00071 ExtHDU * MakeImage (const String &name, int bpix, long naxis, const std::vector<long>& naxes, int version);
00072 void getScaling (long& type, double& zero, double& scale, long& unscaledType) const;
00073 void parent (FITSBase* value);
00074
00075
00076 HDU *m_hdu;
00077
00078
00079
00080 private:
00081
00082 FITSBase* m_parent;
00083
00084
00085
00086 };
00087
00088
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 }
00122
00123
00124 #endif