GammaLib
2.1.0.dev
|
FITS table Bit column. More...
#include <GFitsTableBitCol.hpp>
Public Member Functions | |
GFitsTableBitCol (void) | |
Constructor. More... | |
GFitsTableBitCol (const std::string &name, const int &nrows, const int &size=1) | |
Constructor. More... | |
GFitsTableBitCol (const GFitsTableBitCol &column) | |
Copy constructor. More... | |
virtual | ~GFitsTableBitCol (void) |
Destructor. More... | |
GFitsTableBitCol & | operator= (const GFitsTableBitCol &column) |
Assignment operator. More... | |
bool & | operator() (const int &row, const int &inx=0) |
Column data access operator. More... | |
const bool & | operator() (const int &row, const int &inx=0) const |
Column data access operator (const variant) More... | |
virtual void | clear (void) |
Clear instance. More... | |
virtual GFitsTableBitCol * | clone (void) const |
Clone column. More... | |
virtual std::string | classname (void) const |
Return class name. More... | |
virtual std::string | string (const int &row, const int &col=0) const |
Get string value. More... | |
virtual double | real (const int &row, const int &col=0) const |
Get double precision value. More... | |
virtual int | integer (const int &row, const int &col=0) const |
Get integer value. More... | |
virtual void | insert (const int &row, const int &nrows) |
Insert rows in column. More... | |
virtual void | remove (const int &row, const int &nrows) |
Remove rows from column. More... | |
virtual bool | is_loaded (void) const |
Checks if column has been loaded. More... | |
unsigned char * | data (void) |
Returns pointer to column data. More... | |
unsigned char * | nulval (void) |
Returns pointer to nul value. More... | |
void | nulval (const unsigned char *value) |
Set nul value. More... | |
Public Member Functions inherited from GFitsTableCol | |
GFitsTableCol (void) | |
Void constructor. More... | |
GFitsTableCol (const std::string &name, const int &nrows, const int &number, const int &width) | |
Column constructor. More... | |
GFitsTableCol (const GFitsTableCol &column) | |
Copy constructor. More... | |
virtual | ~GFitsTableCol (void) |
Destructor. More... | |
GFitsTableCol & | operator= (const GFitsTableCol &column) |
Assignment operator. More... | |
void | name (const std::string &name) |
Set column name. More... | |
const std::string & | name (void) const |
Returns column name. More... | |
void | unit (const std::string &unit) |
Set column unit. More... | |
const std::string & | unit (void) const |
Returns column unit. More... | |
void | dim (const std::vector< int > &dim) |
Set column dimension. More... | |
const std::vector< int > & | dim (void) const |
Returns column dimension. More... | |
void | colnum (const int &colnum) |
Set column number. More... | |
const int & | colnum (void) const |
Returns column number in FITS file (starting from 1) More... | |
void | type (const int &type) |
Set type code. More... | |
const int & | type (void) const |
Returns CFITSIO column type. More... | |
void | repeat (const int &repeat) |
Set repeat value. More... | |
const int & | repeat (void) const |
Returns column repeat value (only used for binary tables) More... | |
void | width (const int &width) |
Set width in Bytes of one column element. More... | |
const int & | width (void) const |
Return width in Bytes of one column element. More... | |
void | number (const int &number) |
Set number of elements in column. More... | |
const int & | number (void) const |
Returns number of elements in column. More... | |
void | elements (const int &row, const int &elements) |
Set number of column elements for specific row. More... | |
int | elements (const int &row) const |
Returns number of elements in column for specific row. More... | |
void | nrows (const int &nrows) |
Set number of rows in column. More... | |
const int & | nrows (void) const |
Returns number of rows in column. More... | |
void | is_variable (const bool &variable) |
Set variable-length flag. More... | |
const bool & | is_variable (void) const |
Signals if column is of variable length. More... | |
void | anynul (const int &anynul) |
Set number of NULLs encountered. More... | |
const int & | anynul (void) const |
Return number of NULLs encountered. More... | |
void | tscale (const double &tscale) |
Set TSCALE value. More... | |
const double & | tscale (void) const |
Return TSCALE value. More... | |
std::string | tform_binary (void) const |
Returns TFORM code for binary table column. More... | |
std::string | print (const GChatter &chatter=NORMAL) const |
Print column 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 GFitsTableBitCol &column) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
void | alloc_nulval (const unsigned char *value) |
Allocates null value. More... | |
void | get_bit (const int &row, const int &inx) |
Get Bit for boolean access. More... | |
void | set_pending (void) |
Set pending Bit. More... | |
virtual void | alloc_data (void) |
Allocates column data. More... | |
virtual void | init_data (void) |
Initialise column data. More... | |
virtual void | fetch_data (void) const |
Fetch column data. More... | |
virtual void | resize_data (const int &index, const int &number) |
Resize column data. More... | |
virtual void | release_data (void) |
Release column data. More... | |
virtual void * | ptr_data (const int &index=0) |
Returns void pointer to column data. More... | |
virtual void * | ptr_nulval (void) |
Returns void pointer to nul value. More... | |
virtual std::string | ascii_format (void) const |
Returns format string of ASCII table. More... | |
virtual void | load_column (void) |
Load table column from FITS file. More... | |
virtual void | save_column (void) |
Save table column into FITS file. More... | |
Private Attributes | |
int | m_bits |
Total number of Bits in column. More... | |
int | m_bytes_per_row |
Number of Bytes per row. More... | |
int | m_bits_per_row |
Number of Bits per row. More... | |
unsigned char * | m_data |
Data area. More... | |
unsigned char * | m_nulval |
NULL value. More... | |
bool | m_bit_pending |
Bit value has to be written back. More... | |
bool | m_bit_value |
Actual bit to be accessed. More... | |
int | m_bit_byte |
Row of actual bit to be accessed. More... | |
int | m_bit_mask |
Index of actual bit to be accessed. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from GFitsTableCol | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GFitsTableCol &column) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
void | connect (void *vptr) |
Connect table column to FITS file. More... | |
virtual void | save (void) |
Save table column into FITS file. More... | |
virtual void | load_column_fixed (void) |
Load fixed-length column from FITS file. More... | |
virtual void | load_column_variable (void) |
Load variable-length column from FITS file. More... | |
virtual void | save_column_fixed (void) |
Save table column into FITS file. More... | |
virtual void | save_column_variable (void) |
Save table column into FITS file. More... | |
virtual int | offset (const int &row, const int &inx) const |
Compute offset of column element in memory. More... | |
Protected Attributes inherited from GFitsTableCol | |
std::string | m_name |
Column name. More... | |
std::string | m_unit |
Column unit. More... | |
std::vector< int > | m_dim |
Column dimension. More... | |
int | m_colnum |
Column number (starting from 1). This parameter is used to signal if a table column corresponds to a FITS file column. If it is set to 0 there is no correspondence. More... | |
int | m_type |
Column type. More... | |
int | m_repeat |
Repeat value of column. More... | |
int | m_width |
Width in Bytes of single column element. More... | |
int | m_number |
Number of elements in column. More... | |
int | m_length |
Length of column (number of rows) More... | |
bool | m_variable |
Signals if column is variable length. More... | |
int | m_varlen |
Maximum number of elements in variable-length. More... | |
std::vector< int > | m_rowstart |
Start index of each row. More... | |
int | m_size |
Size of allocated data area (0 if not loaded) More... | |
int | m_anynul |
Number of NULLs encountered. More... | |
void * | m_fitsfile |
FITS file pointer associated with column. More... | |
double | m_tscale |
Optional scaling factor (1 = no scaling) More... | |
FITS table Bit column.
This class implements a FITS table Bit column. Bits are stored internally in an array of type char and is transferred to the file in junks of 8 Bits (using the CFITSIO type TBYTE).
Definition at line 44 of file GFitsTableBitCol.hpp.
GFitsTableBitCol::GFitsTableBitCol | ( | void | ) |
Constructor.
Definition at line 61 of file GFitsTableBitCol.cpp.
References init_members().
Referenced by clone().
GFitsTableBitCol::GFitsTableBitCol | ( | const std::string & | name, |
const int & | nrows, | ||
const int & | size = 1 |
||
) |
Constructor.
[in] | name | Name of column. |
[in] | nrows | Number of rows in column. |
[in] | size | Vector size of column. |
Definition at line 78 of file GFitsTableBitCol.cpp.
References init_members().
GFitsTableBitCol::GFitsTableBitCol | ( | const GFitsTableBitCol & | column | ) |
Copy constructor.
[in] | column | Table column. |
Definition at line 96 of file GFitsTableBitCol.cpp.
References copy_members(), and init_members().
|
virtual |
|
privatevirtual |
Allocates column data.
Implements GFitsTableCol.
Definition at line 680 of file GFitsTableBitCol.cpp.
References m_data, and GFitsTableCol::m_size.
Referenced by copy_members(), insert(), and load_column().
|
private |
Allocates null value.
Definition at line 772 of file GFitsTableBitCol.cpp.
References m_nulval.
Referenced by copy_members(), and nulval().
|
privatevirtual |
Returns format string of ASCII table.
Implements GFitsTableCol.
Definition at line 661 of file GFitsTableBitCol.cpp.
References GFitsTableCol::m_width, and gammalib::str().
|
inlinevirtual |
Return class name.
Implements GFitsTableCol.
Definition at line 119 of file GFitsTableBitCol.hpp.
|
virtual |
Clear instance.
This method properly resets the object to an initial state.
Implements GFitsTableCol.
Definition at line 227 of file GFitsTableBitCol.cpp.
References free_members(), GFitsTableCol::free_members(), init_members(), and GFitsTableCol::init_members().
|
virtual |
Clone column.
Implements GFitsTableCol.
Definition at line 245 of file GFitsTableBitCol.cpp.
References GFitsTableBitCol().
|
private |
Copy class members.
[in] | column | Column. |
Sets the content of the vector column by copying from another column. If the code is compiled with the small memory option, and if the source column has not yet been loaded, then we only load the column temporarily for copying purposes and release it again once copying is finished.
Definition at line 584 of file GFitsTableBitCol.cpp.
References alloc_data(), alloc_nulval(), fetch_data(), is_loaded(), m_bit_byte, m_bit_mask, m_bit_pending, m_bit_value, m_bits, m_bits_per_row, m_bytes_per_row, m_data, m_nulval, GFitsTableCol::m_rowstart, GFitsTableCol::m_size, GFitsTableCol::m_type, GFitsTableCol::m_varlen, and release_data().
Referenced by GFitsTableBitCol(), and operator=().
|
inline |
Returns pointer to column data.
Definition at line 143 of file GFitsTableBitCol.hpp.
References m_data.
|
privatevirtual |
Fetch column data.
This method fetches column data when needed. It is declared const, so that const data access methods can be implemented.
If a FITS file is attached to the column the data are loaded into memory from the FITS file. If no FITS file is attached, memory is allocated to hold the column data and all cells are initialised.
This method calls GFitsTableCol::load_column to do the job.
Implements GFitsTableCol.
Definition at line 720 of file GFitsTableBitCol.cpp.
References load_column().
Referenced by copy_members(), insert(), operator()(), and remove().
|
private |
Delete class members.
Definition at line 630 of file GFitsTableBitCol.cpp.
References m_data, m_nulval, and GFitsTableCol::m_size.
Referenced by clear(), operator=(), and ~GFitsTableBitCol().
|
private |
Get Bit for boolean access.
[in] | row | Row of column. |
[in] | inx | Vector index in column row. |
GException::out_of_range | Table row out of valid range. Table vector index out of valid range. |
Set the Bit for boolean data access. Note that this method assumes that the data have already been loaded.
Definition at line 926 of file GFitsTableBitCol.cpp.
References G_GET_BIT, m_bit_byte, m_bit_mask, m_bit_value, m_bytes_per_row, m_data, GFitsTableCol::m_length, and GFitsTableCol::m_number.
Referenced by operator()().
|
privatevirtual |
Initialise column data.
Implements GFitsTableCol.
Definition at line 794 of file GFitsTableBitCol.cpp.
References m_data, and GFitsTableCol::m_size.
Referenced by insert(), and load_column().
|
private |
Initialise class members.
Definition at line 545 of file GFitsTableBitCol.cpp.
References __TBIT, m_bit_byte, m_bit_mask, m_bit_pending, m_bit_value, m_bits, m_bits_per_row, m_bytes_per_row, m_data, m_nulval, and GFitsTableCol::m_type.
Referenced by clear(), GFitsTableBitCol(), and operator=().
|
virtual |
Insert rows in column.
[in] | row | Row after which rows should be inserted (0=first row). |
[in] | nrows | Number of rows to be inserted. |
GException::out_of_range | Specified row is invalid. |
Inserts rows into a FITS table. This implies that the column will be loaded into memory.
Implements GFitsTableCol.
Definition at line 326 of file GFitsTableBitCol.cpp.
References alloc_data(), fetch_data(), G_INSERT, init_data(), m_bits, m_bits_per_row, m_bytes_per_row, m_data, GFitsTableCol::m_length, GFitsTableCol::m_number, GFitsTableCol::m_size, GFitsTableCol::nrows(), and set_pending().
|
virtual |
Get integer value.
[in] | row | Table row. |
[in] | inx | Table column vector index. |
Returns value of specified row and vector index as integer.
Implements GFitsTableCol.
Definition at line 301 of file GFitsTableBitCol.cpp.
|
inlinevirtual |
Checks if column has been loaded.
Implements GFitsTableCol.
Definition at line 131 of file GFitsTableBitCol.hpp.
References m_data.
Referenced by copy_members().
|
privatevirtual |
Load table column from FITS file.
GException::fits_hdu_not_found | Specified HDU not found in FITS file. |
GException::fits_error | An error occured while loading column data from FITS file. |
Load Bit (vector) column into memory by reading 8 Bits at once.
Reimplemented from GFitsTableCol.
Definition at line 818 of file GFitsTableBitCol.cpp.
References __ffgcv, __ffmahd, __TBYTE, alloc_data(), FPTR, G_LOAD_COLUMN, init_data(), GFitsTableCol::m_anynul, m_bits, m_bits_per_row, m_bytes_per_row, GFitsTableCol::m_colnum, m_data, GFitsTableCol::m_fitsfile, GFitsTableCol::m_length, GFitsTableCol::m_name, m_nulval, GFitsTableCol::m_number, GFitsTableCol::m_size, and gammalib::str().
Referenced by fetch_data().
|
inline |
Returns pointer to nul value.
Definition at line 155 of file GFitsTableBitCol.hpp.
References m_nulval.
void GFitsTableBitCol::nulval | ( | const unsigned char * | value | ) |
Set nul value.
[in] | value | Nul value. |
Definition at line 520 of file GFitsTableBitCol.cpp.
References alloc_nulval().
bool & GFitsTableBitCol::operator() | ( | const int & | row, |
const int & | inx = 0 |
||
) |
Column data access operator.
[in] | row | Row of column to access. |
[in] | inx | Vector index in column row to access. |
Provides access to data in a column.
Definition at line 167 of file GFitsTableBitCol.cpp.
References fetch_data(), get_bit(), m_bit_pending, m_bit_value, m_data, and set_pending().
const bool & GFitsTableBitCol::operator() | ( | const int & | row, |
const int & | inx = 0 |
||
) | const |
Column data access operator (const variant)
[in] | row | Row of column to access. |
[in] | inx | Vector index in column row to access |
Provides access to data in a column.
Definition at line 197 of file GFitsTableBitCol.cpp.
References fetch_data(), get_bit(), m_bit_value, m_data, and set_pending().
GFitsTableBitCol & GFitsTableBitCol::operator= | ( | const GFitsTableBitCol & | column | ) |
Assignment operator.
[in] | column | Table column. |
Definition at line 135 of file GFitsTableBitCol.cpp.
References copy_members(), free_members(), init_members(), and GFitsTableCol::operator=().
|
inlineprivatevirtual |
Returns void pointer to column data.
Implements GFitsTableCol.
Definition at line 167 of file GFitsTableBitCol.hpp.
References m_data.
|
inlineprivatevirtual |
Returns void pointer to nul value.
Implements GFitsTableCol.
Definition at line 179 of file GFitsTableBitCol.hpp.
References m_nulval.
|
virtual |
Get double precision value.
[in] | row | Table row. |
[in] | inx | Table column vector index. |
Returns value of specified row and vector index as double precision.
Implements GFitsTableCol.
Definition at line 280 of file GFitsTableBitCol.cpp.
|
privatevirtual |
Release column data.
Implements GFitsTableCol.
Definition at line 755 of file GFitsTableBitCol.cpp.
References m_data, and GFitsTableCol::m_size.
Referenced by copy_members().
|
virtual |
Remove rows from column.
[in] | row | Row after which rows should be removed (0=first row). |
[in] | nrows | Number of rows to be removed. |
GException::out_of_range | Specified row is invalid. Invalid number of rows specified. |
This method removes rows from a FITS table. This implies that the column will be loaded into memory.
Implements GFitsTableCol.
Definition at line 421 of file GFitsTableBitCol.cpp.
References fetch_data(), G_REMOVE, m_bits, m_bits_per_row, m_bytes_per_row, m_data, GFitsTableCol::m_length, GFitsTableCol::m_number, GFitsTableCol::m_size, GFitsTableCol::nrows(), and set_pending().
|
privatevirtual |
Resize column data.
[in] | index | Start index. |
[in] | number | Number of elements to add/remove. |
Adds or removes elements from specified index on. Adding is done if number
is a positive number, removing if number
is negative. Note that the method does not change the validity of the arguments. This needs to be done by the client.
Implements GFitsTableCol.
Definition at line 743 of file GFitsTableBitCol.cpp.
|
privatevirtual |
Save table column into FITS file.
GException::fits_hdu_not_found | Specified HDU not found in FITS file. |
GException::fits_error | Error occured during writing of the column data. |
Save Bit (vector) column into FITS file by writing 8 Bits at once.
Reimplemented from GFitsTableCol.
Definition at line 879 of file GFitsTableBitCol.cpp.
References __ffmahd, __ffpcn, __TBYTE, FPTR, G_SAVE_COLUMN, GFitsTableCol::m_colnum, m_data, GFitsTableCol::m_fitsfile, m_nulval, GFitsTableCol::m_size, set_pending(), and gammalib::str().
|
private |
Set pending Bit.
Write the pending Bit into the data. Note that this method assumes that the data have already been loaded.
Definition at line 962 of file GFitsTableBitCol.cpp.
References m_bit_byte, m_bit_mask, m_bit_pending, m_bit_value, and m_data.
Referenced by insert(), operator()(), remove(), and save_column().
|
virtual |
Get string value.
[in] | row | Table row. |
[in] | inx | Table column vector index. |
Returns value of specified row and vector index as string.
Implements GFitsTableCol.
Definition at line 259 of file GFitsTableBitCol.cpp.
|
private |
Row of actual bit to be accessed.
Definition at line 108 of file GFitsTableBitCol.hpp.
Referenced by copy_members(), get_bit(), init_members(), and set_pending().
|
private |
Index of actual bit to be accessed.
Definition at line 109 of file GFitsTableBitCol.hpp.
Referenced by copy_members(), get_bit(), init_members(), and set_pending().
|
private |
Bit value has to be written back.
Definition at line 106 of file GFitsTableBitCol.hpp.
Referenced by copy_members(), init_members(), operator()(), and set_pending().
|
private |
Actual bit to be accessed.
Definition at line 107 of file GFitsTableBitCol.hpp.
Referenced by copy_members(), get_bit(), init_members(), operator()(), and set_pending().
|
private |
Total number of Bits in column.
Definition at line 99 of file GFitsTableBitCol.hpp.
Referenced by copy_members(), init_members(), insert(), load_column(), and remove().
|
private |
Number of Bits per row.
Definition at line 101 of file GFitsTableBitCol.hpp.
Referenced by copy_members(), init_members(), insert(), load_column(), and remove().
|
private |
Number of Bytes per row.
Definition at line 100 of file GFitsTableBitCol.hpp.
Referenced by copy_members(), get_bit(), init_members(), insert(), load_column(), and remove().
|
private |
Data area.
Definition at line 102 of file GFitsTableBitCol.hpp.
Referenced by alloc_data(), copy_members(), data(), free_members(), get_bit(), init_data(), init_members(), insert(), is_loaded(), load_column(), operator()(), ptr_data(), release_data(), remove(), save_column(), and set_pending().
|
private |
NULL value.
Definition at line 103 of file GFitsTableBitCol.hpp.
Referenced by alloc_nulval(), copy_members(), free_members(), init_members(), load_column(), nulval(), ptr_nulval(), and save_column().