will.hpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // Copyright Takatoshi Kondo 2015
  2. //
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // (See accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. #if !defined(MQTT_WILL_HPP)
  7. #define MQTT_WILL_HPP
  8. #include <string>
  9. #include <mqtt/namespace.hpp>
  10. #include <mqtt/namespace.hpp>
  11. #include <mqtt/move.hpp>
  12. #include <mqtt/publish.hpp>
  13. #include <mqtt/property_variant.hpp>
  14. namespace MQTT_NS {
  15. class will {
  16. public:
  17. /**
  18. * @brief constructor
  19. * @param topic
  20. * A topic name to publish as a will
  21. * @param message
  22. * The contents to publish as a will
  23. * @param pubopts
  24. * Qos and retain flag
  25. * @param qos
  26. * qos
  27. */
  28. will(buffer topic,
  29. buffer message,
  30. publish_options pubopts = {},
  31. v5::properties props = {})
  32. :topic_(force_move(topic)),
  33. message_(force_move(message)),
  34. pubopts_(pubopts),
  35. props_(force_move(props))
  36. {}
  37. constexpr buffer const& topic() const {
  38. return topic_;
  39. }
  40. constexpr buffer& topic() {
  41. return topic_;
  42. }
  43. constexpr buffer const& message() const {
  44. return message_;
  45. }
  46. constexpr buffer& message() {
  47. return message_;
  48. }
  49. constexpr retain get_retain() const {
  50. return pubopts_.get_retain();
  51. }
  52. constexpr qos get_qos() const {
  53. return pubopts_.get_qos();
  54. }
  55. constexpr v5::properties const& props() const {
  56. return props_;
  57. }
  58. constexpr v5::properties& props() {
  59. return props_;
  60. }
  61. private:
  62. buffer topic_;
  63. buffer message_;
  64. publish_options pubopts_;
  65. v5::properties props_;
  66. };
  67. } // namespace MQTT_NS
  68. #endif // MQTT_WILL_HPP