00001 #ifndef PROTON_CONTAINER_HPP
00002 #define PROTON_CONTAINER_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 "./connection_options.hpp"
00026 #include "./function.hpp"
00027 #include "./listener.hpp"
00028 #include "./receiver_options.hpp"
00029 #include "./sender_options.hpp"
00030 #include "./thread_safe.hpp"
00031
00032 #include "./internal/config.hpp"
00033 #include "./internal/export.hpp"
00034
00035 #include <string>
00036
00037 namespace proton {
00038
00039 class connection;
00040 class connection_options;
00041 class container_impl;
00042 class messaging_handler;
00043 class listen_handler;
00044 class listener;
00045 class receiver;
00046 class receiver_options;
00047 class sender;
00048 class sender_options;
00049 class task;
00050
00062 class PN_CPP_CLASS_EXTERN container {
00063 public:
00064 PN_CPP_EXTERN virtual ~container();
00065
00077 virtual returned<connection> connect(const std::string& url, const connection_options &) = 0;
00078
00080 virtual returned<connection> connect(const std::string& url) = 0;
00081
00085 virtual void stop_listening(const std::string& url) = 0;
00087
00096 virtual listener listen(const std::string& url, listen_handler& lh) = 0;
00097
00100 virtual listener listen(const std::string& url, const connection_options&) = 0;
00101
00104 virtual listener listen(const std::string& url) = 0;
00105
00111 virtual void run() = 0;
00112
00117 virtual void auto_stop(bool) = 0;
00118
00126 virtual void stop(const error_condition& err) = 0;
00127
00132 virtual void stop() = 0;
00133
00135 virtual returned<sender> open_sender(const std::string &url) = 0;
00136
00141 virtual returned<sender> open_sender(const std::string &url,
00142 const proton::sender_options &o) = 0;
00143
00148 virtual returned<sender> open_sender(const std::string &url,
00149 const connection_options &c) = 0;
00150
00155 virtual returned<sender> open_sender(const std::string &url,
00156 const proton::sender_options &o,
00157 const connection_options &c) = 0;
00158
00160 virtual returned<receiver> open_receiver(const std::string&url) = 0;
00161
00162
00167 virtual returned<receiver> open_receiver(const std::string&url,
00168 const proton::receiver_options &o) = 0;
00169
00174 virtual returned<receiver> open_receiver(const std::string&url,
00175 const connection_options &c) = 0;
00176
00181 virtual returned<receiver> open_receiver(const std::string&url,
00182 const proton::receiver_options &o,
00183 const connection_options &c) = 0;
00184
00186 virtual std::string id() const = 0;
00187
00191 virtual void client_connection_options(const connection_options &) = 0;
00192
00194 virtual connection_options client_connection_options() const = 0;
00195
00200 virtual void server_connection_options(const connection_options &) = 0;
00201
00203 virtual connection_options server_connection_options() const = 0;
00204
00208 virtual void sender_options(const class sender_options &) = 0;
00209
00211 virtual class sender_options sender_options() const = 0;
00212
00216 virtual void receiver_options(const class receiver_options &) = 0;
00217
00219 virtual class receiver_options receiver_options() const = 0;
00220
00221 #if PN_CPP_HAS_STD_FUNCTION
00223 virtual void schedule(duration, std::function<void()>) = 0;
00224 #endif
00227 virtual void schedule(duration, void_function0&) = 0;
00228 };
00229
00238 class PN_CPP_CLASS_EXTERN standard_container : public container {
00239 public:
00240
00241 using container::stop;
00242 using container::connect;
00243 using container::listen;
00244 using container::open_receiver;
00245 using container::open_sender;
00246
00247 PN_CPP_EXTERN returned<connection> connect(const std::string& url);
00248 PN_CPP_EXTERN listener listen(const std::string& url, const connection_options&);
00249 PN_CPP_EXTERN listener listen(const std::string& url);
00250 PN_CPP_EXTERN void stop();
00251 PN_CPP_EXTERN returned<sender> open_sender(const std::string &url);
00252 PN_CPP_EXTERN returned<sender> open_sender(const std::string &url,
00253 const proton::sender_options &o);
00254 PN_CPP_EXTERN returned<sender> open_sender(const std::string &url,
00255 const proton::connection_options &o);
00256 PN_CPP_EXTERN returned<receiver> open_receiver(const std::string&url);
00257 PN_CPP_EXTERN returned<receiver> open_receiver(const std::string&url,
00258 const proton::receiver_options &o);
00259 PN_CPP_EXTERN returned<receiver> open_receiver(const std::string&url,
00260 const proton::connection_options &o);
00261 };
00263
00266 template <class Ptr>
00267 class container_ref : public container {
00268 public:
00269 #if PN_CPP_HAS_RVALUE_REFERENCES
00270 container_ref(Ptr&& p) : impl_(std::move(p)) {}
00271 #else
00272
00273
00274 container_ref(Ptr p) : impl_(p) {}
00275 #endif
00276
00277 returned<connection> connect(const std::string& url, const connection_options& opts) { return impl_->connect(url, opts); }
00278 returned<connection> connect(const std::string& url) { return impl_->connect(url); }
00279 listener listen(const std::string& url, listen_handler& l) { return impl_->listen(url, l); }
00280 listener listen(const std::string& url, const connection_options& opts) { return impl_->listen(url, opts); }
00281 listener listen(const std::string& url) { return impl_->listen(url); }
00282
00283 void stop_listening(const std::string& url) { impl_->stop_listening(url); }
00284 void run() { impl_->run(); }
00285 void auto_stop(bool set) { impl_->auto_stop(set); }
00286
00287 void stop(const error_condition& err) { impl_->stop(err); }
00288 void stop() { impl_->stop(); }
00289
00290 returned<sender> open_sender(
00291 const std::string &url,
00292 const class sender_options &o,
00293 const connection_options &c) { return impl_->open_sender(url, o, c); }
00294 returned<sender> open_sender(
00295 const std::string &url,
00296 const class connection_options &o) { return impl_->open_sender(url, o); }
00297 returned<sender> open_sender(
00298 const std::string &url,
00299 const class sender_options &o) { return impl_->open_sender(url, o); }
00300 returned<sender> open_sender(
00301 const std::string &url) { return impl_->open_sender(url); }
00302
00303 returned<receiver> open_receiver(
00304 const std::string&url,
00305 const class receiver_options &o,
00306 const connection_options &c) { return impl_->open_receiver(url, o, c); }
00307 returned<receiver> open_receiver(
00308 const std::string&url,
00309 const class receiver_options &o) { return impl_->open_receiver(url, o); }
00310 returned<receiver> open_receiver(
00311 const std::string&url,
00312 const class connection_options &o) { return impl_->open_receiver(url, o); }
00313 returned<receiver> open_receiver(
00314 const std::string&url) { return impl_->open_receiver(url); }
00315
00316 std::string id() const { return impl_->id(); }
00317
00318 #if PN_CPP_HAS_STD_FUNCTION
00319 PN_CPP_EXTERN void schedule(duration d, std::function<void()> f) { return impl_->schedule(d, f); }
00320 #endif
00321 PN_CPP_EXTERN void schedule(duration d, void_function0& f) { return impl_->schedule(d, f); }
00322
00323 void client_connection_options(const connection_options& c) { impl_->client_connection_options(c); }
00324 connection_options client_connection_options() const { return impl_->client_connection_options(); }
00325
00326 void server_connection_options(const connection_options &o) { impl_->server_connection_options(o); }
00327 connection_options server_connection_options() const { return impl_->server_connection_options(); }
00328
00329 void sender_options(const class sender_options &o) { impl_->sender_options(o); }
00330 class sender_options sender_options() const { return impl_->sender_options(); }
00331
00332 void receiver_options(const class receiver_options & o) { impl_->receiver_options(o); }
00333 class receiver_options receiver_options() const { return impl_->receiver_options(); }
00334
00335 private:
00336 Ptr impl_;
00337 };
00338
00339 }
00340
00341 #endif // PROTON_CONTAINER_HPP