CCfits  2.6
Public Member Functions | Protected Member Functions | List of all members
CCfits::Keyword Class Referenceabstract

Abstract base class defining the interface for Keyword objects. More...

#include <Keyword.h>

Inherited by CCfits::KeyData< T >.

Public Member Functions

virtual ~Keyword ()
 virtual destructor
 
virtual Keywordclone () const =0
 virtual copy constructor
 
const String & comment () const
 return the comment field of the keyword
 
fitsfile * fitsPointer () const
 return a pointer to the FITS file containing the parent HDU.
 
ValueType keytype () const
 return the type of a keyword
 
const String & name () const
 return the name of a keyword
 
bool operator!= (const Keyword &right) const
 inequality operator
 
Keywordoperator= (const Keyword &right)
 assignment operator
 
bool operator== (const Keyword &right) const
 equality operator
 
template<typename T >
void setValue (const T &newValue)
 modify the value of an existing Keyword and write it to the file More...
 
template<typename T >
T & value (T &val) const
 get the keyword value More...
 
virtual void write ()
 left in for historical reasons, this seldom needs to be called by users More...
 

Protected Member Functions

 Keyword (const Keyword &right)
 copy constructor
 
 Keyword (const String &keyname, ValueType keytype, HDU *p, const String &comment="", bool isLongStr=false)
 Keyword constructor. More...
 
void keytype (ValueType value)
 set keyword type.
 
const HDUparent () const
 return a pointer to parent HDU.
 

Detailed Description

Abstract base class defining the interface for Keyword objects.

Keyword object creation is normally performed inside FITS constructors or FITS::read, HDU::readKey, and HDU::addKey functions. Output is performed in HDU::addKey functions and Keyword::setValue.

Keywords consists of a name, a value and a comment field. Concrete templated subclasses, KeyData<T>, have a data member that holds the value of keyword.

Typically, the mandatory keywords for a given HDU type are not stored as object of type Keyword, but as intrinsic data types. The Keyword hierarchy is used to store user-supplied information.

Constructor & Destructor Documentation

◆ Keyword()

CCfits::Keyword::Keyword ( const String &  keyname,
ValueType  keytype,
HDU p,
const String &  comment = "",
bool  isLongStr = false 
)
protected

Keyword constructor.

This is the common behavior of Keywords of any type. Constructor is protected as the class is abstract.

Member Function Documentation

◆ setValue()

template<typename T >
void CCfits::Keyword::setValue ( const T &  newValue)

modify the value of an existing Keyword and write it to the file

Parameters
newValue(T) New value for the Keyword

Allowed T types: This must copy newValue to a data member of type U in the Keyword subclass KeyData<U> (see description for Keyword::value (T& val) for more details). To avoid compilation errors, it is generally best to provide a newValue of type T = type U, though the following type conversions will also be handled:

T (from newValue)U (to Keyword obj)
floatdouble, float
doubledouble, float (will lose precision)
intdouble, float, int, integer string

◆ value()

template<typename T >
T & CCfits::Keyword::value ( T &  val) const

get the keyword value

Parameters
val(T) Will be filled with the keyword value, and is also the function return value.

Allowed T types: CCfits stores keyword values of type U in a templated subclass of Keyword, KeyData<U>. Normally U is set when reading the Keyword in from the file, and is limited to types int, double, string, bool, and complex<float>. (The exception is when the user has created and added a new Keyword using an HDU::addKey function, in which case they might have specified other types for U.) To avoid compilation errors, the user should generally try to provide a val of type T = type U, though there is some flexibility here as the following conversions are handled:

T (to val)U (from Keyword obj)
floatdouble (will lose precision), float, int, integer string
doubledouble, float, int, integer string
intint, integer string
stringdouble, float, int, string

More conversions may be added in the future as the need arises.

◆ write()

void CCfits::Keyword::write ( )
virtual

left in for historical reasons, this seldom needs to be called by users

This writes the Keyword to the file, and is called internally during HDU::addKey operations or the Keyword::setValue function. It shouldn't normally need to be called explicitly.


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