MqttTopic.h 965 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #pragma once
  2. #include <string>
  3. #include "memepp/buffer_def.hpp"
  4. namespace mqtt {
  5. // 定义 mqtt 主题的类
  6. class MqttTopic {
  7. public:
  8. // 构造函数
  9. MqttTopic() {}
  10. MqttTopic(const std::string& topic, const std::string& stationId);
  11. // 构造函数
  12. MqttTopic(const std::string& topic, const std::string& stationId, bool hasReply);
  13. // 构造函数
  14. MqttTopic(const std::string& topic, const std::string& stationId, bool hasReply, bool is_gateway_active);
  15. // 返回订阅topic
  16. memepp::string get_subscribe_topic() const;
  17. // 返回订阅topic
  18. memepp::string get_publish_topic() const;
  19. // 是否有回复
  20. bool hasReply_ = true;
  21. // 是否网关主动
  22. bool is_gateway_active_ = true;
  23. private:
  24. // 成员变量
  25. std::string topic_;
  26. std::string stationId_;
  27. };
  28. } // namespace mqtt