Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
6e3ed62d
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,发现更多精彩内容 >>
提交
6e3ed62d
编写于
9月 20, 2018
作者:
A
azural
提交者:
Zhongjun Ni
9月 20, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
framework: Update WriteMessage interface
上级
bda718b4
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
26 addition
and
34 deletion
+26
-34
framework/cybertron/record/record_writer.h
framework/cybertron/record/record_writer.h
+25
-33
framework/cybertron/test/record/record_test.cpp
framework/cybertron/test/record/record_test.cpp
+1
-1
未找到文件。
framework/cybertron/record/record_writer.h
浏览文件 @
6e3ed62d
...
...
@@ -52,14 +52,9 @@ class RecordWriter : public RecordBase {
const
std
::
string
&
message_type
,
const
std
::
string
&
proto_desc
);
bool
WriteMessage
(
const
std
::
string
&
channel_name
,
const
std
::
shared_ptr
<
const
RawMessage
>&
message
,
const
uint64_t
time
);
template
<
typename
MessageT
>
bool
Write
Pb
Message
(
const
std
::
string
&
channel_name
,
const
MessageT
&
message
,
bool
WriteMessage
(
const
std
::
string
&
channel_name
,
const
MessageT
&
message
,
const
uint64_t
time
,
const
std
::
string
&
proto_desc
=
""
);
void
ShowProgress
();
private:
...
...
@@ -73,34 +68,40 @@ class RecordWriter : public RecordBase {
std
::
unique_ptr
<
RecordFileWriter
>
file_writer_backup_
=
nullptr
;
};
inline
bool
RecordWriter
::
WriteMessage
(
const
std
::
string
&
channel_name
,
const
std
::
shared_ptr
<
const
RawMessage
>&
message
,
const
uint64_t
time
)
{
if
(
message
==
nullptr
)
{
AERROR
<<
"nullptr error, channel: "
<<
channel_name
;
return
false
;
}
template
<
>
inline
bool
RecordWriter
::
WriteMessage
(
const
std
::
string
&
channel_name
,
const
std
::
string
&
content
,
const
uint64_t
time
,
const
std
::
string
&
proto_desc
)
{
OnNewMessage
(
channel_name
);
SingleMessage
single_msg
;
single_msg
.
set_channel_name
(
channel_name
);
single_msg
.
set_content
(
message
->
message
);
single_msg
.
set_content
(
content
);
single_msg
.
set_time
(
time
);
if
(
!
WriteMessage
(
std
::
move
(
single_msg
)))
{
AERROR
<<
"write single msg fail"
;
return
WriteMessage
(
single_msg
);
}
template
<
>
inline
bool
RecordWriter
::
WriteMessage
(
const
std
::
string
&
channel_name
,
const
std
::
shared_ptr
<
RawMessage
>&
message
,
const
uint64_t
time
,
const
std
::
string
&
proto_desc
)
{
if
(
message
==
nullptr
)
{
AERROR
<<
"nullptr error, channel: "
<<
channel_name
;
return
false
;
}
return
true
;
return
WriteMessage
(
channel_name
,
message
->
message
,
time
)
;
}
template
<
typename
MessageT
>
bool
RecordWriter
::
Write
Pb
Message
(
const
std
::
string
&
channel_name
,
bool
RecordWriter
::
WriteMessage
(
const
std
::
string
&
channel_name
,
const
MessageT
&
message
,
const
uint64_t
time
,
const
std
::
string
&
proto_desc
)
{
std
::
string
message_type
=
GetMessageType
(
channel_name
);
const
std
::
string
&
message_type
=
GetMessageType
(
channel_name
);
if
(
message_type
.
empty
())
{
if
(
!
WriteChannel
(
channel_name
,
MessageT
::
descriptor
()
->
full_name
(),
proto_desc
))
{
AERROR
<<
"Write channel fail, channel: "
<<
channel_name
;
AERROR
<<
"Failed to write meta data to channel ["
<<
channel_name
<<
"]."
;
return
false
;
}
}
else
{
...
...
@@ -115,16 +116,7 @@ bool RecordWriter::WritePbMessage(const std::string& channel_name,
AERROR
<<
"Failed to serialize message, channel: "
<<
channel_name
;
return
false
;
}
OnNewMessage
(
channel_name
);
SingleMessage
single_msg
;
single_msg
.
set_channel_name
(
channel_name
);
single_msg
.
set_content
(
content
);
single_msg
.
set_time
(
time
);
if
(
!
WriteMessage
(
std
::
move
(
single_msg
)))
{
AERROR
<<
"write single msg fail"
;
return
false
;
}
return
true
;
return
WriteMessage
(
channel_name
,
content
,
time
);
}
}
// namespace record
...
...
framework/cybertron/test/record/record_test.cpp
浏览文件 @
6e3ed62d
...
...
@@ -134,7 +134,7 @@ TEST(RecordTest, TestMutiMessageFile) {
std
::
string
pbmsg_content
(
""
);
pbmsg
.
SerializeToString
(
&
pbmsg_content
);
ASSERT_TRUE
(
rw
->
Write
Pb
Message
<
Channel
>
(
CHANNEL_NAME_2
,
pbmsg
,
TIME_2
,
PROTO_DESC
));
ASSERT_TRUE
(
rw
->
WriteMessage
<
Channel
>
(
CHANNEL_NAME_2
,
pbmsg
,
TIME_2
,
PROTO_DESC
));
ASSERT_EQ
(
1
,
rw
->
GetMessageNumber
(
CHANNEL_NAME_2
));
ASSERT_TRUE
(
rw
->
WriteMessage
(
CHANNEL_NAME_1
,
rm
,
TIME_3
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录