psusensor: Optimize the naming of some variables
Some variable declarations and parameter types use
`boost::container::flat_map`. The long type names make it difficult
for other developers to read.
This commit makes some minor optimizations, using `using` to declare
an alias to increase the readability of the code.
Tested: built psusensor successfully and works fine.
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I9b632c27fc67694d2de384f6e7c88bf66b97f78e
diff --git a/src/PSUSensorMain.cpp b/src/PSUSensorMain.cpp
index 4073d72..cf98f9b 100644
--- a/src/PSUSensorMain.cpp
+++ b/src/PSUSensorMain.cpp
@@ -131,14 +131,9 @@
static boost::container::flat_map<std::string, std::string> sensorTable;
static boost::container::flat_map<std::string, PSUProperty> labelMatch;
static boost::container::flat_map<std::string, std::string> pwmTable;
-static boost::container::flat_map<std::string, std::vector<std::string>>
- eventMatch;
-static boost::container::flat_map<
- std::string,
- boost::container::flat_map<std::string, std::vector<std::string>>>
- groupEventMatch;
-static boost::container::flat_map<std::string, std::vector<std::string>>
- limitEventMatch;
+static EventPathList eventMatch;
+static GroupEventPathList groupEventMatch;
+static EventPathList limitEventMatch;
static std::vector<PSUProperty> psuProperties;
static boost::container::flat_map<size_t, bool> cpuPresence;
@@ -147,12 +142,8 @@
// Function CheckEvent will check each attribute from eventMatch table in the
// sysfs. If the attributes exists in sysfs, then store the complete path
// of the attribute into eventPathList.
-void checkEvent(
- const std::string& directory,
- const boost::container::flat_map<std::string, std::vector<std::string>>&
- eventMatch,
- boost::container::flat_map<std::string, std::vector<std::string>>&
- eventPathList)
+void checkEvent(const std::string& directory, const EventPathList& eventMatch,
+ EventPathList& eventPathList)
{
for (const auto& match : eventMatch)
{
@@ -177,24 +168,15 @@
// Check Group Events which contains more than one targets in each combine
// events.
-void checkGroupEvent(
- const std::string& directory,
- const boost::container::flat_map<
- std::string,
- boost::container::flat_map<std::string, std::vector<std::string>>>&
- groupEventMatch,
- boost::container::flat_map<
- std::string,
- boost::container::flat_map<std::string, std::vector<std::string>>>&
- groupEventPathList)
+void checkGroupEvent(const std::string& directory,
+ const GroupEventPathList& groupEventMatch,
+ GroupEventPathList& groupEventPathList)
{
for (const auto& match : groupEventMatch)
{
const std::string& groupEventName = match.first;
- const boost::container::flat_map<std::string, std::vector<std::string>>
- events = match.second;
- boost::container::flat_map<std::string, std::vector<std::string>>
- pathList;
+ const EventPathList events = match.second;
+ EventPathList pathList;
for (const auto& match : events)
{
const std::string& eventName = match.first;
@@ -221,12 +203,9 @@
// in sysfs to see if xxx_crit_alarm xxx_lcrit_alarm xxx_max_alarm
// xxx_min_alarm exist, then store the existing paths of the alarm attributes
// to eventPathList.
-void checkEventLimits(
- const std::string& sensorPathStr,
- const boost::container::flat_map<std::string, std::vector<std::string>>&
- limitEventMatch,
- boost::container::flat_map<std::string, std::vector<std::string>>&
- eventPathList)
+void checkEventLimits(const std::string& sensorPathStr,
+ const EventPathList& limitEventMatch,
+ EventPathList& eventPathList)
{
auto attributePartPos = sensorPathStr.find_last_of('_');
if (attributePartPos == std::string::npos)
@@ -328,12 +307,8 @@
boost::container::flat_set<std::string> directories;
for (const auto& pmbusPath : pmbusPaths)
{
- boost::container::flat_map<std::string, std::vector<std::string>>
- eventPathList;
- boost::container::flat_map<
- std::string,
- boost::container::flat_map<std::string, std::vector<std::string>>>
- groupEventPathList;
+ EventPathList eventPathList;
+ GroupEventPathList groupEventPathList;
std::ifstream nameFile(pmbusPath);
if (!nameFile.good())