00001 #ifndef PROTON_IO_CONNECTION_ENGINE_HPP
00002 #define PROTON_IO_CONNECTION_ENGINE_HPP
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "../internal/config.hpp"
00026 #include "../connection.hpp"
00027 #include "../connection_options.hpp"
00028 #include "../error.hpp"
00029 #include "../error_condition.hpp"
00030 #include "../internal/export.hpp"
00031 #include "../internal/pn_unique_ptr.hpp"
00032 #include "../transport.hpp"
00033 #include "../types.hpp"
00034
00035 #include <proton/connection_engine.h>
00036
00037 #include <cstddef>
00038 #include <utility>
00039 #include <string>
00040
00041 namespace proton {
00042
00043 class event_loop;
00044 class proton_handler;
00045
00046 namespace io {
00047
00049 struct mutable_buffer {
00050 char* data;
00051 size_t size;
00052
00054 mutable_buffer(char* data_=0, size_t size_=0) : data(data_), size(size_) {}
00055 };
00056
00058 struct const_buffer {
00059 const char* data;
00060 size_t size;
00061
00063 const_buffer(const char* data_=0, size_t size_=0) : data(data_), size(size_) {}
00064 };
00065
00098 class
00099 PN_CPP_CLASS_EXTERN connection_engine {
00100 public:
00107 PN_CPP_EXTERN connection_engine();
00108
00118 PN_CPP_EXTERN connection_engine(proton::container&, event_loop* loop = 0);
00119
00120 PN_CPP_EXTERN ~connection_engine();
00121
00125 void configure(const connection_options& opts=connection_options());
00126
00129 PN_CPP_EXTERN void connect(const connection_options& opts);
00130
00137 PN_CPP_EXTERN void accept(const connection_options& opts);
00138
00142 PN_CPP_EXTERN mutable_buffer read_buffer();
00143
00146 PN_CPP_EXTERN void read_done(size_t n);
00147
00150 PN_CPP_EXTERN void read_close();
00151
00155 PN_CPP_EXTERN const_buffer write_buffer();
00156
00159 PN_CPP_EXTERN void write_done(size_t n);
00160
00163 PN_CPP_EXTERN void write_close();
00164
00177 PN_CPP_EXTERN void disconnected(const error_condition& = error_condition());
00178
00190 PN_CPP_EXTERN bool dispatch();
00191
00194 PN_CPP_EXTERN proton::connection connection() const;
00195
00197 PN_CPP_EXTERN proton::transport transport() const;
00198
00200 PN_CPP_EXTERN proton::container* container() const;
00201
00202 private:
00203 connection_engine(const connection_engine&);
00204 connection_engine& operator=(const connection_engine&);
00205
00206 internal::pn_unique_ptr<proton_handler> handler_;
00207 proton::container* container_;
00208 pn_connection_engine_t c_engine_;
00209 };
00210
00211 }
00212 }
00213
00214 #endif // PROTON_IO_CONNECTION_ENGINE_HPP