Qpid Proton C++  0.17.0
connection_driver.hpp
1 #ifndef PROTON_IO_CONNECTION_DRIVER_HPP
2 #define PROTON_IO_CONNECTION_DRIVER_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 "../internal/config.hpp"
26 #include "../connection.hpp"
27 #include "../connection_options.hpp"
28 #include "../error.hpp"
29 #include "../error_condition.hpp"
30 #include "../internal/export.hpp"
31 #include "../internal/pn_unique_ptr.hpp"
32 #include "../transport.hpp"
33 #include "../types.hpp"
34 
35 #include <proton/connection_driver.h>
36 
37 #include <cstddef>
38 #include <utility>
39 #include <string>
40 
41 namespace proton {
42 
43 class event_loop;
44 class proton_handler;
45 
46 namespace io {
47 
50  char* data;
51  size_t size;
52 
54  mutable_buffer(char* data_=0, size_t size_=0) : data(data_), size(size_) {}
55 };
56 
58 struct const_buffer {
59  const char* data;
60  size_t size;
61 
63  const_buffer(const char* data_=0, size_t size_=0) : data(data_), size(size_) {}
64 };
65 
94 class
95 PN_CPP_CLASS_EXTERN connection_driver {
96  public:
103  PN_CPP_EXTERN connection_driver();
104 
114  PN_CPP_EXTERN connection_driver(proton::container&);
115 #if PN_CPP_HAS_RVALUE_REFERENCES
116  PN_CPP_EXTERN connection_driver(proton::container&, event_loop&& loop);
117 #endif
118 
119  PN_CPP_EXTERN ~connection_driver();
120 
124  void configure(const connection_options& opts=connection_options(), bool server=false);
125 
128  PN_CPP_EXTERN void connect(const connection_options& opts);
129 
136  PN_CPP_EXTERN void accept(const connection_options& opts);
137 
141  PN_CPP_EXTERN mutable_buffer read_buffer();
142 
145  PN_CPP_EXTERN void read_done(size_t n);
146 
149  PN_CPP_EXTERN void read_close();
150 
154  PN_CPP_EXTERN const_buffer write_buffer();
155 
158  PN_CPP_EXTERN void write_done(size_t n);
159 
162  PN_CPP_EXTERN void write_close();
163 
176  PN_CPP_EXTERN void disconnected(const error_condition& = error_condition());
177 
189  PN_CPP_EXTERN bool dispatch();
190 
193  PN_CPP_EXTERN proton::connection connection() const;
194 
196  PN_CPP_EXTERN proton::transport transport() const;
197 
199  PN_CPP_EXTERN proton::container* container() const;
200 
201  private:
202  void init();
203  connection_driver(const connection_driver&);
204  connection_driver& operator=(const connection_driver&);
205 
206  messaging_handler* handler_;
207  proton::container* container_;
208  pn_connection_driver_t driver_;
209 };
210 
211 } // io
212 } // proton
213 
214 #endif // PROTON_IO_CONNECTION_DRIVER_HPP
size_t size
Number of bytes in the buffer.
Definition: connection_driver.hpp:60
A top-level container of connections, sessions, senders, and receivers.
Definition: container.hpp:50
Experimental - Pointer to a const memory region with a size.
Definition: connection_driver.hpp:58
A connection to a remote AMQP peer.
Definition: connection.hpp:40
Options for creating a connection.
Definition: connection_options.hpp:62
mutable_buffer(char *data_=0, size_t size_=0)
Construct a buffer starting at data_ with size_ bytes.
Definition: connection_driver.hpp:54
Experimental - A serial execution context.
Definition: event_loop.hpp:44
const char * data
Beginning of the buffered data.
Definition: connection_driver.hpp:59
char * data
Beginning of the buffered data.
Definition: connection_driver.hpp:50
size_t size
Number of bytes in the buffer.
Definition: connection_driver.hpp:51
A handler for Proton messaging events.
Definition: messaging_handler.hpp:59
const_buffer(const char *data_=0, size_t size_=0)
Construct a buffer starting at data_ with size_ bytes.
Definition: connection_driver.hpp:63
A network channel supporting an AMQP connection.
Definition: transport.hpp:34
Experimental - Pointer to a mutable memory region with a size.
Definition: connection_driver.hpp:49
Experimental - An AMQP driver for a single connection.
Definition: connection_driver.hpp:94
The main Proton namespace.
Definition: annotation_key.hpp:30
Describes an endpoint error state.
Definition: error_condition.hpp:37