00001 #ifndef PROTON_SESSION_HPP
00002 #define PROTON_SESSION_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/export.hpp"
00026 #include "./endpoint.hpp"
00027 #include "./receiver.hpp"
00028 #include "./sender.hpp"
00029 #include "./session_options.hpp"
00030
00031 #include <proton/types.h>
00032 #include <proton/link.h>
00033
00034 #include <string>
00035
00036 struct pn_connection_t;
00037 struct pn_session_t;
00038
00039 namespace proton {
00040
00041 class container;
00042 class messaging_handler;
00043 template <class T> class thread_safe;
00044
00046 class
00047 PN_CPP_CLASS_EXTERN session : public internal::object<pn_session_t>, public endpoint {
00048 public:
00050 PN_CPP_EXTERN session(pn_session_t* s) : internal::object<pn_session_t>(s) {}
00052
00053 public:
00055 session() : internal::object<pn_session_t>(0) {}
00056
00057 PN_CPP_EXTERN bool uninitialized() const;
00058 PN_CPP_EXTERN bool active() const;
00059 PN_CPP_EXTERN bool closed() const;
00060
00061 PN_CPP_EXTERN class error_condition error() const;
00062
00066 PN_CPP_EXTERN void open();
00067
00069 PN_CPP_EXTERN void open(const session_options &opts);
00070
00071 PN_CPP_EXTERN void close();
00072 PN_CPP_EXTERN void close(const error_condition&);
00073
00075 PN_CPP_EXTERN class container &container() const;
00076
00078 PN_CPP_EXTERN class connection connection() const;
00079
00081 PN_CPP_EXTERN sender open_sender(const std::string &addr);
00082
00084 PN_CPP_EXTERN sender open_sender(const std::string &addr, const sender_options &opts);
00085
00087 PN_CPP_EXTERN receiver open_receiver(const std::string &addr);
00088
00090 PN_CPP_EXTERN receiver open_receiver(const std::string &addr, const receiver_options &opts);
00091
00093 PN_CPP_EXTERN size_t incoming_bytes() const;
00094
00096 PN_CPP_EXTERN size_t outgoing_bytes() const;
00097
00099 PN_CPP_EXTERN sender_range senders() const;
00100
00102 PN_CPP_EXTERN receiver_range receivers() const;
00103
00105 friend class internal::factory<session>;
00106 friend class session_iterator;
00107 friend class thread_safe<session>;
00109 };
00110
00112
00114 class session_iterator : public internal::iter_base<session, session_iterator> {
00115 public:
00116 explicit session_iterator(session s = 0) : internal::iter_base<session, session_iterator>(s) {}
00117
00119 PN_CPP_EXTERN session_iterator operator++();
00120 };
00121
00123 typedef internal::iter_range<session_iterator> session_range;
00124
00126
00127 }
00128
00129 #endif // PROTON_SESSION_HPP