GammaLib 2.0.0
Loading...
Searching...
No Matches
GFitsHeaderCard.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GFitsHeaderCard.hpp - FITS header card class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2008-2018 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- *
6 * *
7 * This program is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19 * *
20 ***************************************************************************/
21/**
22 * @file GFitsHeaderCard.hpp
23 * @brief FITS header card class definition
24 * @author Juergen Knoedlseder
25 */
26
27#ifndef GFITSHEADERCARD_HPP
28#define GFITSHEADERCARD_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include <string>
32#include "GBase.hpp"
33
34
35/***********************************************************************//**
36 * @class GFitsHeaderCard
37 *
38 * @brief Implements FITS header card interface
39 *
40 * This class implements a FITS header card. A header card consists of a
41 * keyname (string), a value (string, floating point, integer or logical)
42 * and a comment (string). COMMENT or HISTORY cards do not have a value.
43 ***************************************************************************/
44class GFitsHeaderCard : public GBase {
45
46 // Friend classes
47 friend class GFitsHeader;
48
49public:
50 // Constructors & Destructors
51 GFitsHeaderCard(void);
52 GFitsHeaderCard(const std::string& keyname, const std::string& value,
53 const std::string& unit, const std::string& comment);
54 GFitsHeaderCard(const std::string& keyname, const std::string& value,
55 const std::string& comment);
56 GFitsHeaderCard(const std::string& keyname, const double& value,
57 const std::string& comment);
58 GFitsHeaderCard(const std::string& keyname, const int& value,
59 const std::string& comment);
60 GFitsHeaderCard(const std::string& keyname, const bool& value,
61 const std::string& comment);
62 GFitsHeaderCard(const std::string& keyname, const char* value,
63 const std::string& comment);
65 virtual ~GFitsHeaderCard(void);
66
67 // Operators
69
70 // Methods
71 void clear(void);
72 GFitsHeaderCard* clone(void) const;
73 std::string classname(void) const;
74 void keyname(const std::string& keyname);
75 const std::string& keyname(void) const;
76 void value(const std::string& value);
77 void value(const bool& value);
78 void value(const float& value);
79 void value(const double& value);
80 void value(const unsigned short& value);
81 void value(const short& value);
82 void value(const unsigned int& value);
83 void value(const int& value);
84 void value(const long& value);
85 void value(const unsigned long& value);
86 void value(const long long& value);
87 const std::string& value(void) const;
88 const int& decimals(void) const;
89 void unit(const std::string& unit);
90 const std::string& unit(void) const;
91 void comment(const std::string& comment);
92 const std::string& comment(void) const;
93 std::string string(void) const;
94 double real(void) const;
95 int integer(void) const;
96 std::string print(const GChatter& chatter = NORMAL) const;
97
98private:
99 // Private methods
100 void init_members(void);
101 void copy_members(const GFitsHeaderCard& card);
102 void free_members(void);
103 void set_members(const std::string& keyname,
104 const std::string& value,
105 const std::string& unit,
106 const std::string& comment);
107 void copy_dtype(const GFitsHeaderCard& card);
108 void free_dtype(void);
109 void set_dtype(const std::string& value);
110 void read(void* vptr, const int& keynum);
111 void read(void* fptr, const std::string& keyname);
112 void write(void* fptr) const;
113
114 // Private data area
115 std::string m_keyname; //!< Name of the card
116 std::string m_value; //!< Value of the card as read from file
117 std::string m_unit; //!< Unit of the card value
118 std::string m_comment; //!< Card comment
119 int m_dtype; //!< Native data type
120 int m_value_decimals; //!< Decimals of value (for float)
121 bool m_comment_write; //!< Signals that comment should be written
122 void* m_value_dtype; //!< Value in native data type
123};
124
125
126/***********************************************************************//**
127 * @brief Return class name
128 *
129 * @return String containing the class name ("GFitsHeaderCard").
130 ***************************************************************************/
131inline
132std::string GFitsHeaderCard::classname(void) const
133{
134 return ("GFitsHeaderCard");
135}
136
137
138/***********************************************************************//**
139 * @brief Set unit of header card value
140 *
141 * @param[in] unit Unit of header card.
142 ***************************************************************************/
143inline
144void GFitsHeaderCard::unit(const std::string& unit)
145{
146 m_unit = unit;
147 return;
148}
149
150
151/***********************************************************************//**
152 * @brief Set comment of header card
153 *
154 * @param[in] comment Header card comment.
155 ***************************************************************************/
156inline
157void GFitsHeaderCard::comment(const std::string& comment)
158{
160 return;
161}
162
163
164/***********************************************************************//**
165 * @brief Return header card keyname
166 ***************************************************************************/
167inline
168const std::string& GFitsHeaderCard::keyname(void) const
169{
170 return m_keyname;
171}
172
173
174/***********************************************************************//**
175 * @brief Return header card value
176 ***************************************************************************/
177inline
178const std::string& GFitsHeaderCard::value(void) const
179{
180 return m_value;
181}
182
183
184/***********************************************************************//**
185 * @brief Return header card decimals
186 ***************************************************************************/
187inline
188const int& GFitsHeaderCard::decimals(void) const
189{
190 return m_value_decimals;
191}
192
193
194/***********************************************************************//**
195 * @brief Return header card value unit
196 ***************************************************************************/
197inline
198const std::string& GFitsHeaderCard::unit(void) const
199{
200 return m_unit;
201}
202
203
204/***********************************************************************//**
205 * @brief Return header card comment
206 ***************************************************************************/
207inline
208const std::string& GFitsHeaderCard::comment(void) const
209{
210 return m_comment;
211}
212
213#endif /* GFITSHEADERCARD_HPP */
Definition of interface for all GammaLib classes.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
Interface class for all GammaLib classes.
Definition GBase.hpp:52
Implements FITS header card interface.
int m_dtype
Native data type.
std::string string(void) const
Return header card value as string.
void clear(void)
Clear header card.
void free_dtype(void)
Free dtype.
void init_members(void)
Initialise class members.
void free_members(void)
Delete class members.
void copy_dtype(const GFitsHeaderCard &card)
Copy dtype.
const std::string & comment(void) const
Return header card comment.
std::string classname(void) const
Return class name.
void set_dtype(const std::string &value)
Set native data type from card string.
const std::string & value(void) const
Return header card value.
std::string m_unit
Unit of the card value.
GFitsHeaderCard * clone(void) const
Clone header card.
const std::string & unit(void) const
Return header card value unit.
std::string m_comment
Card comment.
void copy_members(const GFitsHeaderCard &card)
Copy class members.
const std::string & keyname(void) const
Return header card keyname.
std::string m_keyname
Name of the card.
virtual ~GFitsHeaderCard(void)
Destructor.
double real(void) const
Return header card value as double precision.
std::string print(const GChatter &chatter=NORMAL) const
Print header card information.
GFitsHeaderCard(void)
Void constructor.
void write(void *fptr) const
Write header card.
int m_value_decimals
Decimals of value (for float)
void read(void *vptr, const int &keynum)
Read header card from FITS file.
const int & decimals(void) const
Return header card decimals.
GFitsHeaderCard & operator=(const GFitsHeaderCard &card)
Assignment operator.
std::string m_value
Value of the card as read from file.
bool m_comment_write
Signals that comment should be written.
void set_members(const std::string &keyname, const std::string &value, const std::string &unit, const std::string &comment)
Set card members.
int integer(void) const
Return header card value as integer.
void * m_value_dtype
Value in native data type.
Interface for FITS header class.