1
0
mirror of https://github.com/binary-kitchen/doorlockd synced 2024-12-22 18:34:25 +01:00

Improved Clientmessage

This commit is contained in:
Ralf Ramsauer 2015-10-07 15:54:28 +02:00
parent cba6e337ee
commit 38a8ccadea
2 changed files with 28 additions and 4 deletions

View File

@ -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 std::string Clientmessage::toJson() const
{ {
Json::StyledWriter writer; Json::StyledWriter writer;

View File

@ -13,6 +13,9 @@ public:
Clientmessage(std::string token, Clientmessage(std::string token,
bool isOpen, bool isOpen,
Doormessage doormessage); Doormessage doormessage);
Clientmessage();
Clientmessage &operator=(const Clientmessage& rhs);
static Clientmessage fromJson(const Json::Value &root); static Clientmessage fromJson(const Json::Value &root);
static Clientmessage fromString(const std::string &json); static Clientmessage fromString(const std::string &json);
@ -24,11 +27,11 @@ public:
private: private:
const std::string _token; std::string _token;
const bool _isOpen; bool _isOpen;
const Doormessage _doormessage; Doormessage _doormessage;
static const std::string _tokenKey; const static std::string _tokenKey;
const static std::string _unlockButtonKey; const static std::string _unlockButtonKey;
const static std::string _lockButtonKey; const static std::string _lockButtonKey;
const static std::string _emergencyUnlockKey; const static std::string _emergencyUnlockKey;