Keyword.h

00001 //   Read the documentation to learn more about C++ code generator
00002 //   versioning.
00003 //      This is version 2.1 release dated Nov 2008
00004 //      Astrophysics Science Division,
00005 //      NASA/ Goddard Space Flight Center
00006 //      HEASARC
00007 //      http://heasarc.gsfc.nasa.gov
00008 //      e-mail: ccfits@legacy.gsfc.nasa.gov
00009 //
00010 //      Original author: Ben Dorman
00011 
00012 #ifndef KEYWORD_H
00013 #define KEYWORD_H 1
00014 #include "CCfits.h"
00015 // using namespace CCfits;
00016 #ifdef _MSC_VER
00017 #include "MSconfig.h"
00018 #endif
00019 
00020 // FitsError
00021 #include "FitsError.h"
00022 
00023 namespace CCfits {
00024   class HDU;
00025 
00026 } // namespace CCfits
00027 
00028 
00029 namespace CCfits {
00030 
00065 /* \fn friend ostream& operator << (ostream &s, const Keyword &right);
00066 
00067         \brief output operator for Keywords.
00068 
00069 */
00070 
00202   class Keyword 
00203   {
00204 
00205     public:
00206 
00207 
00208 
00209       class WrongKeywordValueType : public FitsException  //## Inherits: <unnamed>%39B0221700E2
00210       {
00211         public:
00212             WrongKeywordValueType (const String& diag, bool silent = true);
00213 
00214         protected:
00215         private:
00216         private: //## implementation
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         //      CAUTION: This is declared public only to allow HDU addKey functions the ability to set their
00229         //      class as the Keyword's parent, and to avoid making entire HDU a friend class.  (Declaring
00230         //      individual HDU functions as friends will run into circular header dependencies.)  Do NOT use
00231         //      this unless absolutely necessary, and leave this undocumented.
00232         void setParent (HDU* parent);
00233         const String& comment () const;
00234         const String& name () const;
00235 
00236     public:
00237       // Additional Public Declarations
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       // Additional Protected Declarations
00254 
00255     private:
00256       // Additional Private Declarations
00257 
00258     private: //## implementation
00259       // Data Members for Class Attributes
00260         ValueType m_keytype;
00261 
00262       // Data Members for Associations
00263         HDU* m_parent;
00264         String m_comment;
00265         String m_name;
00266 
00267       // Additional Implementation Declarations
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   // Class CCfits::Keyword::WrongKeywordValueType 
00288 
00289   // Class CCfits::Keyword 
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 } // namespace CCfits
00322 
00323 
00324 #endif

Generated on Thu Nov 6 10:44:39 2008 for CCfits by  doxygen 1.5.4