GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCOMTim.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GCOMTim.hpp - COMPTEL Good Time Intervals 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 GCOMTim.hpp
23  * @brief COMPTEL Good Time Intervals class definition
24  * @author Juergen Knodlseder
25  */
26 
27 #ifndef GCOMTIM_HPP
28 #define GCOMTIM_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include "GBase.hpp"
33 #include "GGti.hpp"
34 
35 /* __ Forward declarations _______________________________________________ */
36 class GFilename;
37 class GFitsTable;
38 class GFitsBinTable;
39 
40 /* __ Constants __________________________________________________________ */
41 
42 
43 /***********************************************************************//**
44  * @class GCOMTim
45  *
46  * @brief COMPTEL Good Time Intervals class
47  *
48  * @todo Add class description.
49  ***************************************************************************/
50 class GCOMTim : public GBase {
51 
52 public:
53  // Constructors and destructors
54  GCOMTim(void);
55  explicit GCOMTim(const GGti& gti);
56  GCOMTim(const GCOMTim& tim);
57  GCOMTim(const GFilename& filename, const std::string& usage = "YES",
58  const std::string& mode = "NORMAL");
59  virtual ~GCOMTim(void);
60 
61  // Operators
62  GCOMTim& operator=(const GCOMTim& tim);
63 
64  // Implemented pure virtual base class methods
65  virtual void clear(void);
66  virtual GCOMTim* clone(void) const;
67  virtual std::string classname(void) const;
68  virtual std::string print(const GChatter& chatter = NORMAL) const;
69 
70  // Other methods
71  bool contains(const GTime& time) const;
72  void reduce(const GGti& gti);
73  const GGti& gti(void) const;
74  void gti(const GGti& gti);
75  void load(const GFilename& filename, const std::string& usage = "YES",
76  const std::string& mode = "NORMAL");
77  void save(const GFilename& filename, const bool& clobber = false) const;
78  void read(const GFitsTable& table, const std::string& usage = "YES",
79  const std::string& mode = "NORMAL");
80  void write(GFitsBinTable& table) const;
81 
82 protected:
83  // Protected methods
84  void init_members(void);
85  void copy_members(const GCOMTim& tim);
86  void free_members(void);
87 
88  // Protected members
89  GGti m_gti; //!< Good Time intervals
90 };
91 
92 
93 /***********************************************************************//**
94  * @brief Return class name
95  *
96  * @return String containing the class name ("GCOMTim").
97  ***************************************************************************/
98 inline
99 std::string GCOMTim::classname(void) const
100 {
101  return ("GCOMTim");
102 }
103 
104 
105 /***********************************************************************//**
106  * @brief Check if time is comprised in the Good Time Intervals
107  *
108  * @param[in] time Time.
109  * @return True if time is within Good Time Intervals, false otherwise.
110  *
111  * Checks if a time is comprised in the Good Time Intervals.
112  ***************************************************************************/
113 inline
114 bool GCOMTim::contains(const GTime& time) const
115 {
116  return (m_gti.contains(time));
117 }
118 
119 
120 /***********************************************************************//**
121  * @brief Reduces Good Time Intervals to intersection with intervals
122  *
123  * @param[in] gti Good Time Intervals.
124  *
125  * Reduces the Good Time Intervals to the intersection with the specified
126  * list of Good Time Intervals.
127  ***************************************************************************/
128 inline
129 void GCOMTim::reduce(const GGti& gti)
130 {
131  m_gti.reduce(gti);
132  return;
133 }
134 
135 
136 /***********************************************************************//**
137  * @brief Return Good Time Intervals
138  *
139  * @return Good Time Intervals.
140  *
141  * Returns the Good Time Intervals.
142  ***************************************************************************/
143 inline
144 const GGti& GCOMTim::gti(void) const
145 {
146  return m_gti;
147 }
148 
149 
150 /***********************************************************************//**
151  * @brief Set Good Time Intervals
152  *
153  * @param[in] gti Good Time Intervals.
154  *
155  * Sets the Good Time Intervals.
156  ***************************************************************************/
157 inline
158 void GCOMTim::gti(const GGti& gti)
159 {
160  m_gti = gti;
161  return;
162 }
163 
164 #endif /* GCOMTIM_HPP */
bool contains(const GTime &time) const
Checks whether Good Time Intervals contains time.
Definition: GGti.cpp:1070
GCOMTim & operator=(const GCOMTim &tim)
Assignment operator.
Definition: GCOMTim.cpp:155
virtual std::string print(const GChatter &chatter=NORMAL) const
Print COMPTEL Good Time Intervals.
Definition: GCOMTim.cpp:408
void init_members(void)
Initialise class members.
Definition: GCOMTim.cpp:461
virtual ~GCOMTim(void)
Destructor.
Definition: GCOMTim.cpp:133
void read(const GFitsTable &table, const std::string &usage="YES", const std::string &mode="NORMAL")
Read COMPTEL Good Time Intervals from FITS table.
Definition: GCOMTim.cpp:280
Definition of interface for all GammaLib classes.
Time class.
Definition: GTime.hpp:55
void free_members(void)
Delete class members.
Definition: GCOMTim.cpp:489
Good time interval class interface definition.
void write(GFitsBinTable &table) const
Write COMPTEL Good Time Intervals into FITS binary table.
Definition: GCOMTim.cpp:343
bool contains(const GTime &time) const
Check if time is comprised in the Good Time Intervals.
Definition: GCOMTim.hpp:114
void copy_members(const GCOMTim &tim)
Copy class members.
Definition: GCOMTim.cpp:476
Filename class.
Definition: GFilename.hpp:62
Interface class for all GammaLib classes.
Definition: GBase.hpp:52
GCOMTim(void)
Void constructor.
Definition: GCOMTim.cpp:59
Abstract interface for FITS table.
Definition: GFitsTable.hpp:44
virtual GCOMTim * clone(void) const
Clone COMPTEL good time intervals.
Definition: GCOMTim.cpp:203
virtual void clear(void)
Clear COMPTEL good time intervals.
Definition: GCOMTim.cpp:185
GChatter
Definition: GTypemaps.hpp:33
Good Time Interval class.
Definition: GGti.hpp:62
FITS binary table class.
void load(const GFilename &filename, const std::string &usage="YES", const std::string &mode="NORMAL")
Load COMPTEL Good Time Intervals from FITS file.
Definition: GCOMTim.cpp:218
void save(const GFilename &filename, const bool &clobber=false) const
Save Good Time Intervals into FITS file.
Definition: GCOMTim.cpp:247
virtual std::string classname(void) const
Return class name.
Definition: GCOMTim.hpp:99
COMPTEL Good Time Intervals class.
Definition: GCOMTim.hpp:50
void reduce(const GGti &gti)
Reduces Good Time Intervals to intersection with intervals.
Definition: GCOMTim.hpp:129
GGti m_gti
Good Time intervals.
Definition: GCOMTim.hpp:89
const GGti & gti(void) const
Return Good Time Intervals.
Definition: GCOMTim.hpp:144
void reduce(const GTime &tstart, const GTime &tstop)
Reduce Good Time Intervals to specified interval.
Definition: GGti.cpp:401