GammaLib  1.7.0.dev
 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 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  void append(const double& pmin, const double& pmax);
61  void remove(const int& index);
62  void reserve(const int& num);
63  void extend(const GPhases& phases);
64  double pmin(const int& index) const;
65  double pmax(const int& index) const;
66  std::string print(const GChatter& chatter = NORMAL) const;
67 
68 protected:
69  // Protected methods
70  void init_members(void);
71  void copy_members(const GPhases& phases);
72  void free_members(void);
73  void insert_interval(const int& index, const double& pmin,
74  const double& pmax);
75 
76  // Protected data area
77  std::vector<double> m_pmin; // Lower phase interval boundaries
78  std::vector<double> m_pmax; // Upper phase interval boundaries
79 };
80 
81 
82 /***********************************************************************//**
83  * @brief Return class name
84  *
85  * @return String containing the class name ("GPhases").
86  ***************************************************************************/
87 inline
88 std::string GPhases::classname(void) const
89 {
90  return ("GPhases");
91 }
92 
93 
94 /***********************************************************************//**
95  * @brief Return number of phase intervals
96  *
97  * @return Number of phase intervals.
98  ***************************************************************************/
99 inline
100 int GPhases::size(void) const
101 {
102  return (int)m_pmin.size();
103 }
104 
105 
106 /***********************************************************************//**
107  * @brief Signal if there are no phase intervals
108  *
109  * @return True if there are no phase intervals.
110  ***************************************************************************/
111 inline
112 bool GPhases::is_empty(void) const
113 {
114  return (m_pmin.size() == 0);
115 }
116 
117 #endif /* GPHASES_HPP */
void clear(void)
Clear phase intervals.
Definition: GPhases.cpp:166
void append(const double &pmin, const double &pmax)
Append phase interval.
Definition: GPhases.cpp:198
double pmax(const int &index) const
Returns upper boundary for a given phase interval.
Definition: GPhases.cpp:317
void reserve(const int &num)
Reserve space for phase intervals.
Definition: GPhases.cpp:240
int size(void) const
Return number of phase intervals.
Definition: GPhases.hpp:100
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:112
void init_members(void)
Initialise class members.
Definition: GPhases.cpp:369
void insert_interval(const int &index, const double &pmin, const double &pmax)
Insert phase interval.
Definition: GPhases.cpp:420
GChatter
Definition: GTypemaps.hpp:33
void copy_members(const GPhases &phases)
Copy class members.
Definition: GPhases.cpp:385
void extend(const GPhases &phases)
Append phase intervals.
Definition: GPhases.cpp:258
std::vector< double > m_pmax
Definition: GPhases.hpp:78
void free_members(void)
Delete class members.
Definition: GPhases.cpp:399
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:77
double pmin(const int &index) const
Returns lower boundary for a given phase interval.
Definition: GPhases.cpp:293
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:338
std::string classname(void) const
Return class name.
Definition: GPhases.hpp:88
Interface class for container classes.
Definition: GContainer.hpp:52