paho-mqtt-cpp
MQTT C++ Client for POSIX and Windows
delivery_token.h
Go to the documentation of this file.
1 
8 /*******************************************************************************
9  * Copyright (c) 2013-2016 Frank Pagliughi <fpagliughi@mindspring.com>
10  *
11  * All rights reserved. This program and the accompanying materials
12  * are made available under the terms of the Eclipse Public License v2.0
13  * and Eclipse Distribution License v1.0 which accompany this distribution.
14  *
15  * The Eclipse Public License is available at
16  * http://www.eclipse.org/legal/epl-v20.html
17  * and the Eclipse Distribution License is available at
18  * http://www.eclipse.org/org/documents/edl-v10.php.
19  *
20  * Contributors:
21  * Frank Pagliughi - initial implementation and documentation
22  *******************************************************************************/
23 
24 #ifndef __mqtt_delivery_token_h
25 #define __mqtt_delivery_token_h
26 
27 #include "MQTTAsync.h"
28 #include "mqtt/token.h"
29 #include "mqtt/message.h"
30 #include <memory>
31 
32 namespace mqtt {
33 
35 
41 class delivery_token : public token
42 {
44  const_message_ptr msg_;
45 
47  friend class async_client;
48 
53  void set_message(const_message_ptr msg) { msg_ = msg; }
54 
55 public:
57  using ptr_t = std::shared_ptr<delivery_token>;
59  using const_ptr_t = std::shared_ptr<delivery_token>;
61  using weak_ptr_t = std::weak_ptr<delivery_token>;
62 
74  : token(token::Type::PUBLISH, cli, msg->get_topic()), msg_(std::move(msg)) {}
86  void* userContext, iaction_listener& cb)
87  : token(token::Type::PUBLISH, cli, msg->get_topic(), userContext, cb), msg_(std::move(msg)) {}
92  static ptr_t create(iasync_client& cli) {
93  return std::make_shared<delivery_token>(cli);
94  }
101  return std::make_shared<delivery_token>(cli, msg);
102  }
114  void* userContext, iaction_listener& cb) {
115  return std::make_shared<delivery_token>(cli, msg, userContext, cb);
116  }
121  virtual const_message_ptr get_message() const { return msg_; }
122 };
123 
126 
129 
131 // end namespace mqtt
132 }
133 
134 #endif // __mqtt_delivery_token_h
135 
message::const_ptr_t const_message_ptr
Definition: message.h:368
static ptr_t create(iasync_client &cli)
Definition: delivery_token.h:92
Definition: async_client.h:107
Definition: iaction_listener.h:48
Type
Definition: token.h:63
delivery_token(iasync_client &cli, const_message_ptr msg)
Definition: delivery_token.h:73
static ptr_t create(iasync_client &cli, const_message_ptr msg)
Definition: delivery_token.h:100
Definition: token.h:66
std::weak_ptr< delivery_token > weak_ptr_t
Definition: delivery_token.h:61
Definition: iasync_client.h:58
virtual const_message_ptr get_message() const
Definition: delivery_token.h:121
static ptr_t create(iasync_client &cli, const_message_ptr msg, void *userContext, iaction_listener &cb)
Definition: delivery_token.h:113
delivery_token::ptr_t delivery_token_ptr
Definition: delivery_token.h:125
delivery_token::const_ptr_t const_delivery_token_ptr
Definition: delivery_token.h:128
std::shared_ptr< delivery_token > ptr_t
Definition: delivery_token.h:57
Definition: token.h:52
Definition: async_client.h:49
delivery_token(iasync_client &cli, const_message_ptr msg, void *userContext, iaction_listener &cb)
Definition: delivery_token.h:85
delivery_token(iasync_client &cli)
Definition: delivery_token.h:67
std::shared_ptr< delivery_token > const_ptr_t
Definition: delivery_token.h:59
Definition: delivery_token.h:41