Qpid Proton C++  0.13.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
session.hpp
1 #ifndef PROTON_SESSION_HPP
2 #define PROTON_SESSION_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/export.hpp"
26 #include "./endpoint.hpp"
27 #include "./receiver.hpp"
28 #include "./sender.hpp"
29 #include "./session_options.hpp"
30 
31 #include <proton/types.h>
32 #include <proton/link.h>
33 
34 #include <string>
35 
36 struct pn_connection_t;
37 struct pn_session_t;
38 
39 namespace proton {
40 
41 class container;
42 class messaging_handler;
43 template <class T> class thread_safe;
44 
46 class
47 PN_CPP_CLASS_EXTERN session : public internal::object<pn_session_t>, public endpoint {
48  public:
50  PN_CPP_EXTERN session(pn_session_t* s) : internal::object<pn_session_t>(s) {}
52 
53  public:
55  session() : internal::object<pn_session_t>(0) {}
56 
57  PN_CPP_EXTERN bool uninitialized() const;
58  PN_CPP_EXTERN bool active() const;
59  PN_CPP_EXTERN bool closed() const;
60 
61  PN_CPP_EXTERN class error_condition error() const;
62 
66  PN_CPP_EXTERN void open();
67 
69  PN_CPP_EXTERN void open(const session_options &opts);
70 
71  PN_CPP_EXTERN void close();
72  PN_CPP_EXTERN void close(const error_condition&);
73 
75  PN_CPP_EXTERN class container &container() const;
76 
78  PN_CPP_EXTERN class connection connection() const;
79 
81  PN_CPP_EXTERN sender open_sender(const std::string &addr);
82 
84  PN_CPP_EXTERN sender open_sender(const std::string &addr, const sender_options &opts);
85 
87  PN_CPP_EXTERN receiver open_receiver(const std::string &addr);
88 
90  PN_CPP_EXTERN receiver open_receiver(const std::string &addr, const receiver_options &opts);
91 
93  PN_CPP_EXTERN size_t incoming_bytes() const;
94 
96  PN_CPP_EXTERN size_t outgoing_bytes() const;
97 
99  PN_CPP_EXTERN sender_range senders() const;
100 
102  PN_CPP_EXTERN receiver_range receivers() const;
103 
105  friend class internal::factory<session>;
106  friend class session_iterator;
107  friend class thread_safe<session>;
109 };
110 
112 
114 class session_iterator : public internal::iter_base<session, session_iterator> {
115  public:
116  explicit session_iterator(session s = 0) : internal::iter_base<session, session_iterator>(s) {}
117 
119  PN_CPP_EXTERN session_iterator operator++();
120 };
121 
123 typedef internal::iter_range<session_iterator> session_range;
124 
126 
127 } // proton
128 
129 #endif // PROTON_SESSION_HPP
A top-level container of connections, sessions, senders, and receivers.
Definition: container.hpp:59
A channel for sending messages.
Definition: sender.hpp:40
Options for creating a sender.
Definition: sender_options.hpp:64
A connection to a remote AMQP peer.
Definition: connection.hpp:48
The base class for session, connection, and link.
Definition: endpoint.hpp:33
A container of senders and receivers.
Definition: session.hpp:46
session()
Create an empty session.
Definition: session.hpp:55
Options for creating a receiver.
Definition: receiver_options.hpp:62
A channel for receiving messages.
Definition: receiver.hpp:39
The base Proton error.
Definition: error.hpp:37
Options for creating a session.
Definition: session_options.hpp:42
Experimental - A thread-safe object wrapper.
Definition: connection.hpp:45
Describes an endpoint error state.
Definition: error_condition.hpp:37