00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef HDUCREATOR_H
00010 #define HDUCREATOR_H 1
00011
00012
00013 #include <valarray>
00014
00015 #include <typeinfo>
00016
00017 #include <vector>
00018
00019 #include <string>
00020
00021 #include "CCfits.h"
00022
00023 #include "FitsError.h"
00024
00025 namespace CCfits {
00026 class FITSBase;
00027 class HDU;
00028 class PHDU;
00029 class ExtHDU;
00030
00031 }
00032
00033
00034 namespace CCfits {
00035
00036
00037
00038 class HDUCreator
00039 {
00040
00041 public:
00042 HDUCreator (FITSBase* p);
00043 ~HDUCreator();
00044
00045
00046
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
00053
00054
00055
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
00060
00061 protected:
00062
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
00073 HDU *m_hdu;
00074
00075
00076
00077 private:
00078
00079 FITSBase* m_parent;
00080
00081
00082
00083 };
00084
00085
00086
00087 inline HDU * HDUCreator::getHdu (const String& hduName, bool readDataFlag, const std::vector<String> &keys, bool primary, int version)
00088 {
00090 if ( m_hdu == 0 ) m_hdu = Make(hduName,readDataFlag,keys,primary,version);
00091 return m_hdu;
00092 }
00093
00094 inline void HDUCreator::reset ()
00095 {
00096 m_hdu = 0;
00097 }
00098
00099 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)
00100 {
00102 if (m_hdu == 0) m_hdu = MakeTable(name,xtype,rows,colName,colFmt,colUnit,version);
00103 return m_hdu;
00104 }
00105
00106 inline HDU * HDUCreator::getHdu (int index, bool readDataFlag, const std::vector<String> &keys)
00107 {
00109 if ( m_hdu == 0 ) m_hdu = Make(index,readDataFlag,keys);
00110 return m_hdu;
00111 }
00112
00113 inline void HDUCreator::parent (FITSBase* value)
00114 {
00115 m_parent = value;
00116 }
00117
00118 }
00119
00120
00121 #endif