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