proton/endpoint.hpp

Go to the documentation of this file.
00001 #ifndef PROTON_ENDPOINT_HPP
00002 #define PROTON_ENDPOINT_HPP
00003 
00004 /*
00005  *
00006  * Licensed to the Apache Software Foundation (ASF) under one
00007  * or more contributor license agreements.  See the NOTICE file
00008  * distributed with this work for additional information
00009  * regarding copyright ownership.  The ASF licenses this file
00010  * to you under the Apache License, Version 2.0 (the
00011  * "License"); you may not use this file except in compliance
00012  * with the License.  You may obtain a copy of the License at
00013  *
00014  *   http://www.apache.org/licenses/LICENSE-2.0
00015  *
00016  * Unless required by applicable law or agreed to in writing,
00017  * software distributed under the License is distributed on an
00018  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
00019  * KIND, either express or implied.  See the License for the
00020  * specific language governing permissions and limitations
00021  * under the License.
00022  *
00023  */
00024 
00025 #include "./fwd.hpp"
00026 #include "./error_condition.hpp"
00027 #include "./internal/config.hpp"
00028 #include "./internal/export.hpp"
00029 
00032 
00033 namespace proton {
00034 
00036 class
00037 PN_CPP_CLASS_EXTERN endpoint {
00038   public:
00039     PN_CPP_EXTERN virtual ~endpoint();
00040 
00041     // XXX Add the container accessor here.
00042     
00044     virtual bool uninitialized() const = 0;
00045     
00047     virtual bool active() const = 0;
00048     
00050     virtual bool closed() const = 0;
00051 
00053     virtual class error_condition error() const = 0;
00054 
00055     // XXX Add virtual open() and open(endpoint_options)
00056     
00060     virtual void close() = 0;
00061 
00065     virtual void close(const error_condition&) = 0;
00066 
00067 #if PN_CPP_HAS_DEFAULTED_FUNCTIONS && PN_CPP_HAS_DEFAULTED_MOVE_INITIALIZERS
00068     // Make everything explicit for C++11 compilers
00069 
00071     endpoint() = default;
00072     endpoint& operator=(const endpoint&) = default;
00073     endpoint(const endpoint&) = default;
00074     endpoint& operator=(endpoint&&) = default;
00075     endpoint(endpoint&&) = default;
00077 #endif
00078 };
00079 
00080 namespace internal {
00081 
00082 template <class T, class D> class iter_base {
00083   public:
00084     typedef T value_type;
00085 
00086     T operator*() const { return obj_; }
00087     T* operator->() const { return const_cast<T*>(&obj_); }
00088     D operator++(int) { D x(*this); ++(*this); return x; }
00089     bool operator==(const iter_base<T, D>& x) const { return obj_ == x.obj_; }
00090     bool operator!=(const iter_base<T, D>& x) const { return obj_ != x.obj_; }
00091     
00092   protected:
00093     explicit iter_base(T p = 0) : obj_(p) {}
00094     T obj_;
00095 };
00096 
00097 template<class I> class iter_range {
00098   public:
00099     typedef I iterator;
00100 
00101     explicit iter_range(I begin = I(), I end = I()) : begin_(begin), end_(end) {}
00102     I begin() const { return begin_; }
00103     I end() const { return end_; }
00104     bool empty() const { return begin_ == end_; }
00105     
00106   private:
00107     I begin_, end_;
00108 };
00109 
00110 } // internal
00111 } // proton
00112 
00113 #endif // PROTON_ENDPOINT_HPP

Generated on 28 Nov 2017 for Qpid Proton C++ by  doxygen 1.6.1