Debian Codegraph @

cpp/src/endpoint.cpp

raw
1 /*
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 */
21 #include "proton_bits.hpp"
22
23 #include "proton/connection.hpp"
24 #include "proton/endpoint.hpp"
25 #include "proton/error_condition.hpp"
26 #include "proton/link.hpp"
27 #include "proton/session.hpp"
28
29 #include <proton/connection.h>
30 #include <proton/session.h>
31 #include <proton/link.h>
32
33 namespace {
34
35 inline bool uninitialized(int state) { return state & PN_LOCAL_UNINIT; }
36 inline bool active(int state) { return state & PN_LOCAL_ACTIVE; }
37 inline bool closed(int state) { return (state & PN_LOCAL_CLOSED) && (state & PN_REMOTE_CLOSED); }
38 }
39
40 namespace proton {
41
42 bool connection::uninitialized() const { return ::uninitialized(pn_connection_state(pn_object())); }
43 bool connection::active() const { return ::active(pn_connection_state(pn_object())); }
44 bool connection::closed() const { return ::closed(pn_connection_state(pn_object())); }
45
46 void connection::close(const error_condition& condition) {
47 set_error_condition(condition, pn_connection_condition(pn_object()));
48 close();
49 }
50
51 bool session::uninitialized() const { return ::uninitialized(pn_session_state(pn_object())); }
52 bool session::active() const { return ::active(pn_session_state(pn_object())); }
53 bool session::closed() const { return ::closed(pn_session_state(pn_object())); }
54
55 void session::close(const error_condition& condition) {
56 set_error_condition(condition, pn_session_condition(pn_object()));
57 close();
58 }
59
60 bool link::uninitialized() const { return ::uninitialized(pn_link_state(pn_object())); }
61 bool link::active() const { return ::active(pn_link_state(pn_object())); }
62 bool link::closed() const { return ::closed(pn_link_state(pn_object())); }
63
64 void link::close(const error_condition& condition) {
65 set_error_condition(condition, pn_link_condition(pn_object()));
66 close();
67 }
68
69 endpoint::~endpoint() = default;
70
71 }