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/open_session.cpp b/command/open_session.cpp
index 9ba00ec..2887d37 100644
--- a/command/open_session.cpp
+++ b/command/open_session.cpp
@@ -2,7 +2,7 @@
 
 #include "comm_module.hpp"
 #include "endian.hpp"
-#include "main.hpp"
+#include "sessions_manager.hpp"
 
 #include <phosphor-logging/log.hpp>
 
@@ -77,15 +77,11 @@
     try
     {
         // Start an IPMI session
-        session =
-            std::get<session::Manager&>(singletonPool)
-                .startSession(
-                    endian::from_ipmi<>(request->remoteConsoleSessionID), priv,
-                    static_cast<cipher::rakp_auth::Algorithms>(
-                        request->authAlgo),
-                    static_cast<cipher::integrity::Algorithms>(
-                        request->intAlgo),
-                    static_cast<cipher::crypt::Algorithms>(request->confAlgo));
+        session = session::Manager::get().startSession(
+            endian::from_ipmi<>(request->remoteConsoleSessionID), priv,
+            static_cast<cipher::rakp_auth::Algorithms>(request->authAlgo),
+            static_cast<cipher::integrity::Algorithms>(request->intAlgo),
+            static_cast<cipher::crypt::Algorithms>(request->confAlgo));
     }
     catch (std::exception& e)
     {
diff --git a/command/payload_cmds.cpp b/command/payload_cmds.cpp
index bc987c5..ecb86e7 100644
--- a/command/payload_cmds.cpp
+++ b/command/payload_cmds.cpp
@@ -1,6 +1,6 @@
 #include "payload_cmds.hpp"
 
-#include "main.hpp"
+#include "sessions_manager.hpp"
 #include "sol/sol_manager.hpp"
 #include "sol_cmds.hpp"
 
@@ -41,10 +41,9 @@
         return outPayload;
     }
 
-    std::get<sol::Manager&>(singletonPool)
-        .updateSOLParameter(ipmi::convertCurrentChannelNum(
-            ipmi::currentChNum, getInterfaceIndex()));
-    if (!std::get<sol::Manager&>(singletonPool).enable)
+    sol::Manager::get().updateSOLParameter(ipmi::convertCurrentChannelNum(
+        ipmi::currentChNum, getInterfaceIndex()));
+    if (!sol::Manager::get().enable)
     {
         response->completionCode = IPMI_CC_PAYLOAD_TYPE_DISABLED;
         return outPayload;
@@ -57,8 +56,7 @@
         return outPayload;
     }
 
-    auto session = std::get<session::Manager&>(singletonPool)
-                       .getSession(handler.sessionID);
+    auto session = session::Manager::get().getSession(handler.sessionID);
 
     if (!request->encryption && session->isCryptAlgoEnabled())
     {
@@ -78,8 +76,7 @@
         return outPayload;
     }
 
-    auto status = std::get<sol::Manager&>(singletonPool)
-                      .isPayloadActive(request->payloadInstance);
+    auto status = sol::Manager::get().isPayloadActive(request->payloadInstance);
     if (status)
     {
         response->completionCode = IPMI_CC_PAYLOAD_ALREADY_ACTIVE;
@@ -92,8 +89,8 @@
     // Start the SOL payload
     try
     {
-        std::get<sol::Manager&>(singletonPool)
-            .startPayloadInstance(request->payloadInstance, handler.sessionID);
+        sol::Manager::get().startPayloadInstance(request->payloadInstance,
+                                                 handler.sessionID);
     }
     catch (std::exception& e)
     {
@@ -142,8 +139,7 @@
         return outPayload;
     }
 
-    auto status = std::get<sol::Manager&>(singletonPool)
-                      .isPayloadActive(request->payloadInstance);
+    auto status = sol::Manager::get().isPayloadActive(request->payloadInstance);
     if (!status)
     {
         response->completionCode = IPMI_CC_PAYLOAD_DEACTIVATED;
@@ -152,12 +148,11 @@
 
     try
     {
-        auto& context = std::get<sol::Manager&>(singletonPool)
-                            .getContext(request->payloadInstance);
+        auto& context =
+            sol::Manager::get().getContext(request->payloadInstance);
         auto sessionID = context.sessionID;
 
-        std::get<sol::Manager&>(singletonPool)
-            .stopPayloadInstance(request->payloadInstance);
+        sol::Manager::get().stopPayloadInstance(request->payloadInstance);
 
         try
         {
@@ -213,8 +208,7 @@
     response->capacity = maxSolPayloadInstances;
 
     // Currently we support only one SOL session
-    response->instance1 =
-        std::get<sol::Manager&>(singletonPool).isPayloadActive(1);
+    response->instance1 = sol::Manager::get().isPayloadActive(1);
 
     return outPayload;
 }
@@ -244,13 +238,12 @@
         response->completionCode = IPMI_CC_INVALID_FIELD_REQUEST;
         return outPayload;
     }
-    auto status = std::get<sol::Manager&>(singletonPool)
-                      .isPayloadActive(request->payloadInstance);
+    auto status = sol::Manager::get().isPayloadActive(request->payloadInstance);
 
     if (status)
     {
-        auto& context = std::get<sol::Manager&>(singletonPool)
-                            .getContext(request->payloadInstance);
+        auto& context =
+            sol::Manager::get().getContext(request->payloadInstance);
         response->sessionID = context.sessionID;
     }
     else
diff --git a/command/rakp12.cpp b/command/rakp12.cpp
index 099c5dc..7d349c6 100644
--- a/command/rakp12.cpp
+++ b/command/rakp12.cpp
@@ -3,7 +3,7 @@
 #include "comm_module.hpp"
 #include "endian.hpp"
 #include "guid.hpp"
-#include "main.hpp"
+#include "sessions_manager.hpp"
 
 #include <openssl/rand.h>
 
@@ -50,9 +50,8 @@
     std::shared_ptr<session::Session> session;
     try
     {
-        session =
-            std::get<session::Manager&>(singletonPool)
-                .getSession(endian::from_ipmi(request->managedSystemSessionID));
+        session = session::Manager::get().getSession(
+            endian::from_ipmi(request->managedSystemSessionID));
     }
     catch (std::exception& e)
     {
diff --git a/command/rakp34.cpp b/command/rakp34.cpp
index b106b6f..a8ad86a 100644
--- a/command/rakp34.cpp
+++ b/command/rakp34.cpp
@@ -3,8 +3,8 @@
 #include "comm_module.hpp"
 #include "endian.hpp"
 #include "guid.hpp"
-#include "main.hpp"
 #include "rmcp.hpp"
+#include "sessions_manager.hpp"
 
 #include <algorithm>
 #include <cstring>
@@ -17,8 +17,7 @@
 
 void applyIntegrityAlgo(const uint32_t bmcSessionID)
 {
-    auto session =
-        std::get<session::Manager&>(singletonPool).getSession(bmcSessionID);
+    auto session = session::Manager::get().getSession(bmcSessionID);
 
     auto authAlgo = session->getAuthAlgo();
 
@@ -45,8 +44,7 @@
 
 void applyCryptAlgo(const uint32_t bmcSessionID)
 {
-    auto session =
-        std::get<session::Manager&>(singletonPool).getSession(bmcSessionID);
+    auto session = session::Manager::get().getSession(bmcSessionID);
 
     auto authAlgo = session->getAuthAlgo();
 
@@ -97,8 +95,7 @@
     try
     {
         session =
-            std::get<session::Manager&>(singletonPool)
-                .getSession(endian::from_ipmi(request->managedSystemSessionID));
+            session::Manager::get().getSession(request->managedSystemSessionID);
     }
     catch (std::exception& e)
     {
@@ -174,8 +171,7 @@
         response->remoteConsoleSessionID = rcSessionID;
 
         // close the session
-        std::get<session::Manager&>(singletonPool)
-            .stopSession(session->getBMCSessionID());
+        session::Manager::get().stopSession(session->getBMCSessionID());
 
         return outPayload;
     }
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
     {
diff --git a/command/sol_cmds.cpp b/command/sol_cmds.cpp
index a1e820f..1253ac5 100644
--- a/command/sol_cmds.cpp
+++ b/command/sol_cmds.cpp
@@ -1,6 +1,6 @@
 #include "sol_cmds.hpp"
 
-#include "main.hpp"
+#include "sessions_manager.hpp"
 #include "sol/sol_context.hpp"
 #include "sol/sol_manager.hpp"
 
@@ -35,8 +35,7 @@
 
     try
     {
-        auto& context = std::get<sol::Manager&>(singletonPool)
-                            .getContext(handler.sessionID);
+        auto& context = sol::Manager::get().getContext(handler.sessionID);
 
         context.processInboundPayload(
             request->packetSeqNum, request->packetAckSeqNum,
@@ -62,8 +61,7 @@
     request->majorVersion = MAJOR_VERSION;
     request->minorVersion = MINOR_VERSION;
 
-    auto session =
-        std::get<session::Manager&>(singletonPool).getSession(sessionID);
+    auto session = session::Manager::get().getSession(sessionID);
 
     message::Handler msgHandler(session->channelPtr, sessionID);
 
@@ -90,23 +88,22 @@
     {
         case Parameter::PROGRESS:
         {
-            outPayload.push_back(
-                std::get<sol::Manager&>(singletonPool).progress);
+            outPayload.push_back(sol::Manager::get().progress);
             break;
         }
         case Parameter::ENABLE:
         {
-            outPayload.push_back(std::get<sol::Manager&>(singletonPool).enable);
+            outPayload.push_back(sol::Manager::get().enable);
             break;
         }
         case Parameter::AUTHENTICATION:
         {
             Auth value{0};
 
-            value.encrypt = std::get<sol::Manager&>(singletonPool).forceEncrypt;
-            value.auth = std::get<sol::Manager&>(singletonPool).forceAuth;
-            value.privilege = static_cast<uint8_t>(
-                std::get<sol::Manager&>(singletonPool).solMinPrivilege);
+            value.encrypt = sol::Manager::get().forceEncrypt;
+            value.auth = sol::Manager::get().forceAuth;
+            value.privilege =
+                static_cast<uint8_t>(sol::Manager::get().solMinPrivilege);
             auto buffer = reinterpret_cast<const uint8_t*>(&value);
 
             std::copy_n(buffer, sizeof(value), std::back_inserter(outPayload));
@@ -116,11 +113,9 @@
         {
             Accumulate value{0};
 
-            value.interval = std::get<sol::Manager&>(singletonPool)
-                                 .accumulateInterval.count() /
+            value.interval = sol::Manager::get().accumulateInterval.count() /
                              sol::accIntervalFactor;
-            value.threshold =
-                std::get<sol::Manager&>(singletonPool).sendThreshold;
+            value.threshold = sol::Manager::get().sendThreshold;
             auto buffer = reinterpret_cast<const uint8_t*>(&value);
 
             std::copy_n(buffer, sizeof(value), std::back_inserter(outPayload));
@@ -130,10 +125,9 @@
         {
             Retry value{0};
 
-            value.count = std::get<sol::Manager&>(singletonPool).retryCount;
-            value.interval =
-                std::get<sol::Manager&>(singletonPool).retryInterval.count() /
-                sol::retryIntervalFactor;
+            value.count = sol::Manager::get().retryCount;
+            value.interval = sol::Manager::get().retryInterval.count() /
+                             sol::retryIntervalFactor;
             auto buffer = reinterpret_cast<const uint8_t*>(&value);
 
             std::copy_n(buffer, sizeof(value), std::back_inserter(outPayload));
@@ -149,8 +143,7 @@
         }
         case Parameter::CHANNEL:
         {
-            outPayload.push_back(
-                std::get<sol::Manager&>(singletonPool).channel);
+            outPayload.push_back(sol::Manager::get().channel);
             break;
         }
         case Parameter::NVBITRATE: