PHDU.h

00001 //      This is version 1.6 release dated Nov 2006
00002 //      Astrophysics Science Division,
00003 //      NASA/ Goddard Space Flight Center
00004 //      HEASARC
00005 //      http://heasarc.gsfc.nasa.gov
00006 //      e-mail: ccfits@legacy.gsfc.nasa.gov
00007 //
00008 //      Original author: Ben Dorman, L3-Communications EER Systems Inc.
00009 
00010 #ifndef PHDU_H
00011 #define PHDU_H 1
00012 
00013 // valarray
00014 #include <valarray>
00015 // HDU
00016 #include "HDU.h"
00017 // FITS
00018 #include "FITS.h"
00019 // FITSUtil
00020 #include "FITSUtil.h"
00021 
00022 namespace CCfits {
00023   class FITSBase;
00024 
00025 } // namespace CCfits
00026 // for CLONE_DEFECT
00027 #ifdef _MSC_VER
00028 #include "MSconfig.h"
00029 #endif
00030 
00031 
00032 namespace CCfits {
00033 
00068 /* !\fn  PHDU::PHDU (FITSBase* p)
00069 
00070     \brief Reading Primary HDU constructor.
00071    Constructor used  when reading the primary HDU from an existing file.
00072     Does nothing except initialize, with the real work done by the subclass
00073     PrimaryHDU<T>.
00074 
00075 */
00076 
00080 /* !\fn  virtual void PHDU::readData (bool readFlag = false, const std::vector<String>& keys = std::vector<String>())  = 0;
00081         \brief read primary HDU data
00082 
00083         Called by FITS ctor, not intended for general use.
00084         parameters control how much gets read on initialization. An abstract function,
00085         implemented in the subclasses.
00086 
00087         \param readFlag read the image data if true
00088         \param key      a vector of strings of keyword names to be read from the primary HDU                        
00089 
00090 
00091 
00092 */
00093 
00094 /* !\fn  virtual PHDU::clone(FITSbase* p) const = 0;
00095 
00096         \brief virtual copy constructor for Primary HDUs. 
00097 
00098         The operation is used when creating a copy of a FITS object.
00099 
00100 
00101 */
00102 
00103 
00104 
00265   class PHDU : public HDU  //## Inherits: <unnamed>%394E6F9800C3
00266   {
00267 
00268     public:
00269         virtual ~PHDU();
00270 
00271         //      Read data reads the image if readFlag is true and
00272         //      optional keywords if supplied. Thus, with no arguments,
00273         //      readData() does nothing.
00274         virtual void readData (bool readFlag = false, const std::vector<String>& keys = std::vector<String>()) = 0;
00275         virtual PHDU * clone (FITSBase* p) const = 0;
00276         virtual void zero (double value);
00277         virtual void scale (double value);
00278         virtual double zero () const;
00279         virtual double scale () const;
00280 
00281     public:
00282       // Additional Public Declarations
00283       // image reading/writing interface. 
00284 
00285       // The S template parameter, like for Column, denotes the fact that
00286       // the type of the input array and the object to be read may not match.
00287 
00288 
00289       // the rw interface for images consists of equivalents for fits_read_img,
00290       // fits_read_pix, and fits_read_subset.
00291 
00292       // the paradigm for reading is that the image object (a valarray<T> type)
00293       // is the size of the data already read.
00294 
00295       // write_subset has no null value aware analogue.
00296         template <typename S>
00297         void write(const std::vector<long>& first,
00298                         long nElements,
00299                         const std::valarray<S>& data,
00300                         S* nullValue);
00301 
00302 
00303         template <typename S>
00304         void write(long first,
00305                         long nElements,
00306                         const std::valarray<S>& data,
00307                         S* nullValue);
00308 
00309 
00310         template <typename S>
00311         void write(const std::vector<long>& first,
00312                         long nElements,
00313                         const std::valarray<S>& data);
00314 
00315 
00316         template <typename S>
00317         void write(long first,
00318                         long nElements,
00319                         const std::valarray<S>& data);
00320 
00321         template <typename S>
00322         void write(const std::vector<long>& firstVertex,
00323                         const std::vector<long>& lastVertex,
00324                         const std::vector<long>& stride, 
00325                         const std::valarray<S>& data); 
00326 
00327         // read image data and return an array. Can't return a reference
00328         // because the type conversion needs to allocate a new object in general.
00329 
00330         template<typename S>
00331         void read(std::valarray<S>& image) ; 
00332 
00333         template<typename S>
00334         void  read (std::valarray<S>& image, long first,long nElements); 
00335 
00336         template<typename S>
00337         void read (std::valarray<S>& image, long first,long nElements, S* nullValue) ; 
00338 
00339         template<typename S>
00340         void read (std::valarray<S>& image, const std::vector<long>& first,long nElements)  ; 
00341 
00342         template<typename S>
00343         void read (std::valarray<S>& image, const std::vector<long>& first, long nElements, 
00344                                         S* nullValue); 
00345 
00346         template<typename S>
00347         void read (std::valarray<S>& image, const std::vector<long>& firstVertex, 
00348                                 const std::vector<long>& lastVertex, 
00349                                 const std::vector<long>& stride)  ;      
00350 
00351         template<typename S>
00352         void read (std::valarray<S>& image, const std::vector<long>& firstVertex, 
00353                                 const std::vector<long>& lastVertex, 
00354                                 const std::vector<long>& stride, 
00355                                 S* nullValue) ; 
00356 
00357 
00358     protected:
00359         PHDU(const PHDU &right);
00360         //      Constructor for new FITS objects, takes as arguments
00361         //      the required keywords for a primary HDU.
00362         PHDU (FITSBase* p, int bpix, int naxis, const std::vector<long>& axes);
00363         //      Custom constructor. Allows specification of data to be read and whether to read data at
00364         //      construction or wait until the image data are requested. The default is 'lazy initialization:'
00365         //      wait until asked.
00366         PHDU (FITSBase* p = 0);
00367 
00368         virtual void initRead ();
00369         bool simple () const;
00370         void simple (bool value);
00371         bool extend () const;
00372         void extend (bool value);
00373 
00374       // Additional Protected Declarations
00375 
00376     private:
00377       // Additional Private Declarations
00378 
00379     private: //## implementation
00380       // Data Members for Class Attributes
00381         bool m_simple;
00382         bool m_extend;
00383 
00384       // Additional Implementation Declarations
00385 
00386   };
00387 
00388   // Class CCfits::PHDU 
00389 
00390   inline bool PHDU::simple () const
00391   {
00392     return m_simple;
00393   }
00394 
00395   inline void PHDU::simple (bool value)
00396   {
00397     m_simple = value;
00398   }
00399 
00400   inline bool PHDU::extend () const
00401   {
00402     return m_extend;
00403   }
00404 
00405   inline void PHDU::extend (bool value)
00406   {
00407     m_extend = value;
00408   }
00409 
00410 } // namespace CCfits
00411 
00412 
00413 #endif

Generated on Fri Nov 3 17:09:05 2006 for CCfits by  doxygen 1.4.7