CCfits
2.5
|
00001 // Astrophysics Science Division, 00002 // NASA/ Goddard Space Flight Center 00003 // HEASARC 00004 // http://heasarc.gsfc.nasa.gov 00005 // e-mail: ccfits@legacy.gsfc.nasa.gov 00006 // 00007 // Original author: Ben Dorman 00008 00009 #ifndef KEYWORD_H 00010 #define KEYWORD_H 1 00011 #include "CCfits.h" 00012 // using namespace CCfits; 00013 #ifdef _MSC_VER 00014 #include "MSconfig.h" 00015 #endif 00016 00017 // FitsError 00018 #include "FitsError.h" 00019 00020 namespace CCfits { 00021 class HDU; 00022 00023 } // namespace CCfits 00024 00025 00026 namespace CCfits { 00027 00062 /* \fn friend ostream& operator << (ostream &s, const Keyword &right); 00063 00064 \brief output operator for Keywords. 00065 00066 */ 00067 00198 class Keyword 00199 { 00200 00201 public: 00202 00203 00204 00205 class WrongKeywordValueType : public FitsException //## Inherits: <unnamed>%39B0221700E2 00206 { 00207 public: 00208 WrongKeywordValueType (const String& diag, bool silent = true); 00209 00210 protected: 00211 private: 00212 private: //## implementation 00213 }; 00214 virtual ~Keyword(); 00215 Keyword & operator=(const Keyword &right); 00216 bool operator==(const Keyword &right) const; 00217 00218 bool operator!=(const Keyword &right) const; 00219 00220 virtual std::ostream & put (std::ostream &s) const = 0; 00221 virtual Keyword * clone () const = 0; 00222 virtual void write (); 00223 fitsfile* fitsPointer () const; 00224 // CAUTION: This is declared public only to allow HDU addKey functions the ability to set their 00225 // class as the Keyword's parent, and to avoid making entire HDU a friend class. (Declaring 00226 // individual HDU functions as friends will run into circular header dependencies.) Do NOT use 00227 // this unless absolutely necessary, and leave this undocumented. 00228 void setParent (HDU* parent); 00229 00230 ValueType keytype () const; 00231 const String& comment () const; 00232 const String& name () const; 00233 00234 public: 00235 // Additional Public Declarations 00236 template <typename T> 00237 T& value(T& val) const; 00238 00239 template <typename T> 00240 void setValue(const T& newValue); 00241 protected: 00242 Keyword(const Keyword &right); 00243 Keyword (const String &keyname, ValueType keytype, HDU* p, const String &comment = ""); 00244 00245 virtual void copy (const Keyword& right); 00246 virtual bool compare (const Keyword &right) const; 00247 void keytype (ValueType value); 00248 const HDU* parent () const; 00249 00250 // Additional Protected Declarations 00251 00252 private: 00253 // Additional Private Declarations 00254 00255 private: //## implementation 00256 // Data Members for Class Attributes 00257 ValueType m_keytype; 00258 00259 // Data Members for Associations 00260 HDU* m_parent; 00261 String m_comment; 00262 String m_name; 00263 00264 // Additional Implementation Declarations 00265 friend std::ostream &operator << (std::ostream &s, const Keyword &right); 00266 }; 00267 #ifndef SPEC_TEMPLATE_IMP_DEFECT 00268 #ifndef SPEC_TEMPLATE_DECL_DEFECT 00269 template <> float& Keyword::value(float& val) const; 00270 template <> double& Keyword::value(double& val) const; 00271 template <> int& Keyword::value(int& val) const; 00272 template <> String& Keyword::value(String& val) const; 00273 00274 template <> void Keyword::setValue(const float& newValue); 00275 template <> void Keyword::setValue(const double& newValue); 00276 template <> void Keyword::setValue(const int& newValue); 00277 #endif 00278 #endif 00279 00280 inline std::ostream& operator << (std::ostream &s, const Keyword &right) 00281 { 00282 return right.put(s); 00283 } 00284 00285 // Class CCfits::Keyword::WrongKeywordValueType 00286 00287 // Class CCfits::Keyword 00288 00289 inline void Keyword::setParent (HDU* parent) 00290 { 00291 m_parent = parent; 00292 } 00293 00294 inline ValueType Keyword::keytype () const 00295 { 00296 return m_keytype; 00297 } 00298 00299 inline void Keyword::keytype (ValueType value) 00300 { 00301 m_keytype = value; 00302 } 00303 00304 inline const HDU* Keyword::parent () const 00305 { 00306 return m_parent; 00307 } 00308 00309 inline const String& Keyword::comment () const 00310 { 00311 return m_comment; 00312 } 00313 00314 inline const String& Keyword::name () const 00315 { 00316 return m_name; 00317 } 00318 00319 } // namespace CCfits 00320 00321 00322 #endif