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/command/session_cmds.cpp b/command/session_cmds.cpp
index 98016c9..84c6e85 100644
--- a/command/session_cmds.cpp
+++ b/command/session_cmds.cpp
@@ -1,7 +1,7 @@
#include "session_cmds.hpp"
#include "endian.hpp"
-#include "main.hpp"
+#include "sessions_manager.hpp"
#include <ipmid/api.h>
@@ -34,8 +34,7 @@
response->completionCode = IPMI_CC_OK;
uint8_t reqPrivilegeLevel = request->reqPrivLevel;
- auto session = std::get<session::Manager&>(singletonPool)
- .getSession(handler.sessionID);
+ auto session = session::Manager::get().getSession(handler.sessionID);
if (reqPrivilegeLevel == 0) // Just return present privilege level
{
@@ -176,10 +175,8 @@
{
if (reqSessionId == session::sessionZero)
{
- reqSessionId = std::get<session::Manager&>(singletonPool)
- .getSessionIDbyHandle(
- reqSessionHandle &
- session::multiIntfaceSessionHandleMask);
+ reqSessionId = session::Manager::get().getSessionIDbyHandle(
+ reqSessionHandle & session::multiIntfaceSessionHandleMask);
if (!reqSessionId)
{
return session::ccInvalidSessionHandle;
@@ -187,15 +184,14 @@
}
auto closeSessionInstance =
- std::get<session::Manager&>(singletonPool).getSession(reqSessionId);
+ session::Manager::get().getSession(reqSessionId);
uint8_t closeSessionPriv = closeSessionInstance->currentPrivilege();
if (currentSessionPriv < closeSessionPriv)
{
return ipmi::ccInsufficientPrivilege;
}
- status = std::get<session::Manager&>(singletonPool)
- .stopSession(reqSessionId);
+ status = session::Manager::get().stopSession(reqSessionId);
if (!status)
{
@@ -262,10 +258,9 @@
try
{
- ipmiNetworkInstance =
- std::get<session::Manager&>(singletonPool).getNetworkInstance();
- auto currentSession = std::get<session::Manager&>(singletonPool)
- .getSession(handler.sessionID);
+ ipmiNetworkInstance = session::Manager::get().getNetworkInstance();
+ auto currentSession =
+ session::Manager::get().getSession(handler.sessionID);
currentSessionPriv = currentSession->currentPrivilege();
}
catch (sdbusplus::exception::SdBusError& e)
@@ -285,8 +280,7 @@
{
response->completionCode = closeMyNetInstanceSession(
reqSessionId, reqSessionHandle, currentSessionPriv);
- std::get<session::Manager&>(singletonPool)
- .scheduleSessionCleaner(100us);
+ session::Manager::get().scheduleSessionCleaner(100us);
}
else
{