GammaLib 2.1.0.dev
Loading...
Searching...
No Matches
GTimes.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GTimes.hpp - Time container class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2012-2015 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 GTimes.hpp
23 * @brief Time container class definition
24 * @author Juergen Knoedlseder
25 */
26
27#ifndef GTIMES_HPP
28#define GTIMES_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include <string>
32#include <vector>
33#include "GContainer.hpp"
34#include "GTime.hpp"
35
36
37/***********************************************************************//**
38 * @class GTimes
39 *
40 * @brief Time container class.
41 *
42 * This class is a container for times. Times are implemented by the GTime
43 * class which stores time in a system independent way.
44 ***************************************************************************/
45class GTimes : public GContainer {
46
47public:
48 // Constructors and destructors
49 GTimes(void);
50 GTimes(const GTimes& times);
51 virtual ~GTimes(void);
52
53 // Operators
54 GTimes& operator=(const GTimes& times);
55 GTime& operator[](const int& index);
56 const GTime& operator[](const int& index) const;
57
58 // Methods
59 void clear(void);
60 GTimes* clone(void) const;
61 std::string classname(void) const;
62 int size(void) const;
63 bool is_empty(void) const;
64 void append(const GTime& time);
65 void insert(const int& index, const GTime& time);
66 void remove(const int& index);
67 void reserve(const int& num);
68 void extend(const GTimes& times);
69 std::string print(const GChatter& chatter = NORMAL) const;
70
71protected:
72 // Protected methods
73 void init_members(void);
74 void copy_members(const GTimes& times);
75 void free_members(void);
76
77 // Protected data members
78 std::vector<GTime> m_times; //!< List of times
79};
80
81
82/***********************************************************************//**
83 * @brief Return class name
84 *
85 * @return String containing the class name ("GTimes").
86 ***************************************************************************/
87inline
88std::string GTimes::classname(void) const
89{
90 return ("GTimes");
91}
92
93
94/***********************************************************************//**
95 * @brief Return number of times
96 *
97 * @return Number of times.
98 ***************************************************************************/
99inline
100int GTimes::size(void) const
101{
102 return (int)m_times.size();
103}
104
105
106/***********************************************************************//**
107 * @brief Signal if there are no times
108 *
109 * @return True if there are no times.
110 ***************************************************************************/
111inline
112bool GTimes::is_empty(void) const
113{
114 return m_times.empty();
115}
116
117#endif /* GTIMES_HPP */
Definition of interface for container classes.
Time class interface definition.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
Interface class for container classes.
Time class.
Definition GTime.hpp:55
Time container class.
Definition GTimes.hpp:45
void remove(const int &index)
Remove time from container.
Definition GTimes.cpp:274
GTime & operator[](const int &index)
Return reference to time.
Definition GTimes.cpp:138
void append(const GTime &time)
Append time to container.
Definition GTimes.cpp:216
std::string print(const GChatter &chatter=NORMAL) const
Print time container information.
Definition GTimes.cpp:347
GTimes * clone(void) const
Clone object.
Definition GTimes.cpp:203
void clear(void)
Clear container.
Definition GTimes.cpp:185
virtual ~GTimes(void)
Destructor.
Definition GTimes.cpp:87
bool is_empty(void) const
Signal if there are no times.
Definition GTimes.hpp:112
GTimes(void)
Void constructor.
Definition GTimes.cpp:56
void reserve(const int &num)
Reserve memory for times in container.
Definition GTimes.cpp:331
void extend(const GTimes &times)
Append time container.
Definition GTimes.cpp:299
void free_members(void)
Delete class members.
Definition GTimes.cpp:413
std::string classname(void) const
Return class name.
Definition GTimes.hpp:88
int size(void) const
Return number of times.
Definition GTimes.hpp:100
GTimes & operator=(const GTimes &times)
Assignment operator.
Definition GTimes.cpp:109
std::vector< GTime > m_times
List of times.
Definition GTimes.hpp:78
void insert(const int &index, const GTime &time)
Insert time into container.
Definition GTimes.cpp:238
void init_members(void)
Initialise class members.
Definition GTimes.cpp:385
void copy_members(const GTimes &times)
Copy class members.
Definition GTimes.cpp:400