replace tuple-based singleton with individual singletons
The tuple-based singletons did not actually enforce singleton behavior
and the requirement of the accessor mechanism to include all of the
member types at once was starting to cause a header prerequisite
tangle. This removes the cross-dependencies and enforces actual
singletons by making a single way to access the class.
Tested: Run ipmitool to show that behavior has not changed
Change-Id: Ie966e1142363d279365b1095066380c8383e9f9b
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
diff --git a/message_parsers.cpp b/message_parsers.cpp
index 7b8d832..4271c13 100644
--- a/message_parsers.cpp
+++ b/message_parsers.cpp
@@ -181,8 +181,7 @@
uint32_t sessionID = endian::from_ipmi(header->sessId);
- auto session =
- std::get<session::Manager&>(singletonPool).getSession(sessionID);
+ auto session = session::Manager::get().getSession(sessionID);
if (!session)
{
throw std::runtime_error("RMCP+ message from unknown session");
@@ -345,8 +344,7 @@
return false;
}
- auto session = std::get<session::Manager&>(singletonPool)
- .getSession(message->bmcSessionID);
+ auto session = session::Manager::get().getSession(message->bmcSessionID);
auto integrityAlgo = session->getIntegrityAlgo();
@@ -386,8 +384,7 @@
trailer->padLength = paddingLen;
trailer->nextHeader = parser::RMCP_MESSAGE_CLASS_IPMI;
- auto session = std::get<session::Manager&>(singletonPool)
- .getSession(message->bmcSessionID);
+ auto session = session::Manager::get().getSession(message->bmcSessionID);
auto integrityData =
session->getIntegrityAlgo()->generateIntegrityData(packet);
@@ -399,8 +396,7 @@
const std::shared_ptr<Message> message,
size_t payloadLen)
{
- auto session = std::get<session::Manager&>(singletonPool)
- .getSession(message->bmcSessionID);
+ auto session = session::Manager::get().getSession(message->bmcSessionID);
return session->getCryptAlgo()->decryptPayload(
packet, sizeof(SessionHeader_t), payloadLen);
@@ -408,8 +404,7 @@
std::vector<uint8_t> encryptPayload(std::shared_ptr<Message> message)
{
- auto session = std::get<session::Manager&>(singletonPool)
- .getSession(message->bmcSessionID);
+ auto session = session::Manager::get().getSession(message->bmcSessionID);
return session->getCryptAlgo()->encryptPayload(message->payload);
}