GammaLib 2.0.0
Loading...
Searching...
No Matches
GFitsTableBoolCol.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GFitsTableBoolCol.hpp - FITS table boolean 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 GFitsTableBoolCol.hpp
23 * @brief FITS table Boolean column class interface definition
24 * @author Juergen Knoedlseder
25 */
26
27#ifndef GFITSTABLEBOOLCOL_HPP
28#define GFITSTABLEBOOLCOL_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include <string>
32#include "GFitsTableCol.hpp"
33
34
35/***********************************************************************//**
36 * @class GFitsTableBoolCol
37 *
38 * @brief FITS table Boolean column
39 *
40 * This class implements a FITS table Boolean column.
41 *
42 * @todo Each Bit is actually stored in one Byte. To save memory a more
43 * compact storage scheme should be implemented.
44 ***************************************************************************/
46
47public:
48 // Constructors and destructors
50 GFitsTableBoolCol(const std::string& name, const int& nrows,
51 const int& size = 1);
53 virtual ~GFitsTableBoolCol(void);
54
55 // Operators
57 bool& operator()(const int& row, const int& inx = 0);
58 const bool& operator()(const int& row, const int& inx = 0) const;
59
60 // Implement virtual methods
61 virtual void clear(void);
62 virtual GFitsTableBoolCol* clone(void) const;
63 virtual std::string classname(void) const;
64 virtual std::string string(const int& row, const int& col = 0) const;
65 virtual double real(const int& row, const int& col = 0) const;
66 virtual int integer(const int& row, const int& col = 0) const;
67 virtual void insert(const int& row, const int& nrows);
68 virtual void remove(const int& row, const int& nrows);
69 virtual bool is_loaded(void) const;
70
71 // Other methods
72 bool* data(void);
73 bool* nulval(void);
74 void nulval(const bool* value);
75
76private:
77 // Private methods
78 void init_members(void);
79 void copy_members(const GFitsTableBoolCol& column);
80 void free_members(void);
81 void alloc_nulval(const bool* value);
82 void alloc_buffer(void) const;
83 void free_buffer(void) const;
84
85 // Implemented virtual base class methods
86 virtual void alloc_data(void);
87 virtual void init_data(void);
88 virtual void fetch_data(void) const;
89 virtual void resize_data(const int& index, const int& number);
90 virtual void release_data(void);
91 virtual void* ptr_data(const int& index = 0);
92 virtual void* ptr_nulval(void);
93 virtual std::string ascii_format(void) const;
94
95 // Overloaded base class methods
96 virtual void save(void);
97
98 // Private data area
99 bool* m_data; //!< Data area
100 bool* m_nulval; //!< NULL value
101 mutable char* m_buffer; //!< Data area for CFITSIO transfer
102};
103
104
105/***********************************************************************//**
106 * @brief Return class name
107 *
108 * @return String containing the class name ("GFitsTableBoolCol").
109 ***************************************************************************/
110inline
111std::string GFitsTableBoolCol::classname(void) const
112{
113 return ("GFitsTableBoolCol");
114}
115
116
117/***********************************************************************//**
118 * @brief Checks if column has been loaded
119 *
120 * @return True if column has been loaded, false otherwise
121 ***************************************************************************/
122inline
124{
125 return (m_data != NULL);
126}
127
128
129/***********************************************************************//**
130 * @brief Returns pointer to column data
131 *
132 * @return Pointer to column data.
133 ***************************************************************************/
134inline
136{
137 return m_data;
138}
139
140
141/***********************************************************************//**
142 * @brief Returns pointer to nul value
143 *
144 * @return Pointer to nul value.
145 ***************************************************************************/
146inline
148{
149 return m_nulval;
150}
151
152
153/***********************************************************************//**
154 * @brief Returns void pointer to column data
155 *
156 * @return Void pointer to column data.
157 ***************************************************************************/
158inline
159void* GFitsTableBoolCol::ptr_data(const int& index)
160{
161 return (m_buffer+index);
162}
163
164
165/***********************************************************************//**
166 * @brief Returns void pointer to nul value
167 *
168 * @return Void pointer to nul value.
169 ***************************************************************************/
170inline
172{
173 return m_nulval;
174}
175
176#endif /* GFITSTABLEBOOLCOL_HPP */
FITS table column abstract base class definition.
FITS table Boolean column.
void copy_members(const GFitsTableBoolCol &column)
Copy class members.
bool * data(void)
Returns pointer to column data.
virtual void init_data(void)
Initialise column data.
virtual std::string string(const int &row, const int &col=0) const
Get string value.
void free_members(void)
Delete class members.
void init_members(void)
Initialise class members.
virtual void clear(void)
Clear instance.
bool * m_data
Data area.
char * m_buffer
Data area for CFITSIO transfer.
virtual void save(void)
Save table column into FITS file.
virtual GFitsTableBoolCol * clone(void) const
Clone column.
virtual void remove(const int &row, const int &nrows)
Remove rows from column.
virtual void * ptr_data(const int &index=0)
Returns void pointer to column data.
virtual void insert(const int &row, const int &nrows)
Insert rows in column.
virtual ~GFitsTableBoolCol(void)
Destructor.
GFitsTableBoolCol & operator=(const GFitsTableBoolCol &column)
Assignment operator.
bool * m_nulval
NULL value.
virtual void release_data(void)
Release column data.
bool & operator()(const int &row, const int &inx=0)
Column data access operator.
virtual void alloc_data(void)
Allocates column data.
bool * nulval(void)
Returns pointer to nul value.
GFitsTableBoolCol(void)
Constructor.
virtual void resize_data(const int &index, const int &number)
Resize column data.
void alloc_buffer(void) const
Allocate CFITSIO transfer buffer.
void alloc_nulval(const bool *value)
Allocate null value.
virtual std::string classname(void) const
Return class name.
void free_buffer(void) const
Free CFITSIO transfer buffer.
virtual void fetch_data(void) const
Fetch column data.
virtual bool is_loaded(void) const
Checks if column has been loaded.
virtual void * ptr_nulval(void)
Returns void pointer to nul value.
virtual int integer(const int &row, const int &col=0) const
Get integer value.
virtual std::string ascii_format(void) const
Returns format string of ASCII table.
virtual double real(const int &row, const int &col=0) const
Get double precision value.
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.