Use SensorBaseConfigMap where applicable
If we've got a more concise, descriptive name for it, we might as well
use it.
Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Change-Id: Id2f1bd8f983b4e0c2ca24b24c9fc9b875f4191f5
diff --git a/include/CPUSensor.hpp b/include/CPUSensor.hpp
index 1a98035..f97c71c 100644
--- a/include/CPUSensor.hpp
+++ b/include/CPUSensor.hpp
@@ -58,8 +58,7 @@
// this is added to cpusensor.hpp to avoid having every sensor have to link
// against libgpiod, if another sensor needs it we may move it to utils
-inline bool cpuIsPresent(
- const boost::container::flat_map<std::string, BasicVariantType>& gpioConfig)
+inline bool cpuIsPresent(const SensorBaseConfigMap& gpioConfig)
{
static boost::container::flat_map<std::string, bool> cpuPresence;
diff --git a/include/Utils.hpp b/include/Utils.hpp
index 8fc5e80..92a8b6f 100644
--- a/include/Utils.hpp
+++ b/include/Utils.hpp
@@ -127,9 +127,7 @@
} // namespace association
template <typename T>
-inline T loadVariant(
- const boost::container::flat_map<std::string, BasicVariantType>& data,
- const std::string& key)
+inline T loadVariant(const SensorBaseConfigMap& data, const std::string& key)
{
auto it = data.find(key);
if (it == data.end())
@@ -213,10 +211,8 @@
std::shared_ptr<GetSensorConfiguration> self = shared_from_this();
self->dbusConnection->async_method_call(
- [self, path, interface, owner,
- retries](const boost::system::error_code ec,
- boost::container::flat_map<std::string, BasicVariantType>&
- data) {
+ [self, path, interface, owner, retries](
+ const boost::system::error_code ec, SensorBaseConfigMap& data) {
if (ec)
{
std::cerr << "Error getting " << path << ": retries left"
diff --git a/src/ADCSensorMain.cpp b/src/ADCSensorMain.cpp
index ef9ef44..cec0984 100644
--- a/src/ADCSensorMain.cpp
+++ b/src/ADCSensorMain.cpp
@@ -111,8 +111,7 @@
const SensorData* sensorData = nullptr;
const std::string* interfacePath = nullptr;
- const std::pair<std::string, boost::container::flat_map<
- std::string, BasicVariantType>>*
+ const std::pair<std::string, SensorBaseConfigMap>*
baseConfiguration = nullptr;
for (const std::pair<sdbusplus::message::object_path, SensorData>&
sensor : sensorConfigurations)
diff --git a/src/ExitAirTempSensor.cpp b/src/ExitAirTempSensor.cpp
index 67c690f..8f4f76b 100644
--- a/src/ExitAirTempSensor.cpp
+++ b/src/ExitAirTempSensor.cpp
@@ -300,10 +300,8 @@
{
std::weak_ptr<CFMSensor> weakRef = weak_from_this();
dbusConnection->async_method_call(
- [weakRef,
- path](const boost::system::error_code ec,
- const boost::container::flat_map<std::string, BasicVariantType>&
- data) {
+ [weakRef, path](const boost::system::error_code ec,
+ const SensorBaseConfigMap& data) {
if (ec)
{
std::cerr << "Error getting properties from " << path << "\n";
@@ -838,9 +836,9 @@
thresholds::checkThresholds(this);
}
-static void loadVariantPathArray(
- const boost::container::flat_map<std::string, BasicVariantType>& data,
- const std::string& key, std::vector<std::string>& resp)
+static void loadVariantPathArray(const SensorBaseConfigMap& data,
+ const std::string& key,
+ std::vector<std::string>& resp)
{
auto it = data.find(key);
if (it == data.end())
diff --git a/src/IntrusionSensorMain.cpp b/src/IntrusionSensorMain.cpp
index c4c4cd8..5d2b666 100644
--- a/src/IntrusionSensorMain.cpp
+++ b/src/IntrusionSensorMain.cpp
@@ -68,9 +68,8 @@
}
const SensorData* sensorData = nullptr;
- const std::pair<std::string,
- boost::container::flat_map<std::string, BasicVariantType>>*
- baseConfiguration = nullptr;
+ const std::pair<std::string, SensorBaseConfigMap>* baseConfiguration =
+ nullptr;
// Get bus and addr of matched configuration
for (const std::pair<sdbusplus::message::object_path, SensorData>& sensor :
@@ -182,50 +181,49 @@
const std::shared_ptr<sdbusplus::asio::connection>& dbusConnection)
{
auto getter = std::make_shared<GetSensorConfiguration>(
- dbusConnection,
- [](const ManagedObjectType& sensorConfigurations) {
- // Get NIC name and save to map
- lanInfoMap.clear();
- for (const std::pair<sdbusplus::message::object_path, SensorData>&
- sensor : sensorConfigurations)
- {
- const std::pair<std::string, boost::container::flat_map<
- std::string, BasicVariantType>>*
- baseConfiguration = nullptr;
-
- // find base configuration
- auto sensorBase = sensor.second.find(nicType);
- if (sensorBase == sensor.second.end())
+ dbusConnection, [](const ManagedObjectType& sensorConfigurations) {
+ // Get NIC name and save to map
+ lanInfoMap.clear();
+ for (const std::pair<sdbusplus::message::object_path, SensorData>&
+ sensor : sensorConfigurations)
{
- continue;
- }
- baseConfiguration = &(*sensorBase);
+ const std::pair<std::string, SensorBaseConfigMap>*
+ baseConfiguration = nullptr;
- auto findEthIndex = baseConfiguration->second.find("EthIndex");
- auto findName = baseConfiguration->second.find("Name");
-
- if (findEthIndex != baseConfiguration->second.end() &&
- findName != baseConfiguration->second.end())
- {
- const auto* pEthIndex =
- std::get_if<uint64_t>(&findEthIndex->second);
- const auto* pName = std::get_if<std::string>(&findName->second);
- if (pEthIndex != nullptr && pName != nullptr)
+ // find base configuration
+ auto sensorBase = sensor.second.find(nicType);
+ if (sensorBase == sensor.second.end())
{
- lanInfoMap[*pEthIndex] = *pName;
- if (debugLanLeash)
+ continue;
+ }
+ baseConfiguration = &(*sensorBase);
+
+ auto findEthIndex = baseConfiguration->second.find("EthIndex");
+ auto findName = baseConfiguration->second.find("Name");
+
+ if (findEthIndex != baseConfiguration->second.end() &&
+ findName != baseConfiguration->second.end())
+ {
+ const auto* pEthIndex =
+ std::get_if<uint64_t>(&findEthIndex->second);
+ const auto* pName =
+ std::get_if<std::string>(&findName->second);
+ if (pEthIndex != nullptr && pName != nullptr)
{
- std::cout << "find name of eth" << *pEthIndex << " is "
- << *pName << "\n";
+ lanInfoMap[*pEthIndex] = *pName;
+ if (debugLanLeash)
+ {
+ std::cout << "find name of eth" << *pEthIndex
+ << " is " << *pName << "\n";
+ }
}
}
}
- }
- if (lanInfoMap.empty())
- {
- std::cerr << "can't find matched NIC name. \n";
- }
+ if (lanInfoMap.empty())
+ {
+ std::cerr << "can't find matched NIC name. \n";
+ }
});
getter->getConfiguration(
@@ -236,7 +234,7 @@
{
const std::string& pathName = message.get_path();
std::string interfaceName;
- boost::container::flat_map<std::string, BasicVariantType> properties;
+ SensorBaseConfigMap properties;
message.read(interfaceName, properties);
auto findStateProperty = properties.find("OperationalState");
diff --git a/src/PSUSensorMain.cpp b/src/PSUSensorMain.cpp
index c710b4d..1683e39 100644
--- a/src/PSUSensorMain.cpp
+++ b/src/PSUSensorMain.cpp
@@ -377,8 +377,7 @@
continue;
}
- const std::pair<std::string, boost::container::flat_map<
- std::string, BasicVariantType>>*
+ const std::pair<std::string, SensorBaseConfigMap>*
baseConfig = nullptr;
const SensorData* sensorData = nullptr;
const std::string* interfacePath = nullptr;
diff --git a/src/Thresholds.cpp b/src/Thresholds.cpp
index ff452bc..ae7718e 100644
--- a/src/Thresholds.cpp
+++ b/src/Thresholds.cpp
@@ -136,10 +136,9 @@
std::string thresholdInterface =
baseInterface + ".Thresholds" + std::to_string(ii);
conn->async_method_call(
- [&, path, threshold, thresholdInterface, labelMatch](
- const boost::system::error_code& ec,
- const boost::container::flat_map<std::string, BasicVariantType>&
- result) {
+ [&, path, threshold, thresholdInterface,
+ labelMatch](const boost::system::error_code& ec,
+ const SensorBaseConfigMap& result) {
if (ec)
{
return; // threshold not supported