CCfits  2.4
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 
197  class Keyword
198  {
199 
200  public:
201 
202 
203 
204  class WrongKeywordValueType : public FitsException //## Inherits: <unnamed>%39B0221700E2
205  {
206  public:
207  WrongKeywordValueType (const String& diag, bool silent = true);
208 
209  protected:
210  private:
211  private: //## implementation
212  };
213  virtual ~Keyword();
214  Keyword & operator=(const Keyword &right);
215  bool operator==(const Keyword &right) const;
216 
217  bool operator!=(const Keyword &right) const;
218 
219  virtual std::ostream & put (std::ostream &s) const = 0;
220  virtual Keyword * clone () const = 0;
221  virtual void write ();
222  fitsfile* fitsPointer () const;
223  // CAUTION: This is declared public only to allow HDU addKey functions the ability to set their
224  // class as the Keyword's parent, and to avoid making entire HDU a friend class. (Declaring
225  // individual HDU functions as friends will run into circular header dependencies.) Do NOT use
226  // this unless absolutely necessary, and leave this undocumented.
227  void setParent (HDU* parent);
228 
229  ValueType keytype () const;
230  const String& comment () const;
231  const String& name () const;
232 
233  public:
234  // Additional Public Declarations
235  template <typename T>
236  T& value(T& val) const;
237 
238  template <typename T>
239  void setValue(const T& newValue);
240  protected:
241  Keyword(const Keyword &right);
242  Keyword (const String &keyname, ValueType keytype, HDU* p, const String &comment = "");
243 
244  virtual void copy (const Keyword& right);
245  virtual bool compare (const Keyword &right) const;
246  void keytype (ValueType value);
247  const HDU* parent () const;
248 
249  // Additional Protected Declarations
250 
251  private:
252  // Additional Private Declarations
253 
254  private: //## implementation
255  // Data Members for Class Attributes
256  ValueType m_keytype;
257 
258  // Data Members for Associations
259  HDU* m_parent;
260  String m_comment;
261  String m_name;
262 
263  // Additional Implementation Declarations
264  friend std::ostream &operator << (std::ostream &s, const Keyword &right);
265  };
266 #ifndef SPEC_TEMPLATE_IMP_DEFECT
267 #ifndef SPEC_TEMPLATE_DECL_DEFECT
268  template <> float& Keyword::value(float& val) const;
269  template <> double& Keyword::value(double& val) const;
270  template <> int& Keyword::value(int& val) const;
271 
272  template <> void Keyword::setValue(const float& newValue);
273  template <> void Keyword::setValue(const double& newValue);
274  template <> void Keyword::setValue(const int& newValue);
275 #endif
276 #endif
277 
278 inline std::ostream& operator << (std::ostream &s, const Keyword &right)
279 {
280  return right.put(s);
281 }
282 
283  // Class CCfits::Keyword::WrongKeywordValueType
284 
285  // Class CCfits::Keyword
286 
287  inline void Keyword::setParent (HDU* parent)
288  {
289  m_parent = parent;
290  }
291 
292  inline ValueType Keyword::keytype () const
293  {
294  return m_keytype;
295  }
296 
297  inline void Keyword::keytype (ValueType value)
298  {
299  m_keytype = value;
300  }
301 
302  inline const HDU* Keyword::parent () const
303  {
304  return m_parent;
305  }
306 
307  inline const String& Keyword::comment () const
308  {
309  return m_comment;
310  }
311 
312  inline const String& Keyword::name () const
313  {
314  return m_name;
315  }
316 
317 } // namespace CCfits
318 
319 
320 #endif