CCfits: PHDU.h Source File

CCfits 2.7

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List

PHDU.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 PHDU_H
    00010 #define PHDU_H 1
    00011
    00012 // valarray
    00013 #include <valarray>
    00014 // HDU
    00015 #include "HDU.h"
    00016 // FITS
    00017 #include "FITS.h"
    00018 // FITSUtil
    00019 #include "FITSUtil.h"
    00020
    00021 namespace CCfits {
    00022   class FITS;
    00023
    00024 } // namespace CCfits
    00025 // for CLONE_DEFECT
    00026 #ifdef _MSC_VER
    00027 #include "MSconfig.h"
    00028 #endif
    00029
    00030
    00031 namespace CCfits {
    00032
    00067 /* !\fn  PHDU::PHDU (FITS* p)
    00068
    00069     \brief Reading Primary HDU constructor.
    00070    Constructor used  when reading the primary HDU from an existing file.
    00071     Does nothing except initialize, with the real work done by the subclass
    00072     PrimaryHDU<T>.
    00073
    00074 */
    00075
    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 (FITS* 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         bool simple () const;
    00284         bool extend () const;
    00285
    00286     public:
    00287       // Additional Public Declarations
    00288       // image reading/writing interface.
    00289
    00290       // The S template parameter, like for Column, denotes the fact that
    00291       // the type of the input array and the object to be read may not match.
    00292
    00293
    00294       // the rw interface for images consists of equivalents for fits_read_img,
    00295       // fits_read_pix, and fits_read_subset.
    00296
    00297       // the paradigm for reading is that the image object (a valarray<T> type)
    00298       // is the size of the data already read.
    00299
    00300       // write_subset has no null value aware analogue.
    00301         template <typename S>
    00302         void write(const std::vector<long>& first,
    00303                         long nElements,
    00304                         const std::valarray<S>& data,
    00305                         S* nullValue);
    00306
    00307
    00308         template <typename S>
    00309         void write(long first,
    00310                         long nElements,
    00311                         const std::valarray<S>& data,
    00312                         S* nullValue);
    00313
    00314
    00315         template <typename S>
    00316         void write(const std::vector<long>& first,
    00317                         long nElements,
    00318                         const std::valarray<S>& data);
    00319
    00320
    00321         template <typename S>
    00322         void write(long first,
    00323                         long nElements,
    00324                         const std::valarray<S>& data);
    00325
    00326         template <typename S>
    00327         void write(const std::vector<long>& firstVertex,
    00328                         const std::vector<long>& lastVertex,
    00329                         const std::vector<long>& stride,
    00330                         const std::valarray<S>& data);
    00331
    00332         // read image data and return an array. Can't return a reference
    00333         // because the type conversion needs to allocate a new object in general.
    00334
    00335         template<typename S>
    00336         void read(std::valarray<S>& image) ;
    00337
    00338     template<typename S>
    00339         void  read (std::valarray<S>& image, long first,long nElements);
    00340
    00341     template<typename S>
    00342         void read (std::valarray<S>& image, long first,long nElements, S* nullValue) ;
    00343
    00344     template<typename S>
    00345         void read (std::valarray<S>& image, const std::vector<long>& first,long nElements)  ;
    00346
    00347     template<typename S>
    00348         void read (std::valarray<S>& image, const std::vector<long>& first, long nElements,
    00349                                         S* nullValue);
    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
    00356         template<typename S>
    00357         void read (std::valarray<S>& image, const std::vector<long>& firstVertex,
    00358                 const std::vector<long>& lastVertex,
    00359                 const std::vector<long>& stride,
    00360                                 S* nullValue) ;
    00361
    00362
    00363     protected:
    00364         PHDU(const PHDU &right);
    00365         //  Constructor for new FITS objects, takes as arguments
    00366         //  the required keywords for a primary HDU.
    00367         PHDU (FITS* p, int bpix, int naxis, const std::vector<long>& axes);
    00368         //  Custom constructor. Allows specification of data to be read and whether to read data at
    00369         //  construction or wait until the image data are requested. The default is 'lazy initialization:'
    00370         //  wait until asked.
    00371         PHDU (FITS* p = 0);
    00372
    00373         virtual void initRead ();
    00374         void simple (bool value);
    00375         void extend (bool value);
    00376
    00377       // Additional Protected Declarations
    00378
    00379     private:
    00380       // Additional Private Declarations
    00381
    00382     private: //## implementation
    00383       // Data Members for Class Attributes
    00384         bool m_simple;
    00385         bool m_extend;
    00386
    00387       // Additional Implementation Declarations
    00388
    00389   };
    00390
    00391   // Class CCfits::PHDU
    00392
    00393   inline bool PHDU::simple () const
    00394   {
    00395     return m_simple;
    00396   }
    00397
    00398   inline void PHDU::simple (bool value)
    00399   {
    00400     m_simple = value;
    00401   }
    00402
    00403   inline bool PHDU::extend () const
    00404   {
    00405     return m_extend;
    00406   }
    00407
    00408   inline void PHDU::extend (bool value)
    00409   {
    00410     m_extend = value;
    00411   }
    00412
    00413 } // namespace CCfits
    00414
    00415
    00416 #endif