21 #include "FitsError.h" 
   31   class KeyData : 
public Keyword  
 
   35         KeyData (
const KeyData< T > &right);
 
   36         KeyData (
const String &keyname,
 
   40                  const String &comment = 
"",
 
   41                  bool isLongStr = 
false);
 
   44         virtual KeyData <T>* clone () 
const;
 
   45         virtual void write ();
 
   46         const T& keyval () 
const;
 
   47         void keyval (
const T& value);
 
   52         virtual void copy (
const Keyword& right);
 
   53         virtual bool compare (
const Keyword &right) 
const;
 
   54         virtual std::ostream & put (std::ostream &s) 
const;
 
   68 #if SPEC_TEMPLATE_IMP_DEFECT || SPEC_TEMPLATE_DECL_DEFECT 
   70         inline void KeyData<String>::write() 
 
   74            if (fits_update_key(fitsPointer(), Tstring, 
 
   75                        const_cast<char *>(name().c_str()),
 
   76                        const_cast<char*>(m_keyval.c_str()),
 
   77                        const_cast<char *>(comment().c_str()), 
 
   78                        &status)) 
throw FitsError(status);
 
   82 template<> 
void KeyData<String>::write();
 
   85 #if SPEC_TEMPLATE_IMP_DEFECT || SPEC_TEMPLATE_DECL_DEFECT 
   87         inline void KeyData<bool>::write() 
 
   92            if (m_keyval) value=1; 
 
   93            if (fits_update_key(fitsPointer(), Tlogical, 
 
   94                        const_cast<char *>(name().c_str()),
 
   96                        const_cast<char *>(comment().c_str()), 
 
   97                        &status)) 
throw FitsError(status);
 
  101 template<> 
void KeyData<bool>::write();
 
  104 #ifdef SPEC_TEMPLATE_DECL_DEFECT 
  106         inline const String& KeyData<String>::keyval()
 const 
  112 template<> 
const String& KeyData<String>::keyval() 
const;
 
  115 #ifndef SPEC_TEMPLATE_DECL_DEFECT 
  116 template<> 
void KeyData<String>::keyval(
const String& );
 
  119 #if SPEC_TEMPLATE_IMP_DEFECT || SPEC_TEMPLATE_DECL_DEFECT 
  121         inline std::ostream & KeyData<String>::put (std::ostream &s)
 const 
  124         s << 
"Keyword Name: " << setw(10) << name() << 
"  Value: " << setw(14) 
 
  125                   << keyval() << 
" Type: " << setw(20) << 
" string "  << 
" Comment: " << comment();
 
  130 template<> std::ostream& KeyData<String>::put(std::ostream& s) 
const;
 
  134 #if SPEC_TEMPLATE_IMP_DEFECT || SPEC_TEMPLATE_DECL_DEFECT 
  136         inline std::ostream & KeyData<bool>::put (std::ostream &s)
 const 
  139         s << 
"Keyword Name: " << setw(10) << name() 
 
  140                   << 
"  Value: " << std::boolalpha  << setw(8) << keyval() 
 
  141                   << 
"  Type: " << setw(20) << 
" logical "  << 
" Comment: " << comment();
 
  146 template<> std::ostream& KeyData<bool>::put(std::ostream& s) 
const;
 
  149 #if SPEC_TEMPLATE_IMP_DEFECT || SPEC_TEMPLATE_DECL_DEFECT 
  151         inline void KeyData<std::complex<float> >::write() 
 
  155              FITSUtil::auto_array_ptr<float> keyVal( 
new float[2]);
 
  156              keyVal[0] = m_keyval.real(); 
 
  157              keyVal[1] = m_keyval.imag(); 
 
  158              if (fits_update_key(fitsPointer(), Tcomplex, 
 
  159                        const_cast<char *>(name().c_str()),
 
  161                        const_cast<char *
>(comment().c_str()), 
 
  162                        &status)) 
throw FitsError(status);
 
  166 template<> 
void KeyData<std::complex<float> >::write();
 
  169 #if SPEC_TEMPLATE_IMP_DEFECT || SPEC_TEMPLATE_DECL_DEFECT 
  171         inline void KeyData<std::complex<double> >::write() 
 
  175              FITSUtil::auto_array_ptr<double> keyVal(
new double[2]);
 
  176              keyVal[0] = m_keyval.real(); 
 
  177              keyVal[1] = m_keyval.imag(); 
 
  178              if (fits_update_key(fitsPointer(), Tdblcomplex, 
 
  179                        const_cast<char *>(name().c_str()),
 
  181                        const_cast<char *
>(comment().c_str()), 
 
  182                        &status)) 
throw FitsError(status);
 
  186 template<> 
void KeyData<std::complex<double> >::write();
 
  189 #if SPEC_TEMPLATE_IMP_DEFECT || SPEC_TEMPLATE_DECL_DEFECT 
  191         inline std::ostream & KeyData<std::complex<float> >::put (std::ostream &s)
 const 
  194             s << 
"Keyword Name: " << name() << 
" Value: " << m_keyval.real() << 
" +   i "  
  195                   << m_keyval.imag() <<   
" Type: " <<  setw(20) << 
" complex<float> "  
  196                   << 
" Comment: " << comment()   << std::endl;
 
  201         inline std::ostream & KeyData<std::complex<double> >::put (std::ostream &s)
 const 
  204             s << 
"Keyword Name: " << name() << 
" Value: " << m_keyval.real() << 
" +   i "  
  205                   << m_keyval.imag() <<   
" Type: " <<  setw(20) << 
" complex<double> "  
  206                   << 
" Comment: " << comment()   << std::endl;
 
  211 template<> std::ostream& KeyData<std::complex<float> >::put(std::ostream& s) 
const;
 
  212 template<> std::ostream& KeyData<std::complex<double> >::put(std::ostream& s) 
const;
 
  215 #ifdef SPEC_TEMPLATE_DECL_DEFECT 
  217   inline const std::complex<float>& KeyData<std::complex<float> >::keyval()
 const 
  224   inline void KeyData<std::complex<float> >::keyval(
const std::complex<float>&  newVal)
 
  231   inline const std::complex<double>& KeyData<std::complex<double> >::keyval()
 const 
  238   inline void KeyData<std::complex<double> >::keyval(
const std::complex<double>&  newVal)
 
  245 template<> 
const std::complex<float>&  KeyData<std::complex<float> >::keyval() 
const;
 
  246 template<> 
void KeyData<std::complex<float> >::keyval(
const std::complex<float>&  );
 
  250 template<> 
const std::complex<double>&  KeyData<std::complex<double> >::keyval() 
const;
 
  251 template<> 
void KeyData<std::complex<double> >::keyval(
const std::complex<double>&  );
 
  256   template <
typename T>
 
  257   inline std::ostream & KeyData<T>::put (std::ostream &s)
 const 
  259    s << 
"Keyword Name: " << name() << 
"\t Value: " << keyval() << 
 
  260      "\t Type: " << keytype() << 
"\t Comment: " << comment();
 
  265   template <
typename T>
 
  266   inline const T& KeyData<T>::keyval ()
 const 
  271   template <
typename T>
 
  272   inline void KeyData<T>::keyval (
const T& value)
 
  279   template <
typename T>
 
  280   KeyData<T>::KeyData(
const KeyData<T> &right)
 
  282        m_keyval(right.m_keyval)
 
  286   template <
typename T>
 
  287   KeyData<T>::KeyData (
const String &keyname,
 
  291                        const String &comment,
 
  293        : Keyword(keyname, keytype, p, comment, isLongStr),
 
  299   template <
typename T>
 
  300   KeyData<T>::~KeyData()
 
  305   template <
typename T>
 
  306   void KeyData<T>::copy (
const Keyword& right)
 
  308   Keyword::copy(right);
 
  309   const KeyData<T>& that = 
static_cast<const KeyData<T>&
>(right);
 
  310   m_keyval = that.m_keyval;
 
  313   template <
typename T>
 
  314   bool KeyData<T>::compare (
const Keyword &right)
 const 
  316   if ( !Keyword::compare(right) ) 
return false;
 
  317   const KeyData<T>& that = 
static_cast<const KeyData<T>&
>(right);
 
  318   if (this->m_keyval != that.m_keyval) 
return false;
 
  322   template <
typename T>
 
  323   KeyData <T>* KeyData<T>::clone ()
 const 
  325   return new KeyData<T>(*this);
 
  328   template <
typename T>
 
  329   void KeyData<T>::write ()
 
  333    FITSUtil::MatchType<T> keyType;
 
  334    if ( fits_update_key(fitsPointer(),keyType(), 
 
  335                const_cast<char *>(name().c_str()),
 
  337                const_cast<char *>(comment().c_str()), 
 
  338                &status) ) 
throw FitsError(status);
 
virtual void write()
left in for historical reasons, this seldom needs to be called by users 
Definition: Keyword.cxx:97
ValueType
CCfits value types and their CFITSIO equivalents (in caps) 
Definition: CCfits.h:81