Qpid Proton C++ API  0.37.0
container.hpp
Go to the documentation of this file.
1 #ifndef PROTON_CONTAINER_HPP
2 #define PROTON_CONTAINER_HPP
3 
4 /*
5  *
6  * Licensed to the Apache Software Foundation (ASF) under one
7  * or more contributor license agreements. See the NOTICE file
8  * distributed with this work for additional information
9  * regarding copyright ownership. The ASF licenses this file
10  * to you under the Apache License, Version 2.0 (the
11  * "License"); you may not use this file except in compliance
12  * with the License. You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing,
17  * software distributed under the License is distributed on an
18  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19  * KIND, either express or implied. See the License for the
20  * specific language governing permissions and limitations
21  * under the License.
22  *
23  */
24 
25 #include "./fwd.hpp"
26 #include "./returned.hpp"
27 #include "./types_fwd.hpp"
28 
29 #include "./internal/export.hpp"
30 
31 #include <memory>
32 #include <string>
33 
36 
37 namespace proton {
38 
49 class PN_CPP_CLASS_EXTERN container {
50  public:
61  PN_CPP_EXTERN container(messaging_handler& handler, const std::string& id);
62 
71  PN_CPP_EXTERN container(messaging_handler& handler);
72 
75  PN_CPP_EXTERN container(const std::string& id);
76 
80  PN_CPP_EXTERN container();
81 
91  PN_CPP_EXTERN ~container();
92 
107  PN_CPP_EXTERN returned<connection> connect(const std::string& conn_url,
108  const connection_options& conn_opts);
109 
113  PN_CPP_EXTERN returned<connection> connect(const std::string& conn_url);
114 
118  PN_CPP_EXTERN returned<connection> connect();
119 
132  PN_CPP_EXTERN listener listen(const std::string& listen_url,
133  listen_handler& handler);
134 
143  PN_CPP_EXTERN listener listen(const std::string& listen_url,
144  const connection_options& conn_opts);
145 
151  PN_CPP_EXTERN listener listen(const std::string& listen_url);
152 
161  PN_CPP_EXTERN void run();
162 
169  PN_CPP_EXTERN void run(int count);
170 
177  PN_CPP_EXTERN void auto_stop(bool enabled);
178 
182  PN_CPP_EXTERN void stop(const error_condition& err);
183 
196  PN_CPP_EXTERN void stop();
197 
201  PN_CPP_EXTERN returned<sender> open_sender(const std::string& addr_url);
202 
209  PN_CPP_EXTERN returned<sender> open_sender(const std::string& addr_url,
210  const proton::sender_options& snd_opts);
211 
218  PN_CPP_EXTERN returned<sender> open_sender(const std::string& addr_url,
219  const connection_options& conn_opts);
220 
227  PN_CPP_EXTERN returned<sender> open_sender(const std::string& addr_url,
228  const proton::sender_options& snd_opts,
229  const connection_options& conn_opts);
230 
234  PN_CPP_EXTERN returned<receiver> open_receiver(const std::string& addr_url);
235 
236 
243  PN_CPP_EXTERN returned<receiver> open_receiver(const std::string& addr_url,
244  const proton::receiver_options& rcv_opts);
245 
252  PN_CPP_EXTERN returned<receiver> open_receiver(const std::string& addr_url,
253  const connection_options& conn_opts);
254 
261  PN_CPP_EXTERN returned<receiver> open_receiver(const std::string& addr_url,
262  const proton::receiver_options& rcv_opts,
263  const connection_options& conn_opts);
264 
266  PN_CPP_EXTERN std::string id() const;
267 
271  PN_CPP_EXTERN void client_connection_options(const connection_options& conn_opts);
272 
275 
280  PN_CPP_EXTERN void server_connection_options(const connection_options& conn_opts);
281 
284 
288  PN_CPP_EXTERN void sender_options(const class sender_options& snd_opts);
289 
291  PN_CPP_EXTERN class sender_options sender_options() const;
292 
296  PN_CPP_EXTERN void receiver_options(const class receiver_options& rcv_opts);
297 
299  PN_CPP_EXTERN class receiver_options receiver_options() const;
300 
306  PN_CPP_EXTERN void schedule(duration dur, work fn);
307 
309  PN_CPP_EXTERN PN_CPP_DEPRECATED("Use 'container::schedule(duration, work)'") void schedule(duration dur, void_function0& fn);
310 
311  private:
314  PN_CPP_EXTERN void schedule(duration dur, internal::v03::work fn);
315  class impl;
316  std::unique_ptr<impl> impl_;
317 
319  friend class connection_options;
320  friend class session_options;
321  friend class receiver_options;
322  friend class sender_options;
323  friend class work_queue;
325 };
326 
327 } // proton
328 
329 #endif // PROTON_CONTAINER_HPP
Options for creating a connection.
Definition: connection_options.hpp:67
A top-level container of connections, sessions, and links.
Definition: container.hpp:49
connection_options server_connection_options() const
Connection options applied to incoming connections.
void run()
Run the container in the current thread.
returned< receiver > open_receiver(const std::string &addr_url)
Open a connection and receiver for addr_url.
void auto_stop(bool enabled)
Enable or disable automatic container stop.
returned< receiver > open_receiver(const std::string &addr_url, const proton::receiver_options &rcv_opts)
Open a connection and receiver for addr_url.
void receiver_options(const class receiver_options &rcv_opts)
Receiver options applied to receivers created by this container.
returned< connection > connect()
Connect using the default Connection Configuration file.
container(messaging_handler &handler)
Create a container with a global handler for messaging events.
returned< connection > connect(const std::string &conn_url)
Connect using the default Connection Configuration file.
std::string id() const
A unique identifier for the container.
void sender_options(const class sender_options &snd_opts)
Sender options applied to senders created by this container.
~container()
Destroy a container.
void server_connection_options(const connection_options &conn_opts)
Connection options applied to incoming connections.
returned< receiver > open_receiver(const std::string &addr_url, const proton::receiver_options &rcv_opts, const connection_options &conn_opts)
Open a connection and receiver for addr_url.
container(const std::string &id)
Create a container.
void stop()
Stop the container with an empty error condition.
connection_options client_connection_options() const
Connection options applied to outgoing connections.
void client_connection_options(const connection_options &conn_opts)
Connection options applied to outgoing connections.
container(messaging_handler &handler, const std::string &id)
Create a container with a global handler for messaging events.
listener listen(const std::string &listen_url, listen_handler &handler)
Listen for new connections on listen_url.
returned< receiver > open_receiver(const std::string &addr_url, const connection_options &conn_opts)
Open a connection and receiver for addr_url.
void schedule(duration dur, work fn)
Schedule fn for execution after a duration.
returned< sender > open_sender(const std::string &addr_url, const proton::sender_options &snd_opts, const connection_options &conn_opts)
Open a connection and sender for addr_url.
void run(int count)
Run the container with a pool of count threads, including the current thread.
returned< sender > open_sender(const std::string &addr_url, const connection_options &conn_opts)
Open a connection and sender for addr_url.
listener listen(const std::string &listen_url)
Listen for new connections on listen_url.
returned< connection > connect(const std::string &conn_url, const connection_options &conn_opts)
Connect to conn_url and send an open request to the remote peer.
void stop(const error_condition &err)
Stop the container with error condition err.
returned< sender > open_sender(const std::string &addr_url)
Open a connection and sender for addr_url.
listener listen(const std::string &listen_url, const connection_options &conn_opts)
Listen for new connections on listen_url.
returned< sender > open_sender(const std::string &addr_url, const proton::sender_options &snd_opts)
Open a connection and sender for addr_url.
container()
Create a container.
A span of time in milliseconds.
Definition: duration.hpp:39
Describes an endpoint error state.
Definition: error_condition.hpp:39
Unsettled API - A handler for incoming connections.
Definition: listen_handler.hpp:39
A listener for incoming connections.
Definition: listener.hpp:33
Handler for Proton messaging events.
Definition: messaging_handler.hpp:69
Options for creating a receiver.
Definition: receiver_options.hpp:59
A return type for container methods.
Definition: returned.hpp:51
Options for creating a sender.
Definition: sender_options.hpp:60
Options for creating a session.
Definition: session_options.hpp:41
Unsettled API - A context for thread-safe execution of work.
Definition: work_queue.hpp:327
Forward declarations.
The main Proton namespace.
Definition: annotation_key.hpp:33
A return type for container methods.
Forward declarations for Proton types used to represent AMQP types.