forked from ChunelFeng/CGraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGMessageUtils.h
More file actions
72 lines (55 loc) · 3.24 KB
/
GMessageUtils.h
File metadata and controls
72 lines (55 loc) · 3.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/***************************
@Author: Chunel
@Contact: chunel@foxmail.com
@File: GMessageUtils.h
@Time: 2022/11/1 22:48
@Desc:
***************************/
#ifndef CGRAPH_GMESSAGEUTILS_H
#define CGRAPH_GMESSAGEUTILS_H
#include "GMessageManagerSingleton.h"
CGRAPH_NAMESPACE_BEGIN
/*******************************
* 以下是 send recv 的功能对应的接口
*******************************/
/* 创建一个 topic */
#define CGRAPH_CREATE_MESSAGE_TOPIC(Type, topic, size) \
CGraph::GMessageManagerSingleton::get()->template createTopic<Type>(topic, size); \
/* 删除一个 topic */
#define CGRAPH_REMOVE_MESSAGE_TOPIC(topic) \
CGraph::GMessageManagerSingleton::get()->removeTopic(topic); \
/* 发送一个 message param */
#define CGRAPH_SEND_MPARAM(Type, topic, value, strategy) \
CGraph::GMessageManagerSingleton::get()->template sendTopicValue<Type>(topic, value, strategy); \
/* 接收一个 message param */
#define CGRAPH_RECV_MPARAM(Type, topic, value) \
CGraph::GMessageManagerSingleton::get()->template recvTopicValue<Type>(topic, value); \
/* 有等待时间的接收一个 message param */
#define CGRAPH_RECV_MPARAM_WITH_TIMEOUT(Type, topic, value, timeout) \
CGraph::GMessageManagerSingleton::get()->template recvTopicValue<Type>(topic, value, timeout); \
/*******************************
* 以下是 pub sub 的功能对应的接口
*******************************/
/* 绑定一个topic,并且返回 conn id 信息 */
#define CGRAPH_BIND_MESSAGE_TOPIC(Type, topic, size) \
CGraph::GMessageManagerSingleton::get()->template bindTopic<Type>(topic, size); \
/* 发布一个消息 */
#define CGRAPH_PUB_MPARAM(Type, topic, value, strategy) \
CGraph::GMessageManagerSingleton::get()->template pubTopicValue<Type>(topic, value, strategy); \
/* 订阅一个消息 */
#define CGRAPH_SUB_MPARAM(Type, connId, value) \
CGraph::GMessageManagerSingleton::get()->template subTopicValue<Type>(connId, value); \
/* 有等待时间的订阅一个消息 */
#define CGRAPH_SUB_MPARAM_WITH_TIMEOUT(Type, connId, value, timeout) \
CGraph::GMessageManagerSingleton::get()->template subTopicValue<Type>(connId, value, timeout); \
/* 删除消息 */
#define CGRAPH_DROP_MESSAGE_TOPIC(topic) \
CGraph::GMessageManagerSingleton::get()->dropTopic(topic); \
/****************************
* 以下针对所有功能
****************************/
/* 清空所有的topic */
#define CGRAPH_CLEAR_MESSAGES() \
CGraph::GMessageManagerSingleton::get()->clear(); \
CGRAPH_NAMESPACE_END
#endif //CGRAPH_GMESSAGEUTILS_H