| 192 | } |
| 193 | |
| 194 | class StatusCounter { |
| 195 | public: |
| 196 | StatusCounter() : hz(0), roughness(0), counter(0) {} |
| 197 | StatusCounter(double hz, double roughness, int64_t counter) : hz(hz), roughness(roughness), counter(counter) {} |
| 198 | StatusCounter(const std::string& parsableText) { parseText(parsableText); } |
| 199 | |
| 200 | StatusCounter& parseText(const std::string& parsableText) { |
| 201 | sscanf(parsableText.c_str(), "%lf %lf %" SCNd64 "", &hz, &roughness, &counter); |
| 202 | return *this; |
| 203 | } |
| 204 | |
| 205 | StatusCounter& updateValues(const StatusCounter& statusCounter) { |
| 206 | double hzNew = hz + statusCounter.hz; |
| 207 | double roughnessNew = (hz + statusCounter.hz) ? (roughness * hz + statusCounter.roughness * statusCounter.hz) / |
| 208 | (hz + statusCounter.hz) |
| 209 | : 0.0; |
| 210 | int64_t counterNew = counter + statusCounter.counter; |
| 211 | hz = hzNew; |
| 212 | roughness = roughnessNew; |
| 213 | counter = counterNew; |
| 214 | return *this; |
| 215 | } |
| 216 | |
| 217 | JsonBuilderObject getStatus() const { |
| 218 | JsonBuilderObject statusObject; |
| 219 | statusObject["hz"] = hz; |
| 220 | statusObject["roughness"] = roughness; |
| 221 | statusObject["counter"] = counter; |
| 222 | return statusObject; |
| 223 | } |
| 224 | |
| 225 | double getHz() { return hz; } |
| 226 | |
| 227 | double getRoughness() { return roughness; } |
| 228 | |
| 229 | int64_t getCounter() { return counter; } |
| 230 | |
| 231 | protected: |
| 232 | double hz; |
| 233 | double roughness; |
| 234 | int64_t counter; |
| 235 | }; |
| 236 | |
| 237 | static JsonBuilderObject getLocalityInfo(const LocalityData& locality) { |
| 238 | JsonBuilderObject localityObj; |
no test coverage detected