Skip to content

Commit

Permalink
added a const
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerryliu committed Jun 3, 2017
1 parent 94b9f84 commit 9904d16
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ Device::Device(string file_path)
}
}

const vector<vector<Device::sensor_reading>> &Device::get_sensor_readings() {
const vector<vector<Device::sensor_reading>> &
Device::get_sensor_readings() const {
return sensor_readings;
}

Expand All @@ -38,15 +39,14 @@ void Device::refresh_sensors() {
vector<sensor_reading> &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;
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Device {

void refresh_sensors();
static string formatValue(int val, int sensor_type);
const vector<vector<sensor_reading>> &get_sensor_readings();
const vector<vector<sensor_reading>> &get_sensor_readings() const;

private:
vector<vector<sensor_reading>> sensor_readings =
Expand Down

0 comments on commit 9904d16

Please sign in to comment.