Qpid Proton C++ API 0.40.0
 
Loading...
Searching...
No Matches
connection_driver.hpp
Go to the documentation of this file.
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 "../types_fwd.hpp"
29
30#include <proton/connection_driver.h>
31
32#include <string>
33
36
37namespace proton {
38
39class work_queue;
40class proton_handler;
41
42namespace io {
43
47 char* data;
48 size_t size;
49
51 mutable_buffer(char* data_=0, size_t size_=0) : data(data_), size(size_) {}
52};
53
57 const char* data;
58 size_t size;
59
61 const_buffer(const char* data_=0, size_t size_=0) : data(data_), size(size_) {}
62};
63
92class
93PN_CPP_CLASS_EXTERN connection_driver {
94 public:
96 PN_CPP_EXTERN connection_driver();
97
99 PN_CPP_EXTERN connection_driver(const std::string&);
100
101 PN_CPP_EXTERN ~connection_driver();
102
106 void configure(const connection_options& opts=connection_options(), bool server=false);
107
110 PN_CPP_EXTERN void connect(const connection_options& opts);
111
118 PN_CPP_EXTERN void accept(const connection_options& opts);
119
124
127 PN_CPP_EXTERN void read_done(size_t n);
128
131 PN_CPP_EXTERN void read_close();
132
136 PN_CPP_EXTERN const_buffer write_buffer();
137
140 PN_CPP_EXTERN const_buffer write_done(size_t n);
141
144 PN_CPP_EXTERN void write_close();
145
153 PN_CPP_EXTERN timestamp tick(timestamp now);
154
167 PN_CPP_EXTERN void disconnected(const error_condition& = error_condition());
168
170 PN_CPP_EXTERN bool has_events() const;
171
183 PN_CPP_EXTERN bool dispatch();
184
186 PN_CPP_EXTERN proton::connection connection() const;
187
189 PN_CPP_EXTERN proton::transport transport() const;
190
192 PN_CPP_EXTERN proton::container* container() const;
193
194 private:
195 void init();
197 connection_driver& operator=(const connection_driver&);
198
199 std::string container_id_;
200 messaging_handler* handler_;
201 pn_connection_driver_t driver_;
202};
203
204} // io
205} // proton
206
207#endif // PROTON_IO_CONNECTION_DRIVER_HPP
Options for creating a connection.
Definition connection_options.hpp:67
A connection to a remote AMQP peer.
Definition connection.hpp:47
A top-level container of connections, sessions, and links.
Definition container.hpp:50
Describes an endpoint error state.
Definition error_condition.hpp:39
Unsettled API - An AMQP driver for a single connection.
Definition connection_driver.hpp:93
const_buffer write_done(size_t n)
Indicate that the first n bytes of write_buffer() have been written successfully.
void disconnected(const error_condition &=error_condition())
Inform the engine that the transport been disconnected unexpectedly, without completing the AMQP conn...
void read_done(size_t n)
Indicate that the first n bytes of read_buffer() have valid data.
void connect(const connection_options &opts)
Call configure() with client options and call connection::open() Options applied: container::id(),...
bool dispatch()
Dispatch all available events and call the corresponding messaging_handler methods.
connection_driver()
An engine without a container id.
proton::container * container() const
Get the container associated with this connection_driver, if there is one.
connection_driver(const std::string &)
Create a connection driver associated with a container id.
proton::connection connection() const
Get the AMQP connection associated with this connection_driver.
void configure(const connection_options &opts=connection_options(), bool server=false)
Configure a connection by applying exactly the options in opts (including proton::messaging_handler) ...
void accept(const connection_options &opts)
Call configure() with server options.
bool has_events() const
There are events to be dispatched by dispatch()
void read_close()
Indicate that the read side of the transport is closed and no more data will be read.
timestamp tick(timestamp now)
Indicate that time has passed.
const_buffer write_buffer()
The engine's write buffer.
void write_close()
Indicate that the write side of the transport has closed and no more data can be written.
proton::transport transport() const
Get the transport associated with this connection_driver.
mutable_buffer read_buffer()
The engine's read buffer.
Handler for Proton messaging events.
Definition messaging_handler.hpp:69
A 64-bit timestamp in milliseconds since the Unix epoch.
Definition timestamp.hpp:35
A network channel supporting an AMQP connection.
Definition transport.hpp:37
The main Proton namespace.
Definition annotation_key.hpp:33
Unsettled API - A pointer to an immutable memory region with a size.
Definition connection_driver.hpp:56
size_t size
Number of bytes in the buffer.
Definition connection_driver.hpp:58
const char * data
Beginning of the buffered data.
Definition connection_driver.hpp:57
const_buffer(const char *data_=0, size_t size_=0)
Construct a buffer starting at data_ with size_ bytes.
Definition connection_driver.hpp:61
Unsettled API - A pointer to a mutable memory region with a size.
Definition connection_driver.hpp:46
size_t size
Number of bytes in the buffer.
Definition connection_driver.hpp:48
char * data
Beginning of the buffered data.
Definition connection_driver.hpp:47
mutable_buffer(char *data_=0, size_t size_=0)
Construct a buffer starting at data_ with size_ bytes.
Definition connection_driver.hpp:51