CCfits  2.6
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 
20 namespace CCfits {
21  class HDU;
22 
23 } // namespace CCfits
24 
25 
26 namespace 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 <> float& Keyword::value(float& val) const;
276  template <> double& Keyword::value(double& val) const;
277  template <> int& Keyword::value(int& val) const;
278  template <> String& Keyword::value(String& val) const;
279 
280  template <> void Keyword::setValue(const float& newValue);
281  template <> void Keyword::setValue(const double& newValue);
282  template <> void Keyword::setValue(const int& newValue);
283 #endif
284 #endif
285 
286 inline std::ostream& operator << (std::ostream &s, const Keyword &right)
287 {
288  return right.put(s);
289 }
290 
291  // Class CCfits::Keyword::WrongKeywordValueType
292 
293  // Class CCfits::Keyword
294 
295  inline void Keyword::setParent (HDU* parent)
296  {
297  m_parent = parent;
298  }
299 
300  inline ValueType Keyword::keytype () const
301  {
302  return m_keytype;
303  }
304 
305  inline void Keyword::keytype (ValueType value)
306  {
307  m_keytype = value;
308  }
309 
310  inline const HDU* Keyword::parent () const
311  {
312  return m_parent;
313  }
314 
315  inline const String& Keyword::comment () const
316  {
317  return m_comment;
318  }
319 
320  inline const String& Keyword::name () const
321  {
322  return m_name;
323  }
324 
325  inline bool Keyword::isLongStr () const
326  {
327  return m_isLongStr;
328  }
329 
330 } // namespace CCfits
331 
332 
333 #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:674
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:310
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:300
const String & name() const
return the name of a keyword
Definition: Keyword.h:320
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:315
Keyword(const Keyword &right)
copy constructor
Definition: Keyword.cxx:36
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