Isis 3.0 Object Programmers' Reference
Home
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
GroupedStatistics.cpp
1
#include "
GroupedStatistics.h
"
2
#include "
Statistics.h
"
3
4
#include <QMap>
5
#include <QVector>
6
#include <QString>
7
8
namespace
Isis {
9
11
GroupedStatistics::GroupedStatistics
() {
12
groupedStats
= NULL;
13
groupedStats
=
new
QMap< QString, Statistics >
();
14
}
15
16
22
GroupedStatistics::GroupedStatistics
(
const
GroupedStatistics
&other) {
23
groupedStats
= NULL;
24
groupedStats
=
new
QMap< QString, Statistics >
(*other.
groupedStats
);
25
}
26
27
29
GroupedStatistics::~GroupedStatistics
() {
30
if
(
groupedStats
) {
31
delete
groupedStats
;
32
groupedStats
= NULL;
33
}
34
}
35
36
45
void
GroupedStatistics::AddStatistic
(
const
QString &statType,
const
46
double
&newStat) {
47
(*groupedStats)[statType].AddData(newStat);
48
}
49
50
60
const
Statistics
&
GroupedStatistics::GetStatistics
(
const
QString &statType)
61
const
{
62
QMap< QString, Statistics >::const_iterator
i;
63
i =
groupedStats
->constFind(statType);
64
65
if
(i ==
groupedStats
->constEnd()) {
66
QString msg = statType;
67
msg +=
" passed to GetStats but does not exist within the map"
;
68
throw
IException
(
IException::Programmer
, msg,
_FILEINFO_
);
69
}
70
71
return
i.value();
72
}
73
74
81
const
QVector< QString >
GroupedStatistics::GetStatisticTypes
()
82
const
{
83
QVector< QString >
statTypes;
84
85
// for each key in the groupedStats QMap add the key to a vector
86
QMap< QString, Statistics >::const_iterator
i =
groupedStats
->constBegin();
87
while
(i !=
groupedStats
->constEnd()) {
88
statTypes.push_back(i.key());
89
i++;
90
}
91
92
return
statTypes;
93
}
94
95
101
GroupedStatistics
&
GroupedStatistics::operator=
(
const
GroupedStatistics
102
& other) {
103
delete
groupedStats
;
104
groupedStats
= NULL;
105
106
groupedStats
=
new
QMap< QString, Statistics >
(*other.
groupedStats
);
107
108
return
*
this
;
109
}
110
}