You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2015/06/22 20:08:23 UTC
[5/8] qpid-proton git commit: PROTON-865: Renaming to follow
boost/std library C++ naming conventions.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/types.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/types.hpp b/proton-c/bindings/cpp/include/proton/types.hpp
index d3cdd27..efde10c 100644
--- a/proton-c/bindings/cpp/include/proton/types.hpp
+++ b/proton-c/bindings/cpp/include/proton/types.hpp
@@ -19,19 +19,23 @@
* under the License.
*/
+/**@file
+ * Defines C++ types representing AMQP types.
+ * @ingroup cpp
+ */
+
#include "proton/export.hpp"
#include <proton/codec.h>
#include <algorithm>
#include <bitset>
#include <string>
#include <memory.h>
+#include <algorithm>
// Workaround for older C++ compilers
#if defined(__cplusplus) && __cplusplus >= 201100
#include <cstdint>
-
#else // Workaround for older C++ compilers
-
#include <proton/type_compat.h>
namespace std {
// Exact-size integer types.
@@ -46,16 +50,13 @@ using ::uint64_t;
}
#endif
-/**@file
- * C++ types representing AMQP types.
- * @ingroup cpp
- */
-
namespace proton {
-/** TypeId identifies an AMQP type */
-enum TypeId {
- NULL_=PN_NULL, ///< The null type, contains no data.
+/** type_id identifies an AMQP type.
+ *@ingroup cpp
+ */
+enum type_id {
+ NULl_=PN_NULL, ///< The null type, contains no data.
BOOL=PN_BOOL, ///< Boolean true or false.
UBYTE=PN_UBYTE, ///< Unsigned 8 bit integer.
BYTE=PN_BYTE, ///< Signed 8 bit integer.
@@ -83,194 +84,186 @@ enum TypeId {
};
///@internal
-template <class T> struct Comparable {};
-template<class T> bool operator<(const Comparable<T>& a, const Comparable<T>& b) {
+template <class T> struct comparable {};
+template<class T> bool operator<(const comparable<T>& a, const comparable<T>& b) {
return static_cast<const T&>(a) < static_cast<const T&>(b); // operator < provided by type T
}
-template<class T> bool operator>(const Comparable<T>& a, const Comparable<T>& b) { return b < a; }
-template<class T> bool operator<=(const Comparable<T>& a, const Comparable<T>& b) { return !(a > b); }
-template<class T> bool operator>=(const Comparable<T>& a, const Comparable<T>& b) { return !(a < b); }
-template<class T> bool operator==(const Comparable<T>& a, const Comparable<T>& b) { return a <= b && b <= a; }
-template<class T> bool operator!=(const Comparable<T>& a, const Comparable<T>& b) { return !(a == b); }
-
-/**
- * @name C++ types representing AMQP types.
- * @{
- * @ingroup cpp
- * These types are all distinct for overloading purposes and will insert as the
- * corresponding AMQP type with Encoder operator<<.
- */
-struct Null {};
-typedef bool Bool;
-typedef std::uint8_t Ubyte;
-typedef std::int8_t Byte;
-typedef std::uint16_t Ushort;
-typedef std::int16_t Short;
-typedef std::uint32_t Uint;
-typedef std::int32_t Int;
-typedef wchar_t Char;
-typedef std::uint64_t Ulong;
-typedef std::int64_t Long;
-typedef float Float;
-typedef double Double;
+template<class T> bool operator>(const comparable<T>& a, const comparable<T>& b) { return b < a; }
+template<class T> bool operator<=(const comparable<T>& a, const comparable<T>& b) { return !(a > b); }
+template<class T> bool operator>=(const comparable<T>& a, const comparable<T>& b) { return !(a < b); }
+template<class T> bool operator==(const comparable<T>& a, const comparable<T>& b) { return a <= b && b <= a; }
+template<class T> bool operator!=(const comparable<T>& a, const comparable<T>& b) { return !(a == b); }
+
+/// AMQP NULL type. @ingroup cpp
+struct amqp_null {};
+/// AMQP boolean type. @ingroup cpp
+typedef bool amqp_bool;
+/// AMQP unsigned 8-bit type. @ingroup cpp
+typedef std::uint8_t amqp_ubyte;
+/// AMQP signed 8-bit integer type. @ingroup cpp
+typedef std::int8_t amqp_byte;
+/// AMQP unsigned 16-bit integer type. @ingroup cpp
+typedef std::uint16_t amqp_ushort;
+/// AMQP signed 16-bit integer type. @ingroup cpp
+typedef std::int16_t amqp_short;
+/// AMQP unsigned 32-bit integer type. @ingroup cpp
+typedef std::uint32_t amqp_uint;
+/// AMQP signed 32-bit integer type. @ingroup cpp
+typedef std::int32_t amqp_int;
+/// AMQP 32-bit unicode character type. @ingroup cpp
+typedef wchar_t amqp_char;
+/// AMQP unsigned 64-bit integer type. @ingroup cpp
+typedef std::uint64_t amqp_ulong;
+/// AMQP signed 64-bit integer type. @ingroup cpp
+typedef std::int64_t amqp_long;
+/// AMQP 32-bit floating-point type. @ingroup cpp
+typedef float amqp_float;
+/// AMQP 64-bit floating-point type. @ingroup cpp
+typedef double amqp_double;
-///@internal
PN_CPP_EXTERN pn_bytes_t pn_bytes(const std::string&);
-//@internal
PN_CPP_EXTERN std::string str(const pn_bytes_t& b);
-///@internal
-#define STRING_LIKE(NAME) \
- struct NAME : public std::string{ \
- NAME(const std::string& s=std::string()) : std::string(s) {} \
- NAME(const char* s) : std::string(s) {} \
- NAME(const pn_bytes_t& b) : std::string(b.start, b.size) {} \
- operator pn_bytes_t() const { return pn_bytes(*this); } \
- }
-
-/** UTF-8 encoded string */
-STRING_LIKE(String);
-/** ASCII encoded symbolic name */
-STRING_LIKE(Symbol);
-/** Binary data */
-STRING_LIKE(Binary);
-
-// TODO aconway 2015-06-11: alternative representation of variable-length data
-// as pointer to existing buffer.
+/// AMQP UTF-8 encoded string. @ingroup cpp
+struct amqp_string : public std::string {
+ amqp_string(const std::string& s=std::string()) : std::string(s) {}
+ amqp_string(const char* s) : std::string(s) {}
+ amqp_string(const pn_bytes_t& b) : std::string(b.start, b.size) {}
+ operator pn_bytes_t() const { return pn_bytes(*this); }
+};
-/** Array of 16 bytes representing a UUID */
-struct Uuid : public Comparable<Uuid> { // FIXME aconway 2015-06-18: std::array in C++11
- public:
- static const size_t SIZE = 16;
-
- PN_CPP_EXTERN Uuid();
- PN_CPP_EXTERN Uuid(const pn_uuid_t& u);
- PN_CPP_EXTERN operator pn_uuid_t() const;
- PN_CPP_EXTERN bool operator==(const Uuid&) const;
- PN_CPP_EXTERN bool operator<(const Uuid&) const;
-
- char* begin() { return bytes; }
- const char* begin() const { return bytes; }
- char* end() { return bytes + SIZE; }
- const char* end() const { return bytes + SIZE; }
- char& operator[](size_t i) { return bytes[i]; }
- const char& operator[](size_t i) const { return bytes[i]; }
- size_t size() const { return SIZE; }
-
- // Human-readable representation.
- friend PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const Uuid&);
- private:
- char bytes[SIZE];
+/// AMQP ASCII encoded symbolic name. @ingroup cpp
+struct amqp_symbol : public std::string {
+ amqp_symbol(const std::string& s=std::string()) : std::string(s) {}
+ amqp_symbol(const char* s) : std::string(s) {}
+ amqp_symbol(const pn_bytes_t& b) : std::string(b.start, b.size) {}
+ operator pn_bytes_t() const { return pn_bytes(*this); }
};
-// TODO aconway 2015-06-16: usable representation of decimal types.
-/**@internal*/
-template <class T> struct Decimal : public Comparable<Decimal<T> > {
- char value[sizeof(T)];
- Decimal() { ::memset(value, 0, sizeof(T)); }
- Decimal(const T& v) { ::memcpy(value, &v, sizeof(T)); }
- operator T() const { T x; ::memcpy(&x, value, sizeof(T)); return x; }
- bool operator<(const Decimal<T>& x) {
- return std::lexicographical_compare(value, value+sizeof(T), x.value, x.value+sizeof(T));
- }
+/// AMQP variable-length binary data. @ingroup cpp
+struct amqp_binary : public std::string {
+ amqp_binary(const std::string& s=std::string()) : std::string(s) {}
+ amqp_binary(const char* s) : std::string(s) {}
+ amqp_binary(const pn_bytes_t& b) : std::string(b.start, b.size) {}
+ operator pn_bytes_t() const { return pn_bytes(*this); }
};
-typedef Decimal<pn_decimal32_t> Decimal32;
-typedef Decimal<pn_decimal64_t> Decimal64;
-typedef Decimal<pn_decimal128_t> Decimal128;
+// TODO aconway 2015-06-11: alternative representation of variable-length data
+// as pointer to existing buffer.
-struct Timestamp : public Comparable<Timestamp> {
- pn_timestamp_t milliseconds; ///< Since the epoch 00:00:00 (UTC), 1 January 1970.
- Timestamp(std::int64_t ms=0) : milliseconds(ms) {}
- operator pn_timestamp_t() const { return milliseconds; }
- bool operator==(const Timestamp& x) { return milliseconds == x.milliseconds; }
- bool operator<(const Timestamp& x) { return milliseconds < x.milliseconds; }
+// Wrapper for opaque proton types that can be treated as byte arrays.
+template <class P> struct opaque: public comparable<opaque<P> > {
+ P value;
+ opaque(const P& p=P()) : value(p) {}
+ operator P() const { return value; }
+
+ static size_t size() { return sizeof(P); }
+ char* begin() { return reinterpret_cast<char*>(&value); }
+ char* end() { return reinterpret_cast<char*>(&value)+size(); }
+ const char* begin() const { return reinterpret_cast<const char*>(&value); }
+ const char* end() const { return reinterpret_cast<const char*>(&value)+size(); }
+ char& operator[](size_t i) { return *(begin()+i); }
+ const char& operator[](size_t i) const { return *(begin()+i); }
+
+ bool operator==(const opaque& x) const { return std::equal(begin(), end(), x.begin()); }
+ bool operator<(const opaque& x) const { return std::lexicographical_compare(begin(), end(), x.begin(), x.end()); }
};
-///@}
+/// AMQP 16-byte UUID. @ingroup cpp
+typedef opaque<pn_uuid_t> amqp_uuid;
+PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const amqp_uuid&);
+/// AMQP 32-bit decimal floating point (IEEE 854). @ingroup cpp
+typedef opaque<pn_decimal32_t> amqp_decimal32;
+/// AMQP 64-bit decimal floating point (IEEE 854). @ingroup cpp
+typedef opaque<pn_decimal64_t> amqp_decimal64;
+/// AMQP 128-bit decimal floating point (IEEE 854). @ingroup cpp
+typedef opaque<pn_decimal128_t> amqp_decimal128;
+
+/// AMQP timestamp, milliseconds since the epoch 00:00:00 (UTC), 1 January 1970. @ingroup cpp
+struct amqp_timestamp : public comparable<amqp_timestamp> {
+ pn_timestamp_t milliseconds;
+ amqp_timestamp(std::int64_t ms=0) : milliseconds(ms) {}
+ operator pn_timestamp_t() const { return milliseconds; }
+ bool operator==(const amqp_timestamp& x) { return milliseconds == x.milliseconds; }
+ bool operator<(const amqp_timestamp& x) { return milliseconds < x.milliseconds; }
+};
-template<class T, TypeId A> struct TypePair {
- typedef T CppType;
- TypeId type;
+template<class T, type_id A> struct type_pair {
+ typedef T cpp_type;
+ type_id type;
};
-template<class T, TypeId A> struct Ref : public TypePair<T, A> {
- Ref(T& v) : value(v) {}
+template<class T, type_id A> struct ref : public type_pair<T, A> {
+ ref(T& v) : value(v) {}
T& value;
};
-template<class T, TypeId A> struct CRef : public TypePair<T, A> {
- CRef(const T& v) : value(v) {}
- CRef(const Ref<T,A>& ref) : value(ref.value) {}
+template<class T, type_id A> struct cref : public type_pair<T, A> {
+ cref(const T& v) : value(v) {}
+ cref(const ref<T,A>& ref) : value(ref.value) {}
const T& value;
};
-/** A holder for AMQP values. A holder is always encoded/decoded as its AmqpValue, no need
+/** A holder for AMQP values. A holder is always encoded/decoded as its amqp_value, no need
* for the as<TYPE>() helper functions.
*
* For example to encode an array of arrays using std::vector:
*
- * typedef Holder<std::vector<String>, ARRAY> Inner;
+ * typedef Holder<std::vector<amqp_string>, ARRAY> Inner;
* typedef Holder<std::vector<Inner>, ARRAY> Outer;
* Outer o ...
* encoder << o;
+ * @ingroup cpp
*/
-template<class T, TypeId A> struct Holder : public TypePair<T, A> {
+template<class T, type_id A> struct Holder : public type_pair<T, A> {
T value;
};
-/** Create a reference to value as AMQP type A for decoding. For example to decode an array of Int:
+/** Create a reference to value as AMQP type A for decoding. For example to decode an array of amqp_int:
*
- * std::vector<Int> v;
+ * std::vector<amqp_int> v;
* decoder >> as<ARRAY>(v);
+ * @ingroup cpp
*/
-template <TypeId A, class T> Ref<T, A> as(T& value) { return Ref<T, A>(value); }
+template <type_id A, class T> ref<T, A> as(T& value) { return ref<T, A>(value); }
/** Create a const reference to value as AMQP type A for encoding. */
-template <TypeId A, class T> CRef<T, A> as(const T& value) { return CRef<T, A>(value); }
+template <type_id A, class T> cref<T, A> as(const T& value) { return cref<T, A>(value); }
///@}
// TODO aconway 2015-06-16: described types.
-/** Return the name of a type. */
-PN_CPP_EXTERN std::string typeName(TypeId);
+/** Return the name of a type. @ingroup cpp */
+PN_CPP_EXTERN std::string type_name(type_id);
-/** Print the name of a type */
-PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, TypeId);
+/** Print the name of a type. @ingroup cpp */
+PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, type_id);
/** Information needed to start extracting or inserting a container type.
*
- * With a decoder you can use `Start s = decoder.start()` or `Start s; decoder > s`
- * to get the Start for the current container.
- *
- * With an encoder use one of the member functions startArray, startList, startMap or startDescribed
- * to create an appropriate Start value, e.g. `encoder << startList() << ...`
+ * See encoder::operator<<(encoder&, const start&) and decoder::operator>>(decoder&, start&)
+ * for examples of use.
*/
-struct Start {
- PN_CPP_EXTERN Start(TypeId type=NULL_, TypeId element=NULL_, bool described=false, size_t size=0);
- TypeId type; ///< The container type: ARRAY, LIST, MAP or DESCRIBED.
- TypeId element; ///< the element type for array only.
- bool isDescribed; ///< true if first value is a descriptor.
+struct start {
+ PN_CPP_EXTERN start(type_id type=NULl_, type_id element=NULl_, bool described=false, size_t size=0);
+ type_id type; ///< The container type: ARRAY, LIST, MAP or DESCRIBED.
+ type_id element; ///< the element type for array only.
+ bool is_described; ///< true if first value is a descriptor.
size_t size; ///< the element count excluding the descriptor (if any)
- /** Return a Start for an array */
- PN_CPP_EXTERN static Start array(TypeId element, bool described=false);
- /** Return a Start for a list */
- PN_CPP_EXTERN static Start list();
- /** Return a Start for a map */
- PN_CPP_EXTERN static Start map();
- /** Return a Start for a described type */
- PN_CPP_EXTERN static Start described();
+ /** Return a start for an array */
+ PN_CPP_EXTERN static start array(type_id element, bool described=false);
+ /** Return a start for a list */
+ PN_CPP_EXTERN static start list();
+ /** Return a start for a map */
+ PN_CPP_EXTERN static start map();
+ /** Return a start for a described type */
+ PN_CPP_EXTERN static start described();
};
/** Finish insterting or extracting a container value. */
-struct Finish {};
-inline Finish finish() { return Finish(); }
-
-/** Skip a value */
-struct Skip{};
-inline Skip skip() { return Skip(); }
+struct finish {};
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/value.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/value.hpp b/proton-c/bindings/cpp/include/proton/value.hpp
new file mode 100644
index 0000000..046a98b
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/value.hpp
@@ -0,0 +1,94 @@
+#ifndef VALUE_H
+#define VALUE_H
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "proton/values.hpp"
+
+namespace proton {
+
+/** Holds a single AMQP value. */
+class value {
+ public:
+ PN_CPP_EXTERN value();
+ PN_CPP_EXTERN value(const value&);
+ /** Converting constructor from any settable value */
+ template <class T> explicit value(const T& v);
+
+ PN_CPP_EXTERN ~value();
+
+ PN_CPP_EXTERN value& operator=(const value&);
+
+ PN_CPP_EXTERN type_id type() const;
+
+ /** Set the value. */
+ template<class T> void set(const T& value);
+ /** Get the value. */
+ template<class T> void get(T& value) const;
+ /** Get the value */
+ template<class T> T get() const;
+
+ /** Assignment sets the value */
+ template<class T> value& operator=(const T& value);
+
+ /** Conversion operator gets the value */
+ template<class T> operator T() const;
+
+ /** insert a value into an encoder. */
+ PN_CPP_EXTERN friend encoder& operator<<(encoder&, const value&);
+
+ /** Extract a value from a decoder. */
+ PN_CPP_EXTERN friend decoder& operator>>(decoder&, value&);
+
+ /** Human readable format */
+ PN_CPP_EXTERN friend std::ostream& operator<<(std::ostream&, const value&);
+
+ PN_CPP_EXTERN bool operator==(const value&) const;
+ PN_CPP_EXTERN bool operator !=(const value& v) const{ return !(*this == v); }
+
+ /** operator < makes value valid for use as a std::map key. */
+ PN_CPP_EXTERN bool operator<(const value&) const;
+ bool operator>(const value& v) const { return v < *this; }
+ bool operator<=(const value& v) const { return !(*this > v); }
+ bool operator>=(const value& v) const { return !(*this < v); }
+
+ private:
+ mutable values values_;
+};
+
+template<class T> void value::set(const T& value) {
+ values_.clear();
+ values_ << value;
+}
+
+template<class T> void value::get(T& v) const {
+ values& vv = const_cast<values&>(values_);
+ vv >> proton::rewind() >> v;
+}
+
+template<class T> T value::get() const { T value; get(value); return value; }
+
+template<class T> value& value::operator=(const T& value) { set(value); return *this; }
+
+template<class T> value::operator T() const { return get<T>(); }
+
+template<class T> value::value(const T& value) { set(value); }
+}
+
+#endif // VALUE_H
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/values.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/values.hpp b/proton-c/bindings/cpp/include/proton/values.hpp
new file mode 100644
index 0000000..dc6fc57
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/values.hpp
@@ -0,0 +1,53 @@
+#ifndef VALUES_H
+#define VALUES_H
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <proton/encoder.hpp>
+#include <proton/decoder.hpp>
+
+namespace proton {
+
+
+/** Holds a sequence of AMQP values, allows inserting and extracting.
+ *
+ * After inserting values, call rewind() to extract them.
+ */
+class values : public encoder, public decoder {
+ public:
+ PN_CPP_EXTERN values();
+ PN_CPP_EXTERN values(const values&);
+
+ /** Does not take ownership, just a view on the data */
+ PN_CPP_EXTERN values(pn_data_t*);
+
+ PN_CPP_EXTERN ~values();
+
+ /** Copy data from another values */
+ PN_CPP_EXTERN values& operator=(const values&);
+
+ friend class value;
+ friend class message;
+};
+
+PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const values&);
+
+}
+
+#endif // VALUES_H
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/wait_condition.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/wait_condition.hpp b/proton-c/bindings/cpp/include/proton/wait_condition.hpp
new file mode 100644
index 0000000..f184f71
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/wait_condition.hpp
@@ -0,0 +1,44 @@
+#ifndef PROTON_CPP_WAITCONDITION_H
+#define PROTON_CPP_WAITCONDITION_H
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+#include "proton/export.hpp"
+
+namespace proton {
+
+// Interface class to indicates that an expected contion has been
+// achieved, i.e. for blocking_connection.wait()
+
+class wait_condition
+{
+ public:
+ PN_CPP_EXTERN virtual ~wait_condition();
+
+ // Overide this member function to indicate whether an expected
+ // condition is achieved and requires no further waiting.
+ virtual bool achieved() = 0;
+};
+
+
+}
+
+#endif /*!PROTON_CPP_WAITCONDITION_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/Acceptor.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Acceptor.cpp b/proton-c/bindings/cpp/src/Acceptor.cpp
deleted file mode 100644
index 2756a0a..0000000
--- a/proton-c/bindings/cpp/src/Acceptor.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-#include "proton/Acceptor.hpp"
-#include "proton/Error.hpp"
-#include "ProtonImplRef.hpp"
-#include "Msg.hpp"
-
-namespace proton {
-namespace reactor {
-
-template class ProtonHandle<pn_acceptor_t>;
-typedef ProtonImplRef<Acceptor> PI;
-
-Acceptor::Acceptor() {}
-
-Acceptor::Acceptor(pn_acceptor_t *a)
-{
- PI::ctor(*this, a);
-}
-
-Acceptor::~Acceptor() { PI::dtor(*this); }
-
-
-Acceptor::Acceptor(const Acceptor& a) : ProtonHandle<pn_acceptor_t>() {
- PI::copy(*this, a);
-}
-
-Acceptor& Acceptor::operator=(const Acceptor& a) {
- return PI::assign(*this, a);
-}
-
-void Acceptor::close() {
- if (impl)
- pn_acceptor_close(impl);
-}
-
-}} // namespace proton::reactor
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/Acking.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Acking.cpp b/proton-c/bindings/cpp/src/Acking.cpp
deleted file mode 100644
index 832b9f2..0000000
--- a/proton-c/bindings/cpp/src/Acking.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-#include "proton/Acking.hpp"
-#include "proton/delivery.h"
-
-namespace proton {
-namespace reactor {
-
-void Acking::accept(Delivery &d) {
- settle(d, Delivery::ACCEPTED);
-}
-
-void Acking::reject(Delivery &d) {
- settle(d, Delivery::REJECTED);
-}
-
-void Acking::release(Delivery &d, bool delivered) {
- if (delivered)
- settle(d, Delivery::MODIFIED);
- else
- settle(d, Delivery::RELEASED);
-}
-
-void Acking::settle(Delivery &d, Delivery::state state) {
- if (state)
- pn_delivery_update(d.getPnDelivery(), state);
- d.settle();
-}
-
-}} // namespace proton::reactor
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/BlockingConnection.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/BlockingConnection.cpp b/proton-c/bindings/cpp/src/BlockingConnection.cpp
deleted file mode 100644
index 3e57b91..0000000
--- a/proton-c/bindings/cpp/src/BlockingConnection.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-#include "proton/Container.hpp"
-#include "proton/BlockingConnection.hpp"
-#include "proton/BlockingSender.hpp"
-#include "proton/MessagingHandler.hpp"
-#include "proton/Error.hpp"
-#include "Msg.hpp"
-#include "BlockingConnectionImpl.hpp"
-#include "PrivateImplRef.hpp"
-
-namespace proton {
-namespace reactor {
-
-template class Handle<BlockingConnectionImpl>;
-typedef PrivateImplRef<BlockingConnection> PI;
-
-BlockingConnection::BlockingConnection() {PI::ctor(*this, 0); }
-
-BlockingConnection::BlockingConnection(const BlockingConnection& c) : Handle<BlockingConnectionImpl>() { PI::copy(*this, c); }
-
-BlockingConnection& BlockingConnection::operator=(const BlockingConnection& c) { return PI::assign(*this, c); }
-BlockingConnection::~BlockingConnection() { PI::dtor(*this); }
-
-BlockingConnection::BlockingConnection(std::string &url, Duration d, SslDomain *ssld, Container *c) {
- BlockingConnectionImpl *cimpl = new BlockingConnectionImpl(url, d,ssld, c);
- PI::ctor(*this, cimpl);
-}
-
-void BlockingConnection::close() { impl->close(); }
-
-void BlockingConnection::wait(WaitCondition &cond) { return impl->wait(cond); }
-void BlockingConnection::wait(WaitCondition &cond, std::string &msg, Duration timeout) {
- return impl->wait(cond, msg, timeout);
-}
-
-BlockingSender BlockingConnection::createSender(std::string &address, Handler *h) {
- Sender sender = impl->container.createSender(impl->connection, address, h);
- return BlockingSender(*this, sender);
-}
-
-Duration BlockingConnection::getTimeout() { return impl->getTimeout(); }
-
-}} // namespace proton::reactor
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/BlockingConnectionImpl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/BlockingConnectionImpl.cpp b/proton-c/bindings/cpp/src/BlockingConnectionImpl.cpp
deleted file mode 100644
index 912f11f..0000000
--- a/proton-c/bindings/cpp/src/BlockingConnectionImpl.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-#include "proton/Container.hpp"
-#include "proton/MessagingHandler.hpp"
-#include "proton/Duration.hpp"
-#include "proton/Error.hpp"
-#include "proton/WaitCondition.hpp"
-#include "BlockingConnectionImpl.hpp"
-#include "Msg.hpp"
-#include "contexts.hpp"
-
-#include "proton/connection.h"
-
-namespace proton {
-namespace reactor {
-
-WaitCondition::~WaitCondition() {}
-
-
-void BlockingConnectionImpl::incref(BlockingConnectionImpl *impl) {
- impl->refCount++;
-}
-
-void BlockingConnectionImpl::decref(BlockingConnectionImpl *impl) {
- impl->refCount--;
- if (impl->refCount == 0)
- delete impl;
-}
-
-namespace {
-struct ConnectionOpening : public WaitCondition {
- ConnectionOpening(pn_connection_t *c) : pnConnection(c) {}
- bool achieved() { return (pn_connection_state(pnConnection) & PN_REMOTE_UNINIT); }
- pn_connection_t *pnConnection;
-};
-
-struct ConnectionClosed : public WaitCondition {
- ConnectionClosed(pn_connection_t *c) : pnConnection(c) {}
- bool achieved() { return !(pn_connection_state(pnConnection) & PN_REMOTE_ACTIVE); }
- pn_connection_t *pnConnection;
-};
-
-}
-
-
-BlockingConnectionImpl::BlockingConnectionImpl(std::string &u, Duration timeout0, SslDomain *ssld, Container *c)
- : url(u), timeout(timeout0), refCount(0)
-{
- if (c)
- container = *c;
- container.start();
- container.setTimeout(timeout);
- // Create connection and send the connection events here
- connection = container.connect(url, static_cast<Handler *>(this));
- ConnectionOpening cond(connection.getPnConnection());
- wait(cond);
-}
-
-BlockingConnectionImpl::~BlockingConnectionImpl() {
- container = Container();
-}
-
-void BlockingConnectionImpl::close() {
- connection.close();
- ConnectionClosed cond(connection.getPnConnection());
- wait(cond);
-}
-
-void BlockingConnectionImpl::wait(WaitCondition &condition) {
- std::string empty;
- wait(condition, empty, timeout);
-}
-
-void BlockingConnectionImpl::wait(WaitCondition &condition, std::string &msg, Duration waitTimeout) {
- if (waitTimeout == Duration::FOREVER) {
- while (!condition.achieved()) {
- container.process();
- }
- }
-
- pn_reactor_t *reactor = container.getReactor();
- pn_millis_t origTimeout = pn_reactor_get_timeout(reactor);
- pn_reactor_set_timeout(reactor, waitTimeout.milliseconds);
- try {
- pn_timestamp_t now = pn_reactor_mark(reactor);
- pn_timestamp_t deadline = now + waitTimeout.milliseconds;
- while (!condition.achieved()) {
- container.process();
- if (deadline < pn_reactor_mark(reactor)) {
- std::string txt = "Connection timed out";
- if (!msg.empty())
- txt += ": " + msg;
- // TODO: proper Timeout exception
- throw Error(MSG(txt));
- }
- }
- } catch (...) {
- pn_reactor_set_timeout(reactor, origTimeout);
- throw;
- }
- pn_reactor_set_timeout(reactor, origTimeout);
-}
-
-
-
-}} // namespace proton::reactor
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/BlockingConnectionImpl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/BlockingConnectionImpl.hpp b/proton-c/bindings/cpp/src/BlockingConnectionImpl.hpp
deleted file mode 100644
index 2b2ef7e..0000000
--- a/proton-c/bindings/cpp/src/BlockingConnectionImpl.hpp
+++ /dev/null
@@ -1,63 +0,0 @@
-#ifndef PROTON_CPP_CONNECTIONIMPL_H
-#define PROTON_CPP_CONNECTIONIMPL_H
-
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-#include "proton/export.hpp"
-#include "proton/Endpoint.hpp"
-#include "proton/Container.hpp"
-#include "proton/types.h"
-#include <string>
-
-struct pn_connection_t;
-
-namespace proton {
-namespace reactor {
-
-class Handler;
-class Container;
-class SslDomain;
-
- class BlockingConnectionImpl : public MessagingHandler
-{
- public:
- PN_CPP_EXTERN BlockingConnectionImpl(std::string &url, Duration d, SslDomain *ssld, Container *c);
- PN_CPP_EXTERN ~BlockingConnectionImpl();
- PN_CPP_EXTERN void close();
- PN_CPP_EXTERN void wait(WaitCondition &condition);
- PN_CPP_EXTERN void wait(WaitCondition &condition, std::string &msg, Duration timeout);
- PN_CPP_EXTERN pn_connection_t *getPnBlockingConnection();
- Duration getTimeout() { return timeout; }
- static void incref(BlockingConnectionImpl *);
- static void decref(BlockingConnectionImpl *);
- private:
- friend class BlockingConnection;
- Container container;
- Connection connection;
- std::string url;
- Duration timeout;
- int refCount;
-};
-
-
-}} // namespace proton::reactor
-
-#endif /*!PROTON_CPP_CONNECTIONIMPL_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/BlockingLink.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/BlockingLink.cpp b/proton-c/bindings/cpp/src/BlockingLink.cpp
deleted file mode 100644
index afc5f35..0000000
--- a/proton-c/bindings/cpp/src/BlockingLink.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-#include "proton/BlockingLink.hpp"
-#include "proton/BlockingConnection.hpp"
-#include "proton/MessagingHandler.hpp"
-#include "proton/WaitCondition.hpp"
-#include "proton/Error.hpp"
-#include "Msg.hpp"
-
-
-namespace proton {
-namespace reactor {
-
-namespace {
-struct LinkOpened : public WaitCondition {
- LinkOpened(pn_link_t *l) : pnLink(l) {}
- bool achieved() { return !(pn_link_state(pnLink) & PN_REMOTE_UNINIT); }
- pn_link_t *pnLink;
-};
-
-struct LinkClosed : public WaitCondition {
- LinkClosed(pn_link_t *l) : pnLink(l) {}
- bool achieved() { return (pn_link_state(pnLink) & PN_REMOTE_CLOSED); }
- pn_link_t *pnLink;
-};
-
-struct LinkNotOpen : public WaitCondition {
- LinkNotOpen(pn_link_t *l) : pnLink(l) {}
- bool achieved() { return !(pn_link_state(pnLink) & PN_REMOTE_ACTIVE); }
- pn_link_t *pnLink;
-};
-
-
-} // namespace
-
-
-BlockingLink::BlockingLink(BlockingConnection *c, pn_link_t *pnl) : connection(*c), link(pnl) {
- std::string msg = "Opening link " + link.getName();
- LinkOpened linkOpened(link.getPnLink());
- connection.wait(linkOpened, msg);
-}
-
-BlockingLink::~BlockingLink() {}
-
-void BlockingLink::waitForClosed(Duration timeout) {
- std::string msg = "Closing link " + link.getName();
- LinkClosed linkClosed(link.getPnLink());
- connection.wait(linkClosed, msg);
- checkClosed();
-}
-
-void BlockingLink::checkClosed() {
- pn_link_t * pnLink = link.getPnLink();
- if (pn_link_state(pnLink) & PN_REMOTE_CLOSED) {
- link.close();
- // TODO: LinkDetached exception
- throw Error(MSG("Link detached"));
- }
-}
-
-void BlockingLink::close() {
- link.close();
- std::string msg = "Closing link " + link.getName();
- LinkNotOpen linkNotOpen(link.getPnLink());
- connection.wait(linkNotOpen, msg);
-}
-
-}} // namespace proton::reactor
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/BlockingSender.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/BlockingSender.cpp b/proton-c/bindings/cpp/src/BlockingSender.cpp
deleted file mode 100644
index 7a24324..0000000
--- a/proton-c/bindings/cpp/src/BlockingSender.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-#include "proton/BlockingSender.hpp"
-#include "proton/BlockingConnection.hpp"
-#include "proton/WaitCondition.hpp"
-#include "proton/Error.hpp"
-#include "Msg.hpp"
-
-
-namespace proton {
-namespace reactor {
-
-namespace {
-struct DeliverySettled : public WaitCondition {
- DeliverySettled(pn_delivery_t *d) : pnDelivery(d) {}
- bool achieved() { return pn_delivery_settled(pnDelivery); }
- pn_delivery_t *pnDelivery;
-};
-
-} // namespace
-
-
-BlockingSender::BlockingSender(BlockingConnection &c, Sender &l) : BlockingLink(&c, l.getPnLink()) {
- std::string ta = link.getTarget().getAddress();
- std::string rta = link.getRemoteTarget().getAddress();
- if (ta.empty() || ta.compare(rta) != 0) {
- waitForClosed();
- link.close();
- std::string txt = "Failed to open sender " + link.getName() + ", target does not match";
- throw Error(MSG("Container not started"));
- }
-}
-
-Delivery BlockingSender::send(Message &msg, Duration timeout) {
- Sender snd = link;
- Delivery dlv = snd.send(msg);
- std::string txt = "Sending on sender " + link.getName();
- DeliverySettled cond(dlv.getPnDelivery());
- connection.wait(cond, txt, timeout);
- return dlv;
-}
-
-Delivery BlockingSender::send(Message &msg) {
- // Use default timeout
- return send(msg, connection.getTimeout());
-}
-
-}} // namespace proton::reactor
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/Connection.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Connection.cpp b/proton-c/bindings/cpp/src/Connection.cpp
deleted file mode 100644
index 2f31013..0000000
--- a/proton-c/bindings/cpp/src/Connection.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-#include "proton/Container.hpp"
-#include "proton/Connection.hpp"
-#include "proton/Handler.hpp"
-#include "proton/Error.hpp"
-#include "Msg.hpp"
-#include "contexts.hpp"
-#include "ConnectionImpl.hpp"
-#include "PrivateImplRef.hpp"
-
-#include "proton/connection.h"
-
-namespace proton {
-namespace reactor {
-
-template class Handle<ConnectionImpl>;
-typedef PrivateImplRef<Connection> PI;
-
-Connection::Connection() {PI::ctor(*this, 0); }
-Connection::Connection(ConnectionImpl* p) { PI::ctor(*this, p); }
-Connection::Connection(const Connection& c) : Handle<ConnectionImpl>() { PI::copy(*this, c); }
-
-Connection& Connection::operator=(const Connection& c) { return PI::assign(*this, c); }
-Connection::~Connection() { PI::dtor(*this); }
-
-Connection::Connection(Container &c, Handler *h) {
- ConnectionImpl *cimpl = new ConnectionImpl(c, h);
- PI::ctor(*this, cimpl);
-}
-
-Transport &Connection::getTransport() { return impl->getTransport(); }
-
-Handler* Connection::getOverride() { return impl->getOverride(); }
-void Connection::setOverride(Handler *h) { impl->setOverride(h); }
-
-void Connection::open() { impl->open(); }
-
-void Connection::close() { impl->close(); }
-
-pn_connection_t *Connection::getPnConnection() { return impl->getPnConnection(); }
-
-std::string Connection::getHostname() { return impl->getHostname(); }
-
-Connection &Connection::getConnection() {
- return (*this);
-}
-
-Container &Connection::getContainer() { return impl->getContainer(); }
-
-Link Connection::getLinkHead(Endpoint::State mask) {
- return impl->getLinkHead(mask);
-}
-
-}} // namespace proton::reactor
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/ConnectionImpl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ConnectionImpl.cpp b/proton-c/bindings/cpp/src/ConnectionImpl.cpp
deleted file mode 100644
index 5fa2fb2..0000000
--- a/proton-c/bindings/cpp/src/ConnectionImpl.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-#include "proton/Container.hpp"
-#include "proton/Handler.hpp"
-#include "proton/Error.hpp"
-#include "ConnectionImpl.hpp"
-#include "proton/Transport.hpp"
-#include "Msg.hpp"
-#include "contexts.hpp"
-#include "PrivateImplRef.hpp"
-#include "ContainerImpl.hpp"
-
-#include "proton/connection.h"
-
-namespace proton {
-namespace reactor {
-
-void ConnectionImpl::incref(ConnectionImpl *impl) {
- impl->refCount++;
-}
-
-void ConnectionImpl::decref(ConnectionImpl *impl) {
- impl->refCount--;
- if (impl->refCount == 0)
- delete impl;
-}
-
-ConnectionImpl::ConnectionImpl(Container &c, pn_connection_t &pnConn)
- : container(c), refCount(0), override(0), transport(0), defaultSession(0),
- pnConnection(&pnConn), reactorReference(this)
-{
- setConnectionContext(pnConnection, this);
-}
-
-ConnectionImpl::ConnectionImpl(Container &c, Handler *handler)
- : container(c), refCount(0), override(0), transport(0), defaultSession(0),
- reactorReference(this)
-{
- pn_handler_t *chandler = 0;
- if (handler) {
- ContainerImpl *containerImpl = PrivateImplRef<Container>::get(c);
- chandler = containerImpl->wrapHandler(handler);
- }
- pnConnection = pn_reactor_connection(container.getReactor(), chandler);
- if (chandler)
- pn_decref(chandler);
- setConnectionContext(pnConnection, this);
-}
-
-ConnectionImpl::~ConnectionImpl() {
- delete transport;
- delete override;
-}
-
-Transport &ConnectionImpl::getTransport() {
- if (transport)
- return *transport;
- throw Error(MSG("Connection has no transport"));
-}
-
-Handler* ConnectionImpl::getOverride() { return override; }
-void ConnectionImpl::setOverride(Handler *h) {
- if (override)
- delete override;
- override = h;
-}
-
-void ConnectionImpl::open() {
- pn_connection_open(pnConnection);
-}
-
-void ConnectionImpl::close() {
- pn_connection_close(pnConnection);
-}
-
-pn_connection_t *ConnectionImpl::getPnConnection() { return pnConnection; }
-
-std::string ConnectionImpl::getHostname() {
- return std::string(pn_connection_get_hostname(pnConnection));
-}
-
-Connection &ConnectionImpl::getConnection() {
- // Endpoint interface. Should be implemented in the Connection object.
- throw Error(MSG("Internal error"));
-}
-
-Container &ConnectionImpl::getContainer() {
- return (container);
-}
-
-void ConnectionImpl::reactorDetach() {
- // "save" goes out of scope last, preventing possible recursive destructor
- // confusion with reactorReference.
- Connection save(reactorReference);
- if (reactorReference)
- reactorReference = Connection();
- pnConnection = 0;
-}
-
-Connection &ConnectionImpl::getReactorReference(pn_connection_t *conn) {
- if (!conn)
- throw Error(MSG("Null Proton connection"));
- ConnectionImpl *impl = getConnectionContext(conn);
- if (!impl) {
- // First time we have seen this connection
- pn_reactor_t *reactor = pn_object_reactor(conn);
- if (!reactor)
- throw Error(MSG("Invalid Proton connection specifier"));
- Container container(getContainerContext(reactor));
- if (!container) // can't be one created by our container
- throw Error(MSG("Unknown Proton connection specifier"));
- impl = new ConnectionImpl(container, *conn);
- }
- return impl->reactorReference;
-}
-
-Link ConnectionImpl::getLinkHead(Endpoint::State mask) {
- return Link(pn_link_head(pnConnection, mask));
-}
-
-}} // namespace proton::reactor
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/ConnectionImpl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ConnectionImpl.hpp b/proton-c/bindings/cpp/src/ConnectionImpl.hpp
deleted file mode 100644
index 442998e..0000000
--- a/proton-c/bindings/cpp/src/ConnectionImpl.hpp
+++ /dev/null
@@ -1,75 +0,0 @@
-#ifndef PROTON_CPP_CONNECTIONIMPL_H
-#define PROTON_CPP_CONNECTIONIMPL_H
-
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-#include "proton/export.hpp"
-#include "proton/Endpoint.hpp"
-#include "proton/Container.hpp"
-#include "proton/types.h"
-#include <string>
-
-struct pn_connection_t;
-
-namespace proton {
-namespace reactor {
-
-class Handler;
-class Transport;
-class Container;
-
-class ConnectionImpl : public Endpoint
-{
- public:
- PN_CPP_EXTERN ConnectionImpl(Container &c, pn_connection_t &pnConn);
- PN_CPP_EXTERN ConnectionImpl(Container &c, Handler *h = 0);
- PN_CPP_EXTERN virtual ~ConnectionImpl();
- PN_CPP_EXTERN Transport &getTransport();
- PN_CPP_EXTERN Handler *getOverride();
- PN_CPP_EXTERN void setOverride(Handler *h);
- PN_CPP_EXTERN void open();
- PN_CPP_EXTERN void close();
- PN_CPP_EXTERN pn_connection_t *getPnConnection();
- PN_CPP_EXTERN Container &getContainer();
- PN_CPP_EXTERN std::string getHostname();
- PN_CPP_EXTERN Link getLinkHead(Endpoint::State mask);
- virtual PN_CPP_EXTERN Connection &getConnection();
- static Connection &getReactorReference(pn_connection_t *);
- static ConnectionImpl *getImpl(const Connection &c) { return c.impl; }
- void reactorDetach();
- static void incref(ConnectionImpl *);
- static void decref(ConnectionImpl *);
- private:
- friend class Connector;
- friend class ContainerImpl;
- Container container;
- int refCount;
- Handler *override;
- Transport *transport;
- pn_session_t *defaultSession; // Temporary, for SessionPerConnection style policy.
- pn_connection_t *pnConnection;
- Connection reactorReference; // Keep-alive reference, until PN_CONNECTION_FINAL.
-};
-
-
-}} // namespace proton::reactor
-
-#endif /*!PROTON_CPP_CONNECTIONIMPL_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/Connector.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Connector.cpp b/proton-c/bindings/cpp/src/Connector.cpp
deleted file mode 100644
index 13c197f..0000000
--- a/proton-c/bindings/cpp/src/Connector.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-#include "proton/Connection.hpp"
-#include "proton/Transport.hpp"
-#include "proton/Container.hpp"
-#include "proton/Event.hpp"
-#include "proton/connection.h"
-#include "Connector.hpp"
-#include "ConnectionImpl.hpp"
-#include "Url.hpp"
-
-namespace proton {
-namespace reactor {
-
-Connector::Connector(Connection &c) : connection(c), transport(0) {}
-
-Connector::~Connector() {}
-
-void Connector::setAddress(const std::string &a) {
- address = a;
-}
-
-void Connector::connect() {
- pn_connection_t *conn = connection.getPnConnection();
- pn_connection_set_container(conn, connection.getContainer().getContainerId().c_str());
- Url url(address);
- std::string hostname = url.getHost() + ":" + url.getPort();
- pn_connection_set_hostname(conn, hostname.c_str());
- transport = new Transport();
- transport->bind(connection);
- connection.impl->transport = transport;
-}
-
-
-void Connector::onConnectionLocalOpen(Event &e) {
- connect();
-}
-
-void Connector::onConnectionRemoteOpen(Event &e) {}
-
-void Connector::onConnectionInit(Event &e) {
-}
-
-void Connector::onTransportClosed(Event &e) {
- // TODO: prepend with reconnect logic
- pn_connection_release(connection.impl->pnConnection);
- // No more interaction, so drop our counted reference.
- connection = Connection();
-}
-
-
-}} // namespace proton::reactor
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/Connector.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Connector.hpp b/proton-c/bindings/cpp/src/Connector.hpp
deleted file mode 100644
index 3c080ad..0000000
--- a/proton-c/bindings/cpp/src/Connector.hpp
+++ /dev/null
@@ -1,59 +0,0 @@
-#ifndef PROTON_CPP_CONNECTOR_HANDLER_H
-#define PROTON_CPP_CONNECTOR_HANDLER_H
-
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-#include "proton/ProtonHandler.hpp"
-#include "proton/event.h"
-#include "proton/reactor.h"
-#include <string>
-
-
-namespace proton {
-namespace reactor {
-
-class Event;
-class Connection;
-class Transport;
-
-class Connector : public ProtonHandler
-{
- public:
- Connector(Connection &c);
- ~Connector();
- void setAddress(const std::string &host);
- void connect();
- virtual void onConnectionLocalOpen(Event &e);
- virtual void onConnectionRemoteOpen(Event &e);
- virtual void onConnectionInit(Event &e);
- virtual void onTransportClosed(Event &e);
-
- private:
- Connection connection;
- std::string address;
- Transport *transport;
-};
-
-
-}} // namespace proton::reactor
-
-#endif /*!PROTON_CPP_CONNECTOR_HANDLER_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/Container.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Container.cpp b/proton-c/bindings/cpp/src/Container.cpp
deleted file mode 100644
index 16de0c1..0000000
--- a/proton-c/bindings/cpp/src/Container.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-#include "proton/Container.hpp"
-#include "proton/MessagingEvent.hpp"
-#include "proton/Connection.hpp"
-#include "proton/Session.hpp"
-#include "proton/MessagingAdapter.hpp"
-#include "proton/Acceptor.hpp"
-#include "proton/Error.hpp"
-#include "ContainerImpl.hpp"
-#include "PrivateImplRef.hpp"
-
-#include "Connector.hpp"
-#include "contexts.hpp"
-#include "Url.hpp"
-
-#include "proton/connection.h"
-#include "proton/session.h"
-
-namespace proton {
-namespace reactor {
-
-template class Handle<ContainerImpl>;
-typedef PrivateImplRef<Container> PI;
-
-Container::Container(ContainerImpl* p) { PI::ctor(*this, p); }
-Container::Container(const Container& c) : Handle<ContainerImpl>() { PI::copy(*this, c); }
-Container& Container::operator=(const Container& c) { return PI::assign(*this, c); }
-Container::~Container() { PI::dtor(*this); }
-
-Container::Container(MessagingHandler &mhandler) {
- ContainerImpl *cimpl = new ContainerImpl(mhandler);
- PI::ctor(*this, cimpl);
-}
-
-Container::Container() {
- ContainerImpl *cimpl = new ContainerImpl();
- PI::ctor(*this, cimpl);
-}
-
-Connection Container::connect(std::string &host, Handler *h) { return impl->connect(host, h); }
-
-pn_reactor_t *Container::getReactor() { return impl->getReactor(); }
-
-std::string Container::getContainerId() { return impl->getContainerId(); }
-
-Duration Container::getTimeout() { return impl->getTimeout(); }
-void Container::setTimeout(Duration timeout) { impl->setTimeout(timeout); }
-
-
-Sender Container::createSender(Connection &connection, std::string &addr, Handler *h) {
- return impl->createSender(connection, addr, h);
-}
-
-Sender Container::createSender(std::string &urlString) {
- return impl->createSender(urlString);
-}
-
-Receiver Container::createReceiver(Connection &connection, std::string &addr) {
- return impl->createReceiver(connection, addr);
-}
-
-Receiver Container::createReceiver(const std::string &url) {
- return impl->createReceiver(url);
-}
-
-Acceptor Container::listen(const std::string &urlString) {
- return impl->listen(urlString);
-}
-
-
-void Container::run() { impl->run(); }
-void Container::start() { impl->start(); }
-bool Container::process() { return impl->process(); }
-void Container::stop() { impl->stop(); }
-void Container::wakeup() { impl->wakeup(); }
-bool Container::isQuiesced() { return impl->isQuiesced(); }
-
-}} // namespace proton::reactor
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/ContainerImpl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ContainerImpl.cpp b/proton-c/bindings/cpp/src/ContainerImpl.cpp
deleted file mode 100644
index 29c1e72..0000000
--- a/proton-c/bindings/cpp/src/ContainerImpl.cpp
+++ /dev/null
@@ -1,369 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-#include "proton/Container.hpp"
-#include "proton/MessagingEvent.hpp"
-#include "proton/Connection.hpp"
-#include "proton/Session.hpp"
-#include "proton/MessagingAdapter.hpp"
-#include "proton/Acceptor.hpp"
-#include "proton/Error.hpp"
-
-#include "Msg.hpp"
-#include "ContainerImpl.hpp"
-#include "ConnectionImpl.hpp"
-#include "Connector.hpp"
-#include "contexts.hpp"
-#include "Url.hpp"
-#include "PrivateImplRef.hpp"
-
-#include "proton/connection.h"
-#include "proton/session.h"
-#include "proton/handlers.h"
-
-namespace proton {
-namespace reactor {
-
-namespace {
-
-ConnectionImpl *getImpl(const Connection &c) {
- return PrivateImplRef<Connection>::get(c);
-}
-
-} // namespace
-
-
-class CHandler : public Handler
-{
- public:
- CHandler(pn_handler_t *h) : pnHandler(h) {
- pn_incref(pnHandler);
- }
- ~CHandler() {
- pn_decref(pnHandler);
- }
- pn_handler_t *getPnHandler() { return pnHandler; }
-
- virtual void onUnhandled(Event &e) {
- ProtonEvent *pne = dynamic_cast<ProtonEvent *>(&e);
- if (!pne) return;
- int type = pne->getType();
- if (!type) return; // Not from the reactor
- pn_handler_dispatch(pnHandler, pne->getPnEvent(), (pn_event_type_t) type);
- }
-
- private:
- pn_handler_t *pnHandler;
-};
-
-
-// Used to sniff for Connector events before the reactor's global handler sees them.
-class OverrideHandler : public Handler
-{
- public:
- pn_handler_t *baseHandler;
-
- OverrideHandler(pn_handler_t *h) : baseHandler(h) {
- pn_incref(baseHandler);
- }
- ~OverrideHandler() {
- pn_decref(baseHandler);
- }
-
-
- virtual void onUnhandled(Event &e) {
- ProtonEvent *pne = dynamic_cast<ProtonEvent *>(&e);
- // If not a Proton reactor event, nothing to override, nothing to pass along.
- if (!pne) return;
- int type = pne->getType();
- if (!type) return; // Also not from the reactor
-
- pn_event_t *cevent = pne->getPnEvent();
- pn_connection_t *conn = pn_event_connection(cevent);
- if (conn && type != PN_CONNECTION_INIT) {
- // send to override handler first
- ConnectionImpl *connection = getConnectionContext(conn);
- if (connection) {
- Handler *override = connection->getOverride();
- if (override) {
- e.dispatch(*override);
- }
- }
- }
-
- pn_handler_dispatch(baseHandler, cevent, (pn_event_type_t) type);
-
- if (conn && type == PN_CONNECTION_FINAL) {
- // TODO: this must be the last action of the last handler looking at
- // connection events. Better: generate a custom FINAL event (or task). Or move to
- // separate event streams per connection as part of multi threading support.
- ConnectionImpl *cimpl = getConnectionContext(conn);
- if (cimpl)
- cimpl->reactorDetach();
- // TODO: remember all connections and do reactorDetach of zombie connections
- // not yet pn_connection_release'd at PN_REACTOR_FINAL.
- }
- }
-};
-
-
-namespace {
-
-// TODO: configurable policy. SessionPerConnection for now.
-Session getDefaultSession(pn_connection_t *conn, pn_session_t **ses) {
- if (!*ses) {
- *ses = pn_session(conn);
- pn_session_open(*ses);
- }
- return Session(*ses);
-}
-
-
-struct InboundContext {
- ContainerImpl *containerImpl;
- Handler *cppHandler;
-};
-
-ContainerImpl *getContainerImpl(pn_handler_t *c_handler) {
- struct InboundContext *ctxt = (struct InboundContext *) pn_handler_mem(c_handler);
- return ctxt->containerImpl;
-}
-
-Handler &getCppHandler(pn_handler_t *c_handler) {
- struct InboundContext *ctxt = (struct InboundContext *) pn_handler_mem(c_handler);
- return *ctxt->cppHandler;
-}
-
-void cpp_handler_dispatch(pn_handler_t *c_handler, pn_event_t *cevent, pn_event_type_t type)
-{
- Container c(getContainerImpl(c_handler)); // Ref counted per event, but when is the last event if stop() never called?
- MessagingEvent mevent(cevent, type, c);
- mevent.dispatch(getCppHandler(c_handler));
-}
-
-void cpp_handler_cleanup(pn_handler_t *c_handler)
-{
-}
-
-pn_handler_t *cpp_handler(ContainerImpl *c, Handler *h)
-{
- pn_handler_t *handler = pn_handler_new(cpp_handler_dispatch, sizeof(struct InboundContext), cpp_handler_cleanup);
- struct InboundContext *ctxt = (struct InboundContext *) pn_handler_mem(handler);
- ctxt->containerImpl = c;
- ctxt->cppHandler = h;
- return handler;
-}
-
-
-} // namespace
-
-
-void ContainerImpl::incref(ContainerImpl *impl) {
- impl->refCount++;
-}
-
-void ContainerImpl::decref(ContainerImpl *impl) {
- impl->refCount--;
- if (impl->refCount == 0)
- delete impl;
-}
-
-ContainerImpl::ContainerImpl(Handler &h) :
- reactor(0), handler(&h), messagingAdapter(0),
- overrideHandler(0), flowController(0), containerId(),
- refCount(0)
-{}
-
-ContainerImpl::ContainerImpl() :
- reactor(0), handler(0), messagingAdapter(0),
- overrideHandler(0), flowController(0), containerId(),
- refCount(0)
-{}
-
-ContainerImpl::~ContainerImpl() {
- delete overrideHandler;
- delete flowController;
- delete messagingAdapter;
- pn_reactor_free(reactor);
-}
-
-Connection ContainerImpl::connect(std::string &host, Handler *h) {
- if (!reactor) throw Error(MSG("Container not started"));
- Container cntnr(this);
- Connection connection(cntnr, handler);
- Connector *connector = new Connector(connection);
- // Connector self-deletes depending on reconnect logic
- connector->setAddress(host); // TODO: url vector
- connection.setOverride(connector);
- connection.open();
- return connection;
-}
-
-pn_reactor_t *ContainerImpl::getReactor() { return reactor; }
-
-
-std::string ContainerImpl::getContainerId() { return containerId; }
-
-Duration ContainerImpl::getTimeout() {
- pn_millis_t tmo = pn_reactor_get_timeout(reactor);
- if (tmo == PN_MILLIS_MAX)
- return Duration::FOREVER;
- return Duration(tmo);
-}
-
-void ContainerImpl::setTimeout(Duration timeout) {
- if (timeout == Duration::FOREVER || timeout.milliseconds > PN_MILLIS_MAX)
- pn_reactor_set_timeout(reactor, PN_MILLIS_MAX);
- else {
- pn_millis_t tmo = timeout.milliseconds;
- pn_reactor_set_timeout(reactor, tmo);
- }
-}
-
-
-Sender ContainerImpl::createSender(Connection &connection, std::string &addr, Handler *h) {
- if (!reactor) throw Error(MSG("Container not started"));
- Session session = getDefaultSession(connection.getPnConnection(), &getImpl(connection)->defaultSession);
- Sender snd = session.createSender(containerId + '-' + addr);
- pn_link_t *lnk = snd.getPnLink();
- pn_terminus_set_address(pn_link_target(lnk), addr.c_str());
- if (h) {
- pn_record_t *record = pn_link_attachments(lnk);
- pn_record_set_handler(record, wrapHandler(h));
- }
- snd.open();
- return snd;
-}
-
-Sender ContainerImpl::createSender(std::string &urlString) {
- if (!reactor) throw Error(MSG("Container not started"));
- Connection conn = connect(urlString, 0);
- Session session = getDefaultSession(conn.getPnConnection(), &getImpl(conn)->defaultSession);
- std::string path = Url(urlString).getPath();
- Sender snd = session.createSender(containerId + '-' + path);
- pn_terminus_set_address(pn_link_target(snd.getPnLink()), path.c_str());
- snd.open();
- return snd;
-}
-
-Receiver ContainerImpl::createReceiver(Connection &connection, std::string &addr) {
- if (!reactor) throw Error(MSG("Container not started"));
- ConnectionImpl *connImpl = getImpl(connection);
- Session session = getDefaultSession(connImpl->pnConnection, &connImpl->defaultSession);
- Receiver rcv = session.createReceiver(containerId + '-' + addr);
- pn_terminus_set_address(pn_link_source(rcv.getPnLink()), addr.c_str());
- rcv.open();
- return rcv;
-}
-
-Receiver ContainerImpl::createReceiver(const std::string &urlString) {
- if (!reactor) throw Error(MSG("Container not started"));
- // TODO: const cleanup of API
- Connection conn = connect(const_cast<std::string &>(urlString), 0);
- Session session = getDefaultSession(conn.getPnConnection(), &getImpl(conn)->defaultSession);
- std::string path = Url(urlString).getPath();
- Receiver rcv = session.createReceiver(containerId + '-' + path);
- pn_terminus_set_address(pn_link_source(rcv.getPnLink()), path.c_str());
- rcv.open();
- return rcv;
-}
-
-Acceptor ContainerImpl::acceptor(const std::string &host, const std::string &port) {
- pn_acceptor_t *acptr = pn_reactor_acceptor(reactor, host.c_str(), port.c_str(), NULL);
- if (acptr)
- return Acceptor(acptr);
- else
- throw Error(MSG("accept fail: " << pn_error_text(pn_io_error(pn_reactor_io(reactor))) << "(" << host << ":" << port << ")"));
-}
-
-Acceptor ContainerImpl::listen(const std::string &urlString) {
- if (!reactor) throw Error(MSG("Container not started"));
- Url url(urlString);
- // TODO: SSL
- return acceptor(url.getHost(), url.getPort());
-}
-
-
-pn_handler_t *ContainerImpl::wrapHandler(Handler *h) {
- return cpp_handler(this, h);
-}
-
-
-void ContainerImpl::initializeReactor() {
- if (reactor) throw Error(MSG("Container already running"));
- reactor = pn_reactor();
-
- // Set our context on the reactor
- setContainerContext(reactor, this);
-
- if (handler) {
- pn_handler_t *cppHandler = cpp_handler(this, handler);
- pn_reactor_set_handler(reactor, cppHandler);
- pn_decref(cppHandler);
- }
-
- // Set our own global handler that "subclasses" the existing one
- pn_handler_t *globalHandler = pn_reactor_get_global_handler(reactor);
- overrideHandler = new OverrideHandler(globalHandler);
- pn_handler_t *cppGlobalHandler = cpp_handler(this, overrideHandler);
- pn_reactor_set_global_handler(reactor, cppGlobalHandler);
- pn_decref(cppGlobalHandler);
-
- // Note: we have just set up the following 4/5 handlers that see events in this order:
- // messagingHandler (Proton C events), pn_flowcontroller (optional), messagingAdapter,
- // messagingHandler (Messaging events from the messagingAdapter, i.e. the delegate),
- // connector override, the reactor's default globalhandler (pn_iohandler)
-}
-
-void ContainerImpl::run() {
- initializeReactor();
- pn_reactor_run(reactor);
-}
-
-void ContainerImpl::start() {
- initializeReactor();
- pn_reactor_start(reactor);
-}
-
-bool ContainerImpl::process() {
- if (!reactor) throw Error(MSG("Container not started"));
- bool result = pn_reactor_process(reactor);
- // TODO: check errors
- return result;
-}
-
-void ContainerImpl::stop() {
- if (!reactor) throw Error(MSG("Container not started"));
- pn_reactor_stop(reactor);
- // TODO: check errors
-}
-
-void ContainerImpl::wakeup() {
- if (!reactor) throw Error(MSG("Container not started"));
- pn_reactor_wakeup(reactor);
- // TODO: check errors
-}
-
-bool ContainerImpl::isQuiesced() {
- if (!reactor) throw Error(MSG("Container not started"));
- return pn_reactor_quiesced(reactor);
-}
-
-}} // namespace proton::reactor
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/ContainerImpl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ContainerImpl.hpp b/proton-c/bindings/cpp/src/ContainerImpl.hpp
deleted file mode 100644
index 72cbefa..0000000
--- a/proton-c/bindings/cpp/src/ContainerImpl.hpp
+++ /dev/null
@@ -1,82 +0,0 @@
-#ifndef PROTON_CPP_CONTAINERIMPL_H
-#define PROTON_CPP_CONTAINERIMPL_H
-
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-#include "proton/export.hpp"
-#include "proton/MessagingHandler.hpp"
-#include "proton/Connection.hpp"
-#include "proton/Link.hpp"
-#include "proton/Duration.hpp"
-
-#include "proton/reactor.h"
-
-#include <string>
-namespace proton {
-namespace reactor {
-
-class DispatchHelper;
-class Connection;
-class Connector;
-class Acceptor;
-
-class ContainerImpl
-{
- public:
- PN_CPP_EXTERN ContainerImpl(Handler &h);
- PN_CPP_EXTERN ContainerImpl();
- PN_CPP_EXTERN ~ContainerImpl();
- PN_CPP_EXTERN Connection connect(std::string &host, Handler *h);
- PN_CPP_EXTERN void run();
- PN_CPP_EXTERN pn_reactor_t *getReactor();
- PN_CPP_EXTERN Sender createSender(Connection &connection, std::string &addr, Handler *h);
- PN_CPP_EXTERN Sender createSender(std::string &url);
- PN_CPP_EXTERN Receiver createReceiver(Connection &connection, std::string &addr);
- PN_CPP_EXTERN Receiver createReceiver(const std::string &url);
- PN_CPP_EXTERN Acceptor listen(const std::string &url);
- PN_CPP_EXTERN std::string getContainerId();
- PN_CPP_EXTERN Duration getTimeout();
- PN_CPP_EXTERN void setTimeout(Duration timeout);
- void start();
- bool process();
- void stop();
- void wakeup();
- bool isQuiesced();
- pn_handler_t *wrapHandler(Handler *h);
- static void incref(ContainerImpl *);
- static void decref(ContainerImpl *);
- private:
- void dispatch(pn_event_t *event, pn_event_type_t type);
- Acceptor acceptor(const std::string &host, const std::string &port);
- void initializeReactor();
- pn_reactor_t *reactor;
- Handler *handler;
- MessagingAdapter *messagingAdapter;
- Handler *overrideHandler;
- Handler *flowController;
- std::string containerId;
- int refCount;
-};
-
-
-}} // namespace proton::reactor
-
-#endif /*!PROTON_CPP_CONTAINERIMPL_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/Data.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Data.cpp b/proton-c/bindings/cpp/src/Data.cpp
deleted file mode 100644
index dc017ae..0000000
--- a/proton-c/bindings/cpp/src/Data.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include "proton/Data.hpp"
-#include "proton/codec.h"
-#include "proton_bits.hpp"
-#include <utility>
-
-namespace proton {
-
-Data::Data() : data(pn_data(0)), own_(true) {}
-
-Data::Data(pn_data_t* p) : data(p), own_(false) { }
-
-Data::Data(const Data& x) : data(pn_data(0)), own_(true) { *this = x; }
-
-Data::~Data() { if (own_ && data) pn_data_free(data); }
-
-void Data::view(pn_data_t* newData) {
- if (data && own_) pn_data_free(data);
- data = newData;
- own_ = false;
-}
-
-void Data::swap(Data& x) {
- std::swap(data, x.data);
- std::swap(own_, x.own_);
-}
-
-Data& Data::operator=(const Data& x) {
- if (this != &x) {
- if (!own_) {
- data = pn_data(pn_data_size(x.data));
- own_ = true;
- } else {
- clear();
- }
- pn_data_copy(data, x.data);
- }
- return *this;
-}
-
-void Data::clear() { pn_data_clear(data); }
-
-bool Data::empty() const { return pn_data_size(data) == 0; }
-
-std::ostream& operator<<(std::ostream& o, const Data& d) { return o << PnObject(d.data); }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/Decoder.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Decoder.cpp b/proton-c/bindings/cpp/src/Decoder.cpp
deleted file mode 100644
index 707bcea..0000000
--- a/proton-c/bindings/cpp/src/Decoder.cpp
+++ /dev/null
@@ -1,327 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include "proton/Decoder.hpp"
-#include "proton/Value.hpp"
-#include <proton/codec.h>
-#include "proton_bits.hpp"
-#include "Msg.hpp"
-
-namespace proton {
-
-/**@file
- *
- * Note the pn_data_t "current" node is always pointing *before* the next value
- * to be returned by the Decoder.
- *
- */
-Decoder::Decoder() {}
-Decoder::Decoder(const char* buffer, size_t size) { decode(buffer, size); }
-Decoder::Decoder(const std::string& buffer) { decode(buffer); }
-Decoder::~Decoder() {}
-
-static const std::string prefix("decode: ");
-DecodeError::DecodeError(const std::string& msg) throw() : Error(prefix+msg) {}
-
-namespace {
-struct SaveState {
- pn_data_t* data;
- pn_handle_t handle;
- SaveState(pn_data_t* d) : data(d), handle(pn_data_point(d)) {}
- ~SaveState() { if (data) pn_data_restore(data, handle); }
- void cancel() { data = 0; }
-};
-
-struct Narrow {
- pn_data_t* data;
- Narrow(pn_data_t* d) : data(d) { pn_data_narrow(d); }
- ~Narrow() { pn_data_widen(data); }
-};
-
-template <class T> T check(T result) {
- if (result < 0)
- throw DecodeError("" + errorStr(result));
- return result;
-}
-
-}
-
-void Decoder::decode(const char* i, size_t size) {
- SaveState ss(data);
- const char* end = i + size;
- while (i < end) {
- i += check(pn_data_decode(data, i, end - i));
- }
-}
-
-void Decoder::decode(const std::string& buffer) {
- decode(buffer.data(), buffer.size());
-}
-
-bool Decoder::more() const {
- SaveState ss(data);
- return pn_data_next(data);
-}
-
-namespace {
-
-void badType(TypeId want, TypeId got) {
- if (want != got)
- throw DecodeError("expected "+typeName(want)+" found "+typeName(got));
-}
-
-TypeId preGet(pn_data_t* data) {
- if (!pn_data_next(data)) throw DecodeError("no more data");
- TypeId t = TypeId(pn_data_type(data));
- if (t < 0) throw DecodeError("invalid data");
- return t;
-}
-
-// Simple extract with no type conversion.
-template <class T, class U> void extract(pn_data_t* data, T& value, U (*get)(pn_data_t*)) {
- SaveState ss(data);
- badType(TypeIdOf<T>::value, preGet(data));
- value = get(data);
- ss.cancel(); // No error, no rewind
-}
-
-}
-
-void Decoder::checkType(TypeId want) {
- TypeId got = type();
- if (want != got) badType(want, got);
-}
-
-TypeId Decoder::type() const {
- SaveState ss(data);
- return preGet(data);
-}
-
-Decoder& operator>>(Decoder& d, Start& s) {
- SaveState ss(d.data);
- s.type = preGet(d.data);
- switch (s.type) {
- case ARRAY:
- s.size = pn_data_get_array(d.data);
- s.element = TypeId(pn_data_get_array_type(d.data));
- s.isDescribed = pn_data_is_array_described(d.data);
- break;
- case LIST:
- s.size = pn_data_get_list(d.data);
- break;
- case MAP:
- s.size = pn_data_get_map(d.data);
- break;
- case DESCRIBED:
- s.isDescribed = true;
- s.size = 1;
- break;
- default:
- throw DecodeError(MSG("" << s.type << " is not a container type"));
- }
- pn_data_enter(d.data);
- ss.cancel();
- return d;
-}
-
-Decoder& operator>>(Decoder& d, Finish) { pn_data_exit(d.data); return d; }
-
-Decoder& operator>>(Decoder& d, Skip) { pn_data_next(d.data); return d; }
-
-Decoder& operator>>(Decoder& d, Value& v) {
- if (d.data == v.values.data) throw DecodeError("extract into self");
- pn_data_clear(v.values.data);
- {
- Narrow n(d.data);
- check(pn_data_appendn(v.values.data, d.data, 1));
- }
- if (!pn_data_next(d.data)) throw DecodeError("no more data");
- return d;
-}
-
-
-Decoder& operator>>(Decoder& d, Null) {
- SaveState ss(d.data);
- badType(NULL_, preGet(d.data));
- return d;
-}
-
-Decoder& operator>>(Decoder& d, Bool& value) {
- extract(d.data, value, pn_data_get_bool);
- return d;
-}
-
-Decoder& operator>>(Decoder& d, Ubyte& value) {
- SaveState ss(d.data);
- switch (preGet(d.data)) {
- case UBYTE: value = pn_data_get_ubyte(d.data); break;
- default: badType(UBYTE, TypeId(TypeId(pn_data_type(d.data))));
- }
- ss.cancel();
- return d;
-}
-
-Decoder& operator>>(Decoder& d, Byte& value) {
- SaveState ss(d.data);
- switch (preGet(d.data)) {
- case BYTE: value = pn_data_get_byte(d.data); break;
- default: badType(BYTE, TypeId(TypeId(pn_data_type(d.data))));
- }
- ss.cancel();
- return d;
-}
-
-Decoder& operator>>(Decoder& d, Ushort& value) {
- SaveState ss(d.data);
- switch (preGet(d.data)) {
- case UBYTE: value = pn_data_get_ubyte(d.data); break;
- case USHORT: value = pn_data_get_ushort(d.data); break;
- default: badType(USHORT, TypeId(TypeId(pn_data_type(d.data))));
- }
- ss.cancel();
- return d;
-}
-
-Decoder& operator>>(Decoder& d, Short& value) {
- SaveState ss(d.data);
- switch (preGet(d.data)) {
- case BYTE: value = pn_data_get_byte(d.data); break;
- case SHORT: value = pn_data_get_short(d.data); break;
- default: badType(SHORT, TypeId(pn_data_type(d.data)));
- }
- ss.cancel();
- return d;
-}
-
-Decoder& operator>>(Decoder& d, Uint& value) {
- SaveState ss(d.data);
- switch (preGet(d.data)) {
- case UBYTE: value = pn_data_get_ubyte(d.data); break;
- case USHORT: value = pn_data_get_ushort(d.data); break;
- case UINT: value = pn_data_get_uint(d.data); break;
- default: badType(UINT, TypeId(pn_data_type(d.data)));
- }
- ss.cancel();
- return d;
-}
-
-Decoder& operator>>(Decoder& d, Int& value) {
- SaveState ss(d.data);
- switch (preGet(d.data)) {
- case BYTE: value = pn_data_get_byte(d.data); break;
- case SHORT: value = pn_data_get_short(d.data); break;
- case INT: value = pn_data_get_int(d.data); break;
- default: badType(INT, TypeId(pn_data_type(d.data)));
- }
- ss.cancel();
- return d;
-}
-
-Decoder& operator>>(Decoder& d, Ulong& value) {
- SaveState ss(d.data);
- switch (preGet(d.data)) {
- case UBYTE: value = pn_data_get_ubyte(d.data); break;
- case USHORT: value = pn_data_get_ushort(d.data); break;
- case UINT: value = pn_data_get_uint(d.data); break;
- case ULONG: value = pn_data_get_ulong(d.data); break;
- default: badType(ULONG, TypeId(pn_data_type(d.data)));
- }
- ss.cancel();
- return d;
-}
-
-Decoder& operator>>(Decoder& d, Long& value) {
- SaveState ss(d.data);
- switch (preGet(d.data)) {
- case BYTE: value = pn_data_get_byte(d.data); break;
- case SHORT: value = pn_data_get_short(d.data); break;
- case INT: value = pn_data_get_int(d.data); break;
- case LONG: value = pn_data_get_long(d.data); break;
- default: badType(LONG, TypeId(pn_data_type(d.data)));
- }
- ss.cancel();
- return d;
-}
-
-Decoder& operator>>(Decoder& d, Char& value) {
- extract(d.data, value, pn_data_get_char);
- return d;
-}
-
-Decoder& operator>>(Decoder& d, Timestamp& value) {
- extract(d.data, value, pn_data_get_timestamp);
- return d;
-}
-
-Decoder& operator>>(Decoder& d, Float& value) {
- SaveState ss(d.data);
- switch (preGet(d.data)) {
- case FLOAT: value = pn_data_get_float(d.data); break;
- case DOUBLE: value = pn_data_get_double(d.data); break;
- default: badType(FLOAT, TypeId(pn_data_type(d.data)));
- }
- ss.cancel();
- return d;
-}
-
-Decoder& operator>>(Decoder& d, Double& value) {
- SaveState ss(d.data);
- switch (preGet(d.data)) {
- case FLOAT: value = pn_data_get_float(d.data); break;
- case DOUBLE: value = pn_data_get_double(d.data); break;
- default: badType(DOUBLE, TypeId(pn_data_type(d.data)));
- }
- ss.cancel();
- return d;
-}
-
-// TODO aconway 2015-06-11: decimal conversions.
-Decoder& operator>>(Decoder& d, Decimal32& value) {
- extract(d.data, value, pn_data_get_decimal32);
- return d;
-}
-
-Decoder& operator>>(Decoder& d, Decimal64& value) {
- extract(d.data, value, pn_data_get_decimal64);
- return d;
-}
-
-Decoder& operator>>(Decoder& d, Decimal128& value) {
- extract(d.data, value, pn_data_get_decimal128);
- return d;
-}
-
-Decoder& operator>>(Decoder& d, Uuid& value) {
- extract(d.data, value, pn_data_get_uuid);
- return d;
-}
-
-Decoder& operator>>(Decoder& d, std::string& value) {
- SaveState ss(d.data);
- switch (preGet(d.data)) {
- case STRING: value = str(pn_data_get_string(d.data)); break;
- case BINARY: value = str(pn_data_get_binary(d.data)); break;
- case SYMBOL: value = str(pn_data_get_symbol(d.data)); break;
- default: badType(STRING, TypeId(pn_data_type(d.data)));
- }
- ss.cancel();
- return d;
-}
-
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org