Isis 3 Programmer Reference
GroupedStatistics.cpp
1
6/* SPDX-License-Identifier: CC0-1.0 */
7#include "GroupedStatistics.h"
8#include "Statistics.h"
9
10#include <QMap>
11#include <QVector>
12#include <QString>
13
14namespace Isis {
15
18 groupedStats = NULL;
19 groupedStats = new QMap< QString, Statistics >();
20 }
21
22
29 groupedStats = NULL;
30 groupedStats = new QMap< QString, Statistics >(*other.groupedStats);
31 }
32
33
41
42
51 void GroupedStatistics::AddStatistic(const QString &statType, const
52 double &newStat) {
53 (*groupedStats)[statType].AddData(newStat);
54 }
55
56
66 const Statistics &GroupedStatistics::GetStatistics(const QString &statType)
67 const {
69 i = groupedStats->constFind(statType);
70
71 if(i == groupedStats->constEnd()) {
72 QString msg = statType;
73 msg += " passed to GetStats but does not exist within the map";
74 throw IException(IException::Programmer, msg, _FILEINFO_);
75 }
76
77 return i.value();
78 }
79
80
88 const {
89 QVector< QString > statTypes;
90
91 // for each key in the groupedStats QMap add the key to a vector
93 while(i != groupedStats->constEnd()) {
94 statTypes.push_back(i.key());
95 i++;
96 }
97
98 return statTypes;
99 }
100
101
108 & other) {
109 delete groupedStats;
110 groupedStats = NULL;
111
112 groupedStats = new QMap< QString, Statistics >(*other.groupedStats);
113
114 return *this;
115 }
116}
Grouped Statistics.
void AddStatistic(const QString &statType, const double &newStat)
Add a new data entry for a given type of data.
GroupedStatistics & operator=(const GroupedStatistics &other)
Assign a GroupedStatistics with another GroupedStatistics using =.
GroupedStatistics()
construct a GroupedStatistics object
const QVector< QString > GetStatisticTypes() const
Return a list of all the different statistic tyes that this GroupedStatistics has.
QMap< QString, Statistics > * groupedStats
Map from statistic type to Statistics object.
const Statistics & GetStatistics(const QString &statType) const
Get statistics for a given type of data.
~GroupedStatistics()
destroy a GroupedStatistics object
Isis exception class.
Definition IException.h:91
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition IException.h:146
This class is used to accumulate statistics on double arrays.
Definition Statistics.h:94
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16