HDUCreator.h

00001 //   Read the documentation to learn more about C++ code generator
00002 //   versioning.
00003 //      This is version 2.1 release dated Nov 2008
00004 //      Astrophysics Science Division,
00005 //      NASA/ Goddard Space Flight Center
00006 //      HEASARC
00007 //      http://heasarc.gsfc.nasa.gov
00008 //      e-mail: ccfits@legacy.gsfc.nasa.gov
00009 //
00010 //      Original author: Ben Dorman
00011 
00012 #ifndef HDUCREATOR_H
00013 #define HDUCREATOR_H 1
00014 
00015 // typeinfo
00016 #include <typeinfo>
00017 // vector
00018 #include <vector>
00019 // valarray
00020 #include <valarray>
00021 // string
00022 #include <string>
00023 // CCfitsHeader
00024 #include "CCfits.h"
00025 // FitsError
00026 #include "FitsError.h"
00027 
00028 namespace CCfits {
00029   class FITSBase;
00030   class HDU;
00031   class PHDU;
00032   class ExtHDU;
00033 
00034 } // namespace CCfits
00035 
00036 
00037 namespace CCfits {
00038 
00039 
00040 
00041   class HDUCreator 
00042   {
00043 
00044     public:
00045         HDUCreator (FITSBase* p);
00046         ~HDUCreator();
00047 
00048         //      Read a specified HDU from given fitsfile and
00049         //      return a pointer to it.
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         //      Read a specified HDU from given fitsfile and
00056         //      return a pointer to it.
00057         //
00058         //      With no arguments this reads the PrimaryHDU.
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       // Additional Public Declarations
00063 
00064     protected:
00065       // Additional Protected Declarations
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) const;
00073         void parent (FITSBase* value);
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

Generated on Thu Nov 6 10:44:39 2008 for CCfits by  doxygen 1.5.4