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/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: