CCfits 2.7

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List

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
    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         bool isLongStr () const;
    00234
    00235     public:
    00236       // Additional Public Declarations
    00237       template <typename T>
    00238       T& value(T& val) const;
    00239
    00240       template <typename T>
    00241       void setValue(const T& newValue);
    00242     protected:
    00243         Keyword(const Keyword &right);
    00244         Keyword (const String &keyname,
    00245                  ValueType keytype,
    00246                  HDU* p,
    00247                  const String &comment = "",
    00248                  bool isLongStr = false);
    00249
    00250         virtual void copy (const Keyword& right);
    00251         virtual bool compare (const Keyword &right) const;
    00252         void keytype (ValueType value);
    00253         const HDU* parent () const;
    00254
    00255       // Additional Protected Declarations
    00256
    00257     private:
    00258       // Additional Private Declarations
    00259
    00260     private: //## implementation
    00261       // Data Members for Class Attributes
    00262         ValueType m_keytype;
    00263
    00264       // Data Members for Associations
    00265         HDU* m_parent;
    00266         String m_comment;
    00267         String m_name;
    00268         bool m_isLongStr;
    00269
    00270       // Additional Implementation Declarations
    00271       friend std::ostream &operator << (std::ostream &s, const Keyword &right);
    00272   };
    00273 #ifndef SPEC_TEMPLATE_IMP_DEFECT
    00274 #ifndef SPEC_TEMPLATE_DECL_DEFECT
    00275   template <> bool& Keyword::value(bool& val) const;
    00276   template <> float& Keyword::value(float& val) const;
    00277   template <> double& Keyword::value(double& val) const;
    00278   template <> int& Keyword::value(int& val) const;
    00279   template <> String& Keyword::value(String& val) const;
    00280
    00281   template <> void Keyword::setValue(const float& newValue);
    00282   template <> void Keyword::setValue(const double& newValue);
    00283   template <> void Keyword::setValue(const int& newValue);
    00284   template <> void Keyword::setValue(const String& val);
    00285 #endif
    00286 #endif
    00287
    00288 inline std::ostream& operator << (std::ostream &s, const Keyword &right)
    00289 {
    00290    return right.put(s);
    00291 }
    00292
    00293   // Class CCfits::Keyword::WrongKeywordValueType
    00294
    00295   // Class CCfits::Keyword
    00296
    00297   inline void Keyword::setParent (HDU* parent)
    00298   {
    00299      m_parent = parent;
    00300   }
    00301
    00302   inline ValueType Keyword::keytype () const
    00303   {
    00304     return m_keytype;
    00305   }
    00306
    00307   inline void Keyword::keytype (ValueType value)
    00308   {
    00309     m_keytype = value;
    00310   }
    00311
    00312   inline const HDU* Keyword::parent () const
    00313   {
    00314     return m_parent;
    00315   }
    00316
    00317   inline const String& Keyword::comment () const
    00318   {
    00319     return m_comment;
    00320   }
    00321
    00322   inline const String& Keyword::name () const
    00323   {
    00324     return m_name;
    00325   }
    00326
    00327   inline bool Keyword::isLongStr () const
    00328   {
    00329     return m_isLongStr;
    00330   }
    00331
    00332 } // namespace CCfits
    00333
    00334
    00335 #endif