00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef HDUCREATOR_H
00011 #define HDUCREATOR_H 1
00012
00013
00014 #include <typeinfo>
00015
00016 #include <valarray>
00017
00018 #include <string>
00019
00020 #include <vector>
00021
00022 #include "CCfits.h"
00023
00024 #include "FitsError.h"
00025
00026 namespace CCfits {
00027 class FITSBase;
00028 class HDU;
00029 class PHDU;
00030 class ExtHDU;
00031
00032 }
00033
00034
00035 namespace CCfits {
00036
00037
00038
00039 class HDUCreator
00040 {
00041
00042 public:
00043 HDUCreator (FITSBase* p);
00044 ~HDUCreator();
00045
00046
00047
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
00054
00055
00056
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
00061
00062 protected:
00063
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
00074 HDU *m_hdu;
00075
00076
00077
00078 private:
00079
00080 FITSBase* m_parent;
00081
00082
00083
00084 };
00085
00086
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 }
00120
00121
00122 #endif