diff --git a/doorlockd/lib/clientmessage.cpp b/doorlockd/lib/clientmessage.cpp index d6321cd..b4629ae 100644 --- a/doorlockd/lib/clientmessage.cpp +++ b/doorlockd/lib/clientmessage.cpp @@ -17,6 +17,27 @@ Clientmessage::Clientmessage(std::string token, { } +Clientmessage::Clientmessage() : + _token(), + _isOpen(false), + _doormessage() +{ +} + +Clientmessage &Clientmessage::operator=(const Clientmessage &rhs) +{ + // Protect against self assignement + if (this == &rhs) { + return *this; + } + + this->_token = rhs._token; + this->_isOpen = rhs._isOpen; + this->_doormessage = rhs._doormessage; + + return *this; +} + std::string Clientmessage::toJson() const { Json::StyledWriter writer; diff --git a/doorlockd/lib/clientmessage.h b/doorlockd/lib/clientmessage.h index 2dc643c..33d36ff 100644 --- a/doorlockd/lib/clientmessage.h +++ b/doorlockd/lib/clientmessage.h @@ -13,6 +13,9 @@ public: Clientmessage(std::string token, bool isOpen, Doormessage doormessage); + Clientmessage(); + + Clientmessage &operator=(const Clientmessage& rhs); static Clientmessage fromJson(const Json::Value &root); static Clientmessage fromString(const std::string &json); @@ -24,11 +27,11 @@ public: private: - const std::string _token; - const bool _isOpen; - const Doormessage _doormessage; + std::string _token; + bool _isOpen; + Doormessage _doormessage; - static const std::string _tokenKey; + const static std::string _tokenKey; const static std::string _unlockButtonKey; const static std::string _lockButtonKey; const static std::string _emergencyUnlockKey;