昇腾社区首页
中文
注册

OpenHiva::Node类型定义

OpenHiva::Node主要用来创建发布者(Publisher)、订阅者(Subscriber)、服务端(ServiceServer)、客户端(ServiceClient)对象,Node类接口定义如下:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
namespace OpenHiva {
using RemappingsString = std::unordered_map<std::string, std::string>;
class Node {  
public:  
    Node(const std::string &name, const std::string &ns = std::string(), const RemappingsString& remappingsStr = RemappingsString());  
    ~ Node(); 
    template <typename M>
    std::shared_ptr<Publisher> CreatePublisher(const std::string &topicName, const TopicOptions &topicOptions = TopicOptions());
    template <typename M>
    std::shared_ptr<Subscriber> CreateSubscriber(const std::string &topicName, const std::function<void(M)> &callback, const TopicOptions & topicOptions = TopicOptions());
    template <typename ReqType, typename ResType>
    std::shared_ptr<ServiceServer> CreateServer(const std::string &serviceName, const ServiceOptions &serviceOptions, const std::function<bool(ReqType, ResType)> &serviceCallback);
    template <typename ReqType, typename ResType>
    std::shared_ptr<ServiceClient> CreateClient(const std::string &serviceName, const ServiceOptions &serverOptions);
    std::vector<std::shared_ptr<Subscriber>> GetSubscribers();
    bool Ready();  
    const std::string &GetName();
    const std::string &GetNameSpace();
private:
    void Shutdown();
    std::shared_ptr<TopicManager> topicManagerPtr_;
    std::shared_ptr<NodeUri> nodeUriPtr_;
};
}