Qpid Proton C++  0.16.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
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 "../connection_options.hpp"
26 #include "../error_condition.hpp"
27 #include "../fwd.hpp"
28 #include "../internal/config.hpp"
29 #include "../types_fwd.hpp"
30 
31 #include <proton/connection_driver.h>
32 
33 #include <string>
34 
35 namespace proton {
36 
37 class event_loop;
38 class proton_handler;
39 
40 namespace io {
41 
44  char* data;
45  size_t size;
46 
48  mutable_buffer(char* data_=0, size_t size_=0) : data(data_), size(size_) {}
49 };
50 
52 struct const_buffer {
53  const char* data;
54  size_t size;
55 
57  const_buffer(const char* data_=0, size_t size_=0) : data(data_), size(size_) {}
58 };
59 
88 class
89 PN_CPP_CLASS_EXTERN connection_driver {
90  public:
97  PN_CPP_EXTERN connection_driver();
98 
108  PN_CPP_EXTERN connection_driver(proton::container&);
109 #if PN_CPP_HAS_RVALUE_REFERENCES
110  PN_CPP_EXTERN connection_driver(proton::container&, event_loop&& loop);
111 #endif
112 
113  PN_CPP_EXTERN ~connection_driver();
114 
118  void configure(const connection_options& opts=connection_options(), bool server=false);
119 
122  PN_CPP_EXTERN void connect(const connection_options& opts);
123 
130  PN_CPP_EXTERN void accept(const connection_options& opts);
131 
135  PN_CPP_EXTERN mutable_buffer read_buffer();
136 
139  PN_CPP_EXTERN void read_done(size_t n);
140 
143  PN_CPP_EXTERN void read_close();
144 
148  PN_CPP_EXTERN const_buffer write_buffer();
149 
152  PN_CPP_EXTERN void write_done(size_t n);
153 
156  PN_CPP_EXTERN void write_close();
157 
165  PN_CPP_EXTERN timestamp tick(timestamp now);
166 
179  PN_CPP_EXTERN void disconnected(const error_condition& = error_condition());
180 
192  PN_CPP_EXTERN bool dispatch();
193 
196  PN_CPP_EXTERN proton::connection connection() const;
197 
199  PN_CPP_EXTERN proton::transport transport() const;
200 
202  PN_CPP_EXTERN proton::container* container() const;
203 
204  private:
205  void init();
206  connection_driver(const connection_driver&);
207  connection_driver& operator=(const connection_driver&);
208 
209  messaging_handler* handler_;
210  proton::container* container_;
211  pn_connection_driver_t driver_;
212 };
213 
214 } // io
215 } // proton
216 
217 #endif // PROTON_IO_CONNECTION_DRIVER_HPP
size_t size
Number of bytes in the buffer.
Definition: connection_driver.hpp:54
A top-level container of connections, sessions, senders, and receivers.
Definition: container.hpp:47
Experimental - Pointer to a const memory region with a size.
Definition: connection_driver.hpp:52
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:48
Experimental - A serial execution context.
Definition: event_loop.hpp:44
const char * data
Beginning of the buffered data.
Definition: connection_driver.hpp:53
char * data
Beginning of the buffered data.
Definition: connection_driver.hpp:44
A 64-bit timestamp in milliseconds since the Unix epoch.
Definition: timestamp.hpp:32
size_t size
Number of bytes in the buffer.
Definition: connection_driver.hpp:45
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:57
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:43
Experimental - An AMQP driver for a single connection.
Definition: connection_driver.hpp:88
Describes an endpoint error state.
Definition: error_condition.hpp:37