From 9904d16f1eceb9953d6ffab4763ab9f2500ad3e3 Mon Sep 17 00:00:00 2001 From: Kerry Liu Date: Fri, 2 Jun 2017 22:45:33 -0400 Subject: [PATCH] added a const --- src/device.cpp | 12 ++++++------ src/device.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/device.cpp b/src/device.cpp index 9969eb6..3c29875 100644 --- a/src/device.cpp +++ b/src/device.cpp @@ -26,7 +26,8 @@ Device::Device(string file_path) } } -const vector> &Device::get_sensor_readings() { +const vector> & +Device::get_sensor_readings() const { return sensor_readings; } @@ -38,15 +39,14 @@ void Device::refresh_sensors() { vector &prev_sensor_type_readings = prev_sensor_readings[type]; - for (unsigned int sensor_index = 0; - sensor_index < sensor_type_counts[type]; sensor_index++) { + for (unsigned int sensor_index = 0; sensor_index < sensor_type_counts[type]; + sensor_index++) { string cur_sensor_name; // Previous values to compare against: sensor_reading prev_sensor_type_reading = prev_sensor_type_readings[sensor_index]; - int prev_cur_val = - prev_sensor_type_reading.cur_val; + int prev_cur_val = prev_sensor_type_reading.cur_val; int prev_min_val = prev_sensor_type_reading.min_val; int prev_max_val = prev_sensor_type_reading.max_val; int prev_avg_val = prev_sensor_type_reading.avg_val; @@ -70,7 +70,7 @@ void Device::refresh_sensors() { // Sleep sometimes breaks stoi for some reason try { cur_cur_val = std::stoi(temp_string); - } catch (...){ + } catch (...) { cur_cur_val = prev_cur_val; } // Do calculations for min, max, and avg diff --git a/src/device.h b/src/device.h index 16343e1..661e4e3 100644 --- a/src/device.h +++ b/src/device.h @@ -42,7 +42,7 @@ class Device { void refresh_sensors(); static string formatValue(int val, int sensor_type); - const vector> &get_sensor_readings(); + const vector> &get_sensor_readings() const; private: vector> sensor_readings =