Commit 5d7fa164 authored by legoc's avatar legoc
Browse files

(split) The cameo server sends the value in the remove key event

parent d5472078
...@@ -23,9 +23,9 @@ ...@@ -23,9 +23,9 @@
#include "ResultEvent.h" #include "ResultEvent.h"
#include "StatusEvent.h" #include "StatusEvent.h"
#include "StoreKeyValueEvent.h" #include "StoreKeyValueEvent.h"
#include "RemoveKeyEvent.h"
#include "impl/StreamSocketImpl.h" #include "impl/StreamSocketImpl.h"
#include "message/Message.h" #include "message/Message.h"
#include "RemoveKeyValueEvent.h"
using namespace std; using namespace std;
...@@ -126,7 +126,7 @@ std::unique_ptr<Event> EventStreamSocket::receive(bool blocking) { ...@@ -126,7 +126,7 @@ std::unique_ptr<Event> EventStreamSocket::receive(bool blocking) {
return unique_ptr<Event>(new StoreKeyValueEvent(id, name, key, value)); return unique_ptr<Event>(new StoreKeyValueEvent(id, name, key, value));
} }
else if (response == message::Event::REMOVEKEY) { else if (response == message::Event::REMOVEKEYVALUE) {
message = m_impl->receive(); message = m_impl->receive();
...@@ -134,11 +134,12 @@ std::unique_ptr<Event> EventStreamSocket::receive(bool blocking) { ...@@ -134,11 +134,12 @@ std::unique_ptr<Event> EventStreamSocket::receive(bool blocking) {
json::Object event; json::Object event;
json::parse(event, message.get()); json::parse(event, message.get());
int id = event[message::RemoveKeyEvent::ID].GetInt(); int id = event[message::RemoveKeyValueEvent::ID].GetInt();
string name = event[message::RemoveKeyEvent::NAME].GetString(); string name = event[message::RemoveKeyValueEvent::NAME].GetString();
string key = event[message::RemoveKeyEvent::KEY].GetString(); string key = event[message::RemoveKeyValueEvent::KEY].GetString();
string value = event[message::RemoveKeyValueEvent::VALUE].GetString();
return unique_ptr<Event>(new RemoveKeyEvent(id, name, key)); return unique_ptr<Event>(new RemoveKeyValueEvent(id, name, key, value));
} }
else if (response == message::Event::CANCEL) { else if (response == message::Event::CANCEL) {
......
...@@ -20,17 +20,24 @@ ...@@ -20,17 +20,24 @@
namespace cameo { namespace cameo {
KeyEvent::KeyEvent(int id, const std::string& name, const std::string& key) : KeyEvent::KeyEvent(int id, const std::string& name, const std::string& key, const std::string& value) :
Event(id, name), Event(id, name),
m_key(key) { m_key(key),
m_value(value) {
} }
KeyEvent::KeyEvent(const KeyEvent& event) : KeyEvent::KeyEvent(const KeyEvent& event) :
Event(event), m_key(event.m_key) { Event(event),
m_key(event.m_key),
m_value(event.m_value) {
} }
const std::string& KeyEvent::getKey() const { const std::string& KeyEvent::getKey() const {
return m_key; return m_key;
} }
const std::string& KeyEvent::getValue() const {
return m_value;
}
} }
...@@ -25,13 +25,15 @@ namespace cameo { ...@@ -25,13 +25,15 @@ namespace cameo {
class KeyEvent : public Event { class KeyEvent : public Event {
public: public:
KeyEvent(int id, const std::string& name, const std::string& key); KeyEvent(int id, const std::string& name, const std::string& key, const std::string& value);
KeyEvent(const KeyEvent& event); KeyEvent(const KeyEvent& event);
const std::string& getKey() const; const std::string& getKey() const;
const std::string& getValue() const;
private: private:
std::string m_key; std::string m_key;
std::string m_value;
}; };
} }
......
...@@ -14,28 +14,28 @@ ...@@ -14,28 +14,28 @@
* limitations under the Licence. * limitations under the Licence.
*/ */
#include "RemoveKeyEvent.h"
#include <iostream> #include <iostream>
#include "RemoveKeyValueEvent.h"
namespace cameo { namespace cameo {
RemoveKeyEvent::RemoveKeyEvent(int id, const std::string& name, const std::string& key) : RemoveKeyValueEvent::RemoveKeyValueEvent(int id, const std::string& name, const std::string& key, const std::string& value) :
KeyEvent(id, name, key) { KeyEvent(id, name, key, value) {
} }
RemoveKeyEvent::RemoveKeyEvent(const RemoveKeyEvent& event) : RemoveKeyValueEvent::RemoveKeyValueEvent(const RemoveKeyValueEvent& event) :
KeyEvent(event) { KeyEvent(event) {
} }
RemoveKeyEvent* RemoveKeyEvent::clone() { RemoveKeyValueEvent* RemoveKeyValueEvent::clone() {
return new RemoveKeyEvent(*this); return new RemoveKeyValueEvent(*this);
} }
std::ostream& operator<<(std::ostream& os, const cameo::RemoveKeyEvent& event) { std::ostream& operator<<(std::ostream& os, const cameo::RemoveKeyValueEvent& event) {
os << "name=" << event.m_name os << "name=" << event.m_name
<< "\nid=" << event.m_id << "\nid=" << event.m_id
<< "\nkey=" << event.m_key; << "\nkey=" << event.m_key
<< "\nvalue=" << event.m_value;
return os; return os;
} }
......
...@@ -14,26 +14,26 @@ ...@@ -14,26 +14,26 @@
* limitations under the Licence. * limitations under the Licence.
*/ */
#ifndef CAMEO_REMOVEKEYEVENT_H_ #ifndef CAMEO_REMOVEKEYVALUEEVENT_H_
#define CAMEO_REMOVEKEYEVENT_H_ #define CAMEO_REMOVEKEYVALUEEVENT_H_
#include <iostream> #include <iostream>
#include "KeyEvent.h" #include "KeyEvent.h"
namespace cameo { namespace cameo {
class RemoveKeyEvent : public KeyEvent { class RemoveKeyValueEvent : public KeyEvent {
friend std::ostream& operator<<(std::ostream&, const RemoveKeyEvent&); friend std::ostream& operator<<(std::ostream&, const RemoveKeyValueEvent&);
public: public:
RemoveKeyEvent(int id, const std::string& name, const std::string& key); RemoveKeyValueEvent(int id, const std::string& name, const std::string& key, const std::string& value);
RemoveKeyEvent(const RemoveKeyEvent& event); RemoveKeyValueEvent(const RemoveKeyValueEvent& event);
virtual RemoveKeyEvent* clone(); virtual RemoveKeyValueEvent* clone();
}; };
std::ostream& operator<<(std::ostream&, const RemoveKeyEvent&); std::ostream& operator<<(std::ostream&, const RemoveKeyValueEvent&);
} }
......
...@@ -21,22 +21,17 @@ ...@@ -21,22 +21,17 @@
namespace cameo { namespace cameo {
StoreKeyValueEvent::StoreKeyValueEvent(int id, const std::string& name, const std::string& key, const std::string& value) : StoreKeyValueEvent::StoreKeyValueEvent(int id, const std::string& name, const std::string& key, const std::string& value) :
KeyEvent(id, name, key), KeyEvent(id, name, key, value) {
m_value(value) {
} }
StoreKeyValueEvent::StoreKeyValueEvent(const StoreKeyValueEvent& event) : StoreKeyValueEvent::StoreKeyValueEvent(const StoreKeyValueEvent& event) :
KeyEvent(event), m_value(event.m_value) { KeyEvent(event) {
} }
StoreKeyValueEvent* StoreKeyValueEvent::clone() { StoreKeyValueEvent* StoreKeyValueEvent::clone() {
return new StoreKeyValueEvent(*this); return new StoreKeyValueEvent(*this);
} }
const std::string& StoreKeyValueEvent::getValue() const {
return m_value;
}
std::ostream& operator<<(std::ostream& os, const cameo::StoreKeyValueEvent& event) { std::ostream& operator<<(std::ostream& os, const cameo::StoreKeyValueEvent& event) {
os << "name=" << event.m_name os << "name=" << event.m_name
<< "\nid=" << event.m_id << "\nid=" << event.m_id
......
...@@ -31,11 +31,6 @@ public: ...@@ -31,11 +31,6 @@ public:
StoreKeyValueEvent(const StoreKeyValueEvent& event); StoreKeyValueEvent(const StoreKeyValueEvent& event);
virtual StoreKeyValueEvent* clone(); virtual StoreKeyValueEvent* clone();
const std::string& getValue() const;
private:
std::string m_value;
}; };
std::ostream& operator<<(std::ostream&, const StoreKeyValueEvent&); std::ostream& operator<<(std::ostream&, const StoreKeyValueEvent&);
......
...@@ -70,7 +70,7 @@ namespace message { ...@@ -70,7 +70,7 @@ namespace message {
constexpr const char* PORT = "PORT"; constexpr const char* PORT = "PORT";
constexpr const char* PUBLISHER = "PUBLISHER"; constexpr const char* PUBLISHER = "PUBLISHER";
constexpr const char* STOREKEYVALUE = "STOREKEYVALUE"; constexpr const char* STOREKEYVALUE = "STOREKEYVALUE";
constexpr const char* REMOVEKEY = "REMOVEKEY"; constexpr const char* REMOVEKEYVALUE = "REMOVEKEYVALUE";
} }
namespace SyncStreamRequest { namespace SyncStreamRequest {
...@@ -281,10 +281,11 @@ namespace message { ...@@ -281,10 +281,11 @@ namespace message {
constexpr const char* VALUE = "value"; // string constexpr const char* VALUE = "value"; // string
} }
namespace RemoveKeyEvent { namespace RemoveKeyValueEvent {
constexpr const char* ID = "id"; // int32 constexpr const char* ID = "id"; // int32
constexpr const char* NAME = "name"; // string constexpr const char* NAME = "name"; // string
constexpr const char* KEY = "key"; // string constexpr const char* KEY = "key"; // string
constexpr const char* VALUE = "value"; // string
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment