Qpid Proton C++  0.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
endpoint.hpp
1 #ifndef PROTON_CPP_ENDPOINT_H
2 #define PROTON_CPP_ENDPOINT_H
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 #include "proton/config.hpp"
25 #include "proton/export.hpp"
26 #include "proton/condition.hpp"
27 #include "proton/comparable.hpp"
28 
29 namespace proton {
30 
32 class endpoint {
33  public:
34  PN_CPP_EXTERN virtual ~endpoint();
35 
45  typedef int state;
46 
47  PN_CPP_EXTERN static const state LOCAL_UNINIT;
48  PN_CPP_EXTERN static const state REMOTE_UNINIT;
49  PN_CPP_EXTERN static const state LOCAL_ACTIVE;
50  PN_CPP_EXTERN static const state REMOTE_ACTIVE;
51  PN_CPP_EXTERN static const state LOCAL_CLOSED;
52  PN_CPP_EXTERN static const state REMOTE_CLOSED;
53  PN_CPP_EXTERN static const state LOCAL_MASK;
54  PN_CPP_EXTERN static const state REMOTE_MASK;
55 
56 
58  virtual condition local_condition() const = 0;
59 
61  virtual condition remote_condition() const = 0;
62 
63 #if PN_HAS_CPP11
64  // Make everything explicit for C++11 compilers
65  endpoint() = default;
66  endpoint& operator=(const endpoint&) = default;
67  endpoint& operator=(endpoint&&) = default;
68 
69  endpoint(const endpoint&) = default;
70  endpoint(endpoint&&) = default;
71 #endif
72 };
73 
76 
77 template <class T> class iter_base : public comparable<iter_base<T> > {
78  public:
79  typedef T value_type;
80 
81  T& operator*() const { return *ptr_; }
82  const T* operator->() const { return &ptr_; }
83  operator bool() const { return !!ptr_; }
84  bool operator !() const { return !ptr_; }
85  bool operator==(const iter_base<T>& x) const { return ptr_ == x.ptr_; }
86  bool operator!=(const iter_base<T>& x) const { return ptr_ != x.ptr_; }
87 
88  protected:
89  explicit iter_base(T p = 0, endpoint::state s = 0) : ptr_(p), state_(s) {}
90  T ptr_;
91  endpoint::state state_;
92 };
93 
95 template<class I> class range {
96  public:
97  typedef I iterator;
98 
99  explicit range(I begin = I(), I end = I()) : begin_(begin), end_(end) {}
100  I begin() const { return begin_; }
101  I end() const { return end_; }
102  private:
103  I begin_, end_;
104 };
105 
107 
108 }
109 
110 #endif // PROTON_CPP_H
static const state LOCAL_MASK
Mask including all LOCAL_ bits (UNINIT, ACTIVE, CLOSED)
Definition: endpoint.hpp:53
The base class for session, connection, and link.
Definition: endpoint.hpp:32
Describes an endpoint error state.
Definition: condition.hpp:35
static const state REMOTE_UNINIT
Remote endpoint is uninitialized.
Definition: endpoint.hpp:48
int state
A bit mask of state bit values.
Definition: endpoint.hpp:45
static const state LOCAL_CLOSED
Local endpoint has been closed.
Definition: endpoint.hpp:51
virtual condition remote_condition() const =0
Get the error condition of the remote endpoint.
static const state REMOTE_ACTIVE
Remote endpoint is active.
Definition: endpoint.hpp:50
static const state REMOTE_CLOSED
Remote endpoint has been closed.
Definition: endpoint.hpp:52
static const state LOCAL_ACTIVE
Local endpoint is active.
Definition: endpoint.hpp:49
static const state REMOTE_MASK
Mask including all REMOTE_ bits (UNINIT, ACTIVE, CLOSED)
Definition: endpoint.hpp:54
virtual condition local_condition() const =0
Get the local error condition.
static const state LOCAL_UNINIT
Local endpoint is uninitialized.
Definition: endpoint.hpp:47