Qpid Proton C++  0.13.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
connection_engine.hpp
1 #ifndef PROTON_IO_CONNECTION_ENGINE_HPP
2 #define PROTON_IO_CONNECTION_ENGINE_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 <cstddef>
36 #include <utility>
37 #include <string>
38 
39 struct pn_collector_t;
40 
41 namespace proton {
42 
43 class event_loop;
44 class proton_handler;
45 
46 namespace io {
47 
48 class link_namer;
49 
52  char* data;
53  size_t size;
54 
56  mutable_buffer(char* data_=0, size_t size_=0) : data(data_), size(size_) {}
57 };
58 
60 struct const_buffer {
61  const char* data;
62  size_t size;
63 
65  const_buffer(const char* data_=0, size_t size_=0) : data(data_), size(size_) {}
66 };
67 
100 class
101 PN_CPP_CLASS_EXTERN connection_engine {
102  public:
105  PN_CPP_EXTERN connection_engine(proton::container&, link_namer&, event_loop* loop = 0);
106 
107  PN_CPP_EXTERN ~connection_engine();
108 
112  void configure(const connection_options& opts=connection_options());
113 
116  PN_CPP_EXTERN void connect(const connection_options& opts);
117 
124  PN_CPP_EXTERN void accept(const connection_options& opts);
125 
129  PN_CPP_EXTERN mutable_buffer read_buffer();
130 
133  PN_CPP_EXTERN void read_done(size_t n);
134 
137  PN_CPP_EXTERN void read_close();
138 
142  PN_CPP_EXTERN const_buffer write_buffer() const;
143 
146 
147  PN_CPP_EXTERN void write_done(size_t n);
148 
151  PN_CPP_EXTERN void write_close();
152 
165  PN_CPP_EXTERN void disconnected(const error_condition& = error_condition());
166 
178  PN_CPP_EXTERN bool dispatch();
179 
181  PN_CPP_EXTERN proton::connection connection() const;
182 
184  PN_CPP_EXTERN proton::transport transport() const;
185 
187  PN_CPP_EXTERN proton::container& container() const;
188 
189  private:
190  connection_engine(const connection_engine&);
191  connection_engine& operator=(const connection_engine&);
192 
193  // TODO aconway 2016-05-06: reduce binary compat footprint, move stuff to connection context.
194  proton::proton_handler* handler_;
195  proton::connection connection_;
196  proton::transport transport_;
197  proton::internal::pn_ptr<pn_collector_t> collector_;
198  proton::container& container_;
199 };
200 
201 } // io
202 } // proton
203 
204 #endif // PROTON_IO_CONNECTION_ENGINE_HPP
size_t size
Number of bytes in the buffer.
Definition: connection_engine.hpp:62
A top-level container of connections, sessions, senders, and receivers.
Definition: container.hpp:59
Experimental - Pointer to a const memory region with a size.
Definition: connection_engine.hpp:60
A connection to a remote AMQP peer.
Definition: connection.hpp:48
Options for creating a connection.
Definition: connection_options.hpp:67
mutable_buffer(char *data_=0, size_t size_=0)
Construct a buffer starting at data_ with size_ bytes.
Definition: connection_engine.hpp:56
Experimental - A serial execution context.
Definition: event_loop.hpp:56
const char * data
Beginning of the buffered data.
Definition: connection_engine.hpp:61
char * data
Beginning of the buffered data.
Definition: connection_engine.hpp:52
Experimental - An AMQP protocol engine for a single connection.
Definition: connection_engine.hpp:100
size_t size
Number of bytes in the buffer.
Definition: connection_engine.hpp:53
const_buffer(const char *data_=0, size_t size_=0)
Construct a buffer starting at data_ with size_ bytes.
Definition: connection_engine.hpp:65
A network channel supporting an AMQP connection.
Definition: transport.hpp:42
Experimental - Pointer to a mutable memory region with a size.
Definition: connection_engine.hpp:51
Describes an endpoint error state.
Definition: error_condition.hpp:37