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
1c48efcc
Commit
1c48efcc
authored
Mar 16, 2020
by
legoc
Browse files
(split2) Starting with JSON in C++
parent
613c62ce
Changes
5
Hide whitespace changes
Inline
Side-by-side
configure.ac
View file @
1c48efcc
...
...
@@ -4,8 +4,8 @@
#
# -----------------------------------------------------------------------------
AC_INIT(cameo-api-cpp,
0.2.2
)
LIBRARY_VERSION=
0:2:2
AC_INIT(cameo-api-cpp,
1.0.0
)
LIBRARY_VERSION=
1:0:0
AC_CONFIG_AUX_DIR(config)
AC_CONFIG_SRCDIR(src/cameo/Application.cpp)
...
...
src/Makefile.am
View file @
1c48efcc
...
...
@@ -6,6 +6,7 @@ lib_LTLIBRARIES = libcameo.la
# header files that must be in the dist package but not installed are sources
libcameo_la_SOURCES
=
\
cameo/message/JSON.cpp
\
cameo/Serializer.cpp
\
cameo/TimeCondition.cpp
\
cameo/Event.cpp
\
...
...
@@ -65,6 +66,7 @@ libcameo_la_SOURCES = \
# header files that are installed
nobase_include_HEADERS
=
\
cameo/message/JSON.h
\
cameo/Serializer.h
\
cameo/TimeCondition.h
\
cameo/Application.h
\
...
...
src/cameo/message/JSON.cpp
0 → 100644
View file @
1c48efcc
/*
* 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 "JSON.h"
namespace
cameo
{
JSONObject
::
JSONObject
()
:
m_writer
(
m_buffer
)
{
m_writer
.
StartObject
();
}
void
JSONObject
::
push
(
const
std
::
string
&
key
,
int64_t
value
)
{
m_writer
.
Key
(
key
.
c_str
());
m_writer
.
Int64
(
value
);
}
void
JSONObject
::
push
(
const
std
::
string
&
key
,
bool
value
)
{
m_writer
.
Key
(
key
.
c_str
());
m_writer
.
Bool
(
value
);
}
void
JSONObject
::
push
(
const
std
::
string
&
key
,
double
value
)
{
m_writer
.
Key
(
key
.
c_str
());
m_writer
.
Double
(
value
);
}
void
JSONObject
::
push
(
const
std
::
string
&
key
,
const
std
::
string
&
value
)
{
m_writer
.
Key
(
key
.
c_str
());
m_writer
.
String
(
value
.
c_str
());
}
void
JSONObject
::
startObject
()
{
m_writer
.
StartObject
();
}
void
JSONObject
::
endObject
()
{
m_writer
.
EndObject
();
}
void
JSONObject
::
startArray
()
{
m_writer
.
StartArray
();
}
void
JSONObject
::
endArray
()
{
m_writer
.
EndArray
();
}
std
::
string
JSONObject
::
toString
()
{
m_writer
.
EndObject
();
return
m_buffer
.
GetString
();
}
}
src/cameo/message/JSON.h
0 → 100644
View file @
1c48efcc
/*
* 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_JSON_H_
#define CAMEO_JSON_H_
#include <string>
#include <rapidjson/stringbuffer.h>
#include <rapidjson/prettywriter.h>
#include <stdint.h>
//#include <rapidjson/writer.h>
namespace
cameo
{
class
JSONObject
{
JSONObject
();
void
push
(
const
std
::
string
&
key
,
int64_t
value
);
void
push
(
const
std
::
string
&
key
,
bool
value
);
void
push
(
const
std
::
string
&
key
,
double
value
);
void
push
(
const
std
::
string
&
key
,
const
std
::
string
&
value
);
void
startObject
();
void
endObject
();
void
startArray
();
void
endArray
();
std
::
string
toString
();
private:
rapidjson
::
StringBuffer
m_buffer
;
rapidjson
::
PrettyWriter
<
rapidjson
::
StringBuffer
>
m_writer
;
};
}
#endif
src/cameo/message/Message.h
0 → 100644
View file @
1c48efcc
/*
* 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_MESSAGE_H_
#define CAMEO_MESSAGE_H_
#include <string>
namespace
cameo
{
namespace
message
{
const
std
::
string
TYPE
=
"type"
;
const
int
SYNC
=
1
;
const
int
START
=
2
;
const
int
STOP
=
3
;
const
int
CONNECT
=
4
;
const
int
SHOW_ALL
=
5
;
const
int
SHOW
=
6
;
const
int
ENABLE_STREAM
=
7
;
const
int
IS_ALIVE
=
8
;
const
int
SEND_PARAMETERS
=
9
;
const
int
KILL
=
10
;
const
int
STATUS
=
11
;
const
int
ALL_AVAILABLE
=
12
;
const
int
OUTPUT
=
13
;
const
int
SET_STATUS
=
14
;
const
int
GET_STATUS
=
15
;
const
int
CREATE_PUBLISHER
=
16
;
const
int
TERMINATE_PUBLISHER
=
17
;
const
int
CONNECT_PUBLISHER
=
18
;
const
int
SUBSCRIBE_PUBLISHER
=
19
;
const
int
CANCEL
=
20
;
const
int
SET_RESULT
=
21
;
const
int
REQUEST_PORT
=
22
;
const
int
CONNECT_PORT
=
23
;
const
int
REMOVE_PORT
=
24
;
const
int
REQUEST
=
25
;
const
int
RESPONSE
=
26
;
const
int
STARTED_UNMANAGED
=
27
;
const
int
TERMINATED_UNMANAGED
=
28
;
namespace
StartRequest
{
const
std
::
string
NAME
=
"name"
;
// required string name = 1;
const
std
::
string
ARGS
=
"args"
;
// repeated string args = 2;
const
std
::
string
INSTANCE_REFERENCE
=
"instanceReference"
;
// required string instanceReference = 3;
}
namespace
RequestResponse
{
const
std
::
string
VALUE
=
"value"
;
// required int32 value = 1;
const
std
::
string
MESSAGE
=
"message"
;
// optional string message = 2;
}
namespace
StopRequest
{
const
std
::
string
ID
=
"id"
;
// required int32 id = 1;
}
namespace
ConnectRequest
{
const
std
::
string
NAME
=
"name"
;
// required string name = 1;
}
namespace
ApplicationConfig
{
const
std
::
string
NAME
=
"name"
;
// required string name = 1;
const
std
::
string
DESCRIPTION
=
"description"
;
// optional string description = 2;
const
std
::
string
RUNS_SINGLE
=
"runsSingle"
;
// required bool runsSingle = 3;
const
std
::
string
RESTART
=
"restart"
;
// required bool restart = 4;
const
std
::
string
STARTING_TIME
=
"startingTime"
;
// required int32 startingTime = 5;
const
std
::
string
RETRIES
=
"retries"
;
// required int32 retries = 6;
const
std
::
string
STOPPING_TIME
=
"stoppingTime"
;
// required int32 stoppingTime = 7;
}
namespace
AllAvailableResponse
{
const
std
::
string
APPLICATION_CONFIG
=
"applicationConfig"
;
// repeated ApplicationConfig applicationConfig = 1;
}
namespace
StatusEvent
{
const
std
::
string
ID
=
"id"
;
// required int32 id = 1;
const
std
::
string
NAME
=
"name"
;
// required string name = 2;
const
std
::
string
APPLICATION_STATE
=
"applicationState"
;
// required int32 applicationState = 3;
const
std
::
string
PAST_APPLICATION_STATES
=
"pastApplicationStates"
;
// required int32 pastApplicationStates = 4;
}
namespace
PublisherEvent
{
const
std
::
string
ID
=
"id"
;
// required int32 id = 1;
const
std
::
string
NAME
=
"name"
;
// required string name = 2;
const
std
::
string
PUBLISHER_NAME
=
"publisherName"
;
// required string publisherName = 3;
}
namespace
ResultEvent
{
const
std
::
string
ID
=
"id"
;
// required int32 id = 1;
const
std
::
string
NAME
=
"name"
;
// required string name = 2;
const
std
::
string
DATA
=
"data"
;
// required bytes data = 3;
}
namespace
PortEvent
{
const
std
::
string
ID
=
"id"
;
// required int32 id = 1;
const
std
::
string
NAME
=
"name"
;
// required string name = 2;
const
std
::
string
PORT_NAME
=
"portName"
;
// required string portName = 3;
}
namespace
ApplicationInfo
{
const
std
::
string
ID
=
"id"
;
// required int32 id = 1;
const
std
::
string
NAME
=
"name"
;
// required string name = 2;
const
std
::
string
APPLICATION_STATE
=
"applicationState"
;
// required int32 applicationState = 3;
const
std
::
string
PAST_APPLICATION_STATES
=
"pastApplicationStates"
;
// required int32 pastApplicationStates = 4;
const
std
::
string
ARGS
=
"args"
;
// required string args = 5;
const
std
::
string
PID
=
"pid"
;
// optional int64 pid = 6;
}
namespace
ApplicationInfoListResponse
{
const
std
::
string
APPLICATION_INFO
=
"applicationInfo"
;
// repeated ApplicationInfo applicationInfo = 1;
}
namespace
ShowStreamRequest
{
const
std
::
string
ID
=
"id"
;
// required int32 id = 1;
}
namespace
IsAliveRequest
{
const
std
::
string
ID
=
"id"
;
// required int32 id = 1;
}
namespace
IsAliveResponse
{
const
std
::
string
IS_ALIVE
=
"isAlive"
;
// required bool isAlive = 1;
}
namespace
ApplicationStream
{
const
std
::
string
ID
=
"id"
;
// required int32 id = 1;
const
std
::
string
MESSAGE
=
"message"
;
// required string message = 2;
}
namespace
SendParametersRequest
{
const
std
::
string
ID
=
"id"
;
// required int32 id = 1;
const
std
::
string
PARAMETERS
=
"parameters"
;
// repeated string parameters = 2;
}
namespace
KillRequest
{
const
std
::
string
ID
=
"id"
;
// required int32 id = 1;
}
namespace
OutputRequest
{
const
std
::
string
NAME
=
"name"
;
// required string name = 1;
}
namespace
SetStatusRequest
{
const
std
::
string
ID
=
"id"
;
// required int32 id = 1;
const
std
::
string
APPLICATION_STATE
=
"applicationState"
;
// required int32 applicationState = 2;
}
namespace
GetStatusRequest
{
const
std
::
string
ID
=
"id"
;
// required int32 id = 1;
}
namespace
SetResultRequest
{
const
std
::
string
ID
=
"id"
;
// required int32 id = 1;
const
std
::
string
DATA
=
"data"
;
// required bytes data = 2;
}
namespace
RequestPortRequest
{
const
std
::
string
ID
=
"id"
;
// required int32 id = 1;
const
std
::
string
NAME
=
"name"
;
// required string name = 2;
}
namespace
ConnectPortRequest
{
const
std
::
string
ID
=
"id"
;
// required int32 id = 1;
const
std
::
string
NAME
=
"name"
;
// required string name = 2;
}
namespace
RemovePortRequest
{
const
std
::
string
ID
=
"id"
;
// required int32 id = 1;
const
std
::
string
NAME
=
"name"
;
// required string name = 2;
}
namespace
CreatePublisherRequest
{
const
std
::
string
ID
=
"id"
;
// required int32 id = 1;
const
std
::
string
NAME
=
"name"
;
// required string name = 2;
const
std
::
string
NUMBER_OF_SUBSCRIBERS
=
"numberOfSubscribers"
;
// required int32 numberOfSubscribers = 3;
}
namespace
TerminatePublisherRequest
{
const
std
::
string
ID
=
"id"
;
// required int32 id = 1;
const
std
::
string
NAME
=
"name"
;
// required string name = 2;
}
namespace
ConnectPublisherRequest
{
const
std
::
string
APPLICATION_ID
=
"applicationId"
;
// required int32 applicationId = 1;
const
std
::
string
PUBLISHER_NAME
=
"publisherName"
;
// required string publisherName = 2;
}
namespace
PublisherResponse
{
const
std
::
string
MESSAGE
=
"message"
;
// optional string message = 1;
const
std
::
string
PUBLISHER_PORT
=
"publisherPort"
;
// required int32 publisherPort = 2;
const
std
::
string
SYNCHRONIZER_PORT
=
"synchronizerPort"
;
// required int32 synchronizerPort = 3;
const
std
::
string
NUMBER_OF_SUBSCRIBERS
=
"numberOfSubscribers"
;
// optional int32 numberOfSubscribers = 4;
}
namespace
Request
{
const
std
::
string
APPLICATION_NAME
=
"applicationName"
;
// required string applicationName = 1;
const
std
::
string
APPLICATION_ID
=
"applicationId"
;
// required int32 applicationId = 2;
const
std
::
string
SERVER_URL
=
"serverUrl"
;
// required string serverUrl = 5;
const
std
::
string
SERVER_PORT
=
"serverPort"
;
// required int32 serverPort = 6;
const
std
::
string
REQUESTER_PORT
=
"requesterPort"
;
// required int32 requesterPort = 7;
}
namespace
StartedUnmanagedRequest
{
const
std
::
string
NAME
=
"name"
;
// required string name = 1;
const
std
::
string
PID
=
"pid"
;
// optional int64 pid = 2;
}
namespace
TerminatedUnmanagedRequest
{
const
std
::
string
ID
=
"id"
;
// required int32 id = 1;
}
}
}
#endif
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