GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GPulsar.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GPulsar.hpp - Pulsar class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2022 by Juergen Knoedlseder *
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 GPulsar.hpp
23  * @brief Pulsar class definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GPULSAR_HPP
28 #define GPULSAR_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include <vector>
33 #include "GBase.hpp"
34 #include "GPulsarEphemeris.hpp"
35 
36 /* __ Forward declarations _______________________________________________ */
37 class GTime;
38 class GGti;
39 class GFilename;
40 class GFitsTable;
41 
42 /* __ Constants __________________________________________________________ */
43 
44 
45 /***********************************************************************//**
46  * @class GPulsar
47  *
48  * @brief Pulsar class
49  *
50  * This class implements a pulsar, defined by a name and a list of pulsar
51  * ephemerides.
52  ***************************************************************************/
53 class GPulsar : public GBase {
54 
55 public:
56  // Constructors and destructors
57  GPulsar(void);
58  GPulsar(const GFilename& filename, const std::string& name = "");
59  GPulsar(const GPulsar& pulsar);
60  virtual ~GPulsar(void);
61 
62  // Operators
63  GPulsar& operator=(const GPulsar& pulsar);
64  GPulsarEphemeris& operator[](const int& index);
65  const GPulsarEphemeris& operator[](const int& index) const;
66 
67  // Implemented pure virtual base class methods
68  virtual void clear(void);
69  virtual GPulsar* clone(void) const;
70  virtual std::string classname(void) const;
71  virtual std::string print(const GChatter& chatter = NORMAL) const;
72 
73  // Other methods
74  int size(void) const;
75  bool is_empty(void) const;
76  GPulsarEphemeris& at(const int& index);
77  const GPulsarEphemeris& at(const int& index) const;
78  const std::string& name(void) const;
79  void name(const std::string& name);
80  const GPulsarEphemeris& ephemeris(const GTime& time) const;
81  GGti validity(void) const;
82  void load(const GFilename& filename,
83  const std::string& name = "");
84 
85 protected:
86  // Protected methods
87  void init_members(void);
88  void copy_members(const GPulsar& pulsar);
89  void free_members(void);
90  void load_fits(const GFilename& filename, const std::string& name = "");
91  void load_integral(const GFitsTable* table, const std::string& name = "");
92  void load_fermi(const GFitsTable* table, const std::string& name = "");
93  void load_psrtime(const GFilename& filename, const std::string& name = "");
94  void load_parfile(const GFilename& filename);
95 
96  // Protected members
97  std::string m_name; //!< Pulsar name
98  std::vector<GPulsarEphemeris> m_ephemerides; //!< Pulsar ephemerides
99 };
100 
101 
102 /***********************************************************************//**
103  * @brief Return reference to ephemeris
104  *
105  * @param[in] index Ephemeris index [0,...,size()-1].
106  *
107  * Returns a reference to the ephemeris with the specified @p index.
108  ***************************************************************************/
109 inline
111 {
112  return (m_ephemerides[index]);
113 }
114 
115 
116 /***********************************************************************//**
117  * @brief Return reference to ephemeris (const version)
118  *
119  * @param[in] index Ephemeris index [0,...,size()-1].
120  *
121  * Returns a const reference to the ephemeris with the specified @p index.
122  ***************************************************************************/
123 inline
124 const GPulsarEphemeris& GPulsar::operator[](const int& index) const
125 {
126  return (m_ephemerides[index]);
127 }
128 
129 
130 /***********************************************************************//**
131  * @brief Return class name
132  *
133  * @return String containing the class name ("GPulsar").
134  ***************************************************************************/
135 inline
136 std::string GPulsar::classname(void) const
137 {
138  return ("GPulsar");
139 }
140 
141 
142 /***********************************************************************//**
143  * @brief Return number of ephemerides for pulsar
144  *
145  * @return Number of ephemerides for pulsar.
146  *
147  * Returns the number of ephemerides for pulsar.
148  ***************************************************************************/
149 inline
150 int GPulsar::size(void) const
151 {
152  return (int)m_ephemerides.size();
153 }
154 
155 
156 /***********************************************************************//**
157  * @brief Signals if there are no ephemerides for pulsar
158  *
159  * @return True if there are no ephemerides for pulsar, false otherwise.
160  *
161  * Signals if there are no ephemerides for pulsar.
162  ***************************************************************************/
163 inline
164 bool GPulsar::is_empty(void) const
165 {
166  return (m_ephemerides.empty());
167 }
168 
169 
170 /***********************************************************************//**
171  * @brief Return pulsar name
172  *
173  * @return Pulsar name
174  ***************************************************************************/
175 inline
176 const std::string& GPulsar::name(void) const
177 {
178  return (m_name);
179 }
180 
181 
182 /***********************************************************************//**
183  * @brief Set pulsar name
184  *
185  * @param[in] name Pulsar name.
186  ***************************************************************************/
187 inline
188 void GPulsar::name(const std::string& name)
189 {
190  m_name = name;
191  return;
192 }
193 
194 #endif /* GPULSAR_HPP */
virtual ~GPulsar(void)
Destructor.
Definition: GPulsar.cpp:119
void load(const GFilename &filename, const std::string &name="")
Load Pulsar from ephemerides file.
Definition: GPulsar.cpp:314
void load_fits(const GFilename &filename, const std::string &name="")
Load Pulsar from ephemerides FITS file.
Definition: GPulsar.cpp:484
void free_members(void)
Delete class members.
Definition: GPulsar.cpp:464
GPulsarEphemeris & operator[](const int &index)
Return reference to ephemeris.
Definition: GPulsar.hpp:110
Definition of interface for all GammaLib classes.
void copy_members(const GPulsar &pulsar)
Copy class members.
Definition: GPulsar.cpp:450
Time class.
Definition: GTime.hpp:55
bool is_empty(void) const
Signals if there are no ephemerides for pulsar.
Definition: GPulsar.hpp:164
const GPulsarEphemeris & ephemeris(const GTime &time) const
Return pulsar ephemeris.
Definition: GPulsar.cpp:253
std::string m_name
Pulsar name.
Definition: GPulsar.hpp:97
Filename class.
Definition: GFilename.hpp:62
GPulsar(void)
Void constructor.
Definition: GPulsar.cpp:65
Interface class for all GammaLib classes.
Definition: GBase.hpp:52
virtual std::string print(const GChatter &chatter=NORMAL) const
Print Pulsar.
Definition: GPulsar.cpp:381
void load_psrtime(const GFilename &filename, const std::string &name="")
Load Pulsar from ephemerides psrtime file.
Definition: GPulsar.cpp:740
GPulsarEphemeris & at(const int &index)
Return reference to ephemeris.
Definition: GPulsar.cpp:204
Abstract interface for FITS table.
Definition: GFitsTable.hpp:44
GChatter
Definition: GTypemaps.hpp:33
virtual std::string classname(void) const
Return class name.
Definition: GPulsar.hpp:136
void load_integral(const GFitsTable *table, const std::string &name="")
Load Pulsar from INTEGRAL ephemerides FITS table.
Definition: GPulsar.cpp:529
Good Time Interval class.
Definition: GGti.hpp:62
void load_fermi(const GFitsTable *table, const std::string &name="")
Load Pulsar from Fermi ephemerides FITS table.
Definition: GPulsar.cpp:632
Pulsar ephemeris class.
void init_members(void)
Initialise class members.
Definition: GPulsar.cpp:434
Pulsar class.
Definition: GPulsar.hpp:53
void load_parfile(const GFilename &filename)
Load Pulsar from ephemeris par file.
Definition: GPulsar.cpp:885
GGti validity(void) const
Return validity intervals of pulsar ephemerides.
Definition: GPulsar.cpp:286
int size(void) const
Return number of ephemerides for pulsar.
Definition: GPulsar.hpp:150
const std::string & name(void) const
Return pulsar name.
Definition: GPulsar.hpp:176
virtual void clear(void)
Clear Pulsar.
Definition: GPulsar.cpp:171
virtual GPulsar * clone(void) const
Clone Pulsar.
Definition: GPulsar.cpp:189
GPulsar & operator=(const GPulsar &pulsar)
Assignment operator.
Definition: GPulsar.cpp:141
Pulsar ephemeris class definition.
std::vector< GPulsarEphemeris > m_ephemerides
Pulsar ephemerides.
Definition: GPulsar.hpp:98