GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCOMHkds.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GCOMHkds.hpp - COMPTEL Housekeeping Data collection class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2023 by Juergen Knodlseder *
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 GCOMHkds.hpp
23  * @brief COMPTEL Housekeeping Data collection class definition
24  * @author Juergen Knodlseder
25  */
26 
27 #ifndef GCOMHKDS_HPP
28 #define GCOMHKDS_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include <vector>
33 #include "GCOMHkd.hpp"
34 #include "GContainer.hpp"
35 
36 /* __ Forward declarations _______________________________________________ */
37 class GFilename;
38 class GFitsTable;
39 
40 /* __ Constants __________________________________________________________ */
41 
42 
43 /***********************************************************************//**
44  * @class GCOMHkds
45  *
46  * @brief COMPTEL Housekeeping Data collection class
47  *
48  * The COMPTEL Housekeeping Data collection class holds Housekeeping
49  * Data containers for various parameters.
50  ***************************************************************************/
51 class GCOMHkds : public GContainer {
52 
53 public:
54  // Constructors and destructors
55  GCOMHkds(void);
56  explicit GCOMHkds(const GFilename& filename);
57  GCOMHkds(const GCOMHkds& hkds);
58  virtual ~GCOMHkds(void);
59 
60  // Operators
61  GCOMHkds& operator=(const GCOMHkds& hkds);
62  GCOMHkd& operator[](const int& index);
63  const GCOMHkd& operator[](const int& index) const;
64  GCOMHkd& operator[](const std::string& name);
65  const GCOMHkd& operator[](const std::string& name) const;
66 
67  // Methods
68  void clear(void);
69  GCOMHkds* clone(void) const;
70  std::string classname(void) const;
71  GCOMHkd& at(const int& index);
72  const GCOMHkd& at(const int& index) const;
73  int size(void) const;
74  bool is_empty(void) const;
75  GCOMHkd& set(const int& index, const GCOMHkd& hkd);
76  GCOMHkd& set(const std::string& name, const GCOMHkd& hkd);
77  GCOMHkd& append(const GCOMHkd& hkd);
78  GCOMHkd& insert(const int& index, const GCOMHkd& hkd);
79  void remove(const int& index);
80  void reserve(const int& num);
81  bool contains(const std::string& name) const;
82  void extend(const GCOMHkds& hkds);
83  void load(const GFilename& filename);
84  void read(const GFitsTable& table);
85  std::string print(const GChatter& chatter = NORMAL) const;
86 
87 protected:
88  // Protected methods
89  void init_members(void);
90  void copy_members(const GCOMHkds& hkds);
91  void free_members(void);
92  int get_index(const std::string& name) const;
93 
94  // Protected data members
95  std::vector<GCOMHkd> m_hkds; //!< Housekeeping Data containers
96 };
97 
98 
99 /***********************************************************************//**
100  * @brief Return class name
101  *
102  * @return String containing the class name ("GCOMHkds").
103  ***************************************************************************/
104 inline
105 std::string GCOMHkds::classname(void) const
106 {
107  return ("GCOMHkds");
108 }
109 
110 
111 /***********************************************************************//**
112  * @brief Return reference to Housekeeping Data container
113  *
114  * @param[in] index Housekeeping Data container index [0,...,size()-1].
115  * @return Reference to Housekeeping Data container.
116  *
117  * Returns a reference to the Housekeeping Data container with the specified
118  * @p index.
119  ***************************************************************************/
120 inline
121 GCOMHkd& GCOMHkds::operator[](const int& index)
122 {
123  return (m_hkds[index]);
124 }
125 
126 
127 /***********************************************************************//**
128  * @brief Return reference to Housekeeping Data (const version)
129  *
130  * @param[in] index Housekeeping Data container index [0,...,size()-1].
131  * @return Reference to Housekeeping Data container.
132  *
133  * Returns a reference to the Housekeeping Data container with the specified
134  * @p index.
135  ***************************************************************************/
136 inline
137 const GCOMHkd& GCOMHkds::operator[](const int& index) const
138 {
139  return (m_hkds[index]);
140 }
141 
142 
143 /***********************************************************************//**
144  * @brief Return number of Housekeeping parameters in collection
145  *
146  * @return Number of Housekeeping parameters in collection.
147  *
148  * Returns the number of Housekeeping parameters in the collection.
149  ***************************************************************************/
150 inline
151 int GCOMHkds::size(void) const
152 {
153  return (int)m_hkds.size();
154 }
155 
156 
157 /***********************************************************************//**
158  * @brief Signals if there are no Housekeeping Data containers in collection
159  *
160  * @return True if collection is empty, false otherwise.
161  *
162  * Signals if the collection does not contain any Housekeeping Data
163  * containers.
164  ***************************************************************************/
165 inline
166 bool GCOMHkds::is_empty(void) const
167 {
168  return (m_hkds.empty());
169 }
170 
171 
172 /***********************************************************************//**
173  * @brief Reserves space for Housekeeping Data containers in collection
174  *
175  * @param[in] num Number of Housekeeping Data containers in collection.
176  *
177  * Reserves space for @p num Housekeeping Data containers in the collection.
178  ***************************************************************************/
179 inline
180 void GCOMHkds::reserve(const int& num)
181 {
182  m_hkds.reserve(num);
183  return;
184 }
185 
186 #endif /* GCOMHKDS_HPP */
void load(const GFilename &filename)
Load Housekeeping Data collection from FITS file.
Definition: GCOMHkds.cpp:561
GCOMHkd & append(const GCOMHkd &hkd)
Append Housekeeping Data container to collection.
Definition: GCOMHkds.cpp:421
GCOMHkd & at(const int &index)
Return reference to Housekeeping Data container.
Definition: GCOMHkds.cpp:269
GCOMHkds * clone(void) const
Clone Housekeeping Data collection.
Definition: GCOMHkds.cpp:251
std::string classname(void) const
Return class name.
Definition: GCOMHkds.hpp:105
GCOMHkd & insert(const int &index, const GCOMHkd &hkd)
Insert Housekeeping Data container into collection.
Definition: GCOMHkds.cpp:444
GCOMHkds & operator=(const GCOMHkds &hkds)
Assignment operator.
Definition: GCOMHkds.cpp:139
void reserve(const int &num)
Reserves space for Housekeeping Data containers in collection.
Definition: GCOMHkds.hpp:180
void init_members(void)
Initialise class members.
Definition: GCOMHkds.cpp:676
void clear(void)
Clear Housekeeping Data collection.
Definition: GCOMHkds.cpp:233
void read(const GFitsTable &table)
Read Housekeeping Data collection from FITS table.
Definition: GCOMHkds.cpp:588
void copy_members(const GCOMHkds &hkds)
Copy class members.
Definition: GCOMHkds.cpp:691
bool is_empty(void) const
Signals if there are no Housekeeping Data containers in collection.
Definition: GCOMHkds.hpp:166
std::vector< GCOMHkd > m_hkds
Housekeeping Data containers.
Definition: GCOMHkds.hpp:95
Filename class.
Definition: GFilename.hpp:62
COMPTEL Housekeeping Data collection class.
Definition: GCOMHkds.hpp:51
COMPTEL Housekeeping Data container class definition.
Abstract interface for FITS table.
Definition: GFitsTable.hpp:44
GChatter
Definition: GTypemaps.hpp:33
void extend(const GCOMHkds &hkds)
Extend Housekeeping Data collection.
Definition: GCOMHkds.cpp:525
std::string print(const GChatter &chatter=NORMAL) const
Print Housekeeping Data collection.
Definition: GCOMHkds.cpp:639
void free_members(void)
Delete class members.
Definition: GCOMHkds.cpp:704
COMPTEL Housekeeping Data container class.
Definition: GCOMHkd.hpp:49
int size(void) const
Return number of Housekeeping parameters in collection.
Definition: GCOMHkds.hpp:151
bool contains(const std::string &name) const
Signals if Housekeeping parameter exists in collection.
Definition: GCOMHkds.cpp:507
int get_index(const std::string &name) const
Return Housekeeping Data container index by parameter name.
Definition: GCOMHkds.cpp:722
virtual ~GCOMHkds(void)
Destructor.
Definition: GCOMHkds.cpp:117
Definition of interface for container classes.
GCOMHkds(void)
Void constructor.
Definition: GCOMHkds.cpp:66
GCOMHkd & operator[](const int &index)
Return reference to Housekeeping Data container.
Definition: GCOMHkds.hpp:121
GCOMHkd & set(const int &index, const GCOMHkd &hkd)
Set Housekeeping Data container in collection.
Definition: GCOMHkds.cpp:326
Interface class for container classes.
Definition: GContainer.hpp:52