GammaLib 2.0.0
Loading...
Searching...
No Matches
GFitsTableStringCol.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GFitsTableStringCol.hpp - FITS table string column class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2008-2017 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- *
6 * *
7 * This program is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19 * *
20 ***************************************************************************/
21/**
22 * @file GFitsTableStringCol.hpp
23 * @brief FITS table string column class interface definition
24 * @author Juergen Knoedlseder
25 */
26
27#ifndef GFITSTABLESTRINGCOL_HPP
28#define GFITSTABLESTRINGCOL_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include <string>
32#include "GFitsTableCol.hpp"
33
34
35/***********************************************************************//**
36 * @class GFitsTableStringCol
37 *
38 * @brief FITS table string column
39 *
40 * This class implements a FITS table string column.
41 ***************************************************************************/
43
44public:
45 // Constructors and destructors
47 GFitsTableStringCol(const std::string& name, const int& nrows,
48 const int& width, const int& size = 1);
50 virtual ~GFitsTableStringCol(void);
51
52 // Operators
54 std::string& operator()(const int& row, const int& inx = 0);
55 const std::string& operator()(const int& row, const int& inx = 0) const;
56
57 // Implement virtual methods
58 virtual void clear(void);
59 virtual GFitsTableStringCol* clone(void) const;
60 virtual std::string classname(void) const;
61 virtual std::string string(const int& row, const int& col = 0) const;
62 virtual double real(const int& row, const int& col = 0) const;
63 virtual int integer(const int& row, const int& col = 0) const;
64 virtual void insert(const int& row, const int& nrows);
65 virtual void remove(const int& row, const int& nrows);
66 virtual bool is_loaded(void) const;
67
68 // Other methods
69 std::string* data(void);
70 char* nulval(void);
71 void nulval(const std::string& value);
72
73private:
74 // Private methods
75 void init_members(void);
76 void copy_members(const GFitsTableStringCol& column);
77 void free_members(void);
78 void alloc_nulval(const std::string& value);
79 void alloc_buffer(void) const;
80 void free_buffer(void) const;
81
82 // Implemented virtual base class methods
83 virtual void alloc_data(void);
84 virtual void init_data(void);
85 virtual void fetch_data(void) const;
86 virtual void resize_data(const int& index, const int& number);
87 virtual void release_data(void);
88 virtual void* ptr_data(const int& index = 0);
89 virtual void* ptr_nulval(void);
90 virtual std::string ascii_format(void) const;
91
92 // Overloaded base class methods
93 virtual void save(void);
94
95 // Private data area
96 std::string* m_data; //!< Data area
97 mutable char** m_buffer; //!< Data area for CFITSIO transfer
98 char* m_nulval; //!< NULL string
99};
100
101
102/***********************************************************************//**
103 * @brief Return class name
104 *
105 * @return String containing the class name ("GFitsTableStringCol").
106 ***************************************************************************/
107inline
108std::string GFitsTableStringCol::classname(void) const
109{
110 return ("GFitsTableStringCol");
111}
112
113
114/***********************************************************************//**
115 * @brief Checks if column has been loaded
116 *
117 * @return True if column has been loaded, false otherwise
118 ***************************************************************************/
119inline
121{
122 return (m_data != NULL);
123}
124
125
126/***********************************************************************//**
127 * @brief Returns pointer to column data
128 *
129 * @return Pointer to column data.
130 ***************************************************************************/
131inline
133{
134 return m_data;
135}
136
137
138/***********************************************************************//**
139 * @brief Returns pointer to nul value
140 *
141 * @return Pointer to nul value.
142 ***************************************************************************/
143inline
145{
146 return m_nulval;
147}
148
149
150/***********************************************************************//**
151 * @brief Returns void pointer to column data
152 *
153 * @return Void pointer to column data.
154 ***************************************************************************/
155inline
156void* GFitsTableStringCol::ptr_data(const int& index)
157{
158 return (m_buffer+index);
159}
160
161
162/***********************************************************************//**
163 * @brief Returns void pointer to nul value
164 *
165 * @return Void pointer to nul value.
166 ***************************************************************************/
167inline
169{
170 return m_nulval;
171}
172
173#endif /* GFITSTABLESTRINGCOL_HPP */
FITS table column abstract base class definition.
Abstract interface for FITS table column.
const int & nrows(void) const
Returns number of rows in column.
const int & number(void) const
Returns number of elements in column.
const std::string & name(void) const
Returns column name.
const int & width(void) const
Return width in Bytes of one column element.
FITS table string column.
virtual void insert(const int &row, const int &nrows)
Insert rows in column.
virtual void resize_data(const int &index, const int &number)
Resize column data.
virtual void * ptr_nulval(void)
Returns void pointer to nul value.
virtual ~GFitsTableStringCol(void)
Destructor.
virtual bool is_loaded(void) const
Checks if column has been loaded.
std::string & operator()(const int &row, const int &inx=0)
Column data access operator.
char ** m_buffer
Data area for CFITSIO transfer.
virtual void fetch_data(void) const
Fetch column data.
virtual void clear(void)
Clear instance.
void free_members(void)
Delete class members.
virtual std::string classname(void) const
Return class name.
virtual std::string string(const int &row, const int &col=0) const
Get string value.
std::string * m_data
Data area.
virtual void release_data(void)
Release column data.
GFitsTableStringCol & operator=(const GFitsTableStringCol &column)
Assignment operator.
GFitsTableStringCol(void)
Constructor.
void free_buffer(void) const
Free CFITSIO transfer buffer.
char * m_nulval
NULL string.
virtual void * ptr_data(const int &index=0)
Returns void pointer to column data.
virtual double real(const int &row, const int &col=0) const
Get double precision value.
void init_members(void)
Initialise class members.
virtual void save(void)
Save table column into FITS file.
char * nulval(void)
Returns pointer to nul value.
virtual GFitsTableStringCol * clone(void) const
Clone column.
virtual void alloc_data(void)
Allocates column data.
virtual int integer(const int &row, const int &col=0) const
Get integer value.
void alloc_nulval(const std::string &value)
Allocate nul value.
void alloc_buffer(void) const
Allocate CFITSIO transfer buffer.
virtual std::string ascii_format(void) const
Returns format string of ASCII table.
std::string * data(void)
Returns pointer to column data.
virtual void remove(const int &row, const int &nrows)
Remove rows from column.
void copy_members(const GFitsTableStringCol &column)
Copy class members.
virtual void init_data(void)
Initialise column data.