| Alexander Hansen | 46a755f | 2025-10-27 16:31:08 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: Apache-2.0 |
| 2 | // SPDX-FileCopyrightText: Copyright 2017 Google Inc | ||||
| Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 3 | |
| Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 4 | /* Configuration. */ |
| Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 5 | #include "sensors/manager.hpp" |
| Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 6 | |
| Ed Tanous | f8b6e55 | 2025-06-27 13:27:50 -0700 | [diff] [blame] | 7 | #include "sensor.hpp" |
| Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 8 | |
| Patrick Venture | a076487 | 2020-08-08 07:48:43 -0700 | [diff] [blame] | 9 | #include <memory> |
| 10 | #include <string> | ||||
| Ed Tanous | f8b6e55 | 2025-06-27 13:27:50 -0700 | [diff] [blame] | 11 | #include <utility> |
| Patrick Venture | a076487 | 2020-08-08 07:48:43 -0700 | [diff] [blame] | 12 | |
| 13 | namespace pid_control | ||||
| 14 | { | ||||
| 15 | |||||
| Patrick Venture | ffc5ca7 | 2018-10-30 22:34:53 -0700 | [diff] [blame] | 16 | void SensorManager::addSensor(const std::string& type, const std::string& name, |
| Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 17 | std::unique_ptr<Sensor> sensor) |
| Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 18 | { |
| Patrick Venture | 5e92909 | 2018-06-08 10:55:23 -0700 | [diff] [blame] | 19 | _sensorMap[name] = std::move(sensor); |
| Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 20 | |
| Patrick Venture | 5e92909 | 2018-06-08 10:55:23 -0700 | [diff] [blame] | 21 | auto entry = _sensorTypeList.find(type); |
| 22 | if (entry == _sensorTypeList.end()) | ||||
| Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 23 | { |
| Patrick Venture | 5e92909 | 2018-06-08 10:55:23 -0700 | [diff] [blame] | 24 | _sensorTypeList[type] = {}; |
| Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 25 | } |
| 26 | |||||
| Patrick Venture | 5e92909 | 2018-06-08 10:55:23 -0700 | [diff] [blame] | 27 | _sensorTypeList[type].push_back(name); |
| Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 28 | } |
| Patrick Venture | a076487 | 2020-08-08 07:48:43 -0700 | [diff] [blame] | 29 | |
| 30 | } // namespace pid_control | ||||