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 
14 namespace Isis {
15 
18  groupedStats = NULL;
20  }
21 
22 
29  groupedStats = NULL;
31  }
32 
33 
36  if(groupedStats) {
37  delete groupedStats;
38  groupedStats = NULL;
39  }
40  }
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 
113 
114  return *this;
115  }
116 }
Isis::GroupedStatistics::AddStatistic
void AddStatistic(const QString &statType, const double &newStat)
Add a new data entry for a given type of data.
Definition: GroupedStatistics.cpp:51
Isis::Statistics
This class is used to accumulate statistics on double arrays.
Definition: Statistics.h:94
Isis::GroupedStatistics::GroupedStatistics
GroupedStatistics()
construct a GroupedStatistics object
Definition: GroupedStatistics.cpp:17
Isis::GroupedStatistics::groupedStats
QMap< QString, Statistics > * groupedStats
Map from statistic type to Statistics object.
Definition: GroupedStatistics.h:55
Isis::GroupedStatistics
Grouped Statistics.
Definition: GroupedStatistics.h:41
Isis::GroupedStatistics::GetStatistics
const Statistics & GetStatistics(const QString &statType) const
Get statistics for a given type of data.
Definition: GroupedStatistics.cpp:66
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::IException::Programmer
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:146
Isis::GroupedStatistics::GetStatisticTypes
const QVector< QString > GetStatisticTypes() const
Return a list of all the different statistic tyes that this GroupedStatistics has.
Definition: GroupedStatistics.cpp:87
QMap
This is free and unencumbered software released into the public domain.
Definition: CubeIoHandler.h:22
Isis::GroupedStatistics::operator=
GroupedStatistics & operator=(const GroupedStatistics &other)
Assign a GroupedStatistics with another GroupedStatistics using =.
Definition: GroupedStatistics.cpp:107
Isis::GroupedStatistics::~GroupedStatistics
~GroupedStatistics()
destroy a GroupedStatistics object
Definition: GroupedStatistics.cpp:35
QVector< QString >
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16