GammaLib  1.7.0.dev
 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-2018 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  const GGti& gti(void) const;
73  void gti(const GGti& gti);
74  void load(const GFilename& filename, const std::string& usage = "YES",
75  const std::string& mode = "NORMAL");
76  void save(const GFilename& filename, const bool& clobber = false) const;
77  void read(const GFitsTable& table, const std::string& usage = "YES",
78  const std::string& mode = "NORMAL");
79  void write(GFitsBinTable& table) const;
80 
81 protected:
82  // Protected methods
83  void init_members(void);
84  void copy_members(const GCOMTim& tim);
85  void free_members(void);
86 
87  // Protected members
88  GGti m_gti; //!< Good Time intervals
89 };
90 
91 
92 /***********************************************************************//**
93  * @brief Return class name
94  *
95  * @return String containing the class name ("GCOMTim").
96  ***************************************************************************/
97 inline
98 std::string GCOMTim::classname(void) const
99 {
100  return ("GCOMTim");
101 }
102 
103 
104 /***********************************************************************//**
105  * @brief Check if time is comprised in the Good Time Intervals
106  *
107  * @param[in] time Time.
108  * @return True if time is within Good Time Intervals, false otherwise.
109  *
110  * Checks if a time is comprised in the Good Time Intervals.
111  ***************************************************************************/
112 inline
113 bool GCOMTim::contains(const GTime& time) const
114 {
115  return (m_gti.contains(time));
116 }
117 
118 
119 /***********************************************************************//**
120  * @brief Return Good Time Intervals
121  *
122  * @return Good Time Intervals.
123  *
124  * Returns the Good Time Intervals.
125  ***************************************************************************/
126 inline
127 const GGti& GCOMTim::gti(void) const
128 {
129  return m_gti;
130 }
131 
132 
133 /***********************************************************************//**
134  * @brief Set Good Time Intervals
135  *
136  * @param[in] gti Good Time Intervals.
137  *
138  * Sets the Good Time Intervals.
139  ***************************************************************************/
140 inline
141 void GCOMTim::gti(const GGti& gti)
142 {
143  m_gti = gti;
144  return;
145 }
146 
147 #endif /* GCOMTIM_HPP */
bool contains(const GTime &time) const
Checks whether Good Time Intervals contains time.
Definition: GGti.cpp:952
GCOMTim & operator=(const GCOMTim &tim)
Assignment operator.
Definition: GCOMTim.cpp:154
virtual std::string print(const GChatter &chatter=NORMAL) const
Print COMPTEL Good Time Intervals.
Definition: GCOMTim.cpp:404
void init_members(void)
Initialise class members.
Definition: GCOMTim.cpp:457
virtual ~GCOMTim(void)
Destructor.
Definition: GCOMTim.cpp:132
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:279
Definition of interface for all GammaLib classes.
Time class.
Definition: GTime.hpp:54
void free_members(void)
Delete class members.
Definition: GCOMTim.cpp:485
Good time interval class interface definition.
void write(GFitsBinTable &table) const
Write COMPTEL Good Time Intervals into FITS binary table.
Definition: GCOMTim.cpp:339
bool contains(const GTime &time) const
Check if time is comprised in the Good Time Intervals.
Definition: GCOMTim.hpp:113
void copy_members(const GCOMTim &tim)
Copy class members.
Definition: GCOMTim.cpp:472
Filename class.
Definition: GFilename.hpp:62
Interface class for all GammaLib classes.
Definition: GBase.hpp:52
GCOMTim(void)
Void constructor.
Definition: GCOMTim.cpp:58
Abstract interface for FITS table.
Definition: GFitsTable.hpp:44
virtual GCOMTim * clone(void) const
Clone COMPTEL good time intervals.
Definition: GCOMTim.cpp:202
virtual void clear(void)
Clear COMPTEL good time intervals.
Definition: GCOMTim.cpp:184
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:217
void save(const GFilename &filename, const bool &clobber=false) const
Save Good Time Intervals into FITS file.
Definition: GCOMTim.cpp:246
virtual std::string classname(void) const
Return class name.
Definition: GCOMTim.hpp:98
COMPTEL Good Time Intervals class.
Definition: GCOMTim.hpp:50
GGti m_gti
Good Time intervals.
Definition: GCOMTim.hpp:88
const GGti & gti(void) const
Return Good Time Intervals.
Definition: GCOMTim.hpp:127