Use a real struct
There's no usage of these structures as a tuple, and get<0> isn't very
descriptive. Replace them with a struct.
Change-Id: I7705a14fe1486c9398fd4bbc426f3c8208060c8e
Signed-off-by: Ed Tanous <edtanous@google.com>
diff --git a/snmp_notification.cpp b/snmp_notification.cpp
index cf1aa69..9953038 100644
--- a/snmp_notification.cpp
+++ b/snmp_notification.cpp
@@ -134,8 +134,8 @@
for (const auto& object : objectList)
{
- if (!addPDUVar(*pdu, std::get<0>(object), std::get<1>(object),
- std::get<2>(object), std::get<3>(object)))
+ if (!addPDUVar(*pdu, object.oid, object.oid_len, object.type,
+ object.value))
{
lg2::error("Failed to add the SNMP var");
snmp_free_pdu(pdu);
diff --git a/snmp_notification.hpp b/snmp_notification.hpp
index b48bc78..7477895 100644
--- a/snmp_notification.hpp
+++ b/snmp_notification.hpp
@@ -35,7 +35,6 @@
#include <sstream>
#include <string>
-#include <tuple>
#include <vector>
namespace phosphor
@@ -54,7 +53,13 @@
oid SNMPTrapOID[] = {1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0};
oid sysuptimeOID[] = {1, 3, 6, 1, 2, 1, 1, 3, 0};
-using Object = std::tuple<OID, OID_LEN, Type, Value>;
+struct Object
+{
+ OID oid;
+ OID_LEN oid_len;
+ Type type;
+ Value value;
+};
/** @brief Get the ASN object type from the given templatized type.
* Specialize this template for handling a specific type.
diff --git a/test/test_error_notification.cpp b/test/test_error_notification.cpp
index bfcf8e9..5bf72d5 100644
--- a/test/test_error_notification.cpp
+++ b/test/test_error_notification.cpp
@@ -35,11 +35,11 @@
EXPECT_EQ(ERROR_NOTIF_FIELD_COUNT, oidList.size());
// Verify the type of each field.
- EXPECT_EQ(ASN_UNSIGNED, std::get<Type>(oidList[0]));
+ EXPECT_EQ(ASN_UNSIGNED, oidList[0].type);
- EXPECT_EQ(ASN_OPAQUE_U64, std::get<Type>(oidList[1]));
- EXPECT_EQ(ASN_INTEGER, std::get<Type>(oidList[2]));
- EXPECT_EQ(ASN_OCTET_STR, std::get<Type>(oidList[3]));
+ EXPECT_EQ(ASN_OPAQUE_U64, oidList[1].type);
+ EXPECT_EQ(ASN_INTEGER, oidList[2].type);
+ EXPECT_EQ(ASN_OCTET_STR, oidList[3].type);
}
TEST_F(TestErrorNotification, GetASNType)