diff --git a/src/Connection.cpp b/src/Connection.cpp index 92abf6d..2f32c1f 100644 --- a/src/Connection.cpp +++ b/src/Connection.cpp @@ -12,6 +12,13 @@ // File const values static const char CLASS_NAME[] = "Connection"; +OZMQPP::Connection::Connection(Connection&& other) : + m_connection_unique_id(other.m_connection_unique_id), + m_zmq_connection(other.m_zmq_connection) +{ + other.m_zmq_connection = nullptr; +} + OZMQPP::Connection::~Connection() { if (m_zmq_connection != nullptr) @@ -173,6 +180,15 @@ OZMQPP::Connection::ContextCloseCall() } +OZMQPP::Connection& +OZMQPP::Connection::operator=(Connection&& other) +{ + m_connection_unique_id = other.m_connection_unique_id; + m_zmq_connection = other.m_zmq_connection; + other.m_zmq_connection = nullptr; + return *this; +} + OZMQPP::Connection::Connection(uint connection_unique_id, void* raw_zmq_connection) : m_connection_unique_id (connection_unique_id), m_zmq_connection(raw_zmq_connection) diff --git a/src/Connection.hh b/src/Connection.hh index b7f44a9..0a7edcd 100644 --- a/src/Connection.hh +++ b/src/Connection.hh @@ -37,6 +37,10 @@ public: //! Connection(const Connection& other) = delete; + //! @brief Move constructor. + //! + Connection(Connection&& other); + //! @brief Class destructor. //! //! Check if contains valid raw zeromq resources to de-allocate. @@ -101,6 +105,10 @@ public: //! Connection& operator=(const Connection& other) = delete; + //! @brief Move operator overload. + //! + Connection& operator=(Connection&& other); + protected: //! @brief Friend class used to create default connection objects.