CCfits 2.7
HDUCreator.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 HDUCREATOR_H
10#define HDUCREATOR_H 1
11
12// valarray
13#include <valarray>
14// typeinfo
15#include <typeinfo>
16// vector
17#include <vector>
18// string
19#include <string>
20// CCfitsHeader
21#include "CCfits.h"
22// FitsError
23#include "FitsError.h"
24
25namespace CCfits {
26 class FITS;
27 class HDU;
28 class PHDU;
29 class ExtHDU;
30
31} // namespace CCfits
32
33
34namespace CCfits {
35
36
37
38 class HDUCreator
39 {
40
41 public:
42 HDUCreator (FITS* p);
43 ~HDUCreator();
44
45 // Read a specified HDU from given fitsfile and
46 // return a pointer to it.
47 HDU * getHdu (const String& hduName, bool readDataFlag = false, const std::vector<String> &keys = std::vector<String>(), bool primary = false, int version = 1);
48 PHDU * createImage (int bitpix, long naxis, const std::vector<long>& naxes);
49 void reset ();
50 HDU * Make (const String& hduName, bool readDataFlag, const std::vector<String> &keys, bool primary, int version);
51 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);
52 // Read a specified HDU from given fitsfile and
53 // return a pointer to it.
54 //
55 // With no arguments this reads the PrimaryHDU.
56 HDU * getHdu (int index = 0, bool readDataFlag = false, const std::vector<String> &keys = std::vector<String>());
57 ExtHDU * createImage (const String &name, int bitpix, long naxis, const std::vector<long>& naxes, int version);
58 // MakeImage needs to be public so that FITS.h can friend it, so that
59 // MakeImage can see FITS::m_pHDU pointer, rather than FITS.h friending
60 // entire HDUCreator class
61 PHDU * MakeImage (int bpix, int naxis, const std::vector<long>& naxes);
62
63
64 // Additional Public Declarations
65
66 protected:
67 // Additional Protected Declarations
68
69 private:
70 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);
71 HDU * Make (int index, bool readDataFlag, const std::vector<String> &keys);
72 ExtHDU * MakeImage (const String &name, int bpix, long naxis, const std::vector<long>& naxes, int version);
73 void getScaling (long& type, double& zero, double& scale) const;
74 void parent (FITS* value);
75
76 // Utility function to implement both of the Make() function interfaces.
77 HDU* commonMake(const String& hduName, bool readDataFlag, const std::vector<String> &keys, bool primary, int version);
78
79 // Data Members for Class Attributes
80 HDU *m_hdu;
81
82 // Additional Private Declarations
83
84 private: //## implementation
85 // Data Members for Associations
86 FITS* m_parent;
87
88 // Additional Implementation Declarations
89
90 };
91
92 // Class CCfits::HDUCreator
93
94 inline HDU * HDUCreator::getHdu (const String& hduName, bool readDataFlag, const std::vector<String> &keys, bool primary, int version)
95 {
97 if ( m_hdu == 0 ) m_hdu = Make(hduName,readDataFlag,keys,primary,version);
98 return m_hdu;
99 }
100
101 inline void HDUCreator::reset ()
102 {
103 m_hdu = 0;
104 }
105
106 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)
107 {
109 if (m_hdu == 0) m_hdu = MakeTable(name,xtype,rows,colName,colFmt,colUnit,version);
110 return m_hdu;
111 }
112
113 inline HDU * HDUCreator::getHdu (int index, bool readDataFlag, const std::vector<String> &keys)
114 {
116 if ( m_hdu == 0 ) m_hdu = Make(index,readDataFlag,keys);
117 return m_hdu;
118 }
119
120 inline void HDUCreator::parent (FITS* value)
121 {
122 m_parent = value;
123 }
124
125} // namespace CCfits
126
127
128#endif
Namespace enclosing all CCfits classes and globals definitions.
Definition AsciiTable.cxx:26