CCfits  2.5
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 
25 namespace CCfits {
26  class FITSBase;
27  class HDU;
28  class PHDU;
29  class ExtHDU;
30 
31 } // namespace CCfits
32 
33 
34 namespace CCfits {
35 
36 
37 
38  class HDUCreator
39  {
40 
41  public:
42  HDUCreator (FITSBase* 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 
59  // Additional Public Declarations
60 
61  protected:
62  // Additional Protected Declarations
63 
64  private:
65  PHDU * MakeImage (int bpix, int naxis, const std::vector<long>& naxes);
66  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);
67  HDU * Make (int index, bool readDataFlag, const std::vector<String> &keys);
68  ExtHDU * MakeImage (const String &name, int bpix, long naxis, const std::vector<long>& naxes, int version);
69  void getScaling (long& type, double& zero, double& scale) const;
70  void parent (FITSBase* value);
71 
72  // Utility function to implement both of the Make() function interfaces.
73  HDU* commonMake(const String& hduName, bool readDataFlag, const std::vector<String> &keys, bool primary, int version);
74 
75  // Data Members for Class Attributes
76  HDU *m_hdu;
77 
78  // Additional Private Declarations
79 
80  private: //## implementation
81  // Data Members for Associations
82  FITSBase* m_parent;
83 
84  // Additional Implementation Declarations
85 
86  };
87 
88  // Class CCfits::HDUCreator
89 
90  inline HDU * HDUCreator::getHdu (const String& hduName, bool readDataFlag, const std::vector<String> &keys, bool primary, int version)
91  {
93  if ( m_hdu == 0 ) m_hdu = Make(hduName,readDataFlag,keys,primary,version);
94  return m_hdu;
95  }
96 
97  inline void HDUCreator::reset ()
98  {
99  m_hdu = 0;
100  }
101 
102  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)
103  {
105  if (m_hdu == 0) m_hdu = MakeTable(name,xtype,rows,colName,colFmt,colUnit,version);
106  return m_hdu;
107  }
108 
109  inline HDU * HDUCreator::getHdu (int index, bool readDataFlag, const std::vector<String> &keys)
110  {
112  if ( m_hdu == 0 ) m_hdu = Make(index,readDataFlag,keys);
113  return m_hdu;
114  }
115 
116  inline void HDUCreator::parent (FITSBase* value)
117  {
118  m_parent = value;
119  }
120 
121 } // namespace CCfits
122 
123 
124 #endif
Namespace enclosing all CCfits classes and globals definitions.
Definition: AsciiTable.cxx:26