blob: d5ec6154e9a42dce2e93a036c73f98e4f9e25e18 [file] [log] [blame]
Alexander Hansen46a755f2025-10-27 16:31:08 +01001// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright 2017 Google Inc
Patrick Venture863b9242018-03-08 08:29:23 -08003
Patrick Venture863b9242018-03-08 08:29:23 -08004/* Configuration. */
Patrick Venture863b9242018-03-08 08:29:23 -08005#include "sensors/manager.hpp"
Patrick Venture863b9242018-03-08 08:29:23 -08006
Ed Tanousf8b6e552025-06-27 13:27:50 -07007#include "sensor.hpp"
Patrick Ventureda4a5dd2018-08-31 09:42:48 -07008
Patrick Venturea0764872020-08-08 07:48:43 -07009#include <memory>
10#include <string>
Ed Tanousf8b6e552025-06-27 13:27:50 -070011#include <utility>
Patrick Venturea0764872020-08-08 07:48:43 -070012
13namespace pid_control
14{
15
Patrick Ventureffc5ca72018-10-30 22:34:53 -070016void SensorManager::addSensor(const std::string& type, const std::string& name,
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070017 std::unique_ptr<Sensor> sensor)
Patrick Venture863b9242018-03-08 08:29:23 -080018{
Patrick Venture5e929092018-06-08 10:55:23 -070019 _sensorMap[name] = std::move(sensor);
Patrick Venture863b9242018-03-08 08:29:23 -080020
Patrick Venture5e929092018-06-08 10:55:23 -070021 auto entry = _sensorTypeList.find(type);
22 if (entry == _sensorTypeList.end())
Patrick Venture863b9242018-03-08 08:29:23 -080023 {
Patrick Venture5e929092018-06-08 10:55:23 -070024 _sensorTypeList[type] = {};
Patrick Venture863b9242018-03-08 08:29:23 -080025 }
26
Patrick Venture5e929092018-06-08 10:55:23 -070027 _sensorTypeList[type].push_back(name);
Patrick Venture863b9242018-03-08 08:29:23 -080028}
Patrick Venturea0764872020-08-08 07:48:43 -070029
30} // namespace pid_control