20 #ifndef _STELRENDERERSTATISTICS_HPP_
21 #define _STELRENDERERSTATISTICS_HPP_
26 enum StatisticSwapMode
28 StatisticSwapMode_SetToZero,
29 StatisticSwapMode_DoNothing
67 memset(
statistics,
'\0', MAX_STATISTICS *
sizeof(
double));
68 memset(previousStatistics,
'\0', MAX_STATISTICS *
sizeof(
double));
69 memset(statisticNames,
'\0', MAX_STATISTICS *
sizeof(
const char*));
70 memset(swapModes,
'\0', MAX_STATISTICS *
sizeof(StatisticSwapMode));
80 bool getNext(
const char*& name,
double& value)
82 Q_ASSERT_X(iterationIndex <= statisticCount, Q_FUNC_INFO,
83 "Statistics iteration index out of bounds");
84 if(iterationIndex == statisticCount)
89 name = statisticNames[iterationIndex];
90 value = previousStatistics[iterationIndex];
109 Q_ASSERT_X(index >= 0 && index < statisticCount, Q_FUNC_INFO,
110 "Index of a statistic out of range");
126 (
const char* name,
const StatisticSwapMode swapMode = StatisticSwapMode_DoNothing)
128 Q_ASSERT_X(statisticCount < MAX_STATISTICS, Q_FUNC_INFO,
129 "Can't add any more statistics (at most 48 are supported)");
130 swapModes[statisticCount] = swapMode;
131 statisticNames[statisticCount] = name;
133 return statisticCount - 1;
142 memcpy(previousStatistics,
statistics, MAX_STATISTICS *
sizeof(
double));
143 for(
int s = 0; s < statisticCount; ++s)
145 if(swapModes[s] == StatisticSwapMode_SetToZero)
149 else if(swapModes[s] != StatisticSwapMode_DoNothing)
151 Q_ASSERT_X(
false, Q_FUNC_INFO,
"Unknown statistic swap mode");
165 static const int MAX_STATISTICS = 40;
176 double previousStatistics[MAX_STATISTICS];
185 const char* statisticNames[MAX_STATISTICS];
188 StatisticSwapMode swapModes[MAX_STATISTICS];
194 #endif // _STELRENDERERSTATISTICS_HPP_