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

Abstract interface for FITS table. More...

#include <GFitsTable.hpp>

Inheritance diagram for GFitsTable:
GFitsHDU GBase GFitsAsciiTable GFitsBinTable

Public Member Functions

 GFitsTable (void)
 Void constructor. More...
 
 GFitsTable (const int &nrows)
 Table constructor. More...
 
 GFitsTable (const GFitsTable &table)
 Copy constructor. More...
 
virtual ~GFitsTable (void)
 Destructor. More...
 
GFitsTableoperator= (const GFitsTable &table)
 Assignment operator. More...
 
GFitsTableColoperator[] (const int &colnum)
 Returns pointer to table column. More...
 
const GFitsTableColoperator[] (const int &colnum) const
 Returns pointer to table column (const version) More...
 
GFitsTableColoperator[] (const std::string &colname)
 Returns pointer to table column. More...
 
const GFitsTableColoperator[] (const std::string &colname) const
 Returns pointer to table column (const version) More...
 
virtual void clear (void)=0
 Clear object. More...
 
virtual GFitsTableclone (void) const =0
 Clones object. More...
 
virtual std::string classname (void) const =0
 Return class name. More...
 
virtual HDUType exttype (void) const =0
 
GFitsTableColset (const int &colnum, const GFitsTableCol &column)
 Set column. More...
 
GFitsTableColset (const std::string &colname, const GFitsTableCol &column)
 Set column. More...
 
GFitsTableColappend (const GFitsTableCol &column)
 Append column to the table. More...
 
GFitsTableColinsert (int colnum, const GFitsTableCol &column)
 Insert column into the table. More...
 
GFitsTableColinsert (const std::string &colname, const GFitsTableCol &column)
 Insert column into the table. More...
 
void remove (const int &colnum)
 Remove column from the table. More...
 
void remove (const std::string &colname)
 Remove column from the table. More...
 
void append_rows (const int &nrows)
 Append rows to the table. More...
 
void insert_rows (const int &row, const int &nrows)
 Insert rows into the table. More...
 
void remove_rows (const int &row, const int &nrows)
 Remove rows from the table. More...
 
const int & nrows (void) const
 Return number of rows in table. More...
 
const int & ncols (void) const
 Return number of columns in table. More...
 
bool contains (const std::string &colname) const
 Checks the presence of a column in table. More...
 
std::string print (const GChatter &chatter=NORMAL) const
 Print table information. More...
 
- Public Member Functions inherited from GFitsHDU
 GFitsHDU (void)
 Void constructor. More...
 
 GFitsHDU (const GFitsHDU &hdu)
 Copy constructor. More...
 
virtual ~GFitsHDU (void)
 Destructor. More...
 
GFitsHDUoperator= (const GFitsHDU &hdu)
 Assignment operator. More...
 
int cards (void) const
 Return number of cards in HDU header. More...
 
const std::string & extname (void) const
 Return extension name. More...
 
void extname (const std::string &extname)
 Set HDU extension name (EXTNAME keyword) More...
 
const int & extno (void) const
 Return extension number. More...
 
void extno (const int &extno)
 Set extension number. More...
 
const GFitsHeaderheader (void) const
 Return extension header. More...
 
void header (const GFitsHeader &header)
 Set extension header. More...
 
bool has_card (const int &cardno) const
 Check existence of header card. More...
 
bool has_card (const std::string &keyname) const
 Checks for presence of header card. More...
 
GFitsHeaderCardcard (const int &cardno)
 Return header card. More...
 
const GFitsHeaderCardcard (const int &cardno) const
 Return header card (const version) More...
 
GFitsHeaderCardcard (const std::string &keyname)
 Return header card. More...
 
const GFitsHeaderCardcard (const std::string &keyname) const
 Return header card (const version) More...
 
void card (const GFitsHeaderCard &card)
 Append or update header card. More...
 
void card (const std::string &keyname, const std::string &value, const std::string &comment)
 Append or update string value header card. More...
 
void card (const std::string &keyname, const double &value, const std::string &comment)
 Append or update double precision value header card. More...
 
void card (const std::string &keyname, const int &value, const std::string &comment)
 Append or update integer value header card. More...
 
void card (const std::string &keyname, const bool &value, const std::string &comment)
 Append or update boolean value header card. More...
 
void card (const std::string &keyname, const char *value, const std::string &comment)
 Append or update character value header card. More...
 
std::string string (const std::string &keyname) const
 Return card value as string. More...
 
double real (const std::string &keyname) const
 Return card value as double precision. More...
 
int integer (const std::string &keyname) const
 Return card value as integer. More...
 
- Public Member Functions inherited from GBase
virtual ~GBase (void)
 Destructor. More...
 

Protected Member Functions

void init_members (void)
 Initialise class members. More...
 
void copy_members (const GFitsTable &table)
 Copy class members. More...
 
void free_members (void)
 Free class members. More...
 
void free_columns (void)
 Free column pointers. More...
 
void update_header (void)
 Update header after row or column manipulations. More...
 
void data_open (void *vptr)
 Open Table. More...
 
void data_save (void)
 Save table into FITS file. More...
 
void data_close (void)
 Close table. More...
 
void data_connect (void *vptr)
 Connect table data to FITS file. More...
 
char * get_ttype (const int &colnum) const
 Returns pointer to column type. More...
 
char * get_tform (const int &colnum) const
 Returns pointer to column format. More...
 
char * get_tunit (const int &colnum) const
 Returns pointer to column unit. More...
 
- Protected Member Functions inherited from GFitsHDU
void init_members (void)
 Initialise class members. More...
 
void copy_members (const GFitsHDU &hdu)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
void connect (void *fptr)
 Connect HDU to FITS file. More...
 
void move_to_hdu (void)
 Move FITS file pointer to HDU. More...
 
HDUType get_hdu_type (void) const
 Get HDU type from FITS file. More...
 
void open (void *vptr, int hdunum)
 Open HDU. More...
 
void save (void)
 Saves HDU. More...
 
std::string print_hdu (const GChatter &chatter=NORMAL) const
 Print basic HDU information. More...
 
std::string typecode (int type) const
 Return typecode as string. More...
 

Protected Attributes

int m_type
 Table type (1=ASCII, 2=Binary) More...
 
int m_rows
 Number of rows in table. More...
 
int m_cols
 Number of columns in table. More...
 
GFitsTableCol ** m_columns
 Array of table columns. More...
 
- Protected Attributes inherited from GFitsHDU
void * m_fitsfile
 FITS file pointer pointing on actual HDU. More...
 
int m_hdunum
 HDU number (starting from 0) More...
 
std::string m_name
 HDU name (extname) More...
 
GFitsHeader m_header
 HDU header. More...
 

Private Member Functions

GFitsTableColalloc_column (int typecode) const
 Allocates column. More...
 
GFitsTableColptr_column (const std::string &colname) const
 Returns pointer of column with given name. More...
 
int colnum (const std::string &colname) const
 Returns column number of a given column name. More...
 

Additional Inherited Members

- Public Types inherited from GFitsHDU
enum  HDUType { HT_IMAGE = 0, HT_ASCII_TABLE = 1, HT_BIN_TABLE = 2 }
 

Detailed Description

Abstract interface for FITS table.

This class defines the abstract interface for a FITS table. A FITS table is a collection of columns with an identical number of rows. This class provides high level access to table columns.

Definition at line 44 of file GFitsTable.hpp.

Constructor & Destructor Documentation

GFitsTable::GFitsTable ( void  )

Void constructor.

Construct empty FITS table.

Definition at line 89 of file GFitsTable.cpp.

References init_members().

GFitsTable::GFitsTable ( const int &  nrows)
explicit

Table constructor.

Parameters
[in]nrowsNumber of rows in table.

Construct FITS table with nrows table rows.

Definition at line 106 of file GFitsTable.cpp.

References init_members(), m_rows, and nrows().

GFitsTable::GFitsTable ( const GFitsTable table)

Copy constructor.

Parameters
[in]tableFITS table.

Definition at line 124 of file GFitsTable.cpp.

References copy_members(), and init_members().

GFitsTable::~GFitsTable ( void  )
virtual

Destructor.

Definition at line 140 of file GFitsTable.cpp.

References free_members().

Member Function Documentation

GFitsTableCol * GFitsTable::alloc_column ( int  typecode) const
private

Allocates column.

Parameters
[in]typecodecfitsio type code

Allocates a table column depending on the cfitsio type code. If the type code is not found then return a NULL pointer.

Definition at line 1789 of file GFitsTable.cpp.

References __TBIT, __TBYTE, __TCOMPLEX, __TDBLCOMPLEX, __TDOUBLE, __TFLOAT, __TLOGICAL, __TLONG, __TLONGLONG, __TSHORT, __TSTRING, __TULONG, __TUSHORT, and abs().

Referenced by data_open().

void GFitsTable::append_rows ( const int &  nrows)

Append rows to the table.

Parameters
[in]nrowsNumber of rows to be appended.

Appends nrows rows at the end of the FITS table. The method calls the insert() method to do the job. Note that a call of this method will lead to loading all table data into memory.

Definition at line 606 of file GFitsTable.cpp.

References insert_rows(), and nrows().

virtual std::string GFitsTable::classname ( void  ) const
pure virtual

Return class name.

Returns
String containing the class name.

Returns the class name for non-abstract classes in a human readable way.

Implements GFitsHDU.

Implemented in GFitsAsciiTable, and GFitsBinTable.

Referenced by GVOTable::read().

virtual void GFitsTable::clear ( void  )
pure virtual

Clear object.

Sets the object to a clean initial state. After calling the method the object will be in the same state as it were if an empty instance of the object would have been created.

Implements GFitsHDU.

Implemented in GFitsAsciiTable, and GFitsBinTable.

virtual GFitsTable* GFitsTable::clone ( void  ) const
pure virtual

Clones object.

Returns
Pointer to deep copy of object.

Creates a deep copy of the object and returns a pointer to the object.

Implements GFitsHDU.

Implemented in GFitsAsciiTable, and GFitsBinTable.

Referenced by GCTABackground3D::read(), and GLATEventCube::read_gti().

int GFitsTable::colnum ( const std::string &  colname) const
private

Returns column number of a given column name.

Parameters
[in]colnameName of column.
Returns
Column number (-1 if column has not been found).

Returns the column number of the column with the specified name. If more columns with the same name exist, the first of these columns is returned.

Definition at line 1884 of file GFitsTable.cpp.

References m_cols, and m_columns.

Referenced by data_save(), get_tform(), get_ttype(), get_tunit(), insert(), operator[](), remove(), and set().

bool GFitsTable::contains ( const std::string &  colname) const

Checks the presence of a column in table.

Parameters
[in]colnameColumn name.
Returns
True if the column exists, false otherwise.

Definition at line 716 of file GFitsTable.cpp.

References ptr_column().

Referenced by GCTAResponseIrf::load_aeff(), GCTAResponseIrf::load_edisp(), GCTAResponseIrf::load_psf(), GCTAEventList::read(), GCTAPsfVector::read(), GCOMInstChars::read_coeffs(), GRmf::write(), and GArf::write().

void GFitsTable::copy_members ( const GFitsTable table)
protected

Copy class members.

Parameters
[in]tableFITS Table.

Copies FITS table members from table.

Definition at line 825 of file GFitsTable.cpp.

References GFitsTableCol::clone(), m_cols, m_columns, m_rows, and m_type.

Referenced by GFitsTable(), and operator=().

void GFitsTable::data_close ( void  )
protectedvirtual

Close table.

Implements GFitsHDU.

Definition at line 1633 of file GFitsTable.cpp.

References free_members(), and init_members().

void GFitsTable::data_connect ( void *  vptr)
protectedvirtual

Connect table data to FITS file.

Parameters
[in]vptrFITS file pointer.

Connects the table columns to the file specified by the FITS file pointer. This method does nothing if the file pointer in not valid.

Implements GFitsHDU.

Definition at line 1654 of file GFitsTable.cpp.

References GFitsTableCol::connect(), m_cols, and m_columns.

void GFitsTable::data_open ( void *  vptr)
protectedvirtual

Open Table.

Parameters
[in]vptrFITS file pointer.
Exceptions
GException::fits_hdu_not_foundSpecified HDU not found in FITS file.
GException::fits_errorA CFITSIO error occured during loading the table.
GException::fits_unknown_coltypeFITS column of unsupported type has been found in the FITS file.
GException::fits_inconsistent_tdimThe TDIM information provided in the header is inconsistent with the size of the column.

This method loads a description of the table into memory. Column data are not loaded at this point to save memory. They will be loaded on request later.

Implements GFitsHDU.

Definition at line 1082 of file GFitsTable.cpp.

References __ffgkey, __ffgky, __ffgncl, __ffgnrw, __ffgtcl, __TINT, __TLONG, __TSHORT, __TSTRING, __TUINT, __TULONG, __TUSHORT, alloc_column(), GFitsTableCol::colnum(), GFitsTableCol::connect(), GFitsTableCol::dim(), gammalib::fits_move_to_hdu(), FPTR, FPTR_COPY, free_columns(), G_DATA_OPEN, GFitsTableCol::is_variable(), m_cols, m_columns, GFitsHDU::m_fitsfile, m_rows, GFitsTableCol::name(), nrows(), GFitsTableCol::nrows(), GFitsTableCol::number(), gammalib::number(), GFitsTableCol::repeat(), gammalib::split(), gammalib::str(), gammalib::strip_chars(), gammalib::strip_whitespace(), gammalib::toint(), GFitsTableCol::type(), GFitsHDU::typecode(), GFitsTableCol::unit(), and GFitsTableCol::width().

void GFitsTable::data_save ( void  )
protectedvirtual

Save table into FITS file.

Exceptions
GException::fits_errorA CFITSIO error occured in this method.
GException::fits_bad_col_lengthTable columns have inconsistent lengths.

Saves the FITS table into the FITS file.

In case that no table HDU exists so far in the FITS file, a new table will be appended to the FITS file. In case that a different HDU type exists at the requested extension number, the existing HDU will be deleted and be replaced by the requested table type.

The method also verifies the consistency of all table columns. Table columns need to have identical lengths to be saved into a FITS table. All columns with a length of zero will be excluded from saving, and if they exist in the FITS file, they will be removed from the file.

Todo:
This method should also update the header. Even easier, this method should save the header into the file using the m_header.save() method. Only this assures coherence between the files !!!! Once this has been implemented (also in the GFitsImage method) we should delete the m_header.save() call in GFitsHDU::save.

Implements GFitsHDU.

Definition at line 1296 of file GFitsTable.cpp.

References __ffcrtb, __ffdcol, __ffdhdu, __ffdrow, __ffgabc, __ffgkey, __ffgncl, __ffgnrw, __ffibin, __fficol, __ffirow, __ffitab, __ffmahd, GFitsTableCol::colnum(), colnum(), exttype(), FPTR, FPTR_COPY, G_DATA_SAVE, get_tform(), get_ttype(), get_tunit(), GFitsHDU::HT_ASCII_TABLE, m_cols, m_columns, GFitsHDU::m_fitsfile, GFitsHDU::m_hdunum, m_rows, m_type, nrows(), GFitsTableCol::print(), GFitsTableCol::save(), gammalib::strip_whitespace(), and update_header().

virtual HDUType GFitsTable::exttype ( void  ) const
pure virtual

Implements GFitsHDU.

Implemented in GFitsAsciiTable, and GFitsBinTable.

Referenced by data_save().

void GFitsTable::free_columns ( void  )
protected

Free column pointers.

De-allocates all column pointers.

Definition at line 870 of file GFitsTable.cpp.

References m_cols, and m_columns.

Referenced by data_open(), free_members(), and remove().

void GFitsTable::free_members ( void  )
protected

Free class members.

Free all class members.

Definition at line 855 of file GFitsTable.cpp.

References free_columns().

Referenced by GFitsBinTable::clear(), GFitsAsciiTable::clear(), data_close(), operator=(), and ~GFitsTable().

char * GFitsTable::get_tform ( const int &  colnum) const
protected

Returns pointer to column format.

Parameters
[in]colnumColumn number (starting from 0).
Exceptions
GException::fits_unknown_tabtypeTable is neither ASCII nor Binary.

This methods allocates memory for the character string that holds the column format. The client has to de-allocate this memory after usage. In case that the column does not exist a NULL pointer is returned.

Definition at line 1713 of file GFitsTable.cpp.

References GFitsTableCol::ascii_format(), colnum(), G_GET_TFORM, GFitsHDU::HT_ASCII_TABLE, GFitsHDU::HT_BIN_TABLE, m_cols, m_columns, m_type, and GFitsTableCol::tform_binary().

Referenced by data_save(), and update_header().

char * GFitsTable::get_ttype ( const int &  colnum) const
protected

Returns pointer to column type.

Parameters
[in]colnumColumn number for which type is to be returned

This methods allocates memory for the character string that holds the column type. The client has to de-allocate this memory after usage. In case that the column does not exist a NULL pointer is returned.

Definition at line 1682 of file GFitsTable.cpp.

References colnum(), m_cols, m_columns, and GFitsTableCol::name().

Referenced by data_save(), and update_header().

char * GFitsTable::get_tunit ( const int &  colnum) const
protected

Returns pointer to column unit.

Parameters
[in]colnumColumn number (starting from 0).

This methods allocates memory for the character string that holds the column unit. The client has to de-allocate this memory after usage. In case that the column does not exist a NULL pointer is returned.

Definition at line 1756 of file GFitsTable.cpp.

References colnum(), m_cols, m_columns, and GFitsTableCol::unit().

Referenced by data_save(), and update_header().

void GFitsTable::init_members ( void  )
protected

Initialise class members.

Definition at line 805 of file GFitsTable.cpp.

References m_cols, m_columns, m_rows, and m_type.

Referenced by GFitsBinTable::clear(), GFitsAsciiTable::clear(), data_close(), GFitsTable(), and operator=().

GFitsTableCol * GFitsTable::insert ( int  colnum,
const GFitsTableCol column 
)

Insert column into the table.

Parameters
[in]colnumColumn number [0,...,ncols()].
[in]columnTable column.
Returns
Pointer to table column that has been appended.
Exceptions
GException::fits_bad_col_lengthThe length of the column is incompatible with the number of rows in the table.

A column will be inserted at position 'colnum' of the table. If the position is beyond the end of the table the column will be appended.

If the table is empty and has 0 rows, the number of rows will be set to the length of the column.

The length of the column to be inserted has to be identical to the number of rows in the table.

Definition at line 407 of file GFitsTable.cpp.

References GFitsTableCol::clone(), GFitsTableCol::colnum(), colnum(), G_INSERT1, m_cols, m_columns, m_rows, ncols(), GFitsTableCol::nrows(), and update_header().

Referenced by append(), and insert().

GFitsTableCol * GFitsTable::insert ( const std::string &  colname,
const GFitsTableCol column 
)

Insert column into the table.

Parameters
[in]colnameColumn name.
[in]columnTable column.
Returns
Pointer to table column that has been appended

Inserts the column at the position given by the specified column name.

Definition at line 489 of file GFitsTable.cpp.

References colnum(), G_INSERT2, and insert().

void GFitsTable::insert_rows ( const int &  row,
const int &  nrows 
)

Insert rows into the table.

Parameters
[in]rowRow at which rows are inserted [0,...,nrows()].
[in]nrowsNumber of rows to be inserted.
Exceptions
GException::fits_invalid_rowSpecified rownum is invalid.

Inserts nrows table rows at the specified row into the table. If the row index is set to the number of existing rows, nrows(), nrows will be appened at the end of the table.

Note that this method will load all table data into memory.

Definition at line 634 of file GFitsTable.cpp.

References G_INSERT_ROWS, GFitsTableCol::insert(), m_cols, m_columns, m_rows, nrows(), and update_header().

Referenced by append_rows().

const int & GFitsTable::ncols ( void  ) const
inline

Return number of columns in table.

Returns
Number of columns in table

Returns the number of columns in table. This method is equivalent to the size() method.

Definition at line 134 of file GFitsTable.hpp.

References m_cols.

Referenced by GVOTable::data_from_fits_table(), GFitsBinTable::init_table_header(), GFitsAsciiTable::init_table_header(), insert(), GVOTable::read(), GCTABackground3D::read(), GArf::read(), GPha::read(), GCTAResponseTable::read_colnames(), GCTAEventList::read_events(), GMWLSpectrum::read_fits(), GSkyMap::read_healpix(), remove(), and set().

GFitsTable & GFitsTable::operator= ( const GFitsTable table)

Assignment operator.

Parameters
[in]tableFITS table.
Returns
FITS table.

Definition at line 162 of file GFitsTable.cpp.

References copy_members(), free_members(), init_members(), and GFitsHDU::operator=().

Referenced by GFitsBinTable::operator=(), and GFitsAsciiTable::operator=().

GFitsTableCol * GFitsTable::operator[] ( const int &  colnum)

Returns pointer to table column.

Parameters
[in]colnumColumn number [0,...,ncols()-1].
Returns
Table column pointer.
Exceptions
GException::fits_no_dataNo data found in table.
GException::out_of_rangeColumn number is out of range.

Definition at line 197 of file GFitsTable.cpp.

References colnum(), G_ACCESS1, m_cols, and m_columns.

const GFitsTableCol * GFitsTable::operator[] ( const int &  colnum) const

Returns pointer to table column (const version)

Parameters
[in]colnumColumn number [0,...,ncols()-1].
Returns
Table column pointer.
Exceptions
GException::fits_no_dataNo data found in table.
GException::out_of_rangeColumn number is out of range.

Definition at line 233 of file GFitsTable.cpp.

References colnum(), G_ACCESS1, m_cols, and m_columns.

GFitsTableCol * GFitsTable::operator[] ( const std::string &  colname)

Returns pointer to table column.

Parameters
[in]colnameColumn name.
Returns
Table column pointer.
Exceptions
GException::fits_no_dataNo data found in table.
GException::fits_column_not_foundColumn name not found.

Definition at line 269 of file GFitsTable.cpp.

References G_ACCESS2, m_columns, and ptr_column().

const GFitsTableCol * GFitsTable::operator[] ( const std::string &  colname) const

Returns pointer to table column (const version)

Parameters
[in]colnameColumn name.
Returns
Table column pointer.
Exceptions
GException::fits_no_dataNo data found in table.
GException::fits_column_not_foundColumn name not found.

Definition at line 300 of file GFitsTable.cpp.

References G_ACCESS2, m_columns, and ptr_column().

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

Print table information.

Parameters
[in]chatterChattiness.
Returns
String containing table information.

Implements GFitsHDU.

Definition at line 732 of file GFitsTable.cpp.

References GFitsHDU::HT_ASCII_TABLE, GFitsHDU::HT_BIN_TABLE, m_cols, m_columns, GFitsHDU::m_header, m_rows, m_type, NORMAL, gammalib::parformat(), GFitsHeader::print(), GFitsHDU::print_hdu(), gammalib::reduce(), SILENT, gammalib::str(), and VERBOSE.

GFitsTableCol * GFitsTable::ptr_column ( const std::string &  colname) const
private

Returns pointer of column with given name.

Parameters
[in]colnameName of column.
Returns
Pointer to table column (NULL if column has not been found).

Returns a pointer to the column with the specified name. If more columns with the same name exist, a pointer to the first of these columns is returned. If no column with the specified name is found, a NULL pointer will be returned.

Definition at line 1855 of file GFitsTable.cpp.

References m_cols, and m_columns.

Referenced by contains(), and operator[]().

void GFitsTable::remove ( const int &  colnum)

Remove column from the table.

Parameters
[in]colnumColumn number [0,...,ncols()-1].
Exceptions
GException::fits_bad_col_lengthThe length of the column is incompatible with the number of rows in the table.

Remove the column at position colnum from the table.

Definition at line 516 of file GFitsTable.cpp.

References GFitsTableCol::colnum(), colnum(), free_columns(), G_REMOVE1, m_cols, m_columns, ncols(), and update_header().

Referenced by GCTABackground3D::read().

void GFitsTable::remove ( const std::string &  colname)

Remove column from the table.

Parameters
[in]colnameColumn name.

Remove the column with name colname from the table.

Definition at line 579 of file GFitsTable.cpp.

References colnum(), and G_REMOVE2.

void GFitsTable::remove_rows ( const int &  row,
const int &  nrows 
)

Remove rows from the table.

Parameters
[in]rowRow from which on rows are removed [0,...,nrows()-1].
[in]nrowsNumber of rows to be removed.
Exceptions
GException::fits_invalid_rowSpecified rownum is invalid.
GException::fits_invalid_nrowsInvalid number of rows specified.

Removes nrows table rows from the specified row on from the table.

Note that this method will load all column data into memory.

Definition at line 677 of file GFitsTable.cpp.

References G_REMOVE_ROWS, m_cols, m_columns, m_rows, nrows(), GFitsTableCol::remove(), and update_header().

GFitsTableCol * GFitsTable::set ( const int &  colnum,
const GFitsTableCol column 
)

Set column.

Parameters
[in]colnumColumn number [0,...,ncols()-1].
[in]columnTable column.
Returns
Pointer to table column that has been set.

Sets the column of a table by making a deep copy of the column provided.

Definition at line 336 of file GFitsTable.cpp.

References GFitsTableCol::clone(), colnum(), G_SET1, m_columns, ncols(), and update_header().

Referenced by set().

GFitsTableCol * GFitsTable::set ( const std::string &  colname,
const GFitsTableCol column 
)

Set column.

Parameters
[in]colnameColumn name.
[in]columnTable column.
Returns
Pointer to table column that has been set.

Sets the column of a table by making a deep copy of the column provided.

Definition at line 370 of file GFitsTable.cpp.

References colnum(), G_SET2, and set().

void GFitsTable::update_header ( void  )
protected

Update header after row or column manipulations.

Updates the header after row or column manipulations so that the header is kept up-to-date with the current table structure.

The following keywords are updated:

  • TFIELDS
  • NAXIS1
  • NAXIS2
  • TTYPEi
  • TFORMi
  • TUNITi
  • TZEROi (only for unsigned integer columns)
  • TSCALi (only for unsigned integer columns)
  • TDIMi (only for columns with dimensions)

This method should be called after adding or removing table rows or columns.

Definition at line 908 of file GFitsTable.cpp.

References __TUINT, __TULONG, __TUSHORT, abs(), GFitsHDU::card(), GFitsHeader::contains(), GFitsTableCol::dim(), get_tform(), get_ttype(), get_tunit(), GFitsHDU::header(), m_cols, m_columns, m_rows, GFitsTableCol::number(), GFitsHeader::remove(), gammalib::replace_segment(), gammalib::str(), and GFitsTableCol::width().

Referenced by data_save(), insert(), insert_rows(), remove(), remove_rows(), and set().

Member Data Documentation

int GFitsTable::m_rows
protected

Number of rows in table.

Definition at line 99 of file GFitsTable.hpp.

Referenced by copy_members(), data_open(), data_save(), GFitsTable(), init_members(), insert(), insert_rows(), nrows(), print(), remove_rows(), and update_header().

int GFitsTable::m_type
protected

Table type (1=ASCII, 2=Binary)

Definition at line 98 of file GFitsTable.hpp.

Referenced by copy_members(), data_save(), get_tform(), GFitsBinTable::init_members(), GFitsAsciiTable::init_members(), init_members(), and print().


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