GammaLib 2.0.0
Loading...
Searching...
No Matches
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 _______________________________________________ */
37class GTime;
38class GGti;
39class GFilename;
40class 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 ***************************************************************************/
53class GPulsar : public GBase {
54
55public:
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
85protected:
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 ***************************************************************************/
109inline
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 ***************************************************************************/
123inline
124const 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 ***************************************************************************/
135inline
136std::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 ***************************************************************************/
149inline
150int 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 ***************************************************************************/
163inline
164bool 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 ***************************************************************************/
175inline
176const 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 ***************************************************************************/
187inline
188void GPulsar::name(const std::string& name)
189{
190 m_name = name;
191 return;
192}
193
194#endif /* GPULSAR_HPP */
Definition of interface for all GammaLib classes.
Pulsar ephemeris class definition.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
Interface class for all GammaLib classes.
Definition GBase.hpp:52
Filename class.
Definition GFilename.hpp:62
Abstract interface for FITS table.
Good Time Interval class.
Definition GGti.hpp:62
Pulsar ephemeris class.
Pulsar class.
Definition GPulsar.hpp:53
std::vector< GPulsarEphemeris > m_ephemerides
Pulsar ephemerides.
Definition GPulsar.hpp:98
virtual GPulsar * clone(void) const
Clone Pulsar.
Definition GPulsar.cpp:189
void load_fits(const GFilename &filename, const std::string &name="")
Load Pulsar from ephemerides FITS file.
Definition GPulsar.cpp:484
virtual ~GPulsar(void)
Destructor.
Definition GPulsar.cpp:119
void load_parfile(const GFilename &filename)
Load Pulsar from ephemeris par file.
Definition GPulsar.cpp:885
virtual std::string classname(void) const
Return class name.
Definition GPulsar.hpp:136
std::string m_name
Pulsar name.
Definition GPulsar.hpp:97
void copy_members(const GPulsar &pulsar)
Copy class members.
Definition GPulsar.cpp:450
const std::string & name(void) const
Return pulsar name.
Definition GPulsar.hpp:176
void load(const GFilename &filename, const std::string &name="")
Load Pulsar from ephemerides file.
Definition GPulsar.cpp:314
const GPulsarEphemeris & ephemeris(const GTime &time) const
Return pulsar ephemeris.
Definition GPulsar.cpp:253
void load_fermi(const GFitsTable *table, const std::string &name="")
Load Pulsar from Fermi ephemerides FITS table.
Definition GPulsar.cpp:632
virtual void clear(void)
Clear Pulsar.
Definition GPulsar.cpp:171
void init_members(void)
Initialise class members.
Definition GPulsar.cpp:434
virtual std::string print(const GChatter &chatter=NORMAL) const
Print Pulsar.
Definition GPulsar.cpp:381
GPulsar(void)
Void constructor.
Definition GPulsar.cpp:65
GPulsar & operator=(const GPulsar &pulsar)
Assignment operator.
Definition GPulsar.cpp:141
void load_integral(const GFitsTable *table, const std::string &name="")
Load Pulsar from INTEGRAL ephemerides FITS table.
Definition GPulsar.cpp:529
void free_members(void)
Delete class members.
Definition GPulsar.cpp:464
GPulsarEphemeris & operator[](const int &index)
Return reference to ephemeris.
Definition GPulsar.hpp:110
int size(void) const
Return number of ephemerides for pulsar.
Definition GPulsar.hpp:150
GPulsarEphemeris & at(const int &index)
Return reference to ephemeris.
Definition GPulsar.cpp:204
void load_psrtime(const GFilename &filename, const std::string &name="")
Load Pulsar from ephemerides psrtime file.
Definition GPulsar.cpp:740
bool is_empty(void) const
Signals if there are no ephemerides for pulsar.
Definition GPulsar.hpp:164
GGti validity(void) const
Return validity intervals of pulsar ephemerides.
Definition GPulsar.cpp:286
Time class.
Definition GTime.hpp:55