GammaLib
2.1.0.dev
|
Implements FITS header card interface. More...
#include <GFitsHeaderCard.hpp>
Public Member Functions | |
GFitsHeaderCard (void) | |
Void constructor. More... | |
GFitsHeaderCard (const std::string &keyname, const std::string &value, const std::string &unit, const std::string &comment) | |
Card constructor. More... | |
GFitsHeaderCard (const std::string &keyname, const std::string &value, const std::string &comment) | |
Constructor for string cards. More... | |
GFitsHeaderCard (const std::string &keyname, const double &value, const std::string &comment) | |
Constructor for floating point cards. More... | |
GFitsHeaderCard (const std::string &keyname, const int &value, const std::string &comment) | |
Constructor for boolean cards. More... | |
GFitsHeaderCard (const std::string &keyname, const bool &value, const std::string &comment) | |
Constructor for integer cards. More... | |
GFitsHeaderCard (const std::string &keyname, const char *value, const std::string &comment) | |
Constructor for character string cards. More... | |
GFitsHeaderCard (const GFitsHeaderCard &card) | |
Copy constructor. More... | |
virtual | ~GFitsHeaderCard (void) |
Destructor. More... | |
GFitsHeaderCard & | operator= (const GFitsHeaderCard &card) |
Assignment operator. More... | |
void | clear (void) |
Clear header card. More... | |
GFitsHeaderCard * | clone (void) const |
Clone header card. More... | |
std::string | classname (void) const |
Return class name. More... | |
void | keyname (const std::string &keyname) |
Set name of header card. More... | |
const std::string & | keyname (void) const |
Return header card keyname. More... | |
void | value (const std::string &value) |
Set string value of header card. More... | |
void | value (const bool &value) |
Set boolean value of header card. More... | |
void | value (const float &value) |
Set single precision value of header card. More... | |
void | value (const double &value) |
Set double precision value of header card. More... | |
void | value (const unsigned short &value) |
Set unsigned short integer value of header card. More... | |
void | value (const short &value) |
Set short integer value of header card. More... | |
void | value (const unsigned int &value) |
Set unsigned integer value of header card. More... | |
void | value (const int &value) |
Set integer value of header card. More... | |
void | value (const long &value) |
Set long integer value of header card. More... | |
void | value (const unsigned long &value) |
Set unsigned integer long value of header card. More... | |
void | value (const long long &value) |
Set long long integer value of header card. More... | |
const std::string & | value (void) const |
Return header card value. More... | |
const int & | decimals (void) const |
Return header card decimals. More... | |
void | unit (const std::string &unit) |
Set unit of header card value. More... | |
const std::string & | unit (void) const |
Return header card value unit. More... | |
void | comment (const std::string &comment) |
Set comment of header card. More... | |
const std::string & | comment (void) const |
Return header card comment. More... | |
std::string | string (void) const |
Return header card value as string. More... | |
double | real (void) const |
Return header card value as double precision. More... | |
int | integer (void) const |
Return header card value as integer. More... | |
std::string | print (const GChatter &chatter=NORMAL) const |
Print header card information. More... | |
Public Member Functions inherited from GBase | |
virtual | ~GBase (void) |
Destructor. More... | |
Private Member Functions | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GFitsHeaderCard &card) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
void | set_members (const std::string &keyname, const std::string &value, const std::string &unit, const std::string &comment) |
Set card members. More... | |
void | copy_dtype (const GFitsHeaderCard &card) |
Copy dtype. More... | |
void | free_dtype (void) |
Free dtype. More... | |
void | set_dtype (const std::string &value) |
Set native data type from card string. More... | |
void | read (void *vptr, const int &keynum) |
Read header card from FITS file. More... | |
void | read (void *fptr, const std::string &keyname) |
Read header card from FITS file. More... | |
void | write (void *fptr) const |
Write header card. More... | |
Private Attributes | |
std::string | m_keyname |
Name of the card. More... | |
std::string | m_value |
Value of the card as read from file. More... | |
std::string | m_unit |
Unit of the card value. More... | |
std::string | m_comment |
Card comment. More... | |
int | m_dtype |
Native data type. More... | |
int | m_value_decimals |
Decimals of value (for float) More... | |
bool | m_comment_write |
Signals that comment should be written. More... | |
void * | m_value_dtype |
Value in native data type. More... | |
Friends | |
class | GFitsHeader |
Implements FITS header card interface.
This class implements a FITS header card. A header card consists of a keyname (string), a value (string, floating point, integer or logical) and a comment (string). COMMENT or HISTORY cards do not have a value.
Definition at line 44 of file GFitsHeaderCard.hpp.
GFitsHeaderCard::GFitsHeaderCard | ( | void | ) |
Void constructor.
Definition at line 67 of file GFitsHeaderCard.cpp.
References init_members().
Referenced by clone().
GFitsHeaderCard::GFitsHeaderCard | ( | const std::string & | keyname, |
const std::string & | value, | ||
const std::string & | unit, | ||
const std::string & | comment | ||
) |
Card constructor.
[in] | keyname | Card name. |
[in] | value | Card value. |
[in] | unit | Card unit. |
[in] | comment | Card comment. |
Constructs a header card from keyname
, value
, unit
and comment
string. The card type is determined from the card value format.
Definition at line 88 of file GFitsHeaderCard.cpp.
References init_members(), and set_members().
GFitsHeaderCard::GFitsHeaderCard | ( | const std::string & | keyname, |
const std::string & | value, | ||
const std::string & | comment | ||
) |
Constructor for string cards.
[in] | keyname | Card name. |
[in] | value | Card string value. |
[in] | comment | Card comment. |
This constructor builds a header card from the keyname, value and comment.
Definition at line 115 of file GFitsHeaderCard.cpp.
References comment(), init_members(), keyname(), and value().
GFitsHeaderCard::GFitsHeaderCard | ( | const std::string & | keyname, |
const double & | value, | ||
const std::string & | comment | ||
) |
Constructor for floating point cards.
[in] | keyname | Card name. |
[in] | value | Card floating point value. |
[in] | comment | Card comment. |
This constructor builds a header card from the keyname, value and comment.
Definition at line 141 of file GFitsHeaderCard.cpp.
References comment(), init_members(), keyname(), and value().
GFitsHeaderCard::GFitsHeaderCard | ( | const std::string & | keyname, |
const int & | value, | ||
const std::string & | comment | ||
) |
Constructor for boolean cards.
[in] | keyname | Card name. |
[in] | value | Card integer value. |
[in] | comment | Card comment. |
This constructor builds a header card from the keyname, value and comment.
Definition at line 167 of file GFitsHeaderCard.cpp.
References comment(), init_members(), keyname(), and value().
GFitsHeaderCard::GFitsHeaderCard | ( | const std::string & | keyname, |
const bool & | value, | ||
const std::string & | comment | ||
) |
Constructor for integer cards.
[in] | keyname | Card name. |
[in] | value | Card boolean value. |
[in] | comment | Card comment. |
This constructor builds a header card from the keyname, value and comment.
Definition at line 193 of file GFitsHeaderCard.cpp.
References comment(), init_members(), keyname(), and value().
GFitsHeaderCard::GFitsHeaderCard | ( | const std::string & | keyname, |
const char * | value, | ||
const std::string & | comment | ||
) |
Constructor for character string cards.
[in] | keyname | Card name. |
[in] | value | Card character string value. |
[in] | comment | Card comment. |
This constructor builds a header card from the keyname, value and comment.
Definition at line 219 of file GFitsHeaderCard.cpp.
References comment(), init_members(), keyname(), and value().
GFitsHeaderCard::GFitsHeaderCard | ( | const GFitsHeaderCard & | card | ) |
Copy constructor.
[in] | card | Header card. |
Definition at line 241 of file GFitsHeaderCard.cpp.
References copy_members(), and init_members().
|
virtual |
|
inlinevirtual |
Return class name.
Implements GBase.
Definition at line 132 of file GFitsHeaderCard.hpp.
|
virtual |
Clear header card.
Implements GBase.
Definition at line 308 of file GFitsHeaderCard.cpp.
References free_members(), and init_members().
|
virtual |
Clone header card.
Implements GBase.
Definition at line 326 of file GFitsHeaderCard.cpp.
References GFitsHeaderCard().
|
inline |
Set comment of header card.
[in] | comment | Header card comment. |
Definition at line 157 of file GFitsHeaderCard.hpp.
|
inline |
Return header card comment.
Definition at line 208 of file GFitsHeaderCard.hpp.
References m_comment.
Referenced by comment(), GFitsHeaderCard(), read(), and set_members().
|
private |
Copy dtype.
[in] | card | Header card. |
Copies the data type of a header card.
Definition at line 901 of file GFitsHeaderCard.cpp.
References __TDOUBLE, __TFLOAT, __TINT, __TLOGICAL, __TLONG, __TLONGLONG, __TSHORT, __TSTRING, __TUINT, __TULONG, __TUSHORT, G_COPY_DTYPE, m_dtype, m_value_dtype, gammalib::str(), and gammalib::warning().
Referenced by copy_members().
|
private |
Copy class members.
[in] | card | Header card to be copied |
Definition at line 834 of file GFitsHeaderCard.cpp.
References copy_dtype(), m_comment, m_comment_write, m_keyname, m_unit, m_value, and m_value_decimals.
Referenced by GFitsHeaderCard(), and operator=().
|
inline |
Return header card decimals.
Definition at line 188 of file GFitsHeaderCard.hpp.
References m_value_decimals.
Referenced by write().
|
private |
Free dtype.
Definition at line 956 of file GFitsHeaderCard.cpp.
References __TDOUBLE, __TFLOAT, __TINT, __TLOGICAL, __TLONG, __TLONGLONG, __TSHORT, __TSTRING, __TUINT, __TULONG, __TUSHORT, G_FREE_DTYPE, m_dtype, m_value_dtype, gammalib::str(), and gammalib::warning().
Referenced by free_members(), set_dtype(), and value().
|
private |
Delete class members.
Definition at line 855 of file GFitsHeaderCard.cpp.
References free_dtype().
Referenced by clear(), operator=(), and ~GFitsHeaderCard().
|
private |
Initialise class members.
Definition at line 812 of file GFitsHeaderCard.cpp.
References __TNULL, m_comment, m_comment_write, m_dtype, m_keyname, m_unit, m_value, m_value_decimals, and m_value_dtype.
Referenced by clear(), GFitsHeaderCard(), and operator=().
int GFitsHeaderCard::integer | ( | void | ) | const |
Return header card value as integer.
Convert header card value into a integer value. In case that the card did not contain a numerical value, 0 will be returned by the method.
Definition at line 666 of file GFitsHeaderCard.cpp.
References __TLOGICAL, __TSTRING, m_dtype, m_value, m_value_dtype, and gammalib::toint().
Referenced by GFitsHDU::integer().
void GFitsHeaderCard::keyname | ( | const std::string & | keyname | ) |
Set name of header card.
[in] | keyname | Card name. |
Definition at line 337 of file GFitsHeaderCard.cpp.
References keyname(), and m_keyname.
Referenced by GFitsHeader::append().
|
inline |
Return header card keyname.
Definition at line 168 of file GFitsHeaderCard.hpp.
References m_keyname.
Referenced by GFitsHeaderCard(), keyname(), read(), and set_members().
GFitsHeaderCard & GFitsHeaderCard::operator= | ( | const GFitsHeaderCard & | card | ) |
Assignment operator.
[in] | card | Header card. |
Definition at line 278 of file GFitsHeaderCard.cpp.
References copy_members(), free_members(), and init_members().
Print header card information.
[in] | chatter | Chattiness (defaults to NORMAL). |
Implements GBase.
Definition at line 700 of file GFitsHeaderCard.cpp.
References __TBIT, __TBYTE, __TCOMPLEX, __TDBLCOMPLEX, __TDOUBLE, __TFLOAT, __TINT, __TLOGICAL, __TLONG, __TLONGLONG, __TNULL, __TSBYTE, __TSHORT, __TSTRING, __TUINT, __TULONG, __TUSHORT, gammalib::left(), m_comment, m_dtype, m_keyname, m_unit, m_value, m_value_dtype, gammalib::right(), SILENT, and gammalib::str().
|
private |
Read header card from FITS file.
[in] | vptr | FITS file void pointer. |
[in] | keynum | Number of the header card. |
Definition at line 1125 of file GFitsHeaderCard.cpp.
References __ffgkyn, comment(), gammalib::fits_move_to_hdu(), FPTR, G_READ_NUM, keyname(), m_comment, m_keyname, m_value, set_dtype(), and value().
Referenced by GFitsHeader::load().
|
private |
Read header card from FITS file.
[in] | vptr | FITS file void pointer. |
[in] | keyname | Name of the header card. |
GException::invalid_value | Specified keyname not found in FITS header. |
GException::fits_error | cfitsio error occured. |
Definition at line 1166 of file GFitsHeaderCard.cpp.
References __ffgkey, comment(), gammalib::fits_move_to_hdu(), FPTR, G_READ_STR, keyname(), m_comment, m_keyname, m_value, set_dtype(), gammalib::str(), and value().
double GFitsHeaderCard::real | ( | void | ) | const |
Return header card value as double precision.
Convert header card value into a double precision value. In case that the card did not contain a numerical value, 0 will be returned by the method.
Definition at line 631 of file GFitsHeaderCard.cpp.
References __TLOGICAL, __TSTRING, m_dtype, m_value, m_value_dtype, and gammalib::todouble().
Referenced by GFitsHDU::real().
|
private |
Set native data type from card string.
[in] | value | Card string. |
The native data type is determined from the card string. This method sets the members m_dtype and m_value_type. The card type is determined by analyzing the card value.
Definition at line 1018 of file GFitsHeaderCard.cpp.
References __TDOUBLE, __TFLOAT, __TLONG, __TLONGLONG, __TNULL, __TSHORT, __TULONG, __TUSHORT, free_dtype(), m_dtype, m_keyname, m_value, m_value_dtype, gammalib::todouble(), gammalib::tolonglong(), gammalib::toulonglong(), and value().
Referenced by read(), and set_members().
|
private |
Set card members.
[in] | keyname | Card name. |
[in] | value | Card value. |
[in] | unit | Card unit. |
[in] | comment | Card comment. |
Sets the card members from keyname
, value
, unit
, and comment
strings. The card type is determined from the format of the card value.
Definition at line 876 of file GFitsHeaderCard.cpp.
References comment(), keyname(), m_comment, m_keyname, m_value, set_dtype(), and value().
Referenced by GFitsHeaderCard().
std::string GFitsHeaderCard::string | ( | void | ) | const |
Return header card value as string.
Returns header card value as string. Any hyphens that may occur in the FITS card will be stripped.
Definition at line 594 of file GFitsHeaderCard.cpp.
References __TSTRING, m_dtype, m_value, m_value_dtype, and gammalib::strip_whitespace().
Referenced by GFitsHDU::string().
|
inline |
Set unit of header card value.
[in] | unit | Unit of header card. |
Definition at line 144 of file GFitsHeaderCard.hpp.
|
inline |
Return header card value unit.
Definition at line 198 of file GFitsHeaderCard.hpp.
References m_unit.
Referenced by unit().
void GFitsHeaderCard::value | ( | const std::string & | value | ) |
Set string value of header card.
[in] | value | Card string value. |
This method sets the value of a string header card. The internal string representation contains hyphens, yet for keyword writing the hyphens are stripped.
Definition at line 356 of file GFitsHeaderCard.cpp.
References __TSTRING, free_dtype(), m_dtype, m_value, m_value_dtype, gammalib::strip_whitespace(), and value().
Referenced by GFitsImageByte::GFitsImageByte(), GFitsImageDouble::GFitsImageDouble(), GFitsImageFloat::GFitsImageFloat(), GFitsImageLong::GFitsImageLong(), GFitsImageLongLong::GFitsImageLongLong(), GFitsImageSByte::GFitsImageSByte(), GFitsImageShort::GFitsImageShort(), GFitsImageULong::GFitsImageULong(), and GFitsImageUShort::GFitsImageUShort().
void GFitsHeaderCard::value | ( | const bool & | value | ) |
Set boolean value of header card.
[in] | value | Card boolean value. |
Definition at line 391 of file GFitsHeaderCard.cpp.
References __TLOGICAL, free_dtype(), m_dtype, m_value, m_value_dtype, and value().
void GFitsHeaderCard::value | ( | const float & | value | ) |
Set single precision value of header card.
[in] | value | Card single precision value. |
Definition at line 411 of file GFitsHeaderCard.cpp.
References __TFLOAT, free_dtype(), m_dtype, m_value, m_value_dtype, and gammalib::str().
void GFitsHeaderCard::value | ( | const double & | value | ) |
Set double precision value of header card.
[in] | value | Card double precision value. |
Definition at line 431 of file GFitsHeaderCard.cpp.
References __TDOUBLE, free_dtype(), m_dtype, m_value, m_value_dtype, and gammalib::str().
void GFitsHeaderCard::value | ( | const unsigned short & | value | ) |
Set unsigned short integer value of header card.
[in] | value | Card unsigned short integer value. |
Definition at line 451 of file GFitsHeaderCard.cpp.
References __TUSHORT, free_dtype(), m_dtype, m_value, m_value_dtype, and gammalib::str().
void GFitsHeaderCard::value | ( | const short & | value | ) |
Set short integer value of header card.
[in] | value | Card short integer value. |
Definition at line 471 of file GFitsHeaderCard.cpp.
References __TSHORT, free_dtype(), m_dtype, m_value, m_value_dtype, and gammalib::str().
void GFitsHeaderCard::value | ( | const unsigned int & | value | ) |
Set unsigned integer value of header card.
[in] | value | Card unsigned integer value. |
Definition at line 491 of file GFitsHeaderCard.cpp.
References __TUINT, free_dtype(), m_dtype, m_value, m_value_dtype, and gammalib::str().
void GFitsHeaderCard::value | ( | const int & | value | ) |
Set integer value of header card.
[in] | value | Card integer value. |
Definition at line 511 of file GFitsHeaderCard.cpp.
References __TINT, free_dtype(), m_dtype, m_value, m_value_dtype, and gammalib::str().
void GFitsHeaderCard::value | ( | const long & | value | ) |
Set long integer value of header card.
[in] | value | Card long integer value. |
Definition at line 531 of file GFitsHeaderCard.cpp.
References __TLONG, free_dtype(), m_dtype, m_value, m_value_dtype, and gammalib::str().
void GFitsHeaderCard::value | ( | const unsigned long & | value | ) |
Set unsigned integer long value of header card.
[in] | value | Card unsigned long integer value. |
Definition at line 551 of file GFitsHeaderCard.cpp.
References __TULONG, free_dtype(), m_dtype, m_value, m_value_dtype, and gammalib::str().
void GFitsHeaderCard::value | ( | const long long & | value | ) |
Set long long integer value of header card.
[in] | value | Card long long integer value. |
Definition at line 571 of file GFitsHeaderCard.cpp.
References __TLONGLONG, free_dtype(), m_dtype, m_value, m_value_dtype, and gammalib::str().
|
inline |
Return header card value.
Definition at line 178 of file GFitsHeaderCard.hpp.
References m_value.
Referenced by GFitsHeaderCard(), read(), set_dtype(), set_members(), value(), and write().
|
private |
Write header card.
[in] | vptr | FITS file void pointer. |
Writes any kind of header card to a FITS file.
Definition at line 1214 of file GFitsHeaderCard.cpp.
References __ffpcom, __ffphis, __ffprec, __ffuky, __ffukyd, __ffukye, __ffukyl, __ffukys, __ffukyu, __TDOUBLE, __TFLOAT, __TLOGICAL, __TNULL, __TSTRING, decimals(), gammalib::fits_move_to_hdu(), FPTR, G_WRITE, m_comment, m_comment_write, m_dtype, m_keyname, m_value_dtype, gammalib::str(), value(), and gammalib::warning().
|
friend |
Definition at line 47 of file GFitsHeaderCard.hpp.
|
private |
Card comment.
Definition at line 118 of file GFitsHeaderCard.hpp.
Referenced by comment(), copy_members(), init_members(), print(), read(), set_members(), and write().
|
private |
Signals that comment should be written.
Definition at line 121 of file GFitsHeaderCard.hpp.
Referenced by copy_members(), init_members(), and write().
|
private |
Native data type.
Definition at line 119 of file GFitsHeaderCard.hpp.
Referenced by copy_dtype(), free_dtype(), init_members(), integer(), print(), real(), set_dtype(), string(), value(), and write().
|
private |
Name of the card.
Definition at line 115 of file GFitsHeaderCard.hpp.
Referenced by copy_members(), init_members(), keyname(), print(), read(), set_dtype(), set_members(), and write().
|
private |
Unit of the card value.
Definition at line 117 of file GFitsHeaderCard.hpp.
Referenced by copy_members(), init_members(), print(), and unit().
|
private |
Value of the card as read from file.
Definition at line 116 of file GFitsHeaderCard.hpp.
Referenced by copy_members(), init_members(), integer(), print(), read(), real(), set_dtype(), set_members(), string(), and value().
|
private |
Decimals of value (for float)
Definition at line 120 of file GFitsHeaderCard.hpp.
Referenced by copy_members(), decimals(), and init_members().
|
private |
Value in native data type.
Definition at line 122 of file GFitsHeaderCard.hpp.
Referenced by copy_dtype(), free_dtype(), init_members(), integer(), print(), real(), set_dtype(), string(), value(), and write().