The code.ill.fr has been recreated and upgraded with the latest version this weekend, If you encounter any problem please inform the Helpdesk.

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 @@
#include "ResultEvent.h"
#include "StatusEvent.h"
#include "StoreKeyValueEvent.h"
#include "RemoveKeyEvent.h"
#include "impl/StreamSocketImpl.h"
#include "message/Message.h"
#include "RemoveKeyValueEvent.h"
using namespace std;
......@@ -126,7 +126,7 @@ std::unique_ptr<Event> EventStreamSocket::receive(bool blocking) {
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();
......@@ -134,11 +134,12 @@ std::unique_ptr<Event> EventStreamSocket::receive(bool blocking) {
json::Object event;
json::parse(event, message.get());
int id = event[message::RemoveKeyEvent::ID].GetInt();
string name = event[message::RemoveKeyEvent::NAME].GetString();
string key = event[message::RemoveKeyEvent::KEY].GetString();
int id = event[message::RemoveKeyValueEvent::ID].GetInt();
string name = event[message::RemoveKeyValueEvent::NAME].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) {
......
......@@ -20,17 +20,24 @@
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),
m_key(key) {
m_key(key),
m_value(value) {
}
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 {
return m_key;
}
const std::string& KeyEvent::getValue() const {
return m_value;
}
}
......@@ -25,13 +25,15 @@ namespace cameo {
class KeyEvent : public Event {
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);
const std::string& getKey() const;
const std::string& getValue() const;
private:
std::string m_key;
std::string m_value;
};
}
......
......@@ -14,28 +14,28 @@
* limitations under the Licence.
*/
#include "RemoveKeyEvent.h"
#include <iostream>
#include "RemoveKeyValueEvent.h"
namespace cameo {
RemoveKeyEvent::RemoveKeyEvent(int id, const std::string& name, const std::string& key) :
KeyEvent(id, name, key) {
RemoveKeyValueEvent::RemoveKeyValueEvent(int id, const std::string& name, const std::string& key, const std::string& value) :
KeyEvent(id, name, key, value) {
}
RemoveKeyEvent::RemoveKeyEvent(const RemoveKeyEvent& event) :
RemoveKeyValueEvent::RemoveKeyValueEvent(const RemoveKeyValueEvent& event) :
KeyEvent(event) {
}
RemoveKeyEvent* RemoveKeyEvent::clone() {
return new RemoveKeyEvent(*this);
RemoveKeyValueEvent* RemoveKeyValueEvent::clone() {
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
<< "\nid=" << event.m_id
<< "\nkey=" << event.m_key;
<< "\nkey=" << event.m_key
<< "\nvalue=" << event.m_value;
return os;
}
......
......@@ -14,26 +14,26 @@
* limitations under the Licence.
*/
#ifndef CAMEO_REMOVEKEYEVENT_H_
#define CAMEO_REMOVEKEYEVENT_H_
#ifndef CAMEO_REMOVEKEYVALUEEVENT_H_
#define CAMEO_REMOVEKEYVALUEEVENT_H_
#include <iostream>
#include "KeyEvent.h"
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:
RemoveKeyEvent(int id, const std::string& name, const std::string& key);
RemoveKeyEvent(const RemoveKeyEvent& event);
RemoveKeyValueEvent(int id, const std::string& name, const std::string& key, const std::string& value);
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 @@
namespace cameo {
StoreKeyValueEvent::StoreKeyValueEvent(int id, const std::string& name, const std::string& key, const std::string& value) :
KeyEvent(id, name, key),
m_value(value) {
KeyEvent(id, name, key, value) {
}
StoreKeyValueEvent::StoreKeyValueEvent(const StoreKeyValueEvent& event) :
KeyEvent(event), m_value(event.m_value) {
KeyEvent(event) {
}
StoreKeyValueEvent* StoreKeyValueEvent::clone() {
return new StoreKeyValueEvent(*this);
}
const std::string& StoreKeyValueEvent::getValue() const {
return m_value;
}
std::ostream& operator<<(std::ostream& os, const cameo::StoreKeyValueEvent& event) {
os << "name=" << event.m_name
<< "\nid=" << event.m_id
......
......@@ -31,11 +31,6 @@ public:
StoreKeyValueEvent(const StoreKeyValueEvent& event);
virtual StoreKeyValueEvent* clone();
const std::string& getValue() const;
private:
std::string m_value;
};
std::ostream& operator<<(std::ostream&, const StoreKeyValueEvent&);
......
......@@ -70,7 +70,7 @@ namespace message {
constexpr const char* PORT = "PORT";
constexpr const char* PUBLISHER = "PUBLISHER";
constexpr const char* STOREKEYVALUE = "STOREKEYVALUE";
constexpr const char* REMOVEKEY = "REMOVEKEY";
constexpr const char* REMOVEKEYVALUE = "REMOVEKEYVALUE";
}
namespace SyncStreamRequest {
......@@ -281,10 +281,11 @@ namespace message {
constexpr const char* VALUE = "value"; // string
}
namespace RemoveKeyEvent {
namespace RemoveKeyValueEvent {
constexpr const char* ID = "id"; // int32
constexpr const char* NAME = "name"; // 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