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_handler.cpp b/message_handler.cpp
index 6dadbfc..33bb195 100644
--- a/message_handler.cpp
+++ b/message_handler.cpp
@@ -42,8 +42,7 @@
void Handler::updSessionData(std::shared_ptr<Message>& inMessage)
{
- auto session = std::get<session::Manager&>(singletonPool)
- .getSession(inMessage->bmcSessionID);
+ auto session = session::Manager::get().getSession(inMessage->bmcSessionID);
sessionID = inMessage->bmcSessionID;
inMessage->rcSessionID = session->getRCSessionID();
@@ -114,8 +113,7 @@
auto command = inMessage->getCommand();
if (inMessage->payloadType == PayloadType::IPMI)
{
- auto session =
- std::get<session::Manager&>(singletonPool).getSession(sessionID);
+ auto session = session::Manager::get().getSession(sessionID);
// Process PayloadType::IPMI only if ipmi is enabled or for sessionless
// or for session establisbment command
if (this->sessionID == session::sessionZero ||
@@ -131,8 +129,8 @@
inMessage->payload.begin() + sizeof(LAN::header::Request);
auto end = inMessage->payload.end() - sizeof(LAN::trailer::Request);
std::vector<uint8_t> inPayload(start, end);
- std::get<command::Table&>(singletonPool)
- .executeCommand(command, inPayload, shared_from_this());
+ command::Table::get().executeCommand(command, inPayload,
+ shared_from_this());
}
else
{
@@ -142,8 +140,8 @@
}
else
{
- std::get<command::Table&>(singletonPool)
- .executeCommand(command, inMessage->payload, shared_from_this());
+ command::Table::get().executeCommand(command, inMessage->payload,
+ shared_from_this());
}
}
@@ -169,8 +167,7 @@
void Handler::send(std::shared_ptr<Message> outMessage)
{
- auto session =
- std::get<session::Manager&>(singletonPool).getSession(sessionID);
+ auto session = session::Manager::get().getSession(sessionID);
// Flatten the packet
auto packet = parser::flatten(outMessage, sessionHeader, session);
@@ -181,16 +178,14 @@
void Handler::setChannelInSession() const
{
- auto session =
- std::get<session::Manager&>(singletonPool).getSession(sessionID);
+ auto session = session::Manager::get().getSession(sessionID);
session->channelPtr = channel;
}
void Handler::sendSOLPayload(const std::vector<uint8_t>& input)
{
- auto session =
- std::get<session::Manager&>(singletonPool).getSession(sessionID);
+ auto session = session::Manager::get().getSession(sessionID);
auto outMessage = std::make_shared<Message>();
outMessage->payloadType = PayloadType::SOL;
@@ -206,8 +201,7 @@
void Handler::sendUnsolicitedIPMIPayload(uint8_t netfn, uint8_t cmd,
const std::vector<uint8_t>& output)
{
- auto session =
- std::get<session::Manager&>(singletonPool).getSession(sessionID);
+ auto session = session::Manager::get().getSession(sessionID);
auto outMessage = std::make_shared<Message>();
outMessage->payloadType = PayloadType::IPMI;