Qpid Proton C++  0.17.0
endpoint.hpp
1 #ifndef PROTON_ENDPOINT_HPP
2 #define PROTON_ENDPOINT_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 "./error_condition.hpp"
27 #include "./internal/config.hpp"
28 #include "./internal/export.hpp"
29 
30 namespace proton {
31 
33 class
34 PN_CPP_CLASS_EXTERN endpoint {
35  public:
36  PN_CPP_EXTERN virtual ~endpoint();
37 
38  // XXX Add the container accessor here.
39 
41  virtual bool uninitialized() const = 0;
42 
44  virtual bool active() const = 0;
45 
47  virtual bool closed() const = 0;
48 
50  virtual class error_condition error() const = 0;
51 
52  // XXX Add virtual open() and open(endpoint_options)
53 
57  virtual void close() = 0;
58 
62  virtual void close(const error_condition&) = 0;
63 
64 #if PN_CPP_HAS_DEFAULTED_FUNCTIONS
65  // Make everything explicit for C++11 compilers
66 
68  endpoint() = default;
69  endpoint& operator=(const endpoint&) = default;
70  endpoint& operator=(endpoint&&) = default;
71  endpoint(const endpoint&) = default;
72  endpoint(endpoint&&) = default;
74 #endif
75 };
76 
77 namespace internal {
78 
79 template <class T, class D> class iter_base {
80  public:
81  typedef T value_type;
82 
83  T operator*() const { return obj_; }
84  T* operator->() const { return const_cast<T*>(&obj_); }
85  D operator++(int) { D x(*this); ++(*this); return x; }
86  bool operator==(const iter_base<T, D>& x) const { return obj_ == x.obj_; }
87  bool operator!=(const iter_base<T, D>& x) const { return obj_ != x.obj_; }
88 
89  protected:
90  explicit iter_base(T p = 0) : obj_(p) {}
91  T obj_;
92 };
93 
94 template<class I> class iter_range {
95  public:
96  typedef I iterator;
97 
98  explicit iter_range(I begin = I(), I end = I()) : begin_(begin), end_(end) {}
99  I begin() const { return begin_; }
100  I end() const { return end_; }
101  bool empty() const { return begin_ == end_; }
102 
103  private:
104  I begin_, end_;
105 };
106 
107 } // internal
108 } // proton
109 
110 #endif // PROTON_ENDPOINT_HPP
The base class for session, connection, and link.
Definition: endpoint.hpp:33
The main Proton namespace.
Definition: annotation_key.hpp:30
Describes an endpoint error state.
Definition: error_condition.hpp:37