Qpid Proton C++ API  0.18.1
endpoint.hpp
Go to the documentation of this file.
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 
32 
33 namespace proton {
34 
36 class
37 PN_CPP_CLASS_EXTERN endpoint {
38  public:
39  PN_CPP_EXTERN virtual ~endpoint();
40 
41  // XXX Add the container accessor here.
42 
44  virtual bool uninitialized() const = 0;
45 
47  virtual bool active() const = 0;
48 
50  virtual bool closed() const = 0;
51 
53  virtual class error_condition error() const = 0;
54 
55  // XXX Add virtual open() and open(endpoint_options)
56 
60  virtual void close() = 0;
61 
65  virtual void close(const error_condition&) = 0;
66 
67 #if PN_CPP_HAS_DEFAULTED_FUNCTIONS && PN_CPP_HAS_DEFAULTED_MOVE_INITIALIZERS
68  // Make everything explicit for C++11 compilers
69 
71  endpoint() = default;
72  endpoint& operator=(const endpoint&) = default;
73  endpoint(const endpoint&) = default;
74  endpoint& operator=(endpoint&&) = default;
75  endpoint(endpoint&&) = default;
77 #endif
78 };
79 
80 namespace internal {
81 
82 template <class T, class D> class iter_base {
83  public:
84  typedef T value_type;
85 
86  T operator*() const { return obj_; }
87  T* operator->() const { return const_cast<T*>(&obj_); }
88  D operator++(int) { D x(*this); ++(*this); return x; }
89  bool operator==(const iter_base<T, D>& x) const { return obj_ == x.obj_; }
90  bool operator!=(const iter_base<T, D>& x) const { return obj_ != x.obj_; }
91 
92  protected:
93  explicit iter_base(T p = 0) : obj_(p) {}
94  T obj_;
95 };
96 
97 template<class I> class iter_range {
98  public:
99  typedef I iterator;
100 
101  explicit iter_range(I begin = I(), I end = I()) : begin_(begin), end_(end) {}
102  I begin() const { return begin_; }
103  I end() const { return end_; }
104  bool empty() const { return begin_ == end_; }
105 
106  private:
107  I begin_, end_;
108 };
109 
110 } // internal
111 } // proton
112 
113 #endif // PROTON_ENDPOINT_HPP
Forward declarations.
The base class for session, connection, and link.
Definition: endpoint.hpp:36
Describes an endpoint error state.
The main Proton namespace.
Definition: annotation_key.hpp:33
Describes an endpoint error state.
Definition: error_condition.hpp:40