Move UserSubscription to composition
This allows for two very important simplifying changes. First, we can
use the default copy operators on the UserSubscription class, which is
far less error prone than writing it manually, which we have two copies
of in code already.
Second, it allows the Subscription class to move to using values rather
than shared_ptr everywhere, which cleans up a significant amount of
code.
Tested:
Ran Redfish-Event-Listener, subscription created and destroyed
correctly.
Calling POST SubmitTestEvent showed events propagating to server.
Change-Id: I6d258cfe3594edddf3960ae2d4559d70acca1bf8
Signed-off-by: Ed Tanous <ed@tanous.net>
diff --git a/http/http_client.hpp b/http/http_client.hpp
index 0df0656..546d92c 100644
--- a/http/http_client.hpp
+++ b/http/http_client.hpp
@@ -848,7 +848,9 @@
private:
std::unordered_map<std::string, std::shared_ptr<ConnectionPool>>
connectionPools;
- boost::asio::io_context& ioc;
+
+ // reference_wrapper here makes HttpClient movable
+ std::reference_wrapper<boost::asio::io_context> ioc;
std::shared_ptr<ConnectionPolicy> connPolicy;
// Used as a dummy callback by sendData() in order to call
@@ -868,8 +870,8 @@
HttpClient(const HttpClient&) = delete;
HttpClient& operator=(const HttpClient&) = delete;
- HttpClient(HttpClient&&) = delete;
- HttpClient& operator=(HttpClient&&) = delete;
+ HttpClient(HttpClient&& client) = default;
+ HttpClient& operator=(HttpClient&& client) = default;
~HttpClient() = default;
// Send a request to destIP where additional processing of the