USGS

Isis 3.0 Object Programmers' Reference

Home

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 
12  groupedStats = NULL;
14  }
15 
16 
23  groupedStats = NULL;
25  }
26 
27 
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 {
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";
69  }
70 
71  return i.value();
72  }
73 
74 
82  const {
83  QVector< QString > statTypes;
84 
85  // for each key in the groupedStats QMap add the key to a vector
87  while(i != groupedStats->constEnd()) {
88  statTypes.push_back(i.key());
89  i++;
90  }
91 
92  return statTypes;
93  }
94 
95 
102  & other) {
103  delete groupedStats;
104  groupedStats = NULL;
105 
107 
108  return *this;
109  }
110 }