1 #ifndef PROTON_CONTAINER_HPP
2 #define PROTON_CONTAINER_HPP
25 #include "./connection_options.hpp"
26 #include "./function.hpp"
27 #include "./listener.hpp"
28 #include "./receiver_options.hpp"
29 #include "./sender_options.hpp"
30 #include "./thread_safe.hpp"
32 #include "./internal/config.hpp"
33 #include "./internal/export.hpp"
40 class connection_options;
42 class messaging_handler;
46 class receiver_options;
80 virtual returned<connection> connect(
const std::string& url) = 0;
85 virtual void stop_listening(
const std::string& url) = 0;
104 virtual listener listen(
const std::string& url) = 0;
111 virtual void run() = 0;
117 virtual void auto_stop(
bool) = 0;
130 virtual void stop() = 0;
133 virtual returned<sender> open_sender(
const std::string &url) = 0;
139 virtual returned<sender> open_sender(
const std::string &url,
146 virtual returned<sender> open_sender(
const std::string &url,
151 virtual returned<receiver> open_receiver(
const std::string&url) = 0;
158 virtual returned<receiver> open_receiver(
const std::string&url,
165 virtual returned<receiver> open_receiver(
const std::string&url,
170 virtual std::string id()
const = 0;
205 #if PN_CPP_HAS_STD_FUNCTION
206 virtual void schedule(
duration, std::function<
void()>) = 0;
222 class PN_CPP_CLASS_EXTERN standard_container :
public container {
231 PN_CPP_EXTERN returned<connection> connect(
const std::string&
url);
233 PN_CPP_EXTERN
listener listen(
const std::string&
url);
234 PN_CPP_EXTERN
void stop();
235 PN_CPP_EXTERN returned<sender> open_sender(
const std::string &
url);
236 PN_CPP_EXTERN returned<sender> open_sender(
const std::string &
url,
238 PN_CPP_EXTERN returned<receiver> open_receiver(
const std::string&
url);
239 PN_CPP_EXTERN returned<receiver> open_receiver(
const std::string&
url,
249 #if PN_CPP_HAS_RVALUE_REFERENCES
258 returned<connection>
connect(
const std::string&
url) {
return impl_->connect(url); }
263 void stop_listening(
const std::string&
url) { impl_->stop_listening(url); }
264 void run() { impl_->run(); }
270 returned<sender> open_sender(
271 const std::string &url,
274 returned<sender> open_sender(
275 const std::string &url,
276 const class sender_options &o) {
return impl_->open_sender(url, o); }
278 const std::string &url) {
return impl_->open_sender(url); }
280 returned<receiver> open_receiver(
281 const std::string&url,
284 returned<receiver> open_receiver(
285 const std::string&url,
288 const std::string&url) {
return impl_->open_receiver(url); }
290 std::string
id()
const {
return impl_->id(); }
292 #if PN_CPP_HAS_STD_FUNCTION
293 PN_CPP_EXTERN
void schedule(
duration d, std::function<
void()> f) {
return impl_->schedule(d, f); }
315 #endif // PROTON_CONTAINER_HPP
virtual returned< connection > connect(const std::string &url, const connection_options &)=0
Connect to url and send an open request to the remote peer.
A top-level container of connections, sessions, senders, and receivers.
Definition: container.hpp:62
void sender_options(const class sender_options &o)
Sender options applied to senders created by this container.
Definition: container.hpp:303
connection_options server_connection_options() const
Connection options that will be applied to incoming connections.
Definition: container.hpp:301
listener listen(const std::string &url, listen_handler &l)
Start listening on url.
Definition: container.hpp:259
This is an header only class that can be used to help using containers more natural by allowing them ...
Definition: container.hpp:247
A listener for incoming connections.
Definition: listener.hpp:32
virtual returned< sender > open_sender(const std::string &url)=0
Open a connection and sender for url.
sender_options()
Create an empty set of options.
listener listen(const std::string &url)
Start listening on URL.
Definition: container.hpp:261
Options for creating a sender.
Definition: sender_options.hpp:64
A span of time in milliseconds.
Definition: duration.hpp:34
returned< receiver > open_receiver(const std::string &url)
Open a connection and receiver for url.
Definition: container.hpp:287
virtual returned< receiver > open_receiver(const std::string &url)=0
Open a connection and receiver for url.
void auto_stop(bool set)
If true, stop the container when all active connections and listeners are closed. ...
Definition: container.hpp:265
void client_connection_options(const connection_options &c)
Connection options that will be to outgoing connections.
Definition: container.hpp:297
void receiver_options(const class receiver_options &o)
Receiver options applied to receivers created by this container.
Definition: container.hpp:306
connection_options client_connection_options() const
Connection options that will be to outgoing connections.
Definition: container.hpp:298
Options for creating a connection.
Definition: connection_options.hpp:67
std::string id() const
A unique identifier for the container.
Definition: container.hpp:290
returned< sender > open_sender(const std::string &url)
Open a connection and sender for url.
Definition: container.hpp:277
class sender_options sender_options() const
Sender options applied to senders created by this container.
Definition: container.hpp:304
A C++03 compatible void no-argument callback function object, used by container::schedule() and event...
Definition: function.hpp:33
void stop(const error_condition &err)
Experimental - Stop the container with an optional error_condition err.
Definition: container.hpp:267
virtual listener listen(const std::string &url, listen_handler &lh)=0
Start listening on url.
void run()
Run the container in this thread.
Definition: container.hpp:264
A Proton URL.
Definition: url.hpp:55
returned< connection > connect(const std::string &url, const connection_options &opts)
Connect to url and send an open request to the remote peer.
Definition: container.hpp:257
void schedule(duration d, void_function0 &f)
Schedule a function to be called after the duration.
Definition: container.hpp:295
returned< connection > connect(const std::string &url)
Connect to url and send an open request to the remote peer.
Definition: container.hpp:258
Options for creating a receiver.
Definition: receiver_options.hpp:62
class receiver_options receiver_options() const
Receiver options applied to receivers created by this container.
Definition: container.hpp:307
virtual void stop()=0
Stop the container with an empty error condition.
Experimental - A handler for incoming connections.
Definition: listen_handler.hpp:32
listener listen(const std::string &url, const connection_options &opts)
Listen with a fixed set of options for all accepted connections.
Definition: container.hpp:260
void server_connection_options(const connection_options &o)
Connection options that will be applied to incoming connections.
Definition: container.hpp:300
void stop()
Stop the container with an empty error condition.
Definition: container.hpp:268
receiver_options()
Create an empty set of options.
Describes an endpoint error state.
Definition: error_condition.hpp:37