GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
47 public:
48  // Constructors and destructors
49  GFitsTableBoolCol(void);
50  GFitsTableBoolCol(const std::string& name, const int& nrows,
51  const int& size = 1);
52  GFitsTableBoolCol(const GFitsTableBoolCol& column);
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 
76 private:
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  ***************************************************************************/
110 inline
111 std::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  ***************************************************************************/
122 inline
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  ***************************************************************************/
134 inline
136 {
137  return m_data;
138 }
139 
140 
141 /***********************************************************************//**
142  * @brief Returns pointer to nul value
143  *
144  * @return Pointer to nul value.
145  ***************************************************************************/
146 inline
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  ***************************************************************************/
158 inline
159 void* 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  ***************************************************************************/
170 inline
172 {
173  return m_nulval;
174 }
175 
176 #endif /* GFITSTABLEBOOLCOL_HPP */
virtual GFitsTableBoolCol * clone(void) const
Clone column.
void free_buffer(void) const
Free CFITSIO transfer buffer.
virtual std::string classname(void) const
Return class name.
bool * m_data
Data area.
const std::string & name(void) const
Returns column name.
virtual bool is_loaded(void) const
Checks if column has been loaded.
bool * nulval(void)
Returns pointer to nul value.
virtual void * ptr_data(const int &index=0)
Returns void pointer to column data.
GFitsTableBoolCol(void)
Constructor.
void alloc_buffer(void) const
Allocate CFITSIO transfer buffer.
bool * data(void)
Returns pointer to column data.
virtual double real(const int &row, const int &col=0) const
Get double precision value.
FITS table column abstract base class definition.
GFitsTableBoolCol & operator=(const GFitsTableBoolCol &column)
Assignment operator.
virtual void insert(const int &row, const int &nrows)
Insert rows in column.
virtual std::string ascii_format(void) const
Returns format string of ASCII table.
const int & number(void) const
Returns number of elements in column.
Abstract interface for FITS table column.
FITS table Boolean column.
bool * m_nulval
NULL value.
bool & operator()(const int &row, const int &inx=0)
Column data access operator.
virtual ~GFitsTableBoolCol(void)
Destructor.
void init_members(void)
Initialise class members.
virtual void * ptr_nulval(void)
Returns void pointer to nul value.
virtual void release_data(void)
Release column data.
void alloc_nulval(const bool *value)
Allocate null value.
virtual void resize_data(const int &index, const int &number)
Resize column data.
char * m_buffer
Data area for CFITSIO transfer.
virtual void alloc_data(void)
Allocates column data.
void copy_members(const GFitsTableBoolCol &column)
Copy class members.
const int & nrows(void) const
Returns number of rows in column.
virtual int integer(const int &row, const int &col=0) const
Get integer value.
virtual void fetch_data(void) const
Fetch column data.
virtual void save(void)
Save table column into FITS file.
virtual std::string string(const int &row, const int &col=0) const
Get string value.
virtual void init_data(void)
Initialise column data.
void free_members(void)
Delete class members.
virtual void clear(void)
Clear instance.