CCfits 2.7
PHDU.h
1// Astrophysics Science Division,
2// NASA/ Goddard Space Flight Center
3// HEASARC
4// http://heasarc.gsfc.nasa.gov
5// e-mail: ccfits@legacy.gsfc.nasa.gov
6//
7// Original author: Ben Dorman
8
9#ifndef PHDU_H
10#define PHDU_H 1
11
12// valarray
13#include <valarray>
14// HDU
15#include "HDU.h"
16// FITS
17#include "FITS.h"
18// FITSUtil
19#include "FITSUtil.h"
20
21namespace CCfits {
22 class FITS;
23
24} // namespace CCfits
25// for CLONE_DEFECT
26#ifdef _MSC_VER
27#include "MSconfig.h"
28#endif
29
30
31namespace CCfits {
32
67/* !\fn PHDU::PHDU (FITS* p)
68
69 \brief Reading Primary HDU constructor.
70 Constructor used when reading the primary HDU from an existing file.
71 Does nothing except initialize, with the real work done by the subclass
72 PrimaryHDU<T>.
73
74*/
75
267 class PHDU : public HDU //## Inherits: <unnamed>%394E6F9800C3
268 {
269
270 public:
271 virtual ~PHDU();
272
273 // Read data reads the image if readFlag is true and
274 // optional keywords if supplied. Thus, with no arguments,
275 // readData() does nothing.
276 virtual void readData (bool readFlag = false, const std::vector<String>& keys = std::vector<String>()) = 0;
277 virtual PHDU * clone (FITS* p) const = 0;
278 virtual void zero (double value);
279 virtual void scale (double value);
280 virtual double zero () const;
281 virtual double scale () const;
282
283 bool simple () const;
284 bool extend () const;
285
286 public:
287 // Additional Public Declarations
288 // image reading/writing interface.
289
290 // The S template parameter, like for Column, denotes the fact that
291 // the type of the input array and the object to be read may not match.
292
293
294 // the rw interface for images consists of equivalents for fits_read_img,
295 // fits_read_pix, and fits_read_subset.
296
297 // the paradigm for reading is that the image object (a valarray<T> type)
298 // is the size of the data already read.
299
300 // write_subset has no null value aware analogue.
301 template <typename S>
302 void write(const std::vector<long>& first,
303 long nElements,
304 const std::valarray<S>& data,
305 S* nullValue);
306
307
308 template <typename S>
309 void write(long first,
310 long nElements,
311 const std::valarray<S>& data,
312 S* nullValue);
313
314
315 template <typename S>
316 void write(const std::vector<long>& first,
317 long nElements,
318 const std::valarray<S>& data);
319
320
321 template <typename S>
322 void write(long first,
323 long nElements,
324 const std::valarray<S>& data);
325
326 template <typename S>
327 void write(const std::vector<long>& firstVertex,
328 const std::vector<long>& lastVertex,
329 const std::vector<long>& stride,
330 const std::valarray<S>& data);
331
332 // read image data and return an array. Can't return a reference
333 // because the type conversion needs to allocate a new object in general.
334
335 template<typename S>
336 void read(std::valarray<S>& image) ;
337
338 template<typename S>
339 void read (std::valarray<S>& image, long first,long nElements);
340
341 template<typename S>
342 void read (std::valarray<S>& image, long first,long nElements, S* nullValue) ;
343
344 template<typename S>
345 void read (std::valarray<S>& image, const std::vector<long>& first,long nElements) ;
346
347 template<typename S>
348 void read (std::valarray<S>& image, const std::vector<long>& first, long nElements,
349 S* nullValue);
350
351 template<typename S>
352 void read (std::valarray<S>& image, const std::vector<long>& firstVertex,
353 const std::vector<long>& lastVertex,
354 const std::vector<long>& stride) ;
355
356 template<typename S>
357 void read (std::valarray<S>& image, const std::vector<long>& firstVertex,
358 const std::vector<long>& lastVertex,
359 const std::vector<long>& stride,
360 S* nullValue) ;
361
362
363 protected:
364 PHDU(const PHDU &right);
365 // Constructor for new FITS objects, takes as arguments
366 // the required keywords for a primary HDU.
367 PHDU (FITS* p, int bpix, int naxis, const std::vector<long>& axes);
368 // Custom constructor. Allows specification of data to be read and whether to read data at
369 // construction or wait until the image data are requested. The default is 'lazy initialization:'
370 // wait until asked.
371 PHDU (FITS* p = 0);
372
373 virtual void initRead ();
374 void simple (bool value);
375 void extend (bool value);
376
377 // Additional Protected Declarations
378
379 private:
380 // Additional Private Declarations
381
382 private: //## implementation
383 // Data Members for Class Attributes
384 bool m_simple;
385 bool m_extend;
386
387 // Additional Implementation Declarations
388
389 };
390
391 // Class CCfits::PHDU
392
393 inline bool PHDU::simple () const
394 {
395 return m_simple;
396 }
397
398 inline void PHDU::simple (bool value)
399 {
400 m_simple = value;
401 }
402
403 inline bool PHDU::extend () const
404 {
405 return m_extend;
406 }
407
408 inline void PHDU::extend (bool value)
409 {
410 m_extend = value;
411 }
412
413} // namespace CCfits
414
415
416#endif
Memory object representation of a disk FITS file.
Definition FITS.h:629
Base class for all HDU [Header-Data Unit] objects.
Definition HDU.h:687
long axes() const
return the number of axes in the HDU data section (always 2 for tables).
Definition HDU.h:993
class representing the primary HDU for a FITS file.
Definition PHDU.h:268
virtual void initRead()
Definition PHDU.cxx:75
virtual void readData(bool readFlag=false, const std::vector< String > &keys=std::vector< String >())=0
read primary HDU data
virtual double zero() const
return the BZERO keyword value
Definition PHDU.cxx:160
virtual double scale() const
return the BSCALE keyword value
Definition PHDU.cxx:166
virtual PHDU * clone(FITS *p) const =0
virtual copy constructor for Primary HDUs.
void write(const std::vector< long > &first, long nElements, const std::valarray< S > &data, S *nullValue)
Write a set of pixels to an image extension with the first pixel specified by an n-tuple,...
Definition PHDUT.h:430
virtual ~PHDU()
destructor
Definition PHDU.cxx:69
bool simple() const
Returns the value of the Primary's SIMPLE keyword.
Definition PHDU.h:393
bool extend() const
Returns the value of the Primary's EXTEND keyword.
Definition PHDU.h:403
Namespace enclosing all CCfits classes and globals definitions.
Definition AsciiTable.cxx:26