00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef KEYWORD_H
00013 #define KEYWORD_H 1
00014 #include "CCfits.h"
00015
00016 #ifdef _MSC_VER
00017 #include "MSconfig.h"
00018 #endif
00019
00020
00021 #include "FitsError.h"
00022
00023 namespace CCfits {
00024 class HDU;
00025
00026 }
00027
00028
00029 namespace CCfits {
00030
00065
00066
00067
00068
00069
00070
00202 class Keyword
00203 {
00204
00205 public:
00206
00207
00208
00209 class WrongKeywordValueType : public FitsException
00210 {
00211 public:
00212 WrongKeywordValueType (const String& diag, bool silent = true);
00213
00214 protected:
00215 private:
00216 private:
00217 };
00218 virtual ~Keyword();
00219 Keyword & operator=(const Keyword &right);
00220 bool operator==(const Keyword &right) const;
00221
00222 bool operator!=(const Keyword &right) const;
00223
00224 virtual std::ostream & put (std::ostream &s) const = 0;
00225 virtual Keyword * clone () const = 0;
00226 virtual void write ();
00227 fitsfile* fitsPointer () const;
00228
00229
00230
00231
00232 void setParent (HDU* parent);
00233 const String& comment () const;
00234 const String& name () const;
00235
00236 public:
00237
00238 template <typename T>
00239 T& value(T& val) const;
00240
00241 template <typename T>
00242 void setValue(const T& newValue);
00243 protected:
00244 Keyword(const Keyword &right);
00245 Keyword (const String &keyname, ValueType keytype, HDU* p, const String &comment = "");
00246
00247 virtual void copy (const Keyword& right);
00248 virtual bool compare (const Keyword &right) const;
00249 ValueType keytype () const;
00250 void keytype (ValueType value);
00251 const HDU* parent () const;
00252
00253
00254
00255 private:
00256
00257
00258 private:
00259
00260 ValueType m_keytype;
00261
00262
00263 HDU* m_parent;
00264 String m_comment;
00265 String m_name;
00266
00267
00268 friend std::ostream &operator << (std::ostream &s, const Keyword &right);
00269 };
00270 #ifndef SPEC_TEMPLATE_IMP_DEFECT
00271 #ifndef SPEC_TEMPLATE_DECL_DEFECT
00272 template <> float& Keyword::value(float& val) const;
00273 template <> double& Keyword::value(double& val) const;
00274 template <> int& Keyword::value(int& val) const;
00275
00276 template <> void Keyword::setValue(const float& newValue);
00277 template <> void Keyword::setValue(const double& newValue);
00278 template <> void Keyword::setValue(const int& newValue);
00279 #endif
00280 #endif
00281
00282 inline std::ostream& operator << (std::ostream &s, const Keyword &right)
00283 {
00284 return right.put(s);
00285 }
00286
00287
00288
00289
00290
00291 inline void Keyword::setParent (HDU* parent)
00292 {
00293 m_parent = parent;
00294 }
00295
00296 inline ValueType Keyword::keytype () const
00297 {
00298 return m_keytype;
00299 }
00300
00301 inline void Keyword::keytype (ValueType value)
00302 {
00303 m_keytype = value;
00304 }
00305
00306 inline const HDU* Keyword::parent () const
00307 {
00308 return m_parent;
00309 }
00310
00311 inline const String& Keyword::comment () const
00312 {
00313 return m_comment;
00314 }
00315
00316 inline const String& Keyword::name () const
00317 {
00318 return m_name;
00319 }
00320
00321 }
00322
00323
00324 #endif