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

FITS table string column. More...

#include <GFitsTableStringCol.hpp>

Inheritance diagram for GFitsTableStringCol:
GFitsTableCol GBase

Public Member Functions

 GFitsTableStringCol (void)
 Constructor. More...
 
 GFitsTableStringCol (const std::string &name, const int &nrows, const int &width, const int &size=1)
 Constructor. More...
 
 GFitsTableStringCol (const GFitsTableStringCol &column)
 Copy constructor. More...
 
virtual ~GFitsTableStringCol (void)
 Destructor. More...
 
GFitsTableStringColoperator= (const GFitsTableStringCol &column)
 Assignment operator. More...
 
std::string & operator() (const int &row, const int &inx=0)
 Column data access operator. More...
 
const std::string & operator() (const int &row, const int &inx=0) const
 Column data access operator (const variant) More...
 
virtual void clear (void)
 Clear instance. More...
 
virtual GFitsTableStringColclone (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...
 
std::string * data (void)
 Returns pointer to column data. More...
 
char * nulval (void)
 Returns pointer to nul value. More...
 
void nulval (const std::string &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...
 
GFitsTableColoperator= (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 GFitsTableStringCol &column)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
void alloc_nulval (const std::string &value)
 Allocate nul value. More...
 
void alloc_buffer (void) const
 Allocate CFITSIO transfer buffer. More...
 
void free_buffer (void) const
 Free CFITSIO transfer buffer. 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 save (void)
 Save table column into FITS file. More...
 

Private Attributes

std::string * m_data
 Data area. More...
 
char ** m_buffer
 Data area for CFITSIO transfer. More...
 
char * m_nulval
 NULL string. 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 load_column (void)
 Load table column from 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 (void)
 Save table column into 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...
 

Detailed Description

FITS table string column.

This class implements a FITS table string column.

Definition at line 42 of file GFitsTableStringCol.hpp.

Constructor & Destructor Documentation

GFitsTableStringCol::GFitsTableStringCol ( void  )

Constructor.

Definition at line 58 of file GFitsTableStringCol.cpp.

References init_members().

Referenced by clone().

GFitsTableStringCol::GFitsTableStringCol ( const std::string &  name,
const int &  nrows,
const int &  width,
const int &  size = 1 
)

Constructor.

Parameters
[in]nameName of column.
[in]nrowsNumber of rows in column.
[in]widthLength of individual string.
[in]sizeNumber of strings in each column.

Definition at line 76 of file GFitsTableStringCol.cpp.

References init_members().

GFitsTableStringCol::GFitsTableStringCol ( const GFitsTableStringCol column)

Copy constructor.

Parameters
[in]columnTable column.

Definition at line 95 of file GFitsTableStringCol.cpp.

References copy_members(), and init_members().

GFitsTableStringCol::~GFitsTableStringCol ( void  )
virtual

Destructor.

Definition at line 112 of file GFitsTableStringCol.cpp.

References free_members().

Member Function Documentation

void GFitsTableStringCol::alloc_buffer ( void  ) const
private

Allocate CFITSIO transfer buffer.

The CFITSIO transfer buffer allows transparent conversion from the CFITSIO storage format to a vector of strings.

Definition at line 850 of file GFitsTableStringCol.cpp.

References m_buffer, GFitsTableCol::m_size, and GFitsTableCol::m_width.

Referenced by alloc_data(), and save().

void GFitsTableStringCol::alloc_data ( void  )
privatevirtual

Allocates column data.

Implements GFitsTableCol.

Definition at line 658 of file GFitsTableStringCol.cpp.

References alloc_buffer(), free_buffer(), m_data, and GFitsTableCol::m_size.

Referenced by insert().

void GFitsTableStringCol::alloc_nulval ( const std::string &  value)
private

Allocate nul value.

Parameters
[in]valueNul value string.

Definition at line 805 of file GFitsTableStringCol.cpp.

References m_nulval, and GFitsTableCol::m_width.

Referenced by init_members(), and nulval().

std::string GFitsTableStringCol::ascii_format ( void  ) const
privatevirtual

Returns format string of ASCII table.

Implements GFitsTableCol.

Definition at line 639 of file GFitsTableStringCol.cpp.

References GFitsTableCol::m_width, and gammalib::str().

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

Return class name.

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

Implements GFitsTableCol.

Definition at line 108 of file GFitsTableStringCol.hpp.

void GFitsTableStringCol::clear ( void  )
virtual

Clear instance.

This method properly resets the object to an initial state.

Implements GFitsTableCol.

Definition at line 205 of file GFitsTableStringCol.cpp.

References free_members(), GFitsTableCol::free_members(), init_members(), and GFitsTableCol::init_members().

GFitsTableStringCol * GFitsTableStringCol::clone ( void  ) const
virtual

Clone column.

Implements GFitsTableCol.

Definition at line 223 of file GFitsTableStringCol.cpp.

References GFitsTableStringCol().

void GFitsTableStringCol::copy_members ( const GFitsTableStringCol column)
private

Copy class members.

Parameters
[in]columnColumn.

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 531 of file GFitsTableStringCol.cpp.

References fetch_data(), is_loaded(), m_data, m_nulval, GFitsTableCol::m_rowstart, GFitsTableCol::m_size, GFitsTableCol::m_type, GFitsTableCol::m_varlen, GFitsTableCol::m_width, and release_data().

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

std::string * GFitsTableStringCol::data ( void  )
inline

Returns pointer to column data.

Returns
Pointer to column data.

Definition at line 132 of file GFitsTableStringCol.hpp.

References m_data.

void GFitsTableStringCol::fetch_data ( void  ) const
privatevirtual

Fetch column data.

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 set to 0.

Refer to GFitsTableCol::load_column for more information.

Implements GFitsTableCol.

Definition at line 689 of file GFitsTableStringCol.cpp.

References free_buffer(), GFitsTableCol::load_column(), m_buffer, m_data, and GFitsTableCol::m_size.

Referenced by copy_members(), insert(), integer(), operator()(), real(), remove(), resize_data(), and string().

void GFitsTableStringCol::free_buffer ( void  ) const
private

Free CFITSIO transfer buffer.

Release memory that has been allocated for the CFITSIO transfer buffer.

Definition at line 879 of file GFitsTableStringCol.cpp.

References m_buffer, and GFitsTableCol::m_size.

Referenced by alloc_data(), fetch_data(), free_members(), and save().

void GFitsTableStringCol::free_members ( void  )
private

Delete class members.

Definition at line 576 of file GFitsTableStringCol.cpp.

References free_buffer(), m_data, m_nulval, and GFitsTableCol::m_size.

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

void GFitsTableStringCol::init_data ( void  )
privatevirtual

Initialise column data.

Implements GFitsTableCol.

Definition at line 830 of file GFitsTableStringCol.cpp.

References m_data, and GFitsTableCol::m_size.

Referenced by insert().

void GFitsTableStringCol::init_members ( void  )
private

Initialise class members.

Definition at line 505 of file GFitsTableStringCol.cpp.

References __TSTRING, alloc_nulval(), m_buffer, m_data, m_nulval, and GFitsTableCol::m_type.

Referenced by clear(), GFitsTableStringCol(), and operator=().

void GFitsTableStringCol::insert ( const int &  row,
const int &  nrows 
)
virtual

Insert rows in column.

Parameters
[in]rowRow after which rows should be inserted (0=first row).
[in]nrowsNumber of rows to be inserted.
Exceptions
GException::out_of_rangeSpecified row is invalid.

Inserts rows into a FITS table. This implies that all columns will be loaded into memory.

Implements GFitsTableCol.

Definition at line 301 of file GFitsTableStringCol.cpp.

References alloc_data(), fetch_data(), G_INSERT, init_data(), m_data, GFitsTableCol::m_length, GFitsTableCol::m_number, GFitsTableCol::m_size, and GFitsTableCol::nrows().

int GFitsTableStringCol::integer ( const int &  row,
const int &  inx = 0 
) const
virtual

Get integer value.

Parameters
[in]rowTable row.
[in]inxTable column vector index.

Returns value of specified row and vector index as integer.

Implements GFitsTableCol.

Definition at line 276 of file GFitsTableStringCol.cpp.

References fetch_data(), m_data, GFitsTableCol::offset(), and gammalib::toint().

bool GFitsTableStringCol::is_loaded ( void  ) const
inlinevirtual

Checks if column has been loaded.

Returns
True if column has been loaded, false otherwise

Implements GFitsTableCol.

Definition at line 120 of file GFitsTableStringCol.hpp.

References m_data.

Referenced by copy_members().

char * GFitsTableStringCol::nulval ( void  )
inline

Returns pointer to nul value.

Returns
Pointer to nul value.

Definition at line 144 of file GFitsTableStringCol.hpp.

References m_nulval.

void GFitsTableStringCol::nulval ( const std::string &  value)

Set nul value.

Parameters
[in]valueNul value string.

Allows the specification of the FITS table nul string. The default nul strings is an empty string which results in NULL entries in case that no data has been written.

Todo:
To correctly reflect the nul value in the data, the column should be reloaded. However, the column may have been changed, so in principle saving is needed. However, we may not want to store the data, hence saving is also not desired. We thus have to develop a method to update the column information for a new nul value in place ...

Definition at line 480 of file GFitsTableStringCol.cpp.

References alloc_nulval().

std::string & GFitsTableStringCol::operator() ( const int &  row,
const int &  inx = 0 
)

Column data access operator.

Parameters
[in]rowRow of column to access.
[in]inxVector index in column row to access.

Provides access to data in a column.

Definition at line 166 of file GFitsTableStringCol.cpp.

References fetch_data(), m_data, and GFitsTableCol::offset().

const std::string & GFitsTableStringCol::operator() ( const int &  row,
const int &  inx = 0 
) const

Column data access operator (const variant)

Parameters
[in]rowRow of column to access.
[in]inxVector index in column row to access.

Provides access to data in a column.

Definition at line 184 of file GFitsTableStringCol.cpp.

References fetch_data(), m_data, and GFitsTableCol::offset().

GFitsTableStringCol & GFitsTableStringCol::operator= ( const GFitsTableStringCol column)

Assignment operator.

Parameters
[in]columnTable column.
Returns
Table column.

Definition at line 134 of file GFitsTableStringCol.cpp.

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

void * GFitsTableStringCol::ptr_data ( const int &  index = 0)
inlineprivatevirtual

Returns void pointer to column data.

Returns
Void pointer to column data.

Implements GFitsTableCol.

Definition at line 156 of file GFitsTableStringCol.hpp.

References m_buffer.

void * GFitsTableStringCol::ptr_nulval ( void  )
inlineprivatevirtual

Returns void pointer to nul value.

Returns
Void pointer to nul value.

Implements GFitsTableCol.

Definition at line 168 of file GFitsTableStringCol.hpp.

References m_nulval.

double GFitsTableStringCol::real ( const int &  row,
const int &  inx = 0 
) const
virtual

Get double precision value.

Parameters
[in]rowTable row.
[in]inxTable column vector index.

Returns value of specified row and vector index as double precision.

Implements GFitsTableCol.

Definition at line 255 of file GFitsTableStringCol.cpp.

References fetch_data(), m_data, GFitsTableCol::offset(), and gammalib::todouble().

void GFitsTableStringCol::release_data ( void  )
privatevirtual

Release column data.

Implements GFitsTableCol.

Definition at line 786 of file GFitsTableStringCol.cpp.

References m_data, and GFitsTableCol::m_size.

Referenced by copy_members(), and resize_data().

void GFitsTableStringCol::remove ( const int &  row,
const int &  nrows 
)
virtual

Remove rows from column.

Parameters
[in]rowRow after which rows should be removed (0=first row).
[in]nrowsNumber of rows to be removed.
Exceptions
GException::out_of_rangeSpecified 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 387 of file GFitsTableStringCol.cpp.

References fetch_data(), G_REMOVE, m_data, GFitsTableCol::m_length, GFitsTableCol::m_number, GFitsTableCol::m_size, and GFitsTableCol::nrows().

void GFitsTableStringCol::resize_data ( const int &  index,
const int &  number 
)
privatevirtual

Resize column data.

Parameters
[in]indexStart index.
[in]numberNumber 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 729 of file GFitsTableStringCol.cpp.

References fetch_data(), gammalib::left(), m_data, GFitsTableCol::m_size, GFitsTableCol::number(), and release_data().

void GFitsTableStringCol::save ( void  )
privatevirtual

Save table column into FITS file.

The data is transferred from the internal string vector into a character transfer buffer that can be handled by the cfitsio routines.

The table column is only saved if it is linked to a FITS file and if the data are indeed present in the class instance. This avoids saving of data that have not been modified.

Refer to GFitsTableCol::save_column() for more information.

Reimplemented from GFitsTableCol.

Definition at line 609 of file GFitsTableStringCol.cpp.

References alloc_buffer(), free_buffer(), m_buffer, m_data, GFitsTableCol::m_size, GFitsTableCol::m_width, and GFitsTableCol::save_column().

std::string GFitsTableStringCol::string ( const int &  row,
const int &  inx = 0 
) const
virtual

Get string value.

Parameters
[in]rowTable row.
[in]inxTable column vector index.

Returns value of specified row and vector index as string.

Implements GFitsTableCol.

Definition at line 237 of file GFitsTableStringCol.cpp.

References fetch_data(), m_data, and GFitsTableCol::offset().

Member Data Documentation

char** GFitsTableStringCol::m_buffer
mutableprivate

Data area for CFITSIO transfer.

Definition at line 97 of file GFitsTableStringCol.hpp.

Referenced by alloc_buffer(), fetch_data(), free_buffer(), init_members(), ptr_data(), and save().

std::string* GFitsTableStringCol::m_data
private
char* GFitsTableStringCol::m_nulval
private

NULL string.

Definition at line 98 of file GFitsTableStringCol.hpp.

Referenced by alloc_nulval(), copy_members(), free_members(), init_members(), nulval(), and ptr_nulval().


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