00001 #ifndef PROTON_MESSAGE_HPP
00002 #define PROTON_MESSAGE_HPP
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "./annotation_key.hpp"
00026 #include "./codec/map.hpp"
00027 #include "./duration.hpp"
00028 #include "./internal/export.hpp"
00029 #include "./message_id.hpp"
00030 #include "./value.hpp"
00031
00032 #include "./internal/cached_map.hpp"
00033 #include "./internal/pn_unique_ptr.hpp"
00034
00035 #include <string>
00036 #include <vector>
00037 #include <utility>
00038
00039 struct pn_message_t;
00040
00041 namespace proton {
00042
00043 class delivery;
00044 class message_id;
00045 class annotation_key;
00046
00051 class message {
00052 public:
00055 class property_map : public internal::cached_map<std::string, scalar> {};
00056
00059 class annotation_map : public internal::cached_map<annotation_key, value> {};
00060
00062 PN_CPP_EXTERN message();
00063
00065 PN_CPP_EXTERN message(const message&);
00066
00068 PN_CPP_EXTERN message& operator=(const message&);
00069
00070 #if PN_CPP_HAS_RVALUE_REFERENCES
00072 PN_CPP_EXTERN message(message&&);
00073
00075 PN_CPP_EXTERN message& operator=(message&&);
00076 #endif
00077
00080 PN_CPP_EXTERN message(const value& x);
00081
00082 PN_CPP_EXTERN ~message();
00083
00086
00088 PN_CPP_EXTERN void clear();
00089
00094 PN_CPP_EXTERN void id(const message_id& id);
00095
00097 PN_CPP_EXTERN message_id id() const;
00098
00100 PN_CPP_EXTERN void user(const std::string &user);
00101
00103 PN_CPP_EXTERN std::string user() const;
00104
00107 PN_CPP_EXTERN void encode(std::vector<char> &bytes) const;
00108
00110 PN_CPP_EXTERN std::vector<char> encode() const;
00111
00113 PN_CPP_EXTERN void decode(const std::vector<char> &bytes);
00114
00116
00119
00121 PN_CPP_EXTERN void to(const std::string &addr);
00122
00124 PN_CPP_EXTERN std::string to() const;
00125
00128 PN_CPP_EXTERN void address(const std::string &addr);
00129 PN_CPP_EXTERN std::string address() const;
00131
00133 PN_CPP_EXTERN void reply_to(const std::string &addr);
00134
00136 PN_CPP_EXTERN std::string reply_to() const;
00137
00139 PN_CPP_EXTERN void correlation_id(const message_id&);
00140
00142 PN_CPP_EXTERN message_id correlation_id() const;
00143
00145
00148
00150 PN_CPP_EXTERN void body(const value& x);
00151
00153 PN_CPP_EXTERN const value& body() const;
00154
00156 PN_CPP_EXTERN value& body();
00157
00159 PN_CPP_EXTERN void subject(const std::string &s);
00160
00162 PN_CPP_EXTERN std::string subject() const;
00163
00165 PN_CPP_EXTERN void content_type(const std::string &s);
00166
00168 PN_CPP_EXTERN std::string content_type() const;
00169
00171 PN_CPP_EXTERN void content_encoding(const std::string &s);
00172
00174 PN_CPP_EXTERN std::string content_encoding() const;
00175
00177 PN_CPP_EXTERN void expiry_time(timestamp t);
00178
00180 PN_CPP_EXTERN timestamp expiry_time() const;
00181
00183 PN_CPP_EXTERN void creation_time(timestamp t);
00184
00186 PN_CPP_EXTERN timestamp creation_time() const;
00187
00197 PN_CPP_EXTERN bool inferred() const;
00198
00200 PN_CPP_EXTERN void inferred(bool);
00201
00203
00206
00211 PN_CPP_EXTERN bool durable() const;
00212
00214 PN_CPP_EXTERN void durable(bool);
00215
00223 PN_CPP_EXTERN duration ttl() const;
00224
00226 PN_CPP_EXTERN void ttl(duration);
00227
00233 PN_CPP_EXTERN uint8_t priority() const;
00234
00236 PN_CPP_EXTERN void priority(uint8_t);
00237
00246
00247
00248
00249 PN_CPP_EXTERN bool first_acquirer() const;
00250
00252 PN_CPP_EXTERN void first_acquirer(bool);
00253
00258 PN_CPP_EXTERN uint32_t delivery_count() const;
00259
00261 PN_CPP_EXTERN void delivery_count(uint32_t);
00262
00264
00267
00269 PN_CPP_EXTERN void group_id(const std::string &s);
00270
00272 PN_CPP_EXTERN std::string group_id() const;
00273
00275 PN_CPP_EXTERN void reply_to_group_id(const std::string &s);
00276
00278 PN_CPP_EXTERN std::string reply_to_group_id() const;
00279
00285 PN_CPP_EXTERN int32_t group_sequence() const;
00286
00288 PN_CPP_EXTERN void group_sequence(int32_t);
00289
00291
00294
00297 PN_CPP_EXTERN property_map& properties();
00298
00301 PN_CPP_EXTERN const property_map& properties() const;
00302
00305 PN_CPP_EXTERN annotation_map& message_annotations();
00306
00309 PN_CPP_EXTERN const annotation_map& message_annotations() const;
00310
00313 PN_CPP_EXTERN annotation_map& delivery_annotations();
00314
00317 PN_CPP_EXTERN const annotation_map& delivery_annotations() const;
00318
00320
00322 private:
00323 pn_message_t *pn_msg() const;
00324
00325 mutable pn_message_t *pn_msg_;
00326 mutable internal::value_ref body_;
00327 mutable property_map application_properties_;
00328 mutable annotation_map message_annotations_;
00329 mutable annotation_map delivery_annotations_;
00330
00332 void decode(proton::delivery);
00333
00334 PN_CPP_EXTERN friend void swap(message&, message&);
00335 friend class messaging_adapter;
00337 };
00338
00339 }
00340
00341 #endif // PROTON_MESSAGE_HPP