Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Cameo
cameo
Commits
d7af35f2
Commit
d7af35f2
authored
Oct 15, 2020
by
legoc
Browse files
(split) Simplified storage events into one single KeyEvent (server and APIs)
parent
5d7fa164
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/EventStreamSocket.cpp
View file @
d7af35f2
...
...
@@ -22,10 +22,9 @@
#include "PublisherEvent.h"
#include "ResultEvent.h"
#include "StatusEvent.h"
#include "
StoreKeyValue
Event.h"
#include "
Key
Event.h"
#include "impl/StreamSocketImpl.h"
#include "message/Message.h"
#include "RemoveKeyValueEvent.h"
using
namespace
std
;
...
...
@@ -111,7 +110,7 @@ std::unique_ptr<Event> EventStreamSocket::receive(bool blocking) {
return
unique_ptr
<
Event
>
(
new
PortEvent
(
id
,
name
,
portName
));
}
else
if
(
response
==
message
::
Event
::
STORE
KEYVALUE
)
{
else
if
(
response
==
message
::
Event
::
KEYVALUE
)
{
message
=
m_impl
->
receive
();
...
...
@@ -119,27 +118,18 @@ std::unique_ptr<Event> EventStreamSocket::receive(bool blocking) {
json
::
Object
event
;
json
::
parse
(
event
,
message
.
get
());
int
id
=
event
[
message
::
StoreKeyValueEvent
::
ID
].
GetInt
();
string
name
=
event
[
message
::
StoreKeyValueEvent
::
NAME
].
GetString
();
string
key
=
event
[
message
::
StoreKeyValueEvent
::
KEY
].
GetString
();
string
value
=
event
[
message
::
StoreKeyValueEvent
::
VALUE
].
GetString
();
int
id
=
event
[
message
::
KeyEvent
::
ID
].
GetInt
();
string
name
=
event
[
message
::
KeyEvent
::
NAME
].
GetString
();
long
status
=
event
[
message
::
KeyEvent
::
STATUS
].
GetInt64
();
string
key
=
event
[
message
::
KeyEvent
::
KEY
].
GetString
();
string
value
=
event
[
message
::
KeyEvent
::
VALUE
].
GetString
();
return
unique_ptr
<
Event
>
(
new
StoreKeyValueEvent
(
id
,
name
,
key
,
value
));
}
else
if
(
response
==
message
::
Event
::
REMOVEKEYVALUE
)
{
message
=
m_impl
->
receive
();
// Get the JSON event.
json
::
Object
event
;
json
::
parse
(
event
,
message
.
get
());
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
RemoveKeyValueEvent
(
id
,
name
,
key
,
value
));
if
(
status
==
message
::
STORE_KEY_VALUE
)
{
return
unique_ptr
<
Event
>
(
new
KeyEvent
(
id
,
name
,
KeyEvent
::
Status
::
STORED
,
key
,
value
));
}
else
{
return
unique_ptr
<
Event
>
(
new
KeyEvent
(
id
,
name
,
KeyEvent
::
Status
::
REMOVED
,
key
,
value
));
}
}
else
if
(
response
==
message
::
Event
::
CANCEL
)
{
...
...
src/KeyEvent.cpp
View file @
d7af35f2
...
...
@@ -20,18 +20,28 @@
namespace
cameo
{
KeyEvent
::
KeyEvent
(
int
id
,
const
std
::
string
&
name
,
const
std
::
string
&
key
,
const
std
::
string
&
value
)
:
KeyEvent
::
KeyEvent
(
int
id
,
const
std
::
string
&
name
,
Status
status
,
const
std
::
string
&
key
,
const
std
::
string
&
value
)
:
Event
(
id
,
name
),
m_status
(
status
),
m_key
(
key
),
m_value
(
value
)
{
}
KeyEvent
::
KeyEvent
(
const
KeyEvent
&
event
)
:
Event
(
event
),
m_status
(
event
.
m_status
),
m_key
(
event
.
m_key
),
m_value
(
event
.
m_value
)
{
}
KeyEvent
*
KeyEvent
::
clone
()
{
return
new
KeyEvent
(
*
this
);
}
KeyEvent
::
Status
KeyEvent
::
getStatus
()
const
{
return
m_status
;
}
const
std
::
string
&
KeyEvent
::
getKey
()
const
{
return
m_key
;
}
...
...
@@ -40,4 +50,14 @@ const std::string& KeyEvent::getValue() const {
return
m_value
;
}
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
KeyEvent
&
event
)
{
os
<<
"name="
<<
event
.
m_name
<<
"
\n
id="
<<
event
.
m_id
<<
"
\n
status"
<<
static_cast
<
int
>
(
event
.
m_status
)
<<
"
\n
key="
<<
event
.
m_key
<<
"
\n
value="
<<
event
.
m_value
;
return
os
;
}
}
src/KeyEvent.h
View file @
d7af35f2
...
...
@@ -24,18 +24,28 @@ namespace cameo {
class
KeyEvent
:
public
Event
{
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
,
const
KeyEvent
&
);
public:
KeyEvent
(
int
id
,
const
std
::
string
&
name
,
const
std
::
string
&
key
,
const
std
::
string
&
value
);
enum
Status
{
STORED
,
REMOVED
};
KeyEvent
(
int
id
,
const
std
::
string
&
name
,
Status
status
,
const
std
::
string
&
key
,
const
std
::
string
&
value
);
KeyEvent
(
const
KeyEvent
&
event
);
virtual
KeyEvent
*
clone
();
Status
getStatus
()
const
;
const
std
::
string
&
getKey
()
const
;
const
std
::
string
&
getValue
()
const
;
private:
Status
m_status
;
std
::
string
m_key
;
std
::
string
m_value
;
};
std
::
ostream
&
operator
<<
(
std
::
ostream
&
,
const
KeyEvent
&
);
}
#endif
src/RemoveKeyValueEvent.cpp
deleted
100644 → 0
View file @
5d7fa164
/*
* Copyright 2015 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#include <iostream>
#include "RemoveKeyValueEvent.h"
namespace
cameo
{
RemoveKeyValueEvent
::
RemoveKeyValueEvent
(
int
id
,
const
std
::
string
&
name
,
const
std
::
string
&
key
,
const
std
::
string
&
value
)
:
KeyEvent
(
id
,
name
,
key
,
value
)
{
}
RemoveKeyValueEvent
::
RemoveKeyValueEvent
(
const
RemoveKeyValueEvent
&
event
)
:
KeyEvent
(
event
)
{
}
RemoveKeyValueEvent
*
RemoveKeyValueEvent
::
clone
()
{
return
new
RemoveKeyValueEvent
(
*
this
);
}
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
cameo
::
RemoveKeyValueEvent
&
event
)
{
os
<<
"name="
<<
event
.
m_name
<<
"
\n
id="
<<
event
.
m_id
<<
"
\n
key="
<<
event
.
m_key
<<
"
\n
value="
<<
event
.
m_value
;
return
os
;
}
}
src/RemoveKeyValueEvent.h
deleted
100644 → 0
View file @
5d7fa164
/*
* Copyright 2015 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#ifndef CAMEO_REMOVEKEYVALUEEVENT_H_
#define CAMEO_REMOVEKEYVALUEEVENT_H_
#include <iostream>
#include "KeyEvent.h"
namespace
cameo
{
class
RemoveKeyValueEvent
:
public
KeyEvent
{
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
,
const
RemoveKeyValueEvent
&
);
public:
RemoveKeyValueEvent
(
int
id
,
const
std
::
string
&
name
,
const
std
::
string
&
key
,
const
std
::
string
&
value
);
RemoveKeyValueEvent
(
const
RemoveKeyValueEvent
&
event
);
virtual
RemoveKeyValueEvent
*
clone
();
};
std
::
ostream
&
operator
<<
(
std
::
ostream
&
,
const
RemoveKeyValueEvent
&
);
}
#endif
src/StoreKeyValueEvent.cpp
deleted
100644 → 0
View file @
5d7fa164
/*
* Copyright 2015 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#include "StoreKeyValueEvent.h"
#include <iostream>
namespace
cameo
{
StoreKeyValueEvent
::
StoreKeyValueEvent
(
int
id
,
const
std
::
string
&
name
,
const
std
::
string
&
key
,
const
std
::
string
&
value
)
:
KeyEvent
(
id
,
name
,
key
,
value
)
{
}
StoreKeyValueEvent
::
StoreKeyValueEvent
(
const
StoreKeyValueEvent
&
event
)
:
KeyEvent
(
event
)
{
}
StoreKeyValueEvent
*
StoreKeyValueEvent
::
clone
()
{
return
new
StoreKeyValueEvent
(
*
this
);
}
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
cameo
::
StoreKeyValueEvent
&
event
)
{
os
<<
"name="
<<
event
.
m_name
<<
"
\n
id="
<<
event
.
m_id
<<
"
\n
key="
<<
event
.
m_key
<<
"
\n
value="
<<
event
.
m_value
;
return
os
;
}
}
src/StoreKeyValueEvent.h
deleted
100644 → 0
View file @
5d7fa164
/*
* Copyright 2015 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#ifndef CAMEO_STOREKEYVALUEEVENT_H_
#define CAMEO_STOREKEYVALUEEVENT_H_
#include <iostream>
#include "KeyEvent.h"
namespace
cameo
{
class
StoreKeyValueEvent
:
public
KeyEvent
{
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
,
const
StoreKeyValueEvent
&
);
public:
StoreKeyValueEvent
(
int
id
,
const
std
::
string
&
name
,
const
std
::
string
&
key
,
const
std
::
string
&
value
);
StoreKeyValueEvent
(
const
StoreKeyValueEvent
&
event
);
virtual
StoreKeyValueEvent
*
clone
();
};
std
::
ostream
&
operator
<<
(
std
::
ostream
&
,
const
StoreKeyValueEvent
&
);
}
#endif
src/message/Message.h
View file @
d7af35f2
...
...
@@ -69,8 +69,7 @@ namespace message {
constexpr
const
char
*
RESULT
=
"RESULT"
;
constexpr
const
char
*
PORT
=
"PORT"
;
constexpr
const
char
*
PUBLISHER
=
"PUBLISHER"
;
constexpr
const
char
*
STOREKEYVALUE
=
"STOREKEYVALUE"
;
constexpr
const
char
*
REMOVEKEYVALUE
=
"REMOVEKEYVALUE"
;
constexpr
const
char
*
KEYVALUE
=
"KEYVALUE"
;
}
namespace
SyncStreamRequest
{
...
...
@@ -274,16 +273,10 @@ namespace message {
constexpr
const
char
*
KEY
=
"key"
;
// string
}
namespace
StoreKeyValueEvent
{
constexpr
const
char
*
ID
=
"id"
;
// int32
constexpr
const
char
*
NAME
=
"name"
;
// string
constexpr
const
char
*
KEY
=
"key"
;
// string
constexpr
const
char
*
VALUE
=
"value"
;
// string
}
namespace
RemoveKeyValueEvent
{
namespace
KeyEvent
{
constexpr
const
char
*
ID
=
"id"
;
// int32
constexpr
const
char
*
NAME
=
"name"
;
// string
constexpr
const
char
*
STATUS
=
"status"
;
// long STORE_KEY_VALUE or REMOVE_KEY
constexpr
const
char
*
KEY
=
"key"
;
// string
constexpr
const
char
*
VALUE
=
"value"
;
// string
}
...
...
Shervin Nourbakhsh
@nourbakhsh
mentioned in commit
46e44691
·
Apr 23, 2021
mentioned in commit
46e44691
mentioned in commit 46e44691a03808a23a464818487b0dd014a9c57e
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment