GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GPhases.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GPhases.hpp - Phase intervals class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2017-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 GPhases.hpp
23  * @brief Phase intervals class interface definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GPHASES_HPP
28 #define GPHASES_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include "GContainer.hpp"
33 
34 /* __ Forward declarations _______________________________________________ */
35 
36 
37 /***********************************************************************//**
38  * @class GPhases
39  *
40  * @brief Phase Intervals class
41  ***************************************************************************/
42 class GPhases : public GContainer {
43 
44 public:
45  // Constructors and destructors
46  GPhases(void);
47  GPhases(const GPhases& phases);
48  GPhases(const double& pmin, const double& pmax);
49  virtual ~GPhases(void);
50 
51  // Operators
52  GPhases& operator=(const GPhases& phases);
53 
54  // Methods
55  void clear(void);
56  GPhases* clone(void) const;
57  std::string classname(void) const;
58  int size(void) const;
59  bool is_empty(void) const;
60  bool contains(const double& phase) const;
61  void append(const double& pmin, const double& pmax);
62  void remove(const int& index);
63  void reserve(const int& num);
64  void extend(const GPhases& phases);
65  double pmin(const int& index) const;
66  double pmax(const int& index) const;
67  double length(void) const;
68  std::string print(const GChatter& chatter = NORMAL) const;
69 
70 protected:
71  // Protected methods
72  void init_members(void);
73  void copy_members(const GPhases& phases);
74  void free_members(void);
75  void insert_interval(const int& index, const double& pmin,
76  const double& pmax);
77 
78  // Protected data area
79  std::vector<double> m_pmin; // Lower phase interval boundaries
80  std::vector<double> m_pmax; // Upper phase interval boundaries
81 };
82 
83 
84 /***********************************************************************//**
85  * @brief Return class name
86  *
87  * @return String containing the class name ("GPhases").
88  ***************************************************************************/
89 inline
90 std::string GPhases::classname(void) const
91 {
92  return ("GPhases");
93 }
94 
95 
96 /***********************************************************************//**
97  * @brief Return number of phase intervals
98  *
99  * @return Number of phase intervals.
100  ***************************************************************************/
101 inline
102 int GPhases::size(void) const
103 {
104  return (int)m_pmin.size();
105 }
106 
107 
108 /***********************************************************************//**
109  * @brief Signal if there are no phase intervals
110  *
111  * @return True if there are no phase intervals.
112  ***************************************************************************/
113 inline
114 bool GPhases::is_empty(void) const
115 {
116  return (m_pmin.size() == 0);
117 }
118 
119 #endif /* GPHASES_HPP */
void clear(void)
Clear phase intervals.
Definition: GPhases.cpp:166
double length(void) const
Returns total length of phase intervals.
Definition: GPhases.cpp:365
void append(const double &pmin, const double &pmax)
Append phase interval.
Definition: GPhases.cpp:226
double pmax(const int &index) const
Returns upper boundary for a given phase interval.
Definition: GPhases.cpp:345
void reserve(const int &num)
Reserve space for phase intervals.
Definition: GPhases.cpp:268
int size(void) const
Return number of phase intervals.
Definition: GPhases.hpp:102
GPhases * clone(void) const
Clone phase intervals.
Definition: GPhases.cpp:184
virtual ~GPhases(void)
Destructor.
Definition: GPhases.cpp:114
bool is_empty(void) const
Signal if there are no phase intervals.
Definition: GPhases.hpp:114
void init_members(void)
Initialise class members.
Definition: GPhases.cpp:426
void insert_interval(const int &index, const double &pmin, const double &pmax)
Insert phase interval.
Definition: GPhases.cpp:477
bool contains(const double &phase) const
Check whether phase is contained in phases.
Definition: GPhases.cpp:200
GChatter
Definition: GTypemaps.hpp:33
void copy_members(const GPhases &phases)
Copy class members.
Definition: GPhases.cpp:442
void extend(const GPhases &phases)
Append phase intervals.
Definition: GPhases.cpp:286
std::vector< double > m_pmax
Definition: GPhases.hpp:80
void free_members(void)
Delete class members.
Definition: GPhases.cpp:456
GPhases & operator=(const GPhases &phases)
Assignment operator.
Definition: GPhases.cpp:136
Phase Intervals class.
Definition: GPhases.hpp:42
std::vector< double > m_pmin
Definition: GPhases.hpp:79
double pmin(const int &index) const
Returns lower boundary for a given phase interval.
Definition: GPhases.cpp:321
Definition of interface for container classes.
GPhases(void)
Void constructor.
Definition: GPhases.cpp:59
std::string print(const GChatter &chatter=NORMAL) const
Print phase intervals.
Definition: GPhases.cpp:386
std::string classname(void) const
Return class name.
Definition: GPhases.hpp:90
Interface class for container classes.
Definition: GContainer.hpp:52