GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCOMHkd.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GCOMHkd.hpp - COMPTEL Housekeeping Data container 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 GCOMHkd.hpp
23  * @brief COMPTEL Housekeeping Data container class definition
24  * @author Juergen Knodlseder
25  */
26 
27 #ifndef GCOMHKD_HPP
28 #define GCOMHKD_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include <vector>
33 #include "GContainer.hpp"
34 #include "GTimes.hpp"
35 
36 /* __ Forward declarations _______________________________________________ */
37 class GTime;
38 
39 /* __ Constants __________________________________________________________ */
40 
41 
42 /***********************************************************************//**
43  * @class GCOMHkd
44  *
45  * @brief COMPTEL Housekeeping Data container class
46  *
47  * This class holds data for one housekeeping parameter.
48  ***************************************************************************/
49 class GCOMHkd : public GContainer {
50 
51 public:
52  // Constructors and destructors
53  GCOMHkd(void);
54  explicit GCOMHkd(const std::string& name);
55  GCOMHkd(const GCOMHkd& hkd);
56  virtual ~GCOMHkd(void);
57 
58  // Operators
59  GCOMHkd& operator=(const GCOMHkd& hkd);
60 
61  // Methods
62  void clear(void);
63  GCOMHkd* clone(void) const;
64  std::string classname(void) const;
65  int size(void) const;
66  bool is_empty(void) const;
67  void append(const GTime& time, const double& value);
68  void remove(const int& index);
69  void reserve(const int& num);
70  void extend(const GCOMHkd& hkd);
71  const std::string& name(void) const;
72  void name(const std::string& name);
73  const GTime& time(const int& index) const;
74  void time(const int& index, const GTime& time);
75  const double& value(const int& index) const;
76  void value(const int& index, const double& value);
77  std::string print(const GChatter& chatter = NORMAL) const;
78 
79 protected:
80  // Protected methods
81  void init_members(void);
82  void copy_members(const GCOMHkd& hkd);
83  void free_members(void);
84 
85  // Protected members
86  std::string m_name; //!< Name of housekeeping parameter
87  GTimes m_times; //!< Times
88  std::vector<double> m_values; //!< Values at times
89 };
90 
91 
92 /***********************************************************************//**
93  * @brief Return class name
94  *
95  * @return String containing the class name ("GCOMHkd").
96  ***************************************************************************/
97 inline
98 std::string GCOMHkd::classname(void) const
99 {
100  return ("GCOMHkd");
101 }
102 
103 
104 /***********************************************************************//**
105  * @brief Return number of Housekeeping Data in container
106  *
107  * @return Number of Housekeeping Data in container.
108  *
109  * Returns the number of Housekeeping Data in the container.
110  ***************************************************************************/
111 inline
112 int GCOMHkd::size(void) const
113 {
114  return (int)m_times.size();
115 }
116 
117 
118 /***********************************************************************//**
119  * @brief Signals if there are no Housekeeping Data in container
120  *
121  * @return True if container is empty, false otherwise.
122  *
123  * Signals if the Housekeeping Data container does not contain any
124  * Housekeeping Data.
125  ***************************************************************************/
126 inline
127 bool GCOMHkd::is_empty(void) const
128 {
129  return (m_times.is_empty());
130 }
131 
132 
133 /***********************************************************************//**
134  * @brief Reserves space for Housekeeping Data in container
135  *
136  * @param[in] num Number of Housekeeping Data.
137  *
138  * Reserves space for @p num Housekeeping Data in the container.
139  ***************************************************************************/
140 inline
141 void GCOMHkd::reserve(const int& num)
142 {
143  m_times.reserve(num);
144  m_values.reserve(num);
145  return;
146 }
147 
148 
149 /***********************************************************************//**
150  * @brief Return Housekeeping Data name
151  *
152  * @return Housekeeping Data name.
153  *
154  * Returns the Housekeeping Data name.
155  ***************************************************************************/
156 inline
157 const std::string& GCOMHkd::name(void) const
158 {
159  return (m_name);
160 }
161 
162 
163 /***********************************************************************//**
164  * @brief Set Housekeeping Data name
165  *
166  * @param[in] name Housekeeping Data name.
167  *
168  * Sets the Housekeeping Data name.
169  ***************************************************************************/
170 inline
171 void GCOMHkd::name(const std::string& name)
172 {
173  m_name = name;
174  return;
175 }
176 
177 #endif /* GCOMHKD_HPP */
void init_members(void)
Initialise class members.
Definition: GCOMHkd.cpp:458
std::string classname(void) const
Return class name.
Definition: GCOMHkd.hpp:98
const double & value(const int &index) const
Return reference to Housekeeping Data value.
Definition: GCOMHkd.cpp:356
GCOMHkd & operator=(const GCOMHkd &hkd)
Assignment operator.
Definition: GCOMHkd.cpp:132
int size(void) const
Return number of times.
Definition: GTimes.hpp:100
std::vector< double > m_values
Values at times.
Definition: GCOMHkd.hpp:88
GCOMHkd * clone(void) const
Clone Housekeeping Data container.
Definition: GCOMHkd.cpp:180
virtual ~GCOMHkd(void)
Destructor.
Definition: GCOMHkd.cpp:110
Time class.
Definition: GTime.hpp:55
GTimes m_times
Times.
Definition: GCOMHkd.hpp:87
Time container class definition.
Time container class.
Definition: GTimes.hpp:45
GCOMHkd(void)
Void constructor.
Definition: GCOMHkd.cpp:61
void clear(void)
Clear Housekeeping Data container.
Definition: GCOMHkd.cpp:162
bool is_empty(void) const
Signals if there are no Housekeeping Data in container.
Definition: GCOMHkd.hpp:127
GChatter
Definition: GTypemaps.hpp:33
int size(void) const
Return number of Housekeeping Data in container.
Definition: GCOMHkd.hpp:112
const GTime & time(const int &index) const
Return reference to Housekeeping Data time.
Definition: GCOMHkd.cpp:304
void reserve(const int &num)
Reserves space for Housekeeping Data in container.
Definition: GCOMHkd.hpp:141
COMPTEL Housekeeping Data container class.
Definition: GCOMHkd.hpp:49
std::string print(const GChatter &chatter=NORMAL) const
Print Housekeeping Data container.
Definition: GCOMHkd.cpp:403
void copy_members(const GCOMHkd &hkd)
Copy class members.
Definition: GCOMHkd.cpp:475
const std::string & name(void) const
Return Housekeeping Data name.
Definition: GCOMHkd.hpp:157
void reserve(const int &num)
Reserve memory for times in container.
Definition: GTimes.cpp:331
std::string m_name
Name of housekeeping parameter.
Definition: GCOMHkd.hpp:86
Definition of interface for container classes.
void append(const GTime &time, const double &value)
Append Housekeeping Data to container.
Definition: GCOMHkd.cpp:194
void extend(const GCOMHkd &hkd)
Extend Housekeeping Data.
Definition: GCOMHkd.cpp:243
Interface class for container classes.
Definition: GContainer.hpp:52
bool is_empty(void) const
Signal if there are no times.
Definition: GTimes.hpp:112
void free_members(void)
Delete class members.
Definition: GCOMHkd.cpp:490