GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GFitsHeaderCard Class Reference

Implements FITS header card interface. More...

#include <GFitsHeaderCard.hpp>

Inheritance diagram for GFitsHeaderCard:
GBase

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...
 
GFitsHeaderCardoperator= (const GFitsHeaderCard &card)
 Assignment operator. More...
 
void clear (void)
 Clear header card. More...
 
GFitsHeaderCardclone (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
 

Detailed Description

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.

Constructor & Destructor Documentation

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.

Parameters
[in]keynameCard name.
[in]valueCard value.
[in]unitCard unit.
[in]commentCard 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.

Parameters
[in]keynameCard name.
[in]valueCard string value.
[in]commentCard 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.

Parameters
[in]keynameCard name.
[in]valueCard floating point value.
[in]commentCard 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.

Parameters
[in]keynameCard name.
[in]valueCard integer value.
[in]commentCard 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.

Parameters
[in]keynameCard name.
[in]valueCard boolean value.
[in]commentCard 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.

Parameters
[in]keynameCard name.
[in]valueCard character string value.
[in]commentCard 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.

Parameters
[in]cardHeader card.

Definition at line 241 of file GFitsHeaderCard.cpp.

References copy_members(), and init_members().

GFitsHeaderCard::~GFitsHeaderCard ( void  )
virtual

Destructor.

Definition at line 257 of file GFitsHeaderCard.cpp.

References free_members().

Member Function Documentation

std::string GFitsHeaderCard::classname ( void  ) const
inlinevirtual

Return class name.

Returns
String containing the class name ("GFitsHeaderCard").

Implements GBase.

Definition at line 132 of file GFitsHeaderCard.hpp.

void GFitsHeaderCard::clear ( void  )
virtual

Clear header card.

Implements GBase.

Definition at line 308 of file GFitsHeaderCard.cpp.

References free_members(), and init_members().

GFitsHeaderCard * GFitsHeaderCard::clone ( void  ) const
virtual

Clone header card.

Returns
Pointer to deep copy of header card.

Implements GBase.

Definition at line 326 of file GFitsHeaderCard.cpp.

References GFitsHeaderCard().

void GFitsHeaderCard::comment ( const std::string &  comment)
inline

Set comment of header card.

Parameters
[in]commentHeader card comment.

Definition at line 157 of file GFitsHeaderCard.hpp.

References comment(), and m_comment.

const std::string & GFitsHeaderCard::comment ( void  ) const
inline

Return header card comment.

Definition at line 208 of file GFitsHeaderCard.hpp.

References m_comment.

Referenced by comment(), GFitsHeaderCard(), read(), and set_members().

void GFitsHeaderCard::copy_dtype ( const GFitsHeaderCard card)
private

Copy dtype.

Parameters
[in]cardHeader 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().

void GFitsHeaderCard::copy_members ( const GFitsHeaderCard card)
private

Copy class members.

Parameters
[in]cardHeader 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=().

const int & GFitsHeaderCard::decimals ( void  ) const
inline

Return header card decimals.

Definition at line 188 of file GFitsHeaderCard.hpp.

References m_value_decimals.

Referenced by write().

void GFitsHeaderCard::free_dtype ( void  )
private
void GFitsHeaderCard::free_members ( void  )
private

Delete class members.

Definition at line 855 of file GFitsHeaderCard.cpp.

References free_dtype().

Referenced by clear(), operator=(), and ~GFitsHeaderCard().

void GFitsHeaderCard::init_members ( void  )
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.

Parameters
[in]keynameCard name.

Definition at line 337 of file GFitsHeaderCard.cpp.

References keyname(), and m_keyname.

Referenced by GFitsHeader::append().

const std::string & GFitsHeaderCard::keyname ( void  ) const
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.

Parameters
[in]cardHeader card.
Returns
Header card.

Definition at line 278 of file GFitsHeaderCard.cpp.

References copy_members(), free_members(), and init_members().

std::string GFitsHeaderCard::print ( const GChatter chatter = NORMAL) const
virtual

Print header card information.

Parameters
[in]chatterChattiness (defaults to NORMAL).
Returns
String containing header card information.

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().

void GFitsHeaderCard::read ( void *  vptr,
const int &  keynum 
)
private

Read header card from FITS file.

Parameters
[in]vptrFITS file void pointer.
[in]keynumNumber 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().

void GFitsHeaderCard::read ( void *  vptr,
const std::string &  keyname 
)
private

Read header card from FITS file.

Parameters
[in]vptrFITS file void pointer.
[in]keynameName of the header card.
Exceptions
GException::invalid_valueSpecified keyname not found in FITS header.
GException::fits_errorcfitsio 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().

void GFitsHeaderCard::set_dtype ( const std::string &  value)
private

Set native data type from card string.

Parameters
[in]valueCard 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.

Todo:
Implement syntax checking for integer or float values.

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().

void GFitsHeaderCard::set_members ( const std::string &  keyname,
const std::string &  value,
const std::string &  unit,
const std::string &  comment 
)
private

Set card members.

Parameters
[in]keynameCard name.
[in]valueCard value.
[in]unitCard unit.
[in]commentCard 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

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().

void GFitsHeaderCard::unit ( const std::string &  unit)
inline

Set unit of header card value.

Parameters
[in]unitUnit of header card.

Definition at line 144 of file GFitsHeaderCard.hpp.

References m_unit, and unit().

const std::string & GFitsHeaderCard::unit ( void  ) const
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.

Parameters
[in]valueCard 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.

Parameters
[in]valueCard 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.

Parameters
[in]valueCard 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.

Parameters
[in]valueCard 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.

Parameters
[in]valueCard 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.

Parameters
[in]valueCard 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.

Parameters
[in]valueCard 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.

Parameters
[in]valueCard 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.

Parameters
[in]valueCard 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.

Parameters
[in]valueCard 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.

Parameters
[in]valueCard 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().

const std::string & GFitsHeaderCard::value ( void  ) const
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().

void GFitsHeaderCard::write ( void *  vptr) const
private

Write header card.

Parameters
[in]vptrFITS 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().

Friends And Related Function Documentation

friend class GFitsHeader
friend

Definition at line 47 of file GFitsHeaderCard.hpp.

Member Data Documentation

std::string GFitsHeaderCard::m_comment
private

Card comment.

Definition at line 118 of file GFitsHeaderCard.hpp.

Referenced by comment(), copy_members(), init_members(), print(), read(), set_members(), and write().

bool GFitsHeaderCard::m_comment_write
private

Signals that comment should be written.

Definition at line 121 of file GFitsHeaderCard.hpp.

Referenced by copy_members(), init_members(), and write().

int GFitsHeaderCard::m_dtype
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().

std::string GFitsHeaderCard::m_keyname
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().

std::string GFitsHeaderCard::m_unit
private

Unit of the card value.

Definition at line 117 of file GFitsHeaderCard.hpp.

Referenced by copy_members(), init_members(), print(), and unit().

std::string GFitsHeaderCard::m_value
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().

int GFitsHeaderCard::m_value_decimals
private

Decimals of value (for float)

Definition at line 120 of file GFitsHeaderCard.hpp.

Referenced by copy_members(), decimals(), and init_members().

void* GFitsHeaderCard::m_value_dtype
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().


The documentation for this class was generated from the following files: