Make SessionStore a proper singleton

- SessionStore class now has a proper singleton structure
- session_storage_singleton.hpp is removed
- from_json(..) function for SessionStore is changed to a specialized
template
- minor cosmetic fixes added
- Move the template class usages of Crow App over to a non-template 
parameter


Change-Id: Ic9effd5b7bac089a84c80a0caa97bd46d4984416
Signed-off-by: Borawski.Lukasz <lukasz.borawski@intel.com>
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp
index 48872f8..9071067 100644
--- a/redfish-core/lib/account_service.hpp
+++ b/redfish-core/lib/account_service.hpp
@@ -21,7 +21,6 @@
 
 class AccountService : public Node {
  public:
-  template <typename CrowApp>
   AccountService(CrowApp& app) : Node(app, "/redfish/v1/AccountService/") {
     Node::json["@odata.id"] = "/redfish/v1/AccountService";
     Node::json["@odata.type"] = "#AccountService.v1_1_0.AccountService";
@@ -37,7 +36,8 @@
     Node::json["Roles"]["@odata.id"] = "/redfish/v1/AccountService/Roles";
 
     entityPrivileges = {
-        {boost::beast::http::verb::get, {{"ConfigureUsers"}, {"ConfigureManager"}}},
+        {boost::beast::http::verb::get,
+         {{"ConfigureUsers"}, {"ConfigureManager"}}},
         {boost::beast::http::verb::head, {{"Login"}}},
         {boost::beast::http::verb::patch, {{"ConfigureUsers"}}},
         {boost::beast::http::verb::put, {{"ConfigureUsers"}}},
diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp
index 5cf667a..ef3b7af 100644
--- a/redfish-core/lib/chassis.hpp
+++ b/redfish-core/lib/chassis.hpp
@@ -100,7 +100,6 @@
  */
 class ChassisCollection : public Node {
  public:
-  template <typename CrowApp>
   ChassisCollection(CrowApp &app) : Node(app, "/redfish/v1/Chassis/") {
     Node::json["@odata.type"] = "#ChassisCollection.ChassisCollection";
     Node::json["@odata.id"] = "/redfish/v1/Chassis";
@@ -155,10 +154,6 @@
  */
 class Chassis : public Node {
  public:
-  /*
-   * Default Constructor
-   */
-  template <typename CrowApp>
   Chassis(CrowApp &app)
       : Node(app, "/redfish/v1/Chassis/<str>/", std::string()) {
     Node::json["@odata.type"] = "#Chassis.v1_4_0.Chassis";
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index 32b697a..3bbcff4 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -737,7 +737,6 @@
  */
 class EthernetCollection : public Node {
  public:
-  template <typename CrowApp>
   // TODO(Pawel) Remove line from below, where we assume that there is only one
   // manager called openbmc This shall be generic, but requires to update
   // GetSubroutes method
@@ -809,7 +808,6 @@
   /*
    * Default Constructor
    */
-  template <typename CrowApp>
   // TODO(Pawel) Remove line from below, where we assume that there is only one
   // manager called openbmc This shall be generic, but requires to update
   // GetSubroutes method
diff --git a/redfish-core/lib/network_protocol.hpp b/redfish-core/lib/network_protocol.hpp
index 438de41..d7bf101 100644
--- a/redfish-core/lib/network_protocol.hpp
+++ b/redfish-core/lib/network_protocol.hpp
@@ -22,8 +22,7 @@
 class NetworkProtocol : public Node {
  public:
   NetworkProtocol(CrowApp& app)
-      : Node(app,
-             "/redfish/v1/Managers/openbmc/NetworkProtocol") {
+      : Node(app, "/redfish/v1/Managers/openbmc/NetworkProtocol") {
     Node::json["@odata.type"] =
         "#ManagerNetworkProtocol.v1_1_0.ManagerNetworkProtocol";
     Node::json["@odata.id"] = "/redfish/v1/Managers/openbmc/NetworkProtocol";
@@ -36,12 +35,13 @@
     Node::json["Status"]["HealthRollup"] = "OK";
     Node::json["Status"]["State"] = "Enabled";
 
-    entityPrivileges = {{boost::beast::http::verb::get, {{"Login"}}},
-                        {boost::beast::http::verb::head, {{"Login"}}},
-                        {boost::beast::http::verb::patch, {{"ConfigureManager"}}},
-                        {boost::beast::http::verb::put, {{"ConfigureManager"}}},
-                        {boost::beast::http::verb::delete_, {{"ConfigureManager"}}},
-                        {boost::beast::http::verb::post, {{"ConfigureManager"}}}};
+    entityPrivileges = {
+        {boost::beast::http::verb::get, {{"Login"}}},
+        {boost::beast::http::verb::head, {{"Login"}}},
+        {boost::beast::http::verb::patch, {{"ConfigureManager"}}},
+        {boost::beast::http::verb::put, {{"ConfigureManager"}}},
+        {boost::beast::http::verb::delete_, {{"ConfigureManager"}}},
+        {boost::beast::http::verb::post, {{"ConfigureManager"}}}};
   }
 
  private:
diff --git a/redfish-core/lib/redfish_sessions.hpp b/redfish-core/lib/redfish_sessions.hpp
index 7de6d3b..9e793df 100644
--- a/redfish-core/lib/redfish_sessions.hpp
+++ b/redfish-core/lib/redfish_sessions.hpp
@@ -17,7 +17,7 @@
 
 #include "error_messages.hpp"
 #include "node.hpp"
-#include "session_storage_singleton.hpp"
+#include "persistent_data_middleware.hpp"
 
 namespace redfish {
 
@@ -45,7 +45,8 @@
   void doGet(crow::response& res, const crow::request& req,
              const std::vector<std::string>& params) override {
     auto session =
-        crow::PersistentData::session_store->get_session_by_uid(params[0]);
+        crow::PersistentData::SessionStore::getInstance().get_session_by_uid(
+            params[0]);
 
     if (session == nullptr) {
       messages::addMessageToErrorJson(
@@ -81,7 +82,8 @@
     }
 
     auto session =
-        crow::PersistentData::session_store->get_session_by_uid(params[0]);
+        crow::PersistentData::SessionStore::getInstance().get_session_by_uid(
+            params[0]);
 
     if (session == nullptr) {
       messages::addMessageToErrorJson(
@@ -95,7 +97,7 @@
     // DELETE should return representation of object that will be removed
     doGet(res, req, params);
 
-    crow::PersistentData::session_store->remove_session(session);
+    crow::PersistentData::SessionStore::getInstance().remove_session(session);
   }
 
   /**
@@ -132,7 +134,7 @@
   void doGet(crow::response& res, const crow::request& req,
              const std::vector<std::string>& params) override {
     std::vector<const std::string*> session_ids =
-        crow::PersistentData::session_store->get_unique_ids(
+        crow::PersistentData::SessionStore::getInstance().get_unique_ids(
             false, crow::PersistentData::PersistenceType::TIMEOUT);
 
     Node::json["Members@odata.count"] = session_ids.size();
@@ -161,7 +163,8 @@
 
     // User is authenticated - create session for him
     auto session =
-        crow::PersistentData::session_store->generate_user_session(username);
+        crow::PersistentData::SessionStore::getInstance().generate_user_session(
+            username);
     res.add_header("X-Auth-Token", session->session_token);
 
     // Return data for created session
@@ -301,7 +304,8 @@
     Node::json["Id"] = "SessionService";
     Node::json["Description"] = "Session Service";
     Node::json["SessionTimeout"] =
-        crow::PersistentData::session_store->get_timeout_in_seconds();
+        crow::PersistentData::SessionStore::getInstance()
+            .get_timeout_in_seconds();
     Node::json["ServiceEnabled"] = true;
 
     entityPrivileges = {