00001 #ifndef PROTON_IO_CONNECTION_DRIVER_HPP
00002 #define PROTON_IO_CONNECTION_DRIVER_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 "../connection_options.hpp"
00026 #include "../error_condition.hpp"
00027 #include "../fwd.hpp"
00028 #include "../internal/config.hpp"
00029 #include "../types_fwd.hpp"
00030
00031 #include <proton/connection_driver.h>
00032
00033 #include <string>
00034
00037
00038 namespace proton {
00039
00040 class work_queue;
00041 class proton_handler;
00042
00043 namespace io {
00044
00047 struct mutable_buffer {
00048 char* data;
00049 size_t size;
00050
00052 mutable_buffer(char* data_=0, size_t size_=0) : data(data_), size(size_) {}
00053 };
00054
00057 struct const_buffer {
00058 const char* data;
00059 size_t size;
00060
00062 const_buffer(const char* data_=0, size_t size_=0) : data(data_), size(size_) {}
00063 };
00064
00093 class
00094 PN_CPP_CLASS_EXTERN connection_driver {
00095 public:
00097 PN_CPP_EXTERN connection_driver();
00098
00100 PN_CPP_EXTERN connection_driver(const std::string&);
00101
00102 PN_CPP_EXTERN ~connection_driver();
00103
00107 void configure(const connection_options& opts=connection_options(), bool server=false);
00108
00111 PN_CPP_EXTERN void connect(const connection_options& opts);
00112
00119 PN_CPP_EXTERN void accept(const connection_options& opts);
00120
00124 PN_CPP_EXTERN mutable_buffer read_buffer();
00125
00128 PN_CPP_EXTERN void read_done(size_t n);
00129
00132 PN_CPP_EXTERN void read_close();
00133
00137 PN_CPP_EXTERN const_buffer write_buffer();
00138
00141 PN_CPP_EXTERN void write_done(size_t n);
00142
00145 PN_CPP_EXTERN void write_close();
00146
00154 PN_CPP_EXTERN timestamp tick(timestamp now);
00155
00168 PN_CPP_EXTERN void disconnected(const error_condition& = error_condition());
00169
00171 PN_CPP_EXTERN bool has_events() const;
00172
00184 PN_CPP_EXTERN bool dispatch();
00185
00187 PN_CPP_EXTERN proton::connection connection() const;
00188
00190 PN_CPP_EXTERN proton::transport transport() const;
00191
00193 PN_CPP_EXTERN proton::container* container() const;
00194
00195 private:
00196 void init();
00197 connection_driver(const connection_driver&);
00198 connection_driver& operator=(const connection_driver&);
00199
00200 std::string container_id_;
00201 messaging_handler* handler_;
00202 pn_connection_driver_t driver_;
00203 };
00204
00205 }
00206 }
00207
00208 #endif // PROTON_IO_CONNECTION_DRIVER_HPP