• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List

HDUCreator.h

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       // Data Members for Class Attributes
00073         HDU *m_hdu;
00074 
00075       // Additional Private Declarations
00076 
00077     private: //## implementation
00078       // Data Members for Associations
00079         FITSBase* m_parent;
00080 
00081       // Additional Implementation Declarations
00082 
00083   };
00084 
00085   // Class CCfits::HDUCreator 
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 } // namespace CCfits
00119 
00120 
00121 #endif

Generated on Thu Nov 18 2010 11:59:59 for CCfits by  doxygen 1.7.2