Qpid Proton C++ API 0.41.1
Loading...
Searching...
No Matches
session.hpp
Go to the documentation of this file.
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 "./fwd.hpp"
26#include "./internal/export.hpp"
27#include "./endpoint.hpp"
28#include "./receiver.hpp"
29#include "./sender.hpp"
30
31#include <string>
32
35
36struct pn_session_t;
37
38namespace proton {
39
41class
42PN_CPP_CLASS_EXTERN session : public internal::object<pn_session_t>, public endpoint {
43 public:
45 PN_CPP_EXTERN session(pn_session_t* s) : internal::object<pn_session_t>(s) {}
47
48 public:
50 session() : internal::object<pn_session_t>(0) {}
51
52 PN_CPP_EXTERN ~session();
53
54 PN_CPP_EXTERN bool uninitialized() const;
55 PN_CPP_EXTERN bool active() const;
56 PN_CPP_EXTERN bool closed() const;
57
58 PN_CPP_EXTERN class error_condition error() const;
59
61 PN_CPP_EXTERN void open();
62
64 PN_CPP_EXTERN void open(const session_options &opts);
65
66 PN_CPP_EXTERN void close();
67 PN_CPP_EXTERN void close(const error_condition&);
68
70 PN_CPP_EXTERN class container &container() const;
71
73 PN_CPP_EXTERN class work_queue& work_queue() const;
74
76 PN_CPP_EXTERN class connection connection() const;
77
79 PN_CPP_EXTERN sender open_sender(const std::string &addr);
80
82 PN_CPP_EXTERN sender open_sender(const std::string &addr, const sender_options &opts);
83
85 PN_CPP_EXTERN receiver open_receiver(const std::string &addr);
86
88 PN_CPP_EXTERN receiver open_receiver(const std::string &addr, const receiver_options &opts);
89
91 PN_CPP_EXTERN size_t incoming_bytes() const;
92
94 PN_CPP_EXTERN size_t outgoing_bytes() const;
95
97 PN_CPP_EXTERN sender_range senders() const;
98
100 PN_CPP_EXTERN receiver_range receivers() const;
101
103 PN_CPP_EXTERN void user_data(void* user_data) const;
104
106 PN_CPP_EXTERN void* user_data() const;
107
115 PN_CPP_EXTERN void transaction_declare();
116
119 PN_CPP_EXTERN void transaction_declare(const transaction_options& opts);
120
125 PN_CPP_EXTERN void transaction_commit();
126
131 PN_CPP_EXTERN void transaction_abort();
132
134 PN_CPP_EXTERN bool transaction_is_declared() const;
135
140 PN_CPP_EXTERN binary transaction_id() const;
141
143 PN_CPP_EXTERN error_condition transaction_error() const;
144
146 friend class internal::factory<session>;
147 friend class sender;
148 friend class session_iterator;
150};
151
153
155class session_iterator : public internal::iter_base<session, session_iterator> {
156 public:
157 explicit session_iterator(session s = nullptr) : internal::iter_base<session, session_iterator>(s) {}
158
160 PN_CPP_EXTERN session_iterator operator++();
161};
162
164typedef internal::iter_range<session_iterator> session_range;
165
167
168} // proton
169
170#endif // PROTON_SESSION_HPP
Arbitrary binary data.
Definition binary.hpp:40
The base class for session, connection, and link.
Definition endpoint.hpp:36
Describes an endpoint error state.
Definition error_condition.hpp:39
Options for creating a receiver.
Definition receiver_options.hpp:59
A channel for receiving messages.
Definition receiver.hpp:42
Options for creating a sender.
Definition sender_options.hpp:60
A channel for sending messages.
Definition sender.hpp:40
Options for creating a session.
Definition session_options.hpp:41
A container of senders and receivers.
Definition session.hpp:42
class error_condition error() const
Get the error condition of the remote endpoint.
void * user_data() const
Get user data from this session.
receiver open_receiver(const std::string &addr, const receiver_options &opts)
Open a receiver for addr.
binary transaction_id() const
Unsettled API - Return the identifier of the current transaction.
bool transaction_is_declared() const
Unsettled API - Return true if a transaction is currently declared.
sender_range senders() const
Return the senders on this session.
error_condition transaction_error() const
Unsettled API - Return the error condition associated with transaction.
void close()
Close the endpoint.
void transaction_declare()
Unsettled API - Declare a new local transaction on this session.
receiver_range receivers() const
Return the receivers on this session.
void open(const session_options &opts)
Open the session.
void close(const error_condition &)
Close the endpoint with an error condition.
void transaction_declare(const transaction_options &opts)
Unsettled API - Declare a new local transaction on this session.
session()
Create an empty session.
Definition session.hpp:50
class work_queue & work_queue() const
Get the work_queue for the session.
void open()
Open the session.
void transaction_commit()
Unsettled API - Commit the currently declared transaction.
receiver open_receiver(const std::string &addr)
Open a receiver for addr.
void user_data(void *user_data) const
Set user data on this session.
bool uninitialized() const
True if the local end is uninitialized.
sender open_sender(const std::string &addr, const sender_options &opts)
Open a sender for addr.
class container & container() const
Get the container for this session.
bool active() const
True if the local end is active.
bool closed() const
True if the local and remote ends are closed.
sender open_sender(const std::string &addr)
Open a sender for addr.
void transaction_abort()
Unsettled API - Abort the currently declared transaction.
size_t outgoing_bytes() const
The number of outgoing bytes currently buffered.
size_t incoming_bytes() const
The number of incoming bytes currently buffered.
class connection connection() const
Get the connection this session belongs to.
Options for declaring a session transaction.
Definition transaction_options.hpp:40
The base class for session, connection, and link.
Forward declarations.
The main Proton namespace.
Definition annotation_key.hpp:33
A channel for receiving messages.
A channel for sending messages.