PHDU.h

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

Generated on Fri Oct 12 13:39:38 2007 for CCfits by  doxygen 1.4.7