21 #include "FitsError.h" 31 class KeyData :
public Keyword
35 KeyData(
const KeyData< T > &right);
36 KeyData (
const String &keyname,
ValueType keytype,
const T &value, HDU* p,
37 const String &comment =
"");
40 virtual KeyData <T>* clone ()
const;
41 virtual void write ();
42 const T& keyval ()
const;
43 void keyval (
const T& value);
48 virtual void copy (
const Keyword& right);
49 virtual bool compare (
const Keyword &right)
const;
50 virtual std::ostream & put (std::ostream &s)
const;
64 #if SPEC_TEMPLATE_IMP_DEFECT || SPEC_TEMPLATE_DECL_DEFECT 66 inline void KeyData<String>::write()
71 const_cast<char *>(
name().c_str()),
72 const_cast<char*>(m_keyval.c_str()),
73 const_cast<char *>(
comment().c_str()),
74 &status))
throw FitsError(status);
78 template<>
void KeyData<String>::write();
81 #if SPEC_TEMPLATE_IMP_DEFECT || SPEC_TEMPLATE_DECL_DEFECT 83 inline void KeyData<bool>::write()
88 if (m_keyval)
value=1;
90 const_cast<char *>(
name().c_str()),
92 const_cast<char *>(
comment().c_str()),
93 &status))
throw FitsError(status);
97 template<>
void KeyData<bool>::write();
100 #ifdef SPEC_TEMPLATE_DECL_DEFECT 102 inline const String& KeyData<String>::keyval()
const 108 template<>
const String& KeyData<String>::keyval()
const;
111 #ifndef SPEC_TEMPLATE_DECL_DEFECT 112 template<>
void KeyData<String>::keyval(
const String& );
115 #if SPEC_TEMPLATE_IMP_DEFECT || SPEC_TEMPLATE_DECL_DEFECT 117 inline std::ostream & KeyData<String>::put (std::ostream &s)
const 120 s <<
"Keyword Name: " << setw(10) <<
name() <<
" Value: " << setw(14)
121 << keyval() <<
" Type: " << setw(20) <<
" string " <<
" Comment: " <<
comment();
126 template<> std::ostream& KeyData<String>::put(std::ostream& s)
const;
130 #if SPEC_TEMPLATE_IMP_DEFECT || SPEC_TEMPLATE_DECL_DEFECT 132 inline std::ostream & KeyData<bool>::put (std::ostream &s)
const 135 s <<
"Keyword Name: " << setw(10) <<
name()
136 <<
" Value: " << std::boolalpha << setw(8) << keyval()
137 <<
" Type: " << setw(20) <<
" logical " <<
" Comment: " <<
comment();
142 template<> std::ostream& KeyData<bool>::put(std::ostream& s)
const;
145 #if SPEC_TEMPLATE_IMP_DEFECT || SPEC_TEMPLATE_DECL_DEFECT 147 inline void KeyData<std::complex<float> >::write()
151 FITSUtil::auto_array_ptr<float> keyVal(
new float[2]);
152 keyVal[0] = m_keyval.real();
153 keyVal[1] = m_keyval.imag();
155 const_cast<char *>(
name().c_str()),
157 const_cast<char *
>(
comment().c_str()),
158 &status))
throw FitsError(status);
162 template<>
void KeyData<std::complex<float> >::write();
165 #if SPEC_TEMPLATE_IMP_DEFECT || SPEC_TEMPLATE_DECL_DEFECT 167 inline void KeyData<std::complex<double> >::write()
171 FITSUtil::auto_array_ptr<double> keyVal(
new double[2]);
172 keyVal[0] = m_keyval.real();
173 keyVal[1] = m_keyval.imag();
175 const_cast<char *>(
name().c_str()),
177 const_cast<char *
>(
comment().c_str()),
178 &status))
throw FitsError(status);
182 template<>
void KeyData<std::complex<double> >::write();
185 #if SPEC_TEMPLATE_IMP_DEFECT || SPEC_TEMPLATE_DECL_DEFECT 187 inline std::ostream & KeyData<std::complex<float> >::put (std::ostream &s)
const 190 s <<
"Keyword Name: " <<
name() <<
" Value: " << m_keyval.real() <<
" + i " 191 << m_keyval.imag() <<
" Type: " << setw(20) <<
" complex<float> " 192 <<
" Comment: " <<
comment() << std::endl;
197 inline std::ostream & KeyData<std::complex<double> >::put (std::ostream &s)
const 200 s <<
"Keyword Name: " <<
name() <<
" Value: " << m_keyval.real() <<
" + i " 201 << m_keyval.imag() <<
" Type: " << setw(20) <<
" complex<double> " 202 <<
" Comment: " <<
comment() << std::endl;
207 template<> std::ostream& KeyData<std::complex<float> >::put(std::ostream& s)
const;
208 template<> std::ostream& KeyData<std::complex<double> >::put(std::ostream& s)
const;
211 #ifdef SPEC_TEMPLATE_DECL_DEFECT 213 inline const std::complex<float>& KeyData<std::complex<float> >::keyval()
const 220 inline void KeyData<std::complex<float> >::keyval(
const std::complex<float>& newVal)
227 inline const std::complex<double>& KeyData<std::complex<double> >::keyval()
const 234 inline void KeyData<std::complex<double> >::keyval(
const std::complex<double>& newVal)
241 template<>
const std::complex<float>& KeyData<std::complex<float> >::keyval()
const;
242 template<>
void KeyData<std::complex<float> >::keyval(
const std::complex<float>& );
246 template<>
const std::complex<double>& KeyData<std::complex<double> >::keyval()
const;
247 template<>
void KeyData<std::complex<double> >::keyval(
const std::complex<double>& );
252 template <
typename T>
253 inline std::ostream & KeyData<T>::put (std::ostream &s)
const 255 s <<
"Keyword Name: " <<
name() <<
"\t Value: " << keyval() <<
261 template <
typename T>
262 inline const T& KeyData<T>::keyval ()
const 267 template <
typename T>
268 inline void KeyData<T>::keyval (
const T& value)
275 template <
typename T>
276 KeyData<T>::KeyData(
const KeyData<T> &right)
278 m_keyval(right.m_keyval)
282 template <
typename T>
283 KeyData<T>::KeyData (
const String &keyname,
ValueType keytype,
const T &value,
HDU* p,
const String &
comment)
284 : Keyword(keyname, keytype, p, comment),
290 template <
typename T>
291 KeyData<T>::~KeyData()
296 template <
typename T>
297 void KeyData<T>::copy (
const Keyword& right)
299 Keyword::copy(right);
300 const KeyData<T>& that =
static_cast<const KeyData<T>&
>(right);
301 m_keyval = that.m_keyval;
304 template <
typename T>
305 bool KeyData<T>::compare (
const Keyword &right)
const 307 if ( !Keyword::compare(right) )
return false;
308 const KeyData<T>& that =
static_cast<const KeyData<T>&
>(right);
309 if (this->m_keyval != that.m_keyval)
return false;
313 template <
typename T>
314 KeyData <T>* KeyData<T>::clone ()
const 316 return new KeyData<T>(*this);
319 template <
typename T>
320 void KeyData<T>::write ()
324 FITSUtil::MatchType<T> keyType;
326 const_cast<char *>(name().c_str()),
328 const_cast<char *>(
comment().c_str()),
329 &status) )
throw FitsError(status);
ValueType keytype() const
return the type of a keyword
Definition: Keyword.h:292
const String & comment() const
return the comment field of the keyword
Definition: Keyword.h:307
fitsfile * fitsPointer() const
return the fitsfile pointer for the FITS object containing the HDU
Definition: HDU.cxx:309
const String & name() const
return the name of a keyword
Definition: Keyword.h:312
virtual void write()
left in for historical reasons, this seldom needs to be called by users
Definition: Keyword.cxx:95
Namespace enclosing all CCfits classes and globals definitions.
Definition: AsciiTable.cxx:26
Keyword(const Keyword &right)
copy constructor
Definition: Keyword.cxx:36
ValueType
CCfits value types and their CFITSIO equivalents (in caps)
Definition: CCfits.h:79
HDU(const HDU &right)
copy constructor
Definition: HDU.cxx:87
T & value(T &val) const
get the keyword value
Definition: KeywordT.h:29
fitsfile * fitsPointer() const
return a pointer to the FITS file containing the parent HDU.
Definition: Keyword.cxx:107
const string & comment() const
return the comment string previously read by getComment()
Definition: HDU.h:820