Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
149571e8
A
apollo
项目概览
Pinoxchio
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
apollo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
149571e8
编写于
12月 11, 2017
作者:
A
Aaron Xiao
提交者:
Dong Li
12月 11, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Common: Move json_util and http_client to common util.
上级
8be428fa
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
81 addition
and
84 deletion
+81
-84
modules/common/util/BUILD
modules/common/util/BUILD
+40
-0
modules/common/util/http_client.cc
modules/common/util/http_client.cc
+3
-5
modules/common/util/http_client.h
modules/common/util/http_client.h
+9
-11
modules/common/util/json_util.cc
modules/common/util/json_util.cc
+3
-3
modules/common/util/json_util.h
modules/common/util/json_util.h
+5
-5
modules/common/util/json_util_test.cc
modules/common/util/json_util_test.cc
+7
-7
modules/dreamview/backend/hmi/BUILD
modules/dreamview/backend/hmi/BUILD
+2
-2
modules/dreamview/backend/hmi/hmi.cc
modules/dreamview/backend/hmi/hmi.cc
+5
-5
modules/dreamview/backend/map/BUILD
modules/dreamview/backend/map/BUILD
+1
-1
modules/dreamview/backend/map/map_service.cc
modules/dreamview/backend/map/map_service.cc
+2
-2
modules/dreamview/backend/simulation_world/simulation_world_updater.cc
...view/backend/simulation_world/simulation_world_updater.cc
+4
-3
modules/dreamview/backend/util/BUILD
modules/dreamview/backend/util/BUILD
+0
-40
未找到文件。
modules/common/util/BUILD
浏览文件 @
149571e8
...
...
@@ -186,4 +186,44 @@ cc_test(
],
)
cc_library
(
name
=
"json_util"
,
srcs
=
[
"json_util.cc"
,
],
hdrs
=
[
"json_util.h"
,
],
deps
=
[
"//modules/common:log"
,
"//third_party/json"
,
"@com_google_protobuf//:protobuf"
,
],
)
cc_test
(
name
=
"json_util_test"
,
size
=
"small"
,
srcs
=
[
"json_util_test.cc"
,
],
deps
=
[
":json_util"
,
"//modules/common/proto:error_code_proto"
,
"@gtest//:main"
,
],
)
cc_library
(
name
=
"http_client"
,
srcs
=
[
"http_client.cc"
],
hdrs
=
[
"http_client.h"
],
deps
=
[
"//modules/common:log"
,
"//modules/common/status"
,
"//third_party/json"
,
"@curlpp//:curlpp"
,
],
)
cpplint
()
modules/
dreamview/backend
/util/http_client.cc
→
modules/
common
/util/http_client.cc
浏览文件 @
149571e8
...
...
@@ -14,7 +14,7 @@
* limitations under the License.
*****************************************************************************/
#include "modules/
dreamview/backend
/util/http_client.h"
#include "modules/
common
/util/http_client.h"
#include <curlpp/Easy.hpp>
#include <curlpp/Exception.hpp>
...
...
@@ -24,11 +24,9 @@
#include "modules/common/log.h"
namespace
apollo
{
namespace
dreamview
{
namespace
common
{
namespace
util
{
using
apollo
::
common
::
ErrorCode
;
using
apollo
::
common
::
Status
;
using
Json
=
nlohmann
::
json
;
Status
HttpClient
::
Post
(
const
std
::
string
&
url
,
const
Json
&
json
,
...
...
@@ -73,5 +71,5 @@ Status HttpClient::Post(const std::string &url, const Json &json,
}
}
// namespace util
}
// namespace
dreamview
}
// namespace
common
}
// namespace apollo
modules/
dreamview/backend
/util/http_client.h
→
modules/
common
/util/http_client.h
浏览文件 @
149571e8
...
...
@@ -14,8 +14,8 @@
* limitations under the License.
*****************************************************************************/
#ifndef MODULES_
DREAMVIEW_BACKEND
_UTIL_HTTP_CLIENT_H_
#define MODULES_
DREAMVIEW_BACKEND
_UTIL_HTTP_CLIENT_H_
#ifndef MODULES_
COMMON
_UTIL_HTTP_CLIENT_H_
#define MODULES_
COMMON
_UTIL_HTTP_CLIENT_H_
#include <string>
...
...
@@ -23,7 +23,7 @@
#include "third_party/json/json.hpp"
namespace
apollo
{
namespace
dreamview
{
namespace
common
{
namespace
util
{
class
HttpClient
{
...
...
@@ -31,20 +31,18 @@ class HttpClient {
/**
* @brief post a json to target url, get response as string.
*/
static
apollo
::
common
::
Status
Post
(
const
std
::
string
&
url
,
const
nlohmann
::
json
&
json
,
std
::
string
*
result
=
nullptr
);
static
Status
Post
(
const
std
::
string
&
url
,
const
nlohmann
::
json
&
json
,
std
::
string
*
result
=
nullptr
);
/**
* @brief post a json to target url, get response as json.
*/
static
apollo
::
common
::
Status
Post
(
const
std
::
string
&
url
,
const
nlohmann
::
json
&
json
,
nlohmann
::
json
*
result
);
static
Status
Post
(
const
std
::
string
&
url
,
const
nlohmann
::
json
&
json
,
nlohmann
::
json
*
result
);
};
}
// namespace util
}
// namespace
dreamview
}
// namespace
common
}
// namespace apollo
#endif // MODULES_
DREAMVIEW_BACKEND
_UTIL_HTTP_CLIENT_H_
#endif // MODULES_
COMMON
_UTIL_HTTP_CLIENT_H_
modules/
dreamview/backend
/util/json_util.cc
→
modules/
common
/util/json_util.cc
浏览文件 @
149571e8
...
...
@@ -14,13 +14,13 @@
* limitations under the License.
*****************************************************************************/
#include "modules/
dreamview/backend
/util/json_util.h"
#include "modules/
common
/util/json_util.h"
#include "google/protobuf/util/json_util.h"
#include "modules/common/log.h"
namespace
apollo
{
namespace
dreamview
{
namespace
common
{
namespace
util
{
namespace
{
...
...
@@ -92,5 +92,5 @@ bool JsonUtil::GetStringVectorFromJson(const Json &json, const std::string &key,
}
}
// namespace util
}
// namespace
dreamview
}
// namespace
common
}
// namespace apollo
modules/
dreamview/backend
/util/json_util.h
→
modules/
common
/util/json_util.h
浏览文件 @
149571e8
...
...
@@ -14,8 +14,8 @@
* limitations under the License.
*****************************************************************************/
#ifndef MODULES_
DREAMVIEW_BACKEND
_UTIL_JSON_UTIL_H_
#define MODULES_
DREAMVIEW_BACKEND
_UTIL_JSON_UTIL_H_
#ifndef MODULES_
COMMON
_UTIL_JSON_UTIL_H_
#define MODULES_
COMMON
_UTIL_JSON_UTIL_H_
#include <string>
#include <vector>
...
...
@@ -24,7 +24,7 @@
#include "third_party/json/json.hpp"
namespace
apollo
{
namespace
dreamview
{
namespace
common
{
namespace
util
{
class
JsonUtil
{
...
...
@@ -53,7 +53,7 @@ class JsonUtil {
};
}
// namespace util
}
// namespace
dreamview
}
// namespace
common
}
// namespace apollo
#endif // MODULES_
DREAMVIEW_BACKEND
_UTIL_JSON_UTIL_H_
#endif // MODULES_
COMMON
_UTIL_JSON_UTIL_H_
modules/
dreamview/backend
/util/json_util_test.cc
→
modules/
common
/util/json_util_test.cc
浏览文件 @
149571e8
...
...
@@ -14,27 +14,27 @@
* limitations under the License.
*****************************************************************************/
#include "modules/
dreamview/backend
/util/json_util.h"
#include "modules/
common
/util/json_util.h"
#include "google/protobuf/util/json_util.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "modules/
dreamview/proto/hmi_status
.pb.h"
#include "modules/
common/proto/error_code
.pb.h"
namespace
apollo
{
namespace
dreamview
{
namespace
common
{
namespace
util
{
using
Json
=
nlohmann
::
json
;
TEST
(
JsonUtilTest
,
ProtoToTypedJson
)
{
HMIStatus
status
;
status
.
set_
current_map
(
"Map
A"
);
StatusPb
status
;
status
.
set_
msg
(
"Msg
A"
);
const
std
::
string
json_str
=
JsonUtil
::
ProtoToTypedJson
(
"TypeA"
,
status
);
Json
json_obj
=
Json
::
parse
(
json_str
.
begin
(),
json_str
.
end
());
EXPECT_EQ
(
"TypeA"
,
json_obj
[
"type"
]);
EXPECT_EQ
(
"M
apA"
,
json_obj
[
"data"
][
"currentMap
"
]);
EXPECT_EQ
(
"M
sgA"
,
json_obj
[
"data"
][
"msg
"
]);
}
TEST
(
JsonUtilTest
,
GetStringFromJson
)
{
...
...
@@ -95,5 +95,5 @@ TEST(JsonUtilTest, GetStringVectorFromJson) {
}
}
// namespace util
}
// namespace
dreamview
}
// namespace
common
}
// namespace apollo
modules/dreamview/backend/hmi/BUILD
浏览文件 @
149571e8
...
...
@@ -28,13 +28,13 @@ cc_library(
deps
=
[
":vehicle_manager"
,
"//modules/common/adapters:adapter_manager"
,
"//modules/common/util:http_client"
,
"//modules/common/util:json_util"
,
"//modules/common/util:map_util"
,
"//modules/data/proto:task_proto"
,
"//modules/dreamview/backend/common:dreamview_gflags"
,
"//modules/dreamview/backend/handlers:websocket"
,
"//modules/dreamview/backend/map:map_service"
,
"//modules/dreamview/backend/util:http_client"
,
"//modules/dreamview/backend/util:json_util"
,
"//modules/dreamview/proto:hmi_config_proto"
,
"//modules/dreamview/proto:hmi_status_proto"
,
"@com_google_protobuf//:protobuf"
,
...
...
modules/dreamview/backend/hmi/hmi.cc
浏览文件 @
149571e8
...
...
@@ -22,6 +22,8 @@
#include "gflags/gflags.h"
#include "modules/common/adapters/adapter_manager.h"
#include "modules/common/util/http_client.h"
#include "modules/common/util/json_util.h"
#include "modules/common/util/map_util.h"
#include "modules/common/util/string_tokenizer.h"
#include "modules/common/util/string_util.h"
...
...
@@ -30,8 +32,6 @@
#include "modules/data/proto/task.pb.h"
#include "modules/dreamview/backend/common/dreamview_gflags.h"
#include "modules/dreamview/backend/hmi/vehicle_manager.h"
#include "modules/dreamview/backend/util/http_client.h"
#include "modules/dreamview/backend/util/json_util.h"
#include "modules/monitor/proto/system_status.pb.h"
DEFINE_string
(
global_flagfile
,
"modules/common/data/global_flagfile.txt"
,
...
...
@@ -55,10 +55,10 @@ using apollo::canbus::Chassis;
using
apollo
::
common
::
adapter
::
AdapterManager
;
using
apollo
::
common
::
util
::
FindOrNull
;
using
apollo
::
common
::
util
::
GetProtoFromASCIIFile
;
using
apollo
::
common
::
util
::
JsonUtil
;
using
apollo
::
common
::
util
::
StringTokenizer
;
using
apollo
::
control
::
DrivingAction
;
using
apollo
::
data
::
VehicleInfo
;
using
apollo
::
dreamview
::
util
::
JsonUtil
;
using
google
::
protobuf
::
Map
;
using
Json
=
WebSocketHandler
::
Json
;
...
...
@@ -404,8 +404,8 @@ void HMI::CheckOTAUpdates() {
ota_request
[
"tag"
]
=
std
::
getenv
(
"DOCKER_IMG"
);
Json
ota_response
;
const
auto
status
=
util
::
HttpClient
::
Post
(
FLAGS_ota_service_url
,
ota_request
,
&
ota_response
);
const
auto
status
=
apollo
::
common
::
util
::
HttpClient
::
Post
(
FLAGS_ota_service_url
,
ota_request
,
&
ota_response
);
if
(
status
.
ok
())
{
CHECK
(
JsonUtil
::
GetStringFromJson
(
ota_response
,
"tag"
,
status_
.
mutable_ota_update
()));
...
...
modules/dreamview/backend/map/BUILD
浏览文件 @
149571e8
...
...
@@ -14,7 +14,7 @@ cc_library(
"-lboost_thread"
,
],
deps
=
[
"//modules/
dreamview/backend
/util:json_util"
,
"//modules/
common
/util:json_util"
,
"//modules/map/hdmap:hdmap_util"
,
"//modules/map/pnc_map"
,
"//third_party/json"
,
...
...
modules/dreamview/backend/map/map_service.cc
浏览文件 @
149571e8
...
...
@@ -18,14 +18,15 @@
#include <algorithm>
#include "modules/common/util/json_util.h"
#include "modules/common/util/string_util.h"
#include "modules/map/hdmap/hdmap_util.h"
#include "modules/dreamview/backend/util/json_util.h"
namespace
apollo
{
namespace
dreamview
{
using
apollo
::
common
::
PointENU
;
using
apollo
::
common
::
util
::
JsonUtil
;
using
apollo
::
hdmap
::
Map
;
using
apollo
::
hdmap
::
Id
;
using
apollo
::
hdmap
::
LaneInfoConstPtr
;
...
...
@@ -41,7 +42,6 @@ using apollo::hdmap::RouteSegments;
using
apollo
::
hdmap
::
SimMapFile
;
using
apollo
::
routing
::
RoutingResponse
;
using
apollo
::
routing
::
RoutingRequest
;
using
apollo
::
dreamview
::
util
::
JsonUtil
;
namespace
{
...
...
modules/dreamview/backend/simulation_world/simulation_world_updater.cc
浏览文件 @
149571e8
...
...
@@ -16,9 +16,9 @@
#include "modules/dreamview/backend/simulation_world/simulation_world_updater.h"
#include "modules/common/util/json_util.h"
#include "modules/common/util/map_util.h"
#include "modules/dreamview/backend/common/dreamview_gflags.h"
#include "modules/dreamview/backend/util/json_util.h"
#include "modules/map/hdmap/hdmap_util.h"
namespace
apollo
{
...
...
@@ -26,8 +26,9 @@ namespace dreamview {
using
apollo
::
common
::
adapter
::
AdapterManager
;
using
apollo
::
common
::
monitor
::
MonitorMessageItem
;
using
apollo
::
common
::
util
::
GetProtoFromASCIIFile
;
using
apollo
::
common
::
util
::
ContainsKey
;
using
apollo
::
common
::
util
::
GetProtoFromASCIIFile
;
using
apollo
::
common
::
util
::
JsonUtil
;
using
apollo
::
hdmap
::
EndWayPointFile
;
using
apollo
::
routing
::
RoutingRequest
;
using
Json
=
nlohmann
::
json
;
...
...
@@ -49,7 +50,7 @@ SimulationWorldUpdater::SimulationWorldUpdater(WebSocketHandler *websocket,
MapElementIds
map_element_ids
(
*
iter
);
auto
retrieved
=
map_service_
->
RetrieveMapElements
(
map_element_ids
);
websocket_
->
SendData
(
conn
,
util
::
JsonUtil
::
ProtoToTypedJson
(
"MapData"
,
retrieved
));
conn
,
JsonUtil
::
ProtoToTypedJson
(
"MapData"
,
retrieved
));
}
});
...
...
modules/dreamview/backend/util/BUILD
浏览文件 @
149571e8
...
...
@@ -2,46 +2,6 @@ load("//tools:cpplint.bzl", "cpplint")
package
(
default_visibility
=
[
"//visibility:public"
])
cc_library
(
name
=
"json_util"
,
srcs
=
[
"json_util.cc"
,
],
hdrs
=
[
"json_util.h"
,
],
deps
=
[
"//modules/common:log"
,
"//third_party/json"
,
"@com_google_protobuf//:protobuf"
,
],
)
cc_test
(
name
=
"json_util_test"
,
size
=
"small"
,
srcs
=
[
"json_util_test.cc"
,
],
deps
=
[
":json_util"
,
"//modules/dreamview/proto:hmi_status_proto"
,
"@gtest//:main"
,
],
)
cc_library
(
name
=
"http_client"
,
srcs
=
[
"http_client.cc"
],
hdrs
=
[
"http_client.h"
],
deps
=
[
"//modules/common:log"
,
"//modules/common/status"
,
"//third_party/json"
,
"@curlpp//:curlpp"
,
],
)
cc_library
(
name
=
"trajectory_point_collector"
,
srcs
=
[
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录