| | |
| | | #define BUS_MAP_KEY 1 |
| | | //typedef std::basic_string<char, std::char_traits<char>, SHM_STL_Allocator<char> > SHMString; |
| | | typedef std::set<int, std::less<int>, SHM_STL_Allocator<int> > SHMKeySet; |
| | | typedef std::map<SHMString, SHMKeySet *, std::less<SHMString>, SHM_STL_Allocator<std::pair<SHMString, SHMKeySet *> > > SHMTopicSubMap; |
| | | typedef std::map<SHMString, SHMKeySet *, std::less<SHMString>, SHM_STL_Allocator<std::pair<const SHMString, SHMKeySet *> > > SHMTopicSubMap; |
| | | |
| | | enum socket_mod_t |
| | | { |
| | |
| | | void _proxy_pub( char *topic, size_t head_len, void *buf, size_t size, int port); |
| | | void *run_pubsub_proxy(); |
| | | int parse_pubsub_topic(char *str, size_t size, char **_action, char **_topic, size_t *head_len ); |
| | | int _sub_( void *topic, int size, int port, struct timespec *timeout, int flags); |
| | | int _pub_( void *topic, int topic_size, void *content, int content_size, int port, struct timespec *timeout, int flags); |
| | | int _sub_( char *topic, int size, int port, struct timespec *timeout, int flags); |
| | | int _pub_( char *topic, int topic_size, void *content, int content_size, int port, struct timespec *timeout, int flags); |
| | | |
| | | void _proxy_desub( char *topic, int port); |
| | | void _proxy_desub_all(int port); |
| | | int _desub_( void *topic, int size, int port, struct timespec *timeout, int flags); |
| | | int _desub_( char *topic, int size, int port, struct timespec *timeout, int flags); |
| | | |
| | | static void foreach_subscripters(std::function<void(SHMKeySet *, SHMKeySet::iterator)> cb); |
| | | static void foreach_subscripters(std::function<void(SHMKeySet *, int)> cb); |
| | | static bool include_in_keys(int key, int keys[], size_t length); |
| | | static size_t remove_subscripters(int keys[], size_t length) ; |
| | | public: |
| | |
| | | * @size 主题长度 |
| | | * @port 总线端口 |
| | | */ |
| | | int sub(void *topic, int size, int port); |
| | | int sub(char *topic, int size, int port); |
| | | // 超时返回。 @sec 秒 , @nsec 纳秒 |
| | | int sub_timeout(void *topic, int size, int port, struct timespec *timeout); |
| | | int sub_nowait(void *topic, int size, int port); |
| | | int sub_timeout(char *topic, int size, int port, struct timespec *timeout); |
| | | int sub_nowait(char *topic, int size, int port); |
| | | |
| | | |
| | | /** |
| | | * 取消订阅指定主题 |
| | | * @topic 主题 |
| | | * @topic 主题,主题为空时取消全部订阅 |
| | | * @size 主题长度 |
| | | * @port 总线端口 |
| | | */ |
| | | int desub( void *topic, int size, int port); |
| | | int desub( char *topic, int size, int port); |
| | | // 超时返回。 @sec 秒 , @nsec 纳秒 |
| | | int desub_timeout(void *topic, int size, int port, struct timespec *timeout); |
| | | int desub_nowait(void *topic, int size, int port) ; |
| | | int desub_timeout(char *topic, int size, int port, struct timespec *timeout); |
| | | int desub_nowait(char *topic, int size, int port) ; |
| | | |
| | | /** |
| | | * 发布主题 |
| | |
| | | * @content 主题内容 |
| | | * @port 总线端口 |
| | | */ |
| | | int pub(void *topic, int topic_size, void *content, int content_size, int port); |
| | | int pub(char *topic, int topic_size, void *content, int content_size, int port); |
| | | // 超时返回。 @sec 秒 , @nsec 纳秒 |
| | | int pub_timeout(void *topic, int topic_size, void *content, int content_size, int port, struct timespec *timeout); |
| | | int pub_nowait(void *topic, int topic_size, void *content, int content_size, int port); |
| | | int pub_timeout(char *topic, int topic_size, void *content, int content_size, int port, struct timespec *timeout); |
| | | int pub_nowait(char *topic, int topic_size, void *content, int content_size, int port); |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | }; |
| | | |
| | | #endif |
| | | #endif |