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