CCfits 2.7
Keyword.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 KEYWORD_H
10#define KEYWORD_H 1
11#include "CCfits.h"
12// using namespace CCfits;
13#ifdef _MSC_VER
14#include "MSconfig.h"
15#endif
16
17// FitsError
18#include "FitsError.h"
19
20namespace CCfits {
21 class HDU;
22
23} // namespace CCfits
24
25
26namespace CCfits {
27
62/* \fn friend ostream& operator << (ostream &s, const Keyword &right);
63
64 \brief output operator for Keywords.
65
66*/
67
198 class Keyword
199 {
200
201 public:
202
203
204
205 class WrongKeywordValueType : public FitsException //## Inherits: <unnamed>%39B0221700E2
206 {
207 public:
208 WrongKeywordValueType (const String& diag, bool silent = true);
209
210 protected:
211 private:
212 private: //## implementation
213 };
214 virtual ~Keyword();
215 Keyword & operator=(const Keyword &right);
216 bool operator==(const Keyword &right) const;
217
218 bool operator!=(const Keyword &right) const;
219
220 virtual std::ostream & put (std::ostream &s) const = 0;
221 virtual Keyword * clone () const = 0;
222 virtual void write ();
223 fitsfile* fitsPointer () const;
224 // CAUTION: This is declared public only to allow HDU addKey functions the ability to set their
225 // class as the Keyword's parent, and to avoid making entire HDU a friend class. (Declaring
226 // individual HDU functions as friends will run into circular header dependencies.) Do NOT use
227 // this unless absolutely necessary, and leave this undocumented.
228 void setParent (HDU* parent);
229
230 ValueType keytype () const;
231 const String& comment () const;
232 const String& name () const;
233 bool isLongStr () const;
234
235 public:
236 // Additional Public Declarations
237 template <typename T>
238 T& value(T& val) const;
239
240 template <typename T>
241 void setValue(const T& newValue);
242 protected:
243 Keyword(const Keyword &right);
244 Keyword (const String &keyname,
246 HDU* p,
247 const String &comment = "",
248 bool isLongStr = false);
249
250 virtual void copy (const Keyword& right);
251 virtual bool compare (const Keyword &right) const;
252 void keytype (ValueType value);
253 const HDU* parent () const;
254
255 // Additional Protected Declarations
256
257 private:
258 // Additional Private Declarations
259
260 private: //## implementation
261 // Data Members for Class Attributes
262 ValueType m_keytype;
263
264 // Data Members for Associations
265 HDU* m_parent;
266 String m_comment;
267 String m_name;
268 bool m_isLongStr;
269
270 // Additional Implementation Declarations
271 friend std::ostream &operator << (std::ostream &s, const Keyword &right);
272 };
273#ifndef SPEC_TEMPLATE_IMP_DEFECT
274#ifndef SPEC_TEMPLATE_DECL_DEFECT
275 template <> bool& Keyword::value(bool& val) const;
276 template <> float& Keyword::value(float& val) const;
277 template <> double& Keyword::value(double& val) const;
278 template <> int& Keyword::value(int& val) const;
279 template <> String& Keyword::value(String& val) const;
280
281 template <> void Keyword::setValue(const float& newValue);
282 template <> void Keyword::setValue(const double& newValue);
283 template <> void Keyword::setValue(const int& newValue);
284 template <> void Keyword::setValue(const String& val);
285#endif
286#endif
287
288inline std::ostream& operator << (std::ostream &s, const Keyword &right)
289{
290 return right.put(s);
291}
292
293 // Class CCfits::Keyword::WrongKeywordValueType
294
295 // Class CCfits::Keyword
296
297 inline void Keyword::setParent (HDU* parent)
298 {
299 m_parent = parent;
300 }
301
303 {
304 return m_keytype;
305 }
306
307 inline void Keyword::keytype (ValueType value)
308 {
309 m_keytype = value;
310 }
311
312 inline const HDU* Keyword::parent () const
313 {
314 return m_parent;
315 }
316
317 inline const String& Keyword::comment () const
318 {
319 return m_comment;
320 }
321
322 inline const String& Keyword::name () const
323 {
324 return m_name;
325 }
326
327 inline bool Keyword::isLongStr () const
328 {
329 return m_isLongStr;
330 }
331
332} // namespace CCfits
333
334
335#endif
FitsException is the base class for all exceptions thrown by this library.
Definition FitsError.h:94
Base class for all HDU [Header-Data Unit] objects.
Definition HDU.h:687
Abstract base class defining the interface for Keyword objects.
Definition Keyword.h:199
T & value(T &val) const
get the keyword value
Definition KeywordT.h:29
const HDU * parent() const
return a pointer to parent HDU.
Definition Keyword.h:312
bool operator!=(const Keyword &right) const
inequality operator
Definition Keyword.cxx:72
fitsfile * fitsPointer() const
return a pointer to the FITS file containing the parent HDU.
Definition Keyword.cxx:109
virtual ~Keyword()
virtual destructor
Definition Keyword.cxx:55
Keyword & operator=(const Keyword &right)
assignment operator
Definition Keyword.cxx:60
ValueType keytype() const
return the type of a keyword
Definition Keyword.h:302
const String & name() const
return the name of a keyword
Definition Keyword.h:322
void setValue(const T &newValue)
modify the value of an existing Keyword and write it to the file
Definition KeywordT.h:44
virtual Keyword * clone() const =0
virtual copy constructor
bool operator==(const Keyword &right) const
equality operator
Definition Keyword.cxx:67
virtual void write()
left in for historical reasons, this seldom needs to be called by users
Definition Keyword.cxx:97
const String & comment() const
return the comment field of the keyword
Definition Keyword.h:317
Namespace enclosing all CCfits classes and globals definitions.
Definition AsciiTable.cxx:26
std::ostream & operator<<(std::ostream &s, const Column &right)
output operator for Column objects.
Definition Column.h:1337
ValueType
CCfits value types and their CFITSIO equivalents (in caps)
Definition CCfits.h:81