CCfits  2.4
Keyword.h
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 
00197   class Keyword 
00198   {
00199 
00200     public:
00201 
00202 
00203 
00204       class WrongKeywordValueType : public FitsException  //## Inherits: <unnamed>%39B0221700E2
00205       {
00206         public:
00207             WrongKeywordValueType (const String& diag, bool silent = true);
00208 
00209         protected:
00210         private:
00211         private: //## implementation
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         //      CAUTION: This is declared public only to allow HDU addKey functions the ability to set their
00224         //      class as the Keyword's parent, and to avoid making entire HDU a friend class.  (Declaring
00225         //      individual HDU functions as friends will run into circular header dependencies.)  Do NOT use
00226         //      this unless absolutely necessary, and leave this undocumented.
00227         void setParent (HDU* parent);
00228 
00229         ValueType keytype () const;
00230         const String& comment () const;
00231         const String& name () const;
00232 
00233     public:
00234       // Additional Public Declarations
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       // Additional Protected Declarations
00250 
00251     private:
00252       // Additional Private Declarations
00253 
00254     private: //## implementation
00255       // Data Members for Class Attributes
00256         ValueType m_keytype;
00257 
00258       // Data Members for Associations
00259         HDU* m_parent;
00260         String m_comment;
00261         String m_name;
00262 
00263       // Additional Implementation Declarations
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   // Class CCfits::Keyword::WrongKeywordValueType 
00284 
00285   // Class CCfits::Keyword 
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 } // namespace CCfits
00318 
00319 
00320 #endif