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:19 UTC
[1/8] qpid-proton git commit: PROTON-865: Renaming to follow
boost/std library C++ naming conventions.
Repository: qpid-proton
Updated Branches:
refs/heads/cjansen-cpp-client 9f7e34620 -> 697830998
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/url.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/url.hpp b/proton-c/bindings/cpp/src/url.hpp
new file mode 100644
index 0000000..0cc8690
--- /dev/null
+++ b/proton-c/bindings/cpp/src/url.hpp
@@ -0,0 +1,48 @@
+#ifndef PROTON_CPP_URL_H
+#define PROTON_CPP_URL_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/proton_handle.hpp"
+#include "proton/url.h"
+#include <string>
+
+namespace proton {
+
+class Url : public proton_handle<pn_url_t>
+{
+ public:
+ PN_CPP_EXTERN Url(const std::string &url);
+ PN_CPP_EXTERN ~Url();
+ PN_CPP_EXTERN Url(const Url&);
+ PN_CPP_EXTERN Url& operator=(const Url&);
+ PN_CPP_EXTERN std::string host();
+ PN_CPP_EXTERN std::string port();
+ PN_CPP_EXTERN std::string path();
+ private:
+ friend class proton_impl_ref<Url>;
+};
+
+
+}
+
+#endif /*!PROTON_CPP_URL_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/value.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/value.cpp b/proton-c/bindings/cpp/src/value.cpp
new file mode 100644
index 0000000..ff95e2e
--- /dev/null
+++ b/proton-c/bindings/cpp/src/value.cpp
@@ -0,0 +1,136 @@
+/*
+ * 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/value.hpp"
+#include "proton_bits.hpp"
+#include <proton/codec.h>
+#include <ostream>
+#include <algorithm>
+
+namespace proton {
+
+value::value() { *this = amqp_null(); }
+value::value(const value& v) { *this = v; }
+value::~value() {}
+
+value& value::operator=(const value& v) { values_ = v.values_; return *this; }
+
+type_id value::type() const {
+ const_cast<values&>(values_).rewind();
+ return values_.type();
+}
+
+namespace {
+template <class T> T check(T result) {
+ if (result < 0)
+ throw encode_error("encode: " + error_str(result));
+ return result;
+}
+}
+
+std::ostream& operator<<(std::ostream& o, const value& v) {
+ return o << v.values_;
+}
+
+namespace {
+
+// Compare nodes, return -1 if a<b, 0 if a==b, +1 if a>b
+// Forward-declare so we can use it recursively.
+int compare_next(values& a, values& b);
+
+template <class T> int compare(const T& a, const T& b) {
+ if (a < b) return -1;
+ else if (a > b) return +1;
+ else return 0;
+}
+
+int compare_container(values& a, values& b) {
+ decoder::scope sa(a), sb(b);
+ // Compare described vs. not-described.
+ int cmp = compare(sa.is_described, sb.is_described);
+ if (cmp) return cmp;
+ // Lexical sort (including descriptor if there is one)
+ size_t min_size = std::min(sa.size, sb.size) + int(sa.is_described);
+ for (size_t i = 0; i < min_size; ++i) {
+ cmp = compare_next(a, b);
+ if (cmp) return cmp;
+ }
+ return compare(sa.size, sb.size);
+}
+
+template <class T> int compare_simple(values& a, values& b) {
+ T va, vb;
+ a >> va;
+ b >> vb;
+ return compare(va, vb);
+}
+
+int compare_next(values& a, values& b) {
+ // Sort by type_id first.
+ type_id ta = a.type(), tb = b.type();
+ int cmp = compare(ta, tb);
+ if (cmp) return cmp;
+
+ switch (ta) {
+ case NULl_: return 0;
+ case ARRAY:
+ case LIST:
+ case MAP:
+ case DESCRIBED:
+ return compare_container(a, b);
+ case BOOL: return compare_simple<amqp_bool>(a, b);
+ case UBYTE: return compare_simple<amqp_ubyte>(a, b);
+ case BYTE: return compare_simple<amqp_byte>(a, b);
+ case USHORT: return compare_simple<amqp_ushort>(a, b);
+ case SHORT: return compare_simple<amqp_short>(a, b);
+ case UINT: return compare_simple<amqp_uint>(a, b);
+ case INT: return compare_simple<amqp_int>(a, b);
+ case CHAR: return compare_simple<amqp_char>(a, b);
+ case ULONG: return compare_simple<amqp_ulong>(a, b);
+ case LONG: return compare_simple<amqp_long>(a, b);
+ case TIMESTAMP: return compare_simple<amqp_timestamp>(a, b);
+ case FLOAT: return compare_simple<amqp_float>(a, b);
+ case DOUBLE: return compare_simple<amqp_double>(a, b);
+ case DECIMAL32: return compare_simple<amqp_decimal32>(a, b);
+ case DECIMAL64: return compare_simple<amqp_decimal64>(a, b);
+ case DECIMAL128: return compare_simple<amqp_decimal128>(a, b);
+ case UUID: return compare_simple<amqp_uuid>(a, b);
+ case BINARY: return compare_simple<amqp_binary>(a, b);
+ case STRING: return compare_simple<amqp_string>(a, b);
+ case SYMBOL: return compare_simple<amqp_symbol>(a, b);
+ }
+ // Invalid but equal type_id, treat as equal.
+ return 0;
+}
+
+} // namespace
+
+bool value::operator==(const value& v) const {
+ values_.rewind();
+ v.values_.rewind();
+ return compare_next(values_, v.values_) == 0;
+}
+
+bool value::operator<(const value& v) const {
+ values_.rewind();
+ v.values_.rewind();
+ return compare_next(values_, v.values_) < 0;
+}
+
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/values.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/values.cpp b/proton-c/bindings/cpp/src/values.cpp
new file mode 100644
index 0000000..4c8cda1
--- /dev/null
+++ b/proton-c/bindings/cpp/src/values.cpp
@@ -0,0 +1,38 @@
+/*
+ * 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/value.hpp"
+#include "proton_bits.hpp"
+#include <proton/codec.h>
+#include <ostream>
+
+namespace proton {
+
+values::values() {}
+values::values(const values& v) { *this = v; }
+values::values(pn_data_t* d) : data(d) {}
+
+values::~values() {}
+values& values::operator=(const values& v) { data::operator=(v); return *this; }
+
+std::ostream& operator<<(std::ostream& o, const values& v) {
+ return o << static_cast<const encoder&>(v);
+}
+
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/docs/api/index.md
----------------------------------------------------------------------
diff --git a/proton-c/docs/api/index.md b/proton-c/docs/api/index.md
index 8727d9b..ab3267a 100644
--- a/proton-c/docs/api/index.md
+++ b/proton-c/docs/api/index.md
@@ -5,5 +5,3 @@ The proton library contains two C APIs: The [Engine API](@ref engine),
and the [Messenger API](@ref messenger).
There is also a [C++ API](@ref cpp).
-
-@defgroup cpp C++ binding
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/docs/api/user.doxygen.in
----------------------------------------------------------------------
diff --git a/proton-c/docs/api/user.doxygen.in b/proton-c/docs/api/user.doxygen.in
index 7c6edf7..951c2fb 100644
--- a/proton-c/docs/api/user.doxygen.in
+++ b/proton-c/docs/api/user.doxygen.in
@@ -162,7 +162,7 @@ STRIP_FROM_INC_PATH =
# (but less readable) file names. This can be useful if your file system
# doesn't support long names like on DOS, Mac, or CD-ROM.
-SHORT_NAMES = YES
+SHORT_NAMES = NO
# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
# will interpret the first line (until the first dot) of a JavaDoc-style
@@ -660,7 +660,7 @@ INPUT_ENCODING = UTF-8
# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py
# *.f90 *.f *.for *.vhd *.vhdl
-FILE_PATTERNS = *.h *.md
+FILE_PATTERNS = *.h *.md *.hpp
# The RECURSIVE tag can be used to turn specify whether or not subdirectories
# should be searched for input files as well. Possible values are YES and NO.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[7/8] qpid-proton git commit: PROTON-865: Renaming to follow
boost/std library C++ naming conventions.
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/Decoder.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/Decoder.hpp b/proton-c/bindings/cpp/include/proton/Decoder.hpp
deleted file mode 100644
index 11cd5fb..0000000
--- a/proton-c/bindings/cpp/include/proton/Decoder.hpp
+++ /dev/null
@@ -1,223 +0,0 @@
-#ifndef DECODER_H
-#define DECODER_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/Data.hpp"
-#include "proton/Error.hpp"
-#include "proton/type_traits.hpp"
-#include "proton/types.hpp"
-#include <iosfwd>
-
-namespace proton {
-
-class Value;
-
-/** Raised by Decoder operations on error */
-struct DecodeError : public Error { PN_CPP_EXTERN explicit DecodeError(const std::string&) throw(); };
-
-/**@file
- * Stream-like decoder from AMQP bytes to C++ values.
- * @ingroup cpp
- */
-
-/**
-@ingroup cpp
-
-Stream-like decoder from AMQP bytes to a stream of C++ values.
-
-types.h defines C++ types corresponding to AMQP types.
-
-Decoder operator>> will extract AMQP types into corresponding C++ types, and do
-simple conversions, e.g. from AMQP integer types to corresponding or larger C++
-integer types.
-
-You can require an exact AMQP type using the `as<type>(value)` helper. E.g.
-
- Int i;
- decoder >> as<INT>(i): // Will throw if decoder does not contain an INT
-
-You can also use the `as` helper to extract an AMQP list, array or map into C++ containers.
-
- std::vector<Int> v;
- decoder >> as<LIST>(v); // Extract a list of INT.
-
-AMQP maps can be inserted/extracted to any container with pair<X,Y> as
-value_type, which includes std::map and std::unordered_map but also for
-example std::vector<std::pair<X,Y> >. This allows you to perserve order when
-extracting AMQP maps.
-
-You can also extract container values element-by-element, see the Start class.
-*/
-class Decoder : public virtual Data {
- public:
-
- PN_CPP_EXTERN Decoder();
- PN_CPP_EXTERN ~Decoder();
-
- /** Copy AMQP data from a byte buffer into the Decoder. */
- PN_CPP_EXTERN Decoder(const char* buffer, size_t size);
-
- /** Copy AMQP data from a std::string into the Decoder. */
- PN_CPP_EXTERN Decoder(const std::string&);
-
- /** Decode AMQP data from a byte buffer onto the end of the value stream. */
- PN_CPP_EXTERN void decode(const char* buffer, size_t size);
-
- /** Decode AMQP data from bytes in std::string onto the end of the value stream. */
- PN_CPP_EXTERN void decode(const std::string&);
-
- /** Return true if there are more values to read at the current level. */
- PN_CPP_EXTERN bool more() const;
-
- /** Type of the next value that will be read by operator>>
- *@throw Error if empty().
- */
- PN_CPP_EXTERN TypeId type() const;
-
- /** @name Extract simple types
- * Overloads to extract simple types.
- * @throw Error if the Decoder is empty or the current value has an incompatible type.
- * @{
- */
- PN_CPP_EXTERN friend Decoder& operator>>(Decoder&, Null);
- PN_CPP_EXTERN friend Decoder& operator>>(Decoder&, Bool&);
- PN_CPP_EXTERN friend Decoder& operator>>(Decoder&, Ubyte&);
- PN_CPP_EXTERN friend Decoder& operator>>(Decoder&, Byte&);
- PN_CPP_EXTERN friend Decoder& operator>>(Decoder&, Ushort&);
- PN_CPP_EXTERN friend Decoder& operator>>(Decoder&, Short&);
- PN_CPP_EXTERN friend Decoder& operator>>(Decoder&, Uint&);
- PN_CPP_EXTERN friend Decoder& operator>>(Decoder&, Int&);
- PN_CPP_EXTERN friend Decoder& operator>>(Decoder&, Char&);
- PN_CPP_EXTERN friend Decoder& operator>>(Decoder&, Ulong&);
- PN_CPP_EXTERN friend Decoder& operator>>(Decoder&, Long&);
- PN_CPP_EXTERN friend Decoder& operator>>(Decoder&, Timestamp&);
- PN_CPP_EXTERN friend Decoder& operator>>(Decoder&, Float&);
- PN_CPP_EXTERN friend Decoder& operator>>(Decoder&, Double&);
- PN_CPP_EXTERN friend Decoder& operator>>(Decoder&, Decimal32&);
- PN_CPP_EXTERN friend Decoder& operator>>(Decoder&, Decimal64&);
- PN_CPP_EXTERN friend Decoder& operator>>(Decoder&, Decimal128&);
- PN_CPP_EXTERN friend Decoder& operator>>(Decoder&, Uuid&);
- PN_CPP_EXTERN friend Decoder& operator>>(Decoder&, std::string&);
- PN_CPP_EXTERN friend Decoder& operator>>(Decoder&, Value&);
- ///@}
-
- /** Extract and return a value of type T. */
- template <class T> T get() { T value; *this >> value; return value; }
-
- /** Extract and return a value of type T, as AMQP type. */
- template <class T, TypeId A> T getAs() { T value; *this >> as<A>(value); return value; }
-
- /** Call Decoder::start() in constructor, Decoder::finish in destructor() */
- struct Scope : public Start {
- Decoder& decoder;
- Scope(Decoder& d) : decoder(d) { d >> *this; }
- ~Scope() { decoder >> finish(); }
- };
-
- template <TypeId A, class T> friend Decoder& operator>>(Decoder& d, Ref<T, A> ref) {
- d.checkType(A);
- d >> ref.value;
- return d;
- }
-
- /** start extracting a container value, one of array, list, map, described.
- * The basic pattern is:
- *
- * Start s;
- * decoder >> s;
- * // check s.type() to see if this is an ARRAY, LIST, MAP or DESCRIBED type.
- * if (s.described) extract the descriptor...
- * for (size_t i = 0; i < s.size(); ++i) Extract each element...
- * decoder >> finish();
- *
- * The first value of an ARRAY is a descriptor if Start::descriptor is true,
- * followed by Start::size elemets of type Start::element.
- *
- * A LIST has Start::size elements which may be of mixed type.
- *
- * A MAP has Start::size elements which alternate key, value, key, value...
- * and may be of mixed type.
- *
- * A DESCRIBED contains a descriptor and a single element, so it always has
- * Start::described=true and Start::size=1.
- *
- * Note Scope automatically calls finish() in its destructor.
- *
- *@throw decoder::error if the curent value is not a container type.
- */
- PN_CPP_EXTERN friend Decoder& operator>>(Decoder&, Start&);
-
- /** Finish extracting a container value. */
- PN_CPP_EXTERN friend Decoder& operator>>(Decoder&, Finish);
-
- /** Skip a value */
- PN_CPP_EXTERN friend Decoder& operator>>(Decoder&, Skip);
-
- private:
- template <class T> Decoder& extract(T& value);
- PN_CPP_EXTERN void checkType(TypeId);
-
- friend class Value;
- friend class Encoder;
-};
-
-// operator >> for integer types that are not covered by the standard overrides.
-template <class T>
-typename std::enable_if<IsUnknownInteger<T>::value, Decoder&>::type operator>>(Decoder& d, T& i) {
- typename IntegerType<sizeof(T), std::is_signed<T>::value>::type v;
- d >> v; // Extract as a known integer type
- i = v;
- return d;
-}
-
-template <class T> Decoder& operator>>(Decoder& d, Ref<T, ARRAY> ref) {
- Decoder::Scope s(d);
- if (s.isDescribed) d >> skip();
- ref.value.clear();
- ref.value.resize(s.size);
- for (typename T::iterator i = ref.value.begin(); i != ref.value.end(); ++i) {
- d >> *i;
- }
- return d;
-}
-
-template <class T> Decoder& operator>>(Decoder& d, Ref<T, LIST> ref) {
- Decoder::Scope s(d);
- ref.value.clear();
- ref.value.resize(s.size);
- for (typename T::iterator i = ref.value.begin(); i != ref.value.end(); ++i)
- d >> *i;
- return d;
-}
-
-template <class T> Decoder& operator>>(Decoder& d, Ref<T, MAP> ref) {
- Decoder::Scope m(d);
- ref.value.clear();
- for (size_t i = 0; i < m.size/2; ++i) {
- typename T::key_type k;
- typename T::mapped_type v;
- d >> k >> v;
- ref.value[k] = v;
- }
- return d;
-}
-
-}
-#endif // DECODER_H
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/Delivery.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/Delivery.hpp b/proton-c/bindings/cpp/include/proton/Delivery.hpp
deleted file mode 100644
index 110b1ce..0000000
--- a/proton-c/bindings/cpp/include/proton/Delivery.hpp
+++ /dev/null
@@ -1,60 +0,0 @@
-#ifndef PROTON_CPP_DELIVERY_H
-#define PROTON_CPP_DELIVERY_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/ProtonHandle.hpp"
-
-#include "proton/delivery.h"
-#include "proton/disposition.h"
-
-namespace proton {
-namespace reactor {
-
-class Delivery : public ProtonHandle<pn_delivery_t>
-{
- public:
-
- enum state {
- NONE = 0,
- RECEIVED = PN_RECEIVED,
- ACCEPTED = PN_ACCEPTED,
- REJECTED = PN_REJECTED,
- RELEASED = PN_RELEASED,
- MODIFIED = PN_MODIFIED
- }; // AMQP spec 3.4 Delivery State
-
- PN_CPP_EXTERN Delivery(pn_delivery_t *d);
- PN_CPP_EXTERN Delivery();
- PN_CPP_EXTERN ~Delivery();
- PN_CPP_EXTERN Delivery(const Delivery&);
- PN_CPP_EXTERN Delivery& operator=(const Delivery&);
- PN_CPP_EXTERN bool settled();
- PN_CPP_EXTERN void settle();
- PN_CPP_EXTERN pn_delivery_t *getPnDelivery();
- private:
- friend class ProtonImplRef<Delivery>;
-};
-
-}}
-
-#endif /*!PROTON_CPP_DELIVERY_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/Duration.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/Duration.hpp b/proton-c/bindings/cpp/include/proton/Duration.hpp
deleted file mode 100644
index 596b4d0..0000000
--- a/proton-c/bindings/cpp/include/proton/Duration.hpp
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef PROTON_CPP_DURATION_H
-#define PROTON_CPP_DURATION_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/types.hpp"
-
-namespace proton {
-
-/** @ingroup cpp
- * A duration is a time in milliseconds.
- */
-class Duration : public Comparable<Duration>
-{
- public:
- std::uint64_t milliseconds;
- explicit Duration(std::uint64_t ms) : milliseconds(ms) {}
-
- bool operator<(Duration d) { return milliseconds < d.milliseconds; }
- bool operator==(Duration d) { return milliseconds == d.milliseconds; }
-
- PN_CPP_EXTERN static const Duration FOREVER;
- PN_CPP_EXTERN static const Duration IMMEDIATE;
- PN_CPP_EXTERN static const Duration SECOND;
- PN_CPP_EXTERN static const Duration MINUTE;
-};
-
-inline Duration operator*(Duration d, std::uint64_t n) { return Duration(d.milliseconds*n); }
-inline Duration operator*(std::uint64_t n, Duration d) { return d * n; }
-
-inline Timestamp operator+(Timestamp ts, Duration d) { return Timestamp(ts.milliseconds+d.milliseconds); }
-inline Timestamp operator+(Duration d, Timestamp ts) { return ts + d; }
-}
-
-#endif /*!PROTON_CPP_DURATION_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/Encoder.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/Encoder.hpp b/proton-c/bindings/cpp/include/proton/Encoder.hpp
deleted file mode 100644
index 8b2f77c..0000000
--- a/proton-c/bindings/cpp/include/proton/Encoder.hpp
+++ /dev/null
@@ -1,185 +0,0 @@
-#ifndef ENCODER_H
-#define ENCODER_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/Data.hpp"
-#include "proton/Error.hpp"
-#include "proton/types.hpp"
-#include "proton/type_traits.hpp"
-#include <iosfwd>
-
-#include <iostream> // FIXME aconway 2015-06-18:
-
-struct pn_data_t;
-
-namespace proton {
-
-class Value;
-
-/**@file
- * Stream-like encoder from C++ values to AMQP bytes.
- * @ingroup cpp
-*/
-
-/** Raised by Encoder operations on error */
-struct EncodeError : public Error { PN_CPP_EXTERN explicit EncodeError(const std::string&) throw(); };
-
-/**
-@ingroup cpp
-
-types.h defines C++ typedefs and types for AMQP each type. These types
-insert as the corresponding AMQP type. Normal C++ conversion rules apply if you
-insert any other type.
-
-C++ containers can be inserted as AMQP containers with the as() helper functions. E.g.
-
- std::vector<Symbol> v; encoder << as<List>(v);
-
-AMQP maps can be inserted/extracted to any container with pair<X,Y> as
-value_type, which includes std::map and std::unordered_map but also for
-example std::vector<std::pair<X,Y> >. This allows you to perserve order when
-extracting AMQP maps.
-
-You can also insert containers element-by-element, see the Start class.
-*/
-class Encoder : public virtual Data {
- public:
- PN_CPP_EXTERN Encoder();
- PN_CPP_EXTERN ~Encoder();
-
- /**
- * Encode the current values into buffer and update size to reflect the number of bytes encoded.
- *
- * Clears the encoder.
- *
- *@return if buffer==0 or size is too small then return false and size to the required size.
- *Otherwise return true and set size to the number of bytes encoded.
- */
- PN_CPP_EXTERN bool encode(char* buffer, size_t& size);
-
- /** Encode the current values into a std::string, resize the string if necessary.
- *
- * Clears the encoder.
- */
- PN_CPP_EXTERN void encode(std::string&);
-
- /** Encode the current values into a std::string. Clears the encoder. */
- PN_CPP_EXTERN std::string encode();
-
- /** @name Insert simple types.
- *@{
- */
- friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Null);
- friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Bool);
- friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Ubyte);
- friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Byte);
- friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Ushort);
- friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Short);
- friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Uint);
- friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Int);
- friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Char);
- friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Ulong);
- friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Long);
- friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Timestamp);
- friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Float);
- friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Double);
- friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Decimal32);
- friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Decimal64);
- friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Decimal128);
- friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Uuid);
- friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, String);
- friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Symbol);
- friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, Binary);
- friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, const Value&);
- ///@}
-
- /** Start a container type. See the Start class. */
- friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, const Start&);
-
- /** Finish a container type. */
- friend PN_CPP_EXTERN Encoder& operator<<(Encoder& e, Finish);
-
-
- /**@name Insert values returned by the as<TypeId> helper.
- *@{
- */
- template <class T, TypeId A> friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, CRef<T, A>);
- template <class T> friend Encoder& operator<<(Encoder&, CRef<T, ARRAY>);
- template <class T> friend Encoder& operator<<(Encoder&, CRef<T, LIST>);
- template <class T> friend Encoder& operator<<(Encoder&, CRef<T, MAP>);
- // TODO aconway 2015-06-16: DESCRIBED.
- ///@}
-
- /** Copy data from a raw pn_data_t */
- friend PN_CPP_EXTERN Encoder& operator<<(Encoder&, pn_data_t*);
-
- private:
- PN_CPP_EXTERN Encoder(pn_data_t* pd);
-
- friend class Value;
-};
-
-// Need to disambiguate char* conversion to bool and std::string as String.
-inline Encoder& operator<<(Encoder& e, char* s) { return e << String(s); }
-inline Encoder& operator<<(Encoder& e, const char* s) { return e << String(s); }
-inline Encoder& operator<<(Encoder& e, const std::string& s) { return e << String(s); }
-
-// operator << for integer types that are not covered by the standard overrides.
-template <class T>
-typename std::enable_if<IsUnknownInteger<T>::value, Encoder&>::type operator<<(Encoder& e, T i) {
- typename IntegerType<sizeof(T), std::is_signed<T>::value>::type v = i;
- return e << v; // Insert as a known integer type
-}
-
-// TODO aconway 2015-06-16: described array insertion.
-
-template <class T> Encoder& operator<<(Encoder& e, CRef<T, ARRAY> a) {
- e << Start::array(TypeIdOf<typename T::value_type>::value);
- for (typename T::const_iterator i = a.value.begin(); i != a.value.end(); ++i)
- e << *i;
- e << finish();
- return e;
-}
-
-template <class T> Encoder& operator<<(Encoder& e, CRef<T, LIST> l) {
- e << Start::list();
- for (typename T::const_iterator i = l.value.begin(); i != l.value.end(); ++i)
- e << *i;
- e << finish();
- return e;
-}
-
-template <class T> Encoder& operator<<(Encoder& e, CRef<T, MAP> m){
- e << Start::map();
- for (typename T::const_iterator i = m.value.begin(); i != m.value.end(); ++i) {
- e << i->first;
- e << i->second;
- }
- e << finish();
- return e;
-}
-//@internal Convert a Ref to a CRef.
-template <class T, TypeId A> Encoder& operator<<(Encoder& e, Ref<T, A> ref) {
- return e << CRef<T,A>(ref);
-}
-
-
-}
-#endif // ENCODER_H
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/Endpoint.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/Endpoint.hpp b/proton-c/bindings/cpp/include/proton/Endpoint.hpp
deleted file mode 100644
index 645ca0f..0000000
--- a/proton-c/bindings/cpp/include/proton/Endpoint.hpp
+++ /dev/null
@@ -1,58 +0,0 @@
-#ifndef PROTON_CPP_ENDPOINT_H
-#define PROTON_CPP_ENDPOINT_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/connection.h"
-
-namespace proton {
-namespace reactor {
-
-class Handler;
-class Connection;
-class Transport;
-
-class Endpoint
-{
- public:
- enum {
- LOCAL_UNINIT = PN_LOCAL_UNINIT,
- REMOTE_UNINIT = PN_REMOTE_UNINIT,
- LOCAL_ACTIVE = PN_LOCAL_ACTIVE,
- REMOTE_ACTIVE = PN_REMOTE_ACTIVE,
- LOCAL_CLOSED = PN_LOCAL_CLOSED,
- REMOTE_CLOSED = PN_REMOTE_CLOSED
- };
- typedef int State;
-
- // TODO: getCondition, getRemoteCondition, updateCondition, get/setHandler
- virtual PN_CPP_EXTERN Connection &getConnection() = 0;
- Transport PN_CPP_EXTERN &getTransport();
- protected:
- PN_CPP_EXTERN Endpoint();
- PN_CPP_EXTERN ~Endpoint();
-};
-
-
-}}
-
-#endif /*!PROTON_CPP_ENDPOINT_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/Error.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/Error.hpp b/proton-c/bindings/cpp/include/proton/Error.hpp
deleted file mode 100644
index 578c3d6..0000000
--- a/proton-c/bindings/cpp/include/proton/Error.hpp
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef PROTON_CPP_EXCEPTIONS_H
-#define PROTON_CPP_EXCEPTIONS_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 <stdexcept>
-#include <string>
-#include "proton/export.hpp"
-
-namespace proton {
-
-/** @ingroup cpp
- * Functions in the proton namespace throw a subclass of proton::Error on error.
- */
-struct Error : public std::runtime_error { PN_CPP_EXTERN explicit Error(const std::string&) throw(); };
-
-/** Raised if a message is rejected */
-struct MessageReject : public Error { PN_CPP_EXTERN explicit MessageReject(const std::string&) throw(); };
-
-/** Raised if a message is released */
-struct MessageRelease : public Error { PN_CPP_EXTERN explicit MessageRelease(const std::string&) throw(); };
-
-
-}
-
-#endif /*!PROTON_CPP_EXCEPTIONS_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/Event.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/Event.hpp b/proton-c/bindings/cpp/include/proton/Event.hpp
deleted file mode 100644
index 3fbb6a7..0000000
--- a/proton-c/bindings/cpp/include/proton/Event.hpp
+++ /dev/null
@@ -1,59 +0,0 @@
-#ifndef PROTON_CPP_EVENT_H
-#define PROTON_CPP_EVENT_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/Link.hpp"
-#include "proton/Connection.hpp"
-#include "proton/Message.hpp"
-#include <vector>
-
-
-namespace proton {
-namespace reactor {
-
-class Handler;
-class Container;
-class Connection;
-
-class Event
-{
- public:
- virtual PN_CPP_EXTERN void dispatch(Handler &h) = 0;
- virtual PN_CPP_EXTERN Container &getContainer();
- virtual PN_CPP_EXTERN Connection &getConnection();
- virtual PN_CPP_EXTERN Sender getSender();
- virtual PN_CPP_EXTERN Receiver getReceiver();
- virtual PN_CPP_EXTERN Link getLink();
- virtual PN_CPP_EXTERN Message getMessage();
- virtual PN_CPP_EXTERN void setMessage(Message &);
- virtual PN_CPP_EXTERN ~Event();
- protected:
- PN_CPP_EXTERN Event();
- private:
- Event(const Event&);
- Event& operator=(const Event&);
-};
-
-}}
-
-#endif /*!PROTON_CPP_EVENT_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/Handle.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/Handle.hpp b/proton-c/bindings/cpp/include/proton/Handle.hpp
deleted file mode 100644
index 916fd80..0000000
--- a/proton-c/bindings/cpp/include/proton/Handle.hpp
+++ /dev/null
@@ -1,79 +0,0 @@
-#ifndef PROTON_CPP_HANDLE_H
-#define PROTON_CPP_HANDLE_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 {
-namespace reactor {
-
-template <class> class PrivateImplRef;
-template <class> class ProtonImplRef;
-
-// FIXME aconway 2015-06-09: don't need handle, get rid of it.
-
-/**
- * A handle is like a pointer: refers to an underlying implementation object.
- * Copying the handle does not copy the object.
- *
- * Handles can be null, like a 0 pointer. Use isValid(), isNull() or the
- * conversion to bool to test for a null handle.
- */
-template <class T> class Handle {
- public:
-
- /**@return true if handle is valid, i.e. not null. */
- bool isValid() const { return impl; }
-
- /**@return true if handle is null. It is an error to call any function on a null handle. */
- bool isNull() const { return !impl; }
-
- /** Conversion to bool supports idiom if (handle) { handle->... } */
- operator bool() const { return impl; }
-
- /** Operator ! supports idiom if (!handle) { do_if_handle_is_null(); } */
- bool operator !() const { return !impl; }
-
- /** Operator == equal if they point to same non-null object*/
- bool operator ==(const Handle<T>& other) const { return impl == other.impl; }
- bool operator !=(const Handle<T>& other) const { return impl != other.impl; }
-
- void swap(Handle<T>& h) { T* t = h.impl; h.impl = impl; impl = t; }
-
- private:
- // Not implemented, subclasses must implement.
- Handle(const Handle&);
- Handle& operator=(const Handle&);
-
- protected:
- typedef T Impl;
- Handle() : impl() {}
-
- mutable Impl* impl;
-
- friend class PrivateImplRef<T>;
-};
-
-}}
-
-#endif /*!PROTON_CPP_HANDLE_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/Handler.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/Handler.hpp b/proton-c/bindings/cpp/include/proton/Handler.hpp
deleted file mode 100644
index f7bb23b..0000000
--- a/proton-c/bindings/cpp/include/proton/Handler.hpp
+++ /dev/null
@@ -1,49 +0,0 @@
-#ifndef PROTON_CPP_HANDLER_H
-#define PROTON_CPP_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/export.hpp"
-#include "proton/Event.hpp"
-#include "proton/event.h"
-#include <vector>
-
-namespace proton {
-namespace reactor {
-
-class Handler
-{
- public:
- PN_CPP_EXTERN Handler();
- PN_CPP_EXTERN virtual ~Handler();
-
- PN_CPP_EXTERN virtual void onUnhandled(Event &e);
-
- PN_CPP_EXTERN virtual void addChildHandler(Handler &e);
- PN_CPP_EXTERN std::vector<Handler *>::iterator childHandlersBegin();
- PN_CPP_EXTERN std::vector<Handler *>::iterator childHandlersEnd();
- protected:
- std::vector<Handler *>childHandlers;
-};
-
-}}
-
-#endif /*!PROTON_CPP_HANDLER_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/Link.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/Link.hpp b/proton-c/bindings/cpp/include/proton/Link.hpp
deleted file mode 100644
index ac0e471..0000000
--- a/proton-c/bindings/cpp/include/proton/Link.hpp
+++ /dev/null
@@ -1,69 +0,0 @@
-#ifndef PROTON_CPP_LINK_H
-#define PROTON_CPP_LINK_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/ProtonHandle.hpp"
-#include "proton/Endpoint.hpp"
-#include "proton/Terminus.hpp"
-#include "proton/types.h"
-#include <string>
-
-struct pn_connection_t;
-
-namespace proton {
-namespace reactor {
-
-class Link : public Endpoint, public ProtonHandle<pn_link_t>
-{
- public:
- PN_CPP_EXTERN Link(pn_link_t *);
- PN_CPP_EXTERN Link();
- PN_CPP_EXTERN ~Link();
- PN_CPP_EXTERN Link(const Link&);
- PN_CPP_EXTERN Link& operator=(const Link&);
- PN_CPP_EXTERN void open();
- PN_CPP_EXTERN void close();
- PN_CPP_EXTERN bool isSender();
- PN_CPP_EXTERN bool isReceiver();
- PN_CPP_EXTERN int getCredit();
- PN_CPP_EXTERN Terminus getSource();
- PN_CPP_EXTERN Terminus getTarget();
- PN_CPP_EXTERN Terminus getRemoteSource();
- PN_CPP_EXTERN Terminus getRemoteTarget();
- PN_CPP_EXTERN std::string getName();
- PN_CPP_EXTERN pn_link_t *getPnLink() const;
- virtual PN_CPP_EXTERN Connection &getConnection();
- PN_CPP_EXTERN Link getNext(Endpoint::State mask);
- protected:
- PN_CPP_EXTERN virtual void verifyType(pn_link_t *l);
- private:
- friend class ProtonImplRef<Link>;
- bool senderLink;
-};
-
-}}
-
-#include "proton/Sender.hpp"
-#include "proton/Receiver.hpp"
-
-#endif /*!PROTON_CPP_LINK_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/Message.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/Message.hpp b/proton-c/bindings/cpp/include/proton/Message.hpp
deleted file mode 100644
index c98dc31..0000000
--- a/proton-c/bindings/cpp/include/proton/Message.hpp
+++ /dev/null
@@ -1,112 +0,0 @@
-#ifndef PROTON_CPP_MESSAGE_H
-#define PROTON_CPP_MESSAGE_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/ProtonHandle.hpp"
-#include "proton/Value.hpp"
-#include "proton/Message.hpp"
-#include <string>
-
-struct pn_message_t;
-struct pn_data_t;
-
-namespace proton {
-
-// FIXME aconway 2015-06-17: documentation of properties.
-class Message : public reactor::ProtonHandle<pn_message_t>
-{
- public:
- PN_CPP_EXTERN Message();
- PN_CPP_EXTERN Message(pn_message_t *);
- PN_CPP_EXTERN Message(const Message&);
- PN_CPP_EXTERN Message& operator=(const Message&);
- PN_CPP_EXTERN ~Message();
-
- PN_CPP_EXTERN pn_message_t *pnMessage() const;
-
- PN_CPP_EXTERN void id(const Value& id);
- PN_CPP_EXTERN Value id() const;
-
- PN_CPP_EXTERN void user(const std::string &user);
- PN_CPP_EXTERN std::string user() const;
-
- PN_CPP_EXTERN void address(const std::string &addr);
- PN_CPP_EXTERN std::string address() const;
-
- PN_CPP_EXTERN void subject(const std::string &s);
- PN_CPP_EXTERN std::string subject() const;
-
- PN_CPP_EXTERN void replyTo(const std::string &s);
- PN_CPP_EXTERN std::string replyTo() const;
-
- PN_CPP_EXTERN void correlationId(const Value&);
- PN_CPP_EXTERN Value correlationId() const;
-
- PN_CPP_EXTERN void contentType(const std::string &s);
- PN_CPP_EXTERN std::string contentType() const;
-
- PN_CPP_EXTERN void contentEncoding(const std::string &s);
- PN_CPP_EXTERN std::string contentEncoding() const;
-
- PN_CPP_EXTERN void expiry(Timestamp t);
- PN_CPP_EXTERN Timestamp expiry() const;
-
- PN_CPP_EXTERN void creationTime(Timestamp t);
- PN_CPP_EXTERN Timestamp creationTime() const;
-
- PN_CPP_EXTERN void groupId(const std::string &s);
- PN_CPP_EXTERN std::string groupId() const;
-
- PN_CPP_EXTERN void replyToGroupId(const std::string &s);
- PN_CPP_EXTERN std::string replyToGroupId() const;
-
- /** Set the body to an AMQP value. */
- PN_CPP_EXTERN void body(const Value&);
-
- /** Template to convert any type to a Value and set as the body */
- template <class T> void body(const T& v) { body(Value(v)); }
-
- /** Set the body to a sequence of sections containing AMQP values. */
- PN_CPP_EXTERN void body(const Values&);
-
- PN_CPP_EXTERN const Values& body() const;
-
- PN_CPP_EXTERN Values& body(); ///< Allows in-place modification of body sections.
-
- // FIXME aconway 2015-06-17: consistent and flexible treatment of buffers.
- // Allow convenient std::string encoding/decoding (with re-use of existing
- // string capacity) but also need to allow encoding/decoding of non-string
- // buffers. Introduce a buffer type with begin/end pointers?
-
- PN_CPP_EXTERN void encode(std::string &data);
- PN_CPP_EXTERN std::string encode();
- PN_CPP_EXTERN void decode(const std::string &data);
-
- private:
- mutable Values body_;
- friend class reactor::ProtonImplRef<Message>;
-};
-
-}
-
-#endif /*!PROTON_CPP_MESSAGE_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/MessagingAdapter.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/MessagingAdapter.hpp b/proton-c/bindings/cpp/include/proton/MessagingAdapter.hpp
deleted file mode 100644
index 243e049..0000000
--- a/proton-c/bindings/cpp/include/proton/MessagingAdapter.hpp
+++ /dev/null
@@ -1,77 +0,0 @@
-#ifndef PROTON_CPP_MESSAGING_ADAPTER_H
-#define PROTON_CPP_MESSAGING_ADAPTER_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/MessagingHandler.hpp"
-
-#include "proton/MessagingEvent.hpp"
-#include "proton/event.h"
-#include "proton/reactor.h"
-
-namespace proton {
-namespace reactor {
-
-// Combine's Python's: EndpointStateHandler, IncomingMessageHandler, OutgoingMessageHandler
-
-class MessagingAdapter : public MessagingHandler
-{
- public:
- PN_CPP_EXTERN MessagingAdapter(MessagingHandler &delegate);
- PN_CPP_EXTERN virtual ~MessagingAdapter();
- PN_CPP_EXTERN virtual void onReactorInit(Event &e);
- PN_CPP_EXTERN virtual void onLinkFlow(Event &e);
- PN_CPP_EXTERN virtual void onDelivery(Event &e);
- PN_CPP_EXTERN virtual void onUnhandled(Event &e);
- PN_CPP_EXTERN virtual void onConnectionClosed(Event &e);
- PN_CPP_EXTERN virtual void onConnectionClosing(Event &e);
- PN_CPP_EXTERN virtual void onConnectionError(Event &e);
- PN_CPP_EXTERN virtual void onConnectionLocalOpen(Event &e);
- PN_CPP_EXTERN virtual void onConnectionRemoteOpen(Event &e);
- PN_CPP_EXTERN virtual void onConnectionRemoteClose(Event &e);
- PN_CPP_EXTERN virtual void onConnectionOpened(Event &e);
- PN_CPP_EXTERN virtual void onConnectionOpening(Event &e);
- PN_CPP_EXTERN virtual void onSessionClosed(Event &e);
- PN_CPP_EXTERN virtual void onSessionClosing(Event &e);
- PN_CPP_EXTERN virtual void onSessionError(Event &e);
- PN_CPP_EXTERN virtual void onSessionLocalOpen(Event &e);
- PN_CPP_EXTERN virtual void onSessionRemoteOpen(Event &e);
- PN_CPP_EXTERN virtual void onSessionRemoteClose(Event &e);
- PN_CPP_EXTERN virtual void onSessionOpened(Event &e);
- PN_CPP_EXTERN virtual void onSessionOpening(Event &e);
- PN_CPP_EXTERN virtual void onLinkClosed(Event &e);
- PN_CPP_EXTERN virtual void onLinkClosing(Event &e);
- PN_CPP_EXTERN virtual void onLinkError(Event &e);
- PN_CPP_EXTERN virtual void onLinkLocalOpen(Event &e);
- PN_CPP_EXTERN virtual void onLinkRemoteOpen(Event &e);
- PN_CPP_EXTERN virtual void onLinkRemoteClose(Event &e);
- PN_CPP_EXTERN virtual void onLinkOpened(Event &e);
- PN_CPP_EXTERN virtual void onLinkOpening(Event &e);
- PN_CPP_EXTERN virtual void onTransportTailClosed(Event &e);
- private:
- MessagingHandler &delegate; // The handler for generated MessagingEvent's
-};
-
-}}
-
-#endif /*!PROTON_CPP_MESSAGING_ADAPTER_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/MessagingEvent.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/MessagingEvent.hpp b/proton-c/bindings/cpp/include/proton/MessagingEvent.hpp
deleted file mode 100644
index e80f44b..0000000
--- a/proton-c/bindings/cpp/include/proton/MessagingEvent.hpp
+++ /dev/null
@@ -1,99 +0,0 @@
-#ifndef PROTON_CPP_MESSAGINGEVENT_H
-#define PROTON_CPP_MESSAGINGEVENT_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/ProtonEvent.hpp"
-#include "proton/Link.hpp"
-
-namespace proton {
-namespace reactor {
-
-class Handler;
-class Container;
-class Connection;
-
-typedef enum {
- PN_MESSAGING_PROTON = 0, // Wrapped pn_event_t
- // Covenience events for C++ MessagingHandlers
- PN_MESSAGING_ABORT,
- PN_MESSAGING_ACCEPTED,
- PN_MESSAGING_COMMIT,
- PN_MESSAGING_CONNECTION_CLOSED,
- PN_MESSAGING_CONNECTION_CLOSING,
- PN_MESSAGING_CONNECTION_ERROR,
- PN_MESSAGING_CONNECTION_OPENED,
- PN_MESSAGING_CONNECTION_OPENING,
- PN_MESSAGING_DISCONNECTED,
- PN_MESSAGING_FETCH,
- PN_MESSAGING_ID_LOADED,
- PN_MESSAGING_LINK_CLOSED,
- PN_MESSAGING_LINK_CLOSING,
- PN_MESSAGING_LINK_OPENED,
- PN_MESSAGING_LINK_OPENING,
- PN_MESSAGING_LINK_ERROR,
- PN_MESSAGING_MESSAGE,
- PN_MESSAGING_QUIT,
- PN_MESSAGING_RECORD_INSERTED,
- PN_MESSAGING_RECORDS_LOADED,
- PN_MESSAGING_REJECTED,
- PN_MESSAGING_RELEASED,
- PN_MESSAGING_REQUEST,
- PN_MESSAGING_RESPONSE,
- PN_MESSAGING_SENDABLE,
- PN_MESSAGING_SESSION_CLOSED,
- PN_MESSAGING_SESSION_CLOSING,
- PN_MESSAGING_SESSION_OPENED,
- PN_MESSAGING_SESSION_OPENING,
- PN_MESSAGING_SESSION_ERROR,
- PN_MESSAGING_SETTLED,
- PN_MESSAGING_START,
- PN_MESSAGING_TIMER,
- PN_MESSAGING_TRANSACTION_ABORTED,
- PN_MESSAGING_TRANSACTION_COMMITTED,
- PN_MESSAGING_TRANSACTION_DECLARED,
- PN_MESSAGING_TRANSPORT_CLOSED
-} MessagingEventType_t;
-
-class MessagingEvent : public ProtonEvent
-{
- public:
- MessagingEvent(pn_event_t *ce, pn_event_type_t t, Container &c);
- MessagingEvent(MessagingEventType_t t, ProtonEvent &parent);
- ~MessagingEvent();
- virtual PN_CPP_EXTERN void dispatch(Handler &h);
- virtual PN_CPP_EXTERN Connection &getConnection();
- virtual PN_CPP_EXTERN Sender getSender();
- virtual PN_CPP_EXTERN Receiver getReceiver();
- virtual PN_CPP_EXTERN Link getLink();
- virtual PN_CPP_EXTERN Message getMessage();
- virtual PN_CPP_EXTERN void setMessage(Message &);
- private:
- MessagingEventType_t messagingType;
- ProtonEvent *parentEvent;
- Message *message;
- MessagingEvent operator=(const MessagingEvent&);
- MessagingEvent(const MessagingEvent&);
-};
-
-}}
-
-#endif /*!PROTON_CPP_MESSAGINGEVENT_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/MessagingHandler.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/MessagingHandler.hpp b/proton-c/bindings/cpp/include/proton/MessagingHandler.hpp
deleted file mode 100644
index ddc8165..0000000
--- a/proton-c/bindings/cpp/include/proton/MessagingHandler.hpp
+++ /dev/null
@@ -1,98 +0,0 @@
-#ifndef PROTON_CPP_MESSAGING_HANDLER_H
-#define PROTON_CPP_MESSAGING_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/Acking.hpp"
-#include "proton/event.h"
-
-namespace proton {
-namespace reactor {
-
-class Event;
-class MessagingAdapter;
-
-class MessagingHandler : public ProtonHandler , public Acking
-{
- public:
- PN_CPP_EXTERN MessagingHandler(int prefetch=10, bool autoAccept=true, bool autoSettle=true,
- bool peerCloseIsError=false);
- PN_CPP_EXTERN virtual ~MessagingHandler();
-
- PN_CPP_EXTERN virtual void onAbort(Event &e);
- PN_CPP_EXTERN virtual void onAccepted(Event &e);
- PN_CPP_EXTERN virtual void onCommit(Event &e);
- PN_CPP_EXTERN virtual void onConnectionClosed(Event &e);
- PN_CPP_EXTERN virtual void onConnectionClosing(Event &e);
- PN_CPP_EXTERN virtual void onConnectionError(Event &e);
- PN_CPP_EXTERN virtual void onConnectionOpening(Event &e);
- PN_CPP_EXTERN virtual void onConnectionOpened(Event &e);
- PN_CPP_EXTERN virtual void onDisconnected(Event &e);
- PN_CPP_EXTERN virtual void onFetch(Event &e);
- PN_CPP_EXTERN virtual void onIdLoaded(Event &e);
- PN_CPP_EXTERN virtual void onLinkClosed(Event &e);
- PN_CPP_EXTERN virtual void onLinkClosing(Event &e);
- PN_CPP_EXTERN virtual void onLinkError(Event &e);
- PN_CPP_EXTERN virtual void onLinkOpened(Event &e);
- PN_CPP_EXTERN virtual void onLinkOpening(Event &e);
- PN_CPP_EXTERN virtual void onMessage(Event &e);
- PN_CPP_EXTERN virtual void onQuit(Event &e);
- PN_CPP_EXTERN virtual void onRecordInserted(Event &e);
- PN_CPP_EXTERN virtual void onRecordsLoaded(Event &e);
- PN_CPP_EXTERN virtual void onRejected(Event &e);
- PN_CPP_EXTERN virtual void onReleased(Event &e);
- PN_CPP_EXTERN virtual void onRequest(Event &e);
- PN_CPP_EXTERN virtual void onResponse(Event &e);
- PN_CPP_EXTERN virtual void onSendable(Event &e);
- PN_CPP_EXTERN virtual void onSessionClosed(Event &e);
- PN_CPP_EXTERN virtual void onSessionClosing(Event &e);
- PN_CPP_EXTERN virtual void onSessionError(Event &e);
- PN_CPP_EXTERN virtual void onSessionOpened(Event &e);
- PN_CPP_EXTERN virtual void onSessionOpening(Event &e);
- PN_CPP_EXTERN virtual void onSettled(Event &e);
- PN_CPP_EXTERN virtual void onStart(Event &e);
- PN_CPP_EXTERN virtual void onTimer(Event &e);
- PN_CPP_EXTERN virtual void onTransactionAborted(Event &e);
- PN_CPP_EXTERN virtual void onTransactionCommitted(Event &e);
- PN_CPP_EXTERN virtual void onTransactionDeclared(Event &e);
- PN_CPP_EXTERN virtual void onTransportClosed(Event &e);
-
- protected:
- int prefetch;
- bool autoAccept;
- bool autoSettle;
- bool peerCloseIsError;
- MessagingAdapter *messagingAdapter;
- Handler *flowController;
- PN_CPP_EXTERN MessagingHandler(
- bool rawHandler, int prefetch=10, bool autoAccept=true,
- bool autoSettle=true, bool peerCloseIsError=false);
- private:
- friend class ContainerImpl;
- friend class MessagingAdapter;
- PN_CPP_EXTERN void createHelpers();
-};
-
-}}
-
-#endif /*!PROTON_CPP_MESSAGING_HANDLER_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/ProtonEvent.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/ProtonEvent.hpp b/proton-c/bindings/cpp/include/proton/ProtonEvent.hpp
deleted file mode 100644
index 0d1d534..0000000
--- a/proton-c/bindings/cpp/include/proton/ProtonEvent.hpp
+++ /dev/null
@@ -1,56 +0,0 @@
-#ifndef PROTON_CPP_PROTONEVENT_H
-#define PROTON_CPP_PROTONEVENT_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/Event.hpp"
-#include "proton/Link.hpp"
-
-namespace proton {
-namespace reactor {
-
-class Handler;
-class Container;
-class Connection;
-class Container;
-
-class ProtonEvent : public Event
-{
- public:
- virtual PN_CPP_EXTERN void dispatch(Handler &h);
- virtual PN_CPP_EXTERN Container &getContainer();
- virtual PN_CPP_EXTERN Connection &getConnection();
- virtual PN_CPP_EXTERN Sender getSender();
- virtual PN_CPP_EXTERN Receiver getReceiver();
- virtual PN_CPP_EXTERN Link getLink();
- PN_CPP_EXTERN int getType();
- PN_CPP_EXTERN pn_event_t* getPnEvent();
- protected:
- PN_CPP_EXTERN ProtonEvent(pn_event_t *ce, pn_event_type_t t, Container &c);
- private:
- pn_event_t *pnEvent;
- int type;
- Container &container;
-};
-
-}}
-
-#endif /*!PROTON_CPP_PROTONEVENT_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/ProtonHandle.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/ProtonHandle.hpp b/proton-c/bindings/cpp/include/proton/ProtonHandle.hpp
deleted file mode 100644
index da12c09..0000000
--- a/proton-c/bindings/cpp/include/proton/ProtonHandle.hpp
+++ /dev/null
@@ -1,68 +0,0 @@
-#ifndef PROTON_CPP_PROTONHANDLE_H
-#define PROTON_CPP_PROTONHANDLE_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 {
-namespace reactor {
-
-template <class> class ProtonImplRef;
-
-/**
- * See Handle.h. Similar but for lightly wrapped Proton pn_object_t targets.
- */
-template <class T> class ProtonHandle {
- public:
-
- /**@return true if handle is valid, i.e. not null. */
- bool isValid() const { return impl; }
-
- /**@return true if handle is null. It is an error to call any function on a null handle. */
- bool isNull() const { return !impl; }
-
- /** Conversion to bool supports idiom if (handle) { handle->... } */
- operator bool() const { return impl; }
-
- /** Operator ! supports idiom if (!handle) { do_if_handle_is_null(); } */
- bool operator !() const { return !impl; }
-
- void swap(ProtonHandle<T>& h) { T* t = h.impl; h.impl = impl; impl = t; }
-
- private:
- // Not implemented, subclasses must implement.
- ProtonHandle(const ProtonHandle&);
- ProtonHandle& operator=(const ProtonHandle&);
-
- protected:
- typedef T Impl;
- ProtonHandle() :impl() {}
-
- mutable Impl* impl;
-
- friend class ProtonImplRef<T>;
-};
-
-}}
-
-#endif /*!PROTON_CPP_PROTONHANDLE_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/ProtonHandler.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/ProtonHandler.hpp b/proton-c/bindings/cpp/include/proton/ProtonHandler.hpp
deleted file mode 100644
index 3768f78..0000000
--- a/proton-c/bindings/cpp/include/proton/ProtonHandler.hpp
+++ /dev/null
@@ -1,82 +0,0 @@
-#ifndef PROTON_CPP_PROTONHANDLER_H
-#define PROTON_CPP_PROTONHANDLER_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/Handler.hpp"
-
-namespace proton {
-namespace reactor {
-
-class Event;
-class ProtonEvent;
-
-class ProtonHandler : public Handler
-{
- public:
- PN_CPP_EXTERN ProtonHandler();
- PN_CPP_EXTERN virtual void onReactorInit(Event &e);
- PN_CPP_EXTERN virtual void onReactorQuiesced(Event &e);
- PN_CPP_EXTERN virtual void onReactorFinal(Event &e);
- PN_CPP_EXTERN virtual void onTimerTask(Event &e);
- PN_CPP_EXTERN virtual void onConnectionInit(Event &e);
- PN_CPP_EXTERN virtual void onConnectionBound(Event &e);
- PN_CPP_EXTERN virtual void onConnectionUnbound(Event &e);
- PN_CPP_EXTERN virtual void onConnectionLocalOpen(Event &e);
- PN_CPP_EXTERN virtual void onConnectionLocalClose(Event &e);
- PN_CPP_EXTERN virtual void onConnectionRemoteOpen(Event &e);
- PN_CPP_EXTERN virtual void onConnectionRemoteClose(Event &e);
- PN_CPP_EXTERN virtual void onConnectionFinal(Event &e);
- PN_CPP_EXTERN virtual void onSessionInit(Event &e);
- PN_CPP_EXTERN virtual void onSessionLocalOpen(Event &e);
- PN_CPP_EXTERN virtual void onSessionLocalClose(Event &e);
- PN_CPP_EXTERN virtual void onSessionRemoteOpen(Event &e);
- PN_CPP_EXTERN virtual void onSessionRemoteClose(Event &e);
- PN_CPP_EXTERN virtual void onSessionFinal(Event &e);
- PN_CPP_EXTERN virtual void onLinkInit(Event &e);
- PN_CPP_EXTERN virtual void onLinkLocalOpen(Event &e);
- PN_CPP_EXTERN virtual void onLinkLocalClose(Event &e);
- PN_CPP_EXTERN virtual void onLinkLocalDetach(Event &e);
- PN_CPP_EXTERN virtual void onLinkRemoteOpen(Event &e);
- PN_CPP_EXTERN virtual void onLinkRemoteClose(Event &e);
- PN_CPP_EXTERN virtual void onLinkRemoteDetach(Event &e);
- PN_CPP_EXTERN virtual void onLinkFlow(Event &e);
- PN_CPP_EXTERN virtual void onLinkFinal(Event &e);
- PN_CPP_EXTERN virtual void onDelivery(Event &e);
- PN_CPP_EXTERN virtual void onTransport(Event &e);
- PN_CPP_EXTERN virtual void onTransportError(Event &e);
- PN_CPP_EXTERN virtual void onTransportHeadClosed(Event &e);
- PN_CPP_EXTERN virtual void onTransportTailClosed(Event &e);
- PN_CPP_EXTERN virtual void onTransportClosed(Event &e);
- PN_CPP_EXTERN virtual void onSelectableInit(Event &e);
- PN_CPP_EXTERN virtual void onSelectableUpdated(Event &e);
- PN_CPP_EXTERN virtual void onSelectableReadable(Event &e);
- PN_CPP_EXTERN virtual void onSelectableWritable(Event &e);
- PN_CPP_EXTERN virtual void onSelectableExpired(Event &e);
- PN_CPP_EXTERN virtual void onSelectableError(Event &e);
- PN_CPP_EXTERN virtual void onSelectableFinal(Event &e);
-
- PN_CPP_EXTERN virtual void onUnhandled(Event &e);
-};
-
-}}
-
-#endif /*!PROTON_CPP_PROTONHANDLER_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/Receiver.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/Receiver.hpp b/proton-c/bindings/cpp/include/proton/Receiver.hpp
deleted file mode 100644
index 4f2333e..0000000
--- a/proton-c/bindings/cpp/include/proton/Receiver.hpp
+++ /dev/null
@@ -1,47 +0,0 @@
-#ifndef PROTON_CPP_RECEIVER_H
-#define PROTON_CPP_RECEIVER_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/Link.hpp"
-#include "proton/types.h"
-#include <string>
-
-struct pn_connection_t;
-
-namespace proton {
-namespace reactor {
-
-class Receiver : public Link
-{
- public:
- PN_CPP_EXTERN Receiver(pn_link_t *lnk);
- PN_CPP_EXTERN Receiver();
- PN_CPP_EXTERN Receiver(const Link& c);
- protected:
- PN_CPP_EXTERN virtual void verifyType(pn_link_t *l);
-};
-
-}}
-
-#endif /*!PROTON_CPP_RECEIVER_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/Sender.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/Sender.hpp b/proton-c/bindings/cpp/include/proton/Sender.hpp
deleted file mode 100644
index 33e02b7..0000000
--- a/proton-c/bindings/cpp/include/proton/Sender.hpp
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef PROTON_CPP_SENDER_H
-#define PROTON_CPP_SENDER_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/Delivery.hpp"
-#include "proton/Link.hpp"
-#include "proton/Message.hpp"
-
-#include "proton/types.h"
-#include <string>
-
-struct pn_connection_t;
-
-namespace proton {
-namespace reactor {
-
-
-class Sender : public Link
-{
- public:
- PN_CPP_EXTERN Sender(pn_link_t *lnk=0);
- PN_CPP_EXTERN Sender(const Link& c);
- PN_CPP_EXTERN Delivery send(Message &m);
-
- protected:
- PN_CPP_EXTERN virtual void verifyType(pn_link_t *l);
-};
-
-
-}}
-
-#endif /*!PROTON_CPP_SENDER_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/Session.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/Session.hpp b/proton-c/bindings/cpp/include/proton/Session.hpp
deleted file mode 100644
index eaae4ce..0000000
--- a/proton-c/bindings/cpp/include/proton/Session.hpp
+++ /dev/null
@@ -1,61 +0,0 @@
-#ifndef PROTON_CPP_SESSION_H
-#define PROTON_CPP_SESSION_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/Link.hpp"
-
-#include "proton/types.h"
-#include "proton/link.h"
-#include <string>
-
-struct pn_connection_t;
-
-namespace proton {
-namespace reactor {
-
-class Container;
-class Handler;
-class Transport;
-
- class Session : public Endpoint, public ProtonHandle<pn_session_t>
-{
- public:
- PN_CPP_EXTERN Session(pn_session_t *s);
- PN_CPP_EXTERN Session();
- PN_CPP_EXTERN ~Session();
- PN_CPP_EXTERN void open();
- PN_CPP_EXTERN Session(const Session&);
- PN_CPP_EXTERN Session& operator=(const Session&);
- PN_CPP_EXTERN void close();
- PN_CPP_EXTERN pn_session_t *getPnSession();
- PN_CPP_EXTERN virtual Connection &getConnection();
- PN_CPP_EXTERN Receiver createReceiver(std::string name);
- PN_CPP_EXTERN Sender createSender(std::string name);
- private:
- friend class ProtonImplRef<Session>;
-};
-
-}}
-
-#endif /*!PROTON_CPP_SESSION_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/Terminus.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/Terminus.hpp b/proton-c/bindings/cpp/include/proton/Terminus.hpp
deleted file mode 100644
index 91d4f6f..0000000
--- a/proton-c/bindings/cpp/include/proton/Terminus.hpp
+++ /dev/null
@@ -1,81 +0,0 @@
-#ifndef PROTON_CPP_TERMINUS_H
-#define PROTON_CPP_TERMINUS_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/Link.hpp"
-
-#include "proton/link.h"
-#include <string>
-
-namespace proton {
-namespace reactor {
-
-class Link;
-
-class Terminus : public ProtonHandle<pn_terminus_t>
-{
- enum Type {
- TYPE_UNSPECIFIED = PN_UNSPECIFIED,
- SOURCE = PN_SOURCE,
- TARGET = PN_TARGET,
- COORDINATOR = PN_COORDINATOR
- };
- enum ExpiryPolicy {
- NONDURABLE = PN_NONDURABLE,
- CONFIGURATION = PN_CONFIGURATION,
- DELIVERIES = PN_DELIVERIES
- };
- enum DistributionMode {
- MODE_UNSPECIFIED = PN_DIST_MODE_UNSPECIFIED,
- COPY = PN_DIST_MODE_COPY,
- MOVE = PN_DIST_MODE_MOVE
- };
-
- public:
- PN_CPP_EXTERN Terminus();
- PN_CPP_EXTERN ~Terminus();
- PN_CPP_EXTERN Terminus(const Terminus&);
- PN_CPP_EXTERN Terminus& operator=(const Terminus&);
- PN_CPP_EXTERN pn_terminus_t *getPnTerminus();
- PN_CPP_EXTERN Type getType();
- PN_CPP_EXTERN void setType(Type);
- PN_CPP_EXTERN ExpiryPolicy getExpiryPolicy();
- PN_CPP_EXTERN void setExpiryPolicy(ExpiryPolicy);
- PN_CPP_EXTERN DistributionMode getDistributionMode();
- PN_CPP_EXTERN void setDistributionMode(DistributionMode);
- PN_CPP_EXTERN std::string getAddress();
- PN_CPP_EXTERN void setAddress(std::string &);
- PN_CPP_EXTERN bool isDynamic();
- PN_CPP_EXTERN void setDynamic(bool);
-
- private:
- Link *link;
- PN_CPP_EXTERN Terminus(pn_terminus_t *, Link *);
- friend class Link;
- friend class ProtonImplRef<Terminus>;
-};
-
-
-}}
-
-#endif /*!PROTON_CPP_TERMINUS_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/Transport.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/Transport.hpp b/proton-c/bindings/cpp/include/proton/Transport.hpp
deleted file mode 100644
index 1a8d39c..0000000
--- a/proton-c/bindings/cpp/include/proton/Transport.hpp
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef PROTON_CPP_TRANSPORT_H
-#define PROTON_CPP_TRANSPORT_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/transport.h"
-#include <string>
-
-struct pn_connection_t;
-
-namespace proton {
-namespace reactor {
-
-class Connection;
-
-class Transport
-{
- public:
- PN_CPP_EXTERN Transport();
- PN_CPP_EXTERN ~Transport();
- PN_CPP_EXTERN void bind(Connection &c);
- Connection *connection;
- pn_transport_t *pnTransport;
-};
-
-
-}}
-
-#endif /*!PROTON_CPP_TRANSPORT_H*/
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
deleted file mode 100644
index 43a5878..0000000
--- a/proton-c/bindings/cpp/include/proton/Value.hpp
+++ /dev/null
@@ -1,104 +0,0 @@
-#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"
-
-struct pn_data_t;
-
-/**@file
- * Holder for an AMQP value.
- * @ingroup cpp
- */
-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&);
-
- /** Copy the first value from a raw pn_data_t. */
- PN_CPP_EXTERN Value& operator=(pn_data_t*);
-
- PN_CPP_EXTERN TypeId 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& value) const {
- Values& v = const_cast<Values&>(values);
- v.rewind() >> value;
-}
-
-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
deleted file mode 100644
index 275f905..0000000
--- a/proton-c/bindings/cpp/include/proton/Values.hpp
+++ /dev/null
@@ -1,60 +0,0 @@
-#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>
-
-/**@file
- * Holder for a sequence of AMQP values.
- * @ingroup cpp
- */
-
-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&);
-
- PN_CPP_EXTERN Values& rewind();
-
- 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/WaitCondition.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/WaitCondition.hpp b/proton-c/bindings/cpp/include/proton/WaitCondition.hpp
deleted file mode 100644
index c175841..0000000
--- a/proton-c/bindings/cpp/include/proton/WaitCondition.hpp
+++ /dev/null
@@ -1,45 +0,0 @@
-#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 {
-namespace reactor {
-
-// Interface class to indicates that an expected contion has been
-// achieved, i.e. for BlockingConnection.wait()
-
-class WaitCondition
-{
- public:
- PN_CPP_EXTERN virtual ~WaitCondition();
-
- // 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/include/proton/acceptor.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/acceptor.hpp b/proton-c/bindings/cpp/include/proton/acceptor.hpp
new file mode 100644
index 0000000..0df9589
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/acceptor.hpp
@@ -0,0 +1,49 @@
+#ifndef PROTON_CPP_ACCEPTOR_H
+#define PROTON_CPP_ACCEPTOR_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/reactor.h"
+#include "proton/export.hpp"
+#include "proton/proton_handle.hpp"
+
+struct pn_connection_t;
+
+namespace proton {
+
+class acceptor : public proton_handle<pn_acceptor_t>
+{
+ public:
+ PN_CPP_EXTERN acceptor();
+ PN_CPP_EXTERN acceptor(pn_acceptor_t *);
+ PN_CPP_EXTERN acceptor(const acceptor&);
+ PN_CPP_EXTERN acceptor& operator=(const acceptor&);
+ PN_CPP_EXTERN ~acceptor();
+
+ PN_CPP_EXTERN void close();
+ private:
+ friend class proton_impl_ref<acceptor>;
+};
+
+}
+
+#endif /*!PROTON_CPP_ACCEPTOR_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/acking.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/acking.hpp b/proton-c/bindings/cpp/include/proton/acking.hpp
new file mode 100644
index 0000000..edc2d81
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/acking.hpp
@@ -0,0 +1,43 @@
+#ifndef PROTON_CPP_ACKING_H
+#define PROTON_CPP_ACKING_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/delivery.hpp"
+
+namespace proton {
+
+
+class acking
+{
+ public:
+ PN_CPP_EXTERN virtual void accept(delivery &d);
+ PN_CPP_EXTERN virtual void reject(delivery &d);
+ PN_CPP_EXTERN virtual void release(delivery &d, bool delivered=true);
+ PN_CPP_EXTERN virtual void settle(delivery &d, delivery::state s = delivery::REJECTED);
+};
+
+
+}
+
+#endif /*!PROTON_CPP_ACKING_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/blocking_connection.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/blocking_connection.hpp b/proton-c/bindings/cpp/include/proton/blocking_connection.hpp
new file mode 100644
index 0000000..27d7cdd
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/blocking_connection.hpp
@@ -0,0 +1,65 @@
+#ifndef PROTON_CPP_BLOCKINGCONNECTION_H
+#define PROTON_CPP_BLOCKINGCONNECTION_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/handle.hpp"
+#include "proton/endpoint.hpp"
+#include "proton/container.hpp"
+#include "proton/duration.hpp"
+#include "proton/messaging_handler.hpp"
+#include "proton/types.h"
+#include <string>
+
+struct pn_connection_t;
+
+namespace proton {
+
+class container;
+class blocking_connection_impl;
+class ssl_domain;
+class blocking_sender;
+class wait_condition;
+
+class blocking_connection : public handle<blocking_connection_impl>
+{
+ public:
+ PN_CPP_EXTERN blocking_connection();
+ PN_CPP_EXTERN blocking_connection(const blocking_connection& c);
+ PN_CPP_EXTERN blocking_connection& operator=(const blocking_connection& c);
+ PN_CPP_EXTERN ~blocking_connection();
+
+ PN_CPP_EXTERN blocking_connection(std::string &url, duration = duration::FOREVER,
+ ssl_domain *ssld=0, container *c=0);
+ PN_CPP_EXTERN void close();
+
+ PN_CPP_EXTERN blocking_sender create_sender(std::string &address, handler *h=0);
+ PN_CPP_EXTERN void wait(wait_condition &condition);
+ PN_CPP_EXTERN void wait(wait_condition &condition, std::string &msg, duration timeout=duration::FOREVER);
+ PN_CPP_EXTERN duration timeout();
+ private:
+ friend class private_impl_ref<blocking_connection>;
+};
+
+}
+
+#endif /*!PROTON_CPP_BLOCKINGCONNECTION_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/blocking_link.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/blocking_link.hpp b/proton-c/bindings/cpp/include/proton/blocking_link.hpp
new file mode 100644
index 0000000..c1872a4
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/blocking_link.hpp
@@ -0,0 +1,57 @@
+#ifndef PROTON_CPP_BLOCKINGLINK_H
+#define PROTON_CPP_BLOCKINGLINK_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/handle.hpp"
+#include "proton/endpoint.hpp"
+#include "proton/container.hpp"
+#include "proton/duration.hpp"
+#include "proton/messaging_handler.hpp"
+#include "proton/blocking_connection.hpp"
+#include "proton/types.h"
+#include <string>
+
+namespace proton {
+
+class blocking_connection;
+
+class blocking_link
+{
+ public:
+ PN_CPP_EXTERN void close();
+ PN_CPP_EXTERN ~blocking_link();
+ protected:
+ PN_CPP_EXTERN blocking_link(blocking_connection *c, pn_link_t *l);
+ PN_CPP_EXTERN void wait_for_closed(duration timeout=duration::SECOND);
+ private:
+ blocking_connection connection_;
+ link link_;
+ PN_CPP_EXTERN void check_closed();
+ friend class blocking_connection;
+ friend class blocking_sender;
+ friend class blocking_receiver;
+};
+
+}
+
+#endif /*!PROTON_CPP_BLOCKINGLINK_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/blocking_sender.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/blocking_sender.hpp b/proton-c/bindings/cpp/include/proton/blocking_sender.hpp
new file mode 100644
index 0000000..0df5a9c
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/blocking_sender.hpp
@@ -0,0 +1,52 @@
+#ifndef PROTON_CPP_BLOCKINGSENDER_H
+#define PROTON_CPP_BLOCKINGSENDER_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/handle.hpp"
+#include "proton/endpoint.hpp"
+#include "proton/container.hpp"
+#include "proton/duration.hpp"
+#include "proton/messaging_handler.hpp"
+#include "proton/blocking_link.hpp"
+#include "proton/types.h"
+#include "proton/delivery.h"
+#include <string>
+
+namespace proton {
+
+class blocking_connection;
+class blocking_link;
+
+class blocking_sender : public blocking_link
+{
+ public:
+ PN_CPP_EXTERN delivery send(message &msg);
+ PN_CPP_EXTERN delivery send(message &msg, duration timeout);
+ private:
+ PN_CPP_EXTERN blocking_sender(blocking_connection &c, sender &l);
+ friend class blocking_connection;
+};
+
+}
+
+#endif /*!PROTON_CPP_BLOCKINGSENDER_H*/
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[8/8] qpid-proton git commit: PROTON-865: Renaming to follow
boost/std library C++ naming conventions.
Posted by ac...@apache.org.
PROTON-865: Renaming to follow boost/std library C++ naming conventions.
- private member variables end in underscore_ to avoid clash with accessors.
- identifiers like_this, not LikeThis
- no get/set prefixes on attribute accessor functions.
- drop reactor namespace, proton seems sufficient.
- No `using namespace proton` in examples
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/69783099
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/69783099
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/69783099
Branch: refs/heads/cjansen-cpp-client
Commit: 697830998ab4768bf76129deabfaf474ddc10713
Parents: 9f7e346
Author: Alan Conway <ac...@redhat.com>
Authored: Fri Jun 19 09:03:43 2015 -0400
Committer: Alan Conway <ac...@redhat.com>
Committed: Mon Jun 22 13:21:42 2015 -0400
----------------------------------------------------------------------
.gitignore | 3 +
examples/cpp/README_dev.md | 9 +
examples/cpp/broker.cpp | 161 ++++----
examples/cpp/encode_decode.cpp | 201 +++++----
examples/cpp/example_test.py | 10 +-
examples/cpp/helloworld.cpp | 40 +-
examples/cpp/helloworld_blocking.cpp | 37 +-
examples/cpp/helloworld_direct.cpp | 47 ++-
examples/cpp/simple_recv.cpp | 36 +-
examples/cpp/simple_send.cpp | 42 +-
proton-c/bindings/cpp/CMakeCache.txt | 334 ---------------
proton-c/bindings/cpp/CMakeLists.txt | 70 ++--
.../bindings/cpp/include/proton/Acceptor.hpp | 50 ---
proton-c/bindings/cpp/include/proton/Acking.hpp | 44 --
.../cpp/include/proton/BlockingConnection.hpp | 66 ---
.../cpp/include/proton/BlockingLink.hpp | 58 ---
.../cpp/include/proton/BlockingSender.hpp | 53 ---
.../bindings/cpp/include/proton/Connection.hpp | 69 ----
.../bindings/cpp/include/proton/Container.hpp | 77 ----
proton-c/bindings/cpp/include/proton/Data.hpp | 71 ----
.../bindings/cpp/include/proton/Decoder.hpp | 223 ----------
.../bindings/cpp/include/proton/Delivery.hpp | 60 ---
.../bindings/cpp/include/proton/Duration.hpp | 55 ---
.../bindings/cpp/include/proton/Encoder.hpp | 185 ---------
.../bindings/cpp/include/proton/Endpoint.hpp | 58 ---
proton-c/bindings/cpp/include/proton/Error.hpp | 44 --
proton-c/bindings/cpp/include/proton/Event.hpp | 59 ---
proton-c/bindings/cpp/include/proton/Handle.hpp | 79 ----
.../bindings/cpp/include/proton/Handler.hpp | 49 ---
proton-c/bindings/cpp/include/proton/Link.hpp | 69 ----
.../bindings/cpp/include/proton/Message.hpp | 112 -----
.../cpp/include/proton/MessagingAdapter.hpp | 77 ----
.../cpp/include/proton/MessagingEvent.hpp | 99 -----
.../cpp/include/proton/MessagingHandler.hpp | 98 -----
.../bindings/cpp/include/proton/ProtonEvent.hpp | 56 ---
.../cpp/include/proton/ProtonHandle.hpp | 68 ---
.../cpp/include/proton/ProtonHandler.hpp | 82 ----
.../bindings/cpp/include/proton/Receiver.hpp | 47 ---
proton-c/bindings/cpp/include/proton/Sender.hpp | 52 ---
.../bindings/cpp/include/proton/Session.hpp | 61 ---
.../bindings/cpp/include/proton/Terminus.hpp | 81 ----
.../bindings/cpp/include/proton/Transport.hpp | 48 ---
proton-c/bindings/cpp/include/proton/Value.hpp | 104 -----
proton-c/bindings/cpp/include/proton/Values.hpp | 60 ---
.../cpp/include/proton/WaitCondition.hpp | 45 --
.../bindings/cpp/include/proton/acceptor.hpp | 49 +++
proton-c/bindings/cpp/include/proton/acking.hpp | 43 ++
.../cpp/include/proton/blocking_connection.hpp | 65 +++
.../cpp/include/proton/blocking_link.hpp | 57 +++
.../cpp/include/proton/blocking_sender.hpp | 52 +++
.../bindings/cpp/include/proton/connection.hpp | 67 +++
.../bindings/cpp/include/proton/container.hpp | 76 ++++
proton-c/bindings/cpp/include/proton/data.hpp | 70 ++++
.../bindings/cpp/include/proton/decoder.hpp | 230 +++++++++++
.../bindings/cpp/include/proton/delivery.hpp | 59 +++
.../bindings/cpp/include/proton/duration.hpp | 55 +++
.../bindings/cpp/include/proton/encoder.hpp | 198 +++++++++
.../bindings/cpp/include/proton/endpoint.hpp | 58 +++
proton-c/bindings/cpp/include/proton/error.hpp | 44 ++
proton-c/bindings/cpp/include/proton/event.hpp | 58 +++
proton-c/bindings/cpp/include/proton/handle.hpp | 78 ++++
.../bindings/cpp/include/proton/handler.hpp | 43 ++
proton-c/bindings/cpp/include/proton/index.md | 7 +
proton-c/bindings/cpp/include/proton/link.hpp | 69 ++++
.../bindings/cpp/include/proton/message.hpp | 112 +++++
.../cpp/include/proton/messaging_adapter.hpp | 76 ++++
.../cpp/include/proton/messaging_event.hpp | 98 +++++
.../cpp/include/proton/messaging_handler.hpp | 96 +++++
.../cpp/include/proton/proton_event.hpp | 55 +++
.../cpp/include/proton/proton_handle.hpp | 67 +++
.../cpp/include/proton/proton_handler.hpp | 81 ++++
.../bindings/cpp/include/proton/receiver.hpp | 46 +++
proton-c/bindings/cpp/include/proton/sender.hpp | 51 +++
.../bindings/cpp/include/proton/session.hpp | 60 +++
.../bindings/cpp/include/proton/terminus.hpp | 83 ++++
.../bindings/cpp/include/proton/transport.hpp | 52 +++
.../bindings/cpp/include/proton/type_traits.hpp | 88 ++--
proton-c/bindings/cpp/include/proton/types.hpp | 281 ++++++-------
proton-c/bindings/cpp/include/proton/value.hpp | 94 +++++
proton-c/bindings/cpp/include/proton/values.hpp | 53 +++
.../cpp/include/proton/wait_condition.hpp | 44 ++
proton-c/bindings/cpp/src/Acceptor.cpp | 56 ---
proton-c/bindings/cpp/src/Acking.cpp | 49 ---
.../bindings/cpp/src/BlockingConnection.cpp | 62 ---
.../bindings/cpp/src/BlockingConnectionImpl.cpp | 124 ------
.../bindings/cpp/src/BlockingConnectionImpl.hpp | 63 ---
proton-c/bindings/cpp/src/BlockingLink.cpp | 86 ----
proton-c/bindings/cpp/src/BlockingSender.cpp | 66 ---
proton-c/bindings/cpp/src/Connection.cpp | 73 ----
proton-c/bindings/cpp/src/ConnectionImpl.cpp | 139 -------
proton-c/bindings/cpp/src/ConnectionImpl.hpp | 75 ----
proton-c/bindings/cpp/src/Connector.cpp | 71 ----
proton-c/bindings/cpp/src/Connector.hpp | 59 ---
proton-c/bindings/cpp/src/Container.cpp | 97 -----
proton-c/bindings/cpp/src/ContainerImpl.cpp | 369 -----------------
proton-c/bindings/cpp/src/ContainerImpl.hpp | 82 ----
proton-c/bindings/cpp/src/Data.cpp | 65 ---
proton-c/bindings/cpp/src/Decoder.cpp | 327 ---------------
proton-c/bindings/cpp/src/Delivery.cpp | 58 ---
proton-c/bindings/cpp/src/Duration.cpp | 31 --
proton-c/bindings/cpp/src/Encoder.cpp | 160 -------
proton-c/bindings/cpp/src/Endpoint.cpp | 37 --
proton-c/bindings/cpp/src/Error.cpp | 32 --
proton-c/bindings/cpp/src/Event.cpp | 71 ----
proton-c/bindings/cpp/src/Handler.cpp | 44 --
proton-c/bindings/cpp/src/Link.cpp | 114 -----
proton-c/bindings/cpp/src/Message.cpp | 253 ------------
proton-c/bindings/cpp/src/MessagingAdapter.cpp | 412 -------------------
proton-c/bindings/cpp/src/MessagingEvent.cpp | 150 -------
proton-c/bindings/cpp/src/MessagingHandler.cpp | 126 ------
proton-c/bindings/cpp/src/Msg.hpp | 59 ---
proton-c/bindings/cpp/src/PrivateImplRef.hpp | 97 -----
proton-c/bindings/cpp/src/ProtonEvent.cpp | 153 -------
proton-c/bindings/cpp/src/ProtonHandler.cpp | 74 ----
proton-c/bindings/cpp/src/ProtonImplRef.hpp | 66 ---
proton-c/bindings/cpp/src/Receiver.cpp | 45 --
proton-c/bindings/cpp/src/Sender.cpp | 72 ----
proton-c/bindings/cpp/src/Session.cpp | 74 ----
proton-c/bindings/cpp/src/Terminus.cpp | 102 -----
proton-c/bindings/cpp/src/Transport.cpp | 39 --
proton-c/bindings/cpp/src/Url.cpp | 77 ----
proton-c/bindings/cpp/src/Url.hpp | 49 ---
proton-c/bindings/cpp/src/Value.cpp | 136 ------
proton-c/bindings/cpp/src/Values.cpp | 40 --
proton-c/bindings/cpp/src/acceptor.cpp | 55 +++
proton-c/bindings/cpp/src/acking.cpp | 48 +++
.../bindings/cpp/src/blocking_connection.cpp | 61 +++
.../cpp/src/blocking_connection_impl.cpp | 123 ++++++
.../cpp/src/blocking_connection_impl.hpp | 62 +++
proton-c/bindings/cpp/src/blocking_link.cpp | 85 ++++
proton-c/bindings/cpp/src/blocking_sender.cpp | 65 +++
proton-c/bindings/cpp/src/connection.cpp | 68 +++
proton-c/bindings/cpp/src/connection_impl.cpp | 136 ++++++
proton-c/bindings/cpp/src/connection_impl.hpp | 74 ++++
proton-c/bindings/cpp/src/connector.cpp | 70 ++++
proton-c/bindings/cpp/src/connector.hpp | 58 +++
proton-c/bindings/cpp/src/container.cpp | 96 +++++
proton-c/bindings/cpp/src/container_impl.cpp | 361 ++++++++++++++++
proton-c/bindings/cpp/src/container_impl.hpp | 81 ++++
proton-c/bindings/cpp/src/contexts.cpp | 41 +-
proton-c/bindings/cpp/src/contexts.hpp | 31 +-
proton-c/bindings/cpp/src/data.cpp | 67 +++
proton-c/bindings/cpp/src/decoder.cpp | 329 +++++++++++++++
proton-c/bindings/cpp/src/delivery.cpp | 57 +++
proton-c/bindings/cpp/src/duration.cpp | 31 ++
proton-c/bindings/cpp/src/encoder.cpp | 142 +++++++
proton-c/bindings/cpp/src/endpoint.cpp | 40 ++
proton-c/bindings/cpp/src/error.cpp | 32 ++
proton-c/bindings/cpp/src/event.cpp | 70 ++++
proton-c/bindings/cpp/src/handler.cpp | 35 ++
proton-c/bindings/cpp/src/interop_test.cpp | 69 ++--
proton-c/bindings/cpp/src/link.cpp | 113 +++++
proton-c/bindings/cpp/src/message.cpp | 252 ++++++++++++
proton-c/bindings/cpp/src/messaging_adapter.cpp | 411 ++++++++++++++++++
proton-c/bindings/cpp/src/messaging_event.cpp | 148 +++++++
proton-c/bindings/cpp/src/messaging_handler.cpp | 125 ++++++
proton-c/bindings/cpp/src/msg.hpp | 58 +++
proton-c/bindings/cpp/src/private_impl_ref.hpp | 96 +++++
proton-c/bindings/cpp/src/proton_bits.cpp | 10 +-
proton-c/bindings/cpp/src/proton_bits.hpp | 8 +-
proton-c/bindings/cpp/src/proton_event.cpp | 151 +++++++
proton-c/bindings/cpp/src/proton_handler.cpp | 73 ++++
proton-c/bindings/cpp/src/proton_impl_ref.hpp | 65 +++
proton-c/bindings/cpp/src/receiver.cpp | 44 ++
proton-c/bindings/cpp/src/sender.cpp | 71 ++++
proton-c/bindings/cpp/src/session.cpp | 73 ++++
proton-c/bindings/cpp/src/terminus.cpp | 101 +++++
proton-c/bindings/cpp/src/transport.cpp | 38 ++
proton-c/bindings/cpp/src/types.cpp | 49 +--
proton-c/bindings/cpp/src/url.cpp | 76 ++++
proton-c/bindings/cpp/src/url.hpp | 48 +++
proton-c/bindings/cpp/src/value.cpp | 136 ++++++
proton-c/bindings/cpp/src/values.cpp | 38 ++
proton-c/docs/api/index.md | 2 -
proton-c/docs/api/user.doxygen.in | 4 +-
175 files changed, 7412 insertions(+), 7863 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 45dd364..0b26644 100644
--- a/.gitignore
+++ b/.gitignore
@@ -34,3 +34,6 @@ proton-c/bindings/go/bin
# Testresults from the jenkins build script
testresults
+
+# KDE project files
+/*.kdev*
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/examples/cpp/README_dev.md
----------------------------------------------------------------------
diff --git a/examples/cpp/README_dev.md b/examples/cpp/README_dev.md
new file mode 100644
index 0000000..0b23a2f
--- /dev/null
+++ b/examples/cpp/README_dev.md
@@ -0,0 +1,9 @@
+# Notes for example developers
+
+Use the C++ std library/boost conventions. File names are (*.hpp, *.cpp) and
+identifiers are lowercase_underscore names not CamelCase.
+
+No "using namespace proton" in examples. This is not a general rule, but for
+_example_ code the explicit `proton::` qualifier makes it easier to see what is
+part of the proton library vs. standard library or code that is just part of the
+example.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/examples/cpp/broker.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/broker.cpp b/examples/cpp/broker.cpp
index 468af48..cd5eb54 100644
--- a/examples/cpp/broker.cpp
+++ b/examples/cpp/broker.cpp
@@ -19,64 +19,57 @@
*
*/
-#include "proton/Container.hpp"
-#include "proton/MessagingHandler.hpp"
+#include "proton/container.hpp"
+#include "proton/messaging_handler.hpp"
#include <iostream>
+#include <sstream>
#include <deque>
#include <map>
#include <list>
-#include <stdlib.h>
-#include <string.h>
+#include <string>
-using namespace proton;
-using namespace proton::reactor;
-
-std::string generateUuid(){
- throw "TODO: platform neutral uuid";
-}
-
-class Queue {
+class queue {
public:
bool dynamic;
- typedef std::deque<Message> MsgQ;
- typedef std::list<Sender> List;
- MsgQ queue;
- List consumers;
+ typedef std::deque<proton::message> message_queue;
+ typedef std::list<proton::sender> sender_list;
+ message_queue messages;
+ sender_list consumers;
- Queue(bool dyn = false) : dynamic(dyn), queue(MsgQ()), consumers(List()) {}
+ queue(bool dyn = false) : dynamic(dyn) {}
- void subscribe(Sender &c) {
+ void subscribe(proton::sender &c) {
consumers.push_back(c);
}
- bool unsubscribe(Sender &c) {
+ bool unsubscribe(proton::sender &c) {
consumers.remove(c);
- return (consumers.size() == 0 && (dynamic || queue.size() == 0));
+ return (consumers.size() == 0 && (dynamic || messages.size() == 0));
}
- void publish(Message &m) {
- queue.push_back(m);
+ void publish(proton::message &m) {
+ messages.push_back(m);
dispatch(0);
}
- void dispatch(Sender *s) {
- while (deliverTo(s)) {
+ void dispatch(proton::sender *s) {
+ while (deliver_to(s)) {
}
}
- bool deliverTo(Sender *consumer) {
+ bool deliver_to(proton::sender *consumer) {
// deliver to single consumer if supplied, else all consumers
int count = consumer ? 1 : consumers.size();
if (!count) return false;
bool result = false;
- List::iterator it = consumers.begin();
+ sender_list::iterator it = consumers.begin();
if (!consumer && count) consumer = &*it;
- while (queue.size()) {
- if (consumer->getCredit()) {
- consumer->send(queue.front());
- queue.pop_front();
+ while (messages.size()) {
+ if (consumer->credit()) {
+ consumer->send(messages.front());
+ messages.pop_front();
result = true;
}
if (--count)
@@ -88,24 +81,26 @@ class Queue {
}
};
-class Broker : public MessagingHandler {
+class broker : public proton::messaging_handler {
private:
+ typedef std::map<std::string, queue *> queue_map;
std::string url;
- typedef std::map<std::string, Queue *> QMap;
- QMap queues;
+ queue_map queues;
+ uint64_t queue_count; // Use to generate unique queue IDs.
+
public:
- Broker(const std::string &s) : url(s), queues(QMap()) {}
+ broker(const std::string &s) : url(s), queue_count(0) {}
- void onStart(Event &e) {
- e.getContainer().listen(url);
+ void on_start(proton::event &e) {
+ e.container().listen(url);
std::cout << "broker listening on " << url << std::endl;
}
- Queue &queue(std::string &address) {
- QMap::iterator it = queues.find(address);
+ class queue &get_queue(std::string &address) {
+ queue_map::iterator it = queues.find(address);
if (it == queues.end()) {
- queues[address] = new Queue();
+ queues[address] = new queue();
return *queues[address];
}
else {
@@ -113,88 +108,94 @@ class Broker : public MessagingHandler {
}
}
- void onLinkOpening(Event &e) {
- Link lnk = e.getLink();
- if (lnk.isSender()) {
- Sender sender(lnk);
- Terminus remoteSource(lnk.getRemoteSource());
- if (remoteSource.isDynamic()) {
- std::string address = generateUuid();
- lnk.getSource().setAddress(address);
- Queue *q = new Queue(true);
+ std::string queue_name() {
+ std::ostringstream os;
+ os << "q" << queue_count++;
+ return os.str();
+ }
+
+ void on_link_opening(proton::event &e) {
+ proton::link lnk = e.link();
+ if (lnk.is_sender()) {
+ proton::sender sender(lnk);
+ proton::terminus remote_source(lnk.remote_source());
+ if (remote_source.is_dynamic()) {
+ std::string address = queue_name();
+ lnk.source().address(address);
+ queue *q = new queue(true);
queues[address] = q;
q->subscribe(sender);
}
else {
- std::string address = remoteSource.getAddress();
+ std::string address = remote_source.address();
if (!address.empty()) {
- lnk.getSource().setAddress(address);
- queue(address).subscribe(sender);
+ lnk.source().address(address);
+ get_queue(address).subscribe(sender);
}
}
}
else {
- std::string address = lnk.getRemoteTarget().getAddress();
+ std::string address = lnk.remote_target().address();
if (!address.empty())
- lnk.getTarget().setAddress(address);
+ lnk.target().address(address);
}
}
- void unsubscribe (Sender &lnk) {
- std::string address = lnk.getSource().getAddress();
- QMap::iterator it = queues.find(address);
+ void unsubscribe (proton::sender &lnk) {
+ std::string address = lnk.source().address();
+ queue_map::iterator it = queues.find(address);
if (it != queues.end() && it->second->unsubscribe(lnk)) {
delete it->second;
queues.erase(it);
}
}
- void onLinkClosing(Event &e) {
- Link lnk = e.getLink();
- if (lnk.isSender()) {
- Sender s(lnk);
+ void on_link_closing(proton::event &e) {
+ proton::link lnk = e.link();
+ if (lnk.is_sender()) {
+ proton::sender s(lnk);
unsubscribe(s);
}
}
- void onConnectionClosing(Event &e) {
- removeStaleConsumers(e.getConnection());
+ void on_connection_closing(proton::event &e) {
+ remove_stale_consumers(e.connection());
}
- void onDisconnected(Event &e) {
- removeStaleConsumers(e.getConnection());
+ void on_disconnected(proton::event &e) {
+ remove_stale_consumers(e.connection());
}
- void removeStaleConsumers(Connection &connection) {
- Link l = connection.getLinkHead(Endpoint::REMOTE_ACTIVE);
+ void remove_stale_consumers(proton::connection &connection) {
+ proton::link l = connection.link_head(proton::endpoint::REMOTE_ACTIVE);
while (l) {
- if (l.isSender()) {
- Sender s(l);
+ if (l.is_sender()) {
+ proton::sender s(l);
unsubscribe(s);
}
- l = l.getNext(Endpoint::REMOTE_ACTIVE);
+ l = l.next(proton::endpoint::REMOTE_ACTIVE);
}
}
- void onSendable(Event &e) {
- Link lnk = e.getLink();
- Sender sender(lnk);
- std::string addr = lnk.getSource().getAddress();
- queue(addr).dispatch(&sender);
+ void on_sendable(proton::event &e) {
+ proton::link lnk = e.link();
+ proton::sender sender(lnk);
+ std::string addr = lnk.source().address();
+ get_queue(addr).dispatch(&sender);
}
- void onMessage(Event &e) {
- std::string addr = e.getLink().getTarget().getAddress();
- Message msg = e.getMessage();
- queue(addr).publish(msg);
+ void on_message(proton::event &e) {
+ std::string addr = e.link().target().address();
+ proton::message msg = e.message();
+ get_queue(addr).publish(msg);
}
};
int main(int argc, char **argv) {
std::string url = argc > 1 ? argv[1] : ":5672";
- Broker broker(url);
+ broker broker(url);
try {
- Container(broker).run();
+ proton::container(broker).run();
} catch (const std::exception& e) {
std::cerr << e.what() << std::endl;
return 1;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/examples/cpp/encode_decode.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/encode_decode.cpp b/examples/cpp/encode_decode.cpp
index fd65ebd..df9ad15 100644
--- a/examples/cpp/encode_decode.cpp
+++ b/examples/cpp/encode_decode.cpp
@@ -17,73 +17,70 @@
* under the License.
*/
-#include <proton/Values.hpp>
-#include <proton/Value.hpp>
+#include <proton/value.hpp>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <map>
#include <sstream>
-#include <stdexcept>
#include <vector>
using namespace std;
-using namespace proton;
-// Examples of how to use the Encoder and Decoder to create and examine AMQP values.
+// Examples of how to use the encoder and decoder to create and examine AMQP values.
//
// Print is defined at the end as an example of how to query and extract complex
// values in terms of their simple components.
-void print(Values& values);
+void print(proton::values& values);
// Inserting and extracting simple C++ values.
void simple_insert_extract() {
- Values values;
+ proton::values vv;
cout << endl << "== Simple values: int, string, bool" << endl;
- values << 42 << "foo" << true;
- print(values);
+ vv << 42 << "foo" << true;
+ print(vv);
int i;
- std::string s;
+ string s;
bool b;
- values.rewind();
- values >> i >> s >> b;
+ vv.rewind();
+ vv >> i >> s >> b;
cout << "Extracted: " << i << ", " << s << ", " << b << endl;
// Encode and decode as AMQP
- string amqpData = values.encode();
- cout << "Encoded as AMQP in " << amqpData.size() << " bytes" << endl;
- Values values2;
- values.decode(amqpData);
- values >> i >> s >> b;
+ string amqp_data = vv.encode();
+ cout << "Encoded as AMQP in " << amqp_data.size() << " bytes" << endl;
+ proton::values vv2;
+ vv2.decode(amqp_data);
+ vv2 >> i >> s >> b;
cout << "Decoded: " << i << ", " << s << ", " << b << endl;
}
// Inserting values as a specific AMQP type
void simple_insert_extract_exact_type() {
- Values values;
+ proton::values vv;
cout << endl << "== Specific AMQP types: byte, long, symbol" << endl;
- values << Byte('x') << Long(123456789123456789) << Symbol("bar");
- print(values);
- values.rewind();
+ vv << proton::amqp_byte('x') << proton::amqp_long(123456789123456789) << proton::amqp_symbol("bar");
+ print(vv);
+ vv.rewind();
// Check that we encoded the correct types, but note that decoding will
// still convert to standard C++ types, in particular any AMQP integer type
// can be converted to a long-enough C++ integer type..
- std::int64_t i1, i2;
- std::string s;
- values >> i1 >> i2 >> s;
+ int64_t i1, i2;
+ string s;
+ vv >> i1 >> i2 >> s;
cout << "Extracted (with conversion) " << i1 << ", " << i2 << ", " << s << endl;
// Now use the as() function to fail unless we extract the exact AMQP type expected.
- values.rewind(); // Byte(1) << Long(2) << Symbol("bar");
- Long l;
- // Fails, extracting Byte as Long
- try { values >> as<LONG>(l); throw logic_error("expected error"); } catch (DecodeError) {}
- Byte b;
- values >> as<BYTE>(b) >> as<LONG>(l); // OK, extract Byte as Byte, Long as Long.
- std::string str;
- // Fails, extracting Symbol as String.
- try { values >> as<STRING>(str); throw logic_error("expected error"); } catch (DecodeError) {}
- values >> as<SYMBOL>(str); // OK, extract Symbol as Symbol
+ vv.rewind(); // amqp_byte(1) << amqp_long(2) << amqp_symbol("bar");
+ proton::amqp_long l;
+ // Fails, extracting amqp_byte as amqp_long
+ try { vv >> proton::as<proton::LONG>(l); throw logic_error("expected error"); } catch (proton::decode_error) {}
+ proton::amqp_byte b;
+ vv >> proton::as<proton::BYTE>(b) >> proton::as<proton::LONG>(l); // OK, extract amqp_byte as amqp_byte, amqp_long as amqp_long.
+ string str;
+ // Fails, extracting amqp_symbol as amqp_string.
+ try { vv >> proton::as<proton::STRING>(str); throw logic_error("expected error"); } catch (proton::decode_error) {}
+ vv >> proton::as<proton::SYMBOL>(str); // OK, extract amqp_symbol as amqp_symbol
cout << "Extracted (exact) " << b << ", " << l << ", " << str << endl;
}
@@ -121,54 +118,54 @@ void insert_extract_containers() {
m["one"] = 1;
m["two"] = 2;
- Values values;
- values << as<ARRAY>(a) << as<LIST>(l) << as<MAP>(m);
- print(values);
+ proton::values vv;
+ vv << proton::as<proton::ARRAY>(a) << proton::as<proton::LIST>(l) << proton::as<proton::MAP>(m);
+ print(vv);
vector<int> a1, l1;
map<string, int> m1;
- values.rewind();
- values >> as<ARRAY>(a1) >> as<LIST>(l1) >> as<MAP>(m1);
+ vv.rewind();
+ vv >> proton::as<proton::ARRAY>(a1) >> proton::as<proton::LIST>(l1) >> proton::as<proton::MAP>(m1);
cout << "Extracted: " << a1 << ", " << l1 << ", " << m1 << endl;
}
-// Containers with mixed types, use Value to represent arbitrary AMQP types.
+// Containers with mixed types, use value to represent arbitrary AMQP types.
void mixed_containers() {
cout << endl << "== List and map of mixed type values." << endl;
- vector<Value> l;
- l.push_back(Value(42));
- l.push_back(Value(String("foo")));
- map<Value, Value> m;
- m[Value("five")] = Value(5);
- m[Value(4)] = Value("four");
- Values values;
- values << as<LIST>(l) << as<MAP>(m);
- print(values);
+ vector<proton::value> l;
+ l.push_back(proton::value(42));
+ l.push_back(proton::value(proton::amqp_string("foo")));
+ map<proton::value, proton::value> m;
+ m[proton::value("five")] = proton::value(5);
+ m[proton::value(4)] = proton::value("four");
+ proton::values vv;
+ vv << proton::as<proton::LIST>(l) << proton::as<proton::MAP>(m);
+ print(vv);
- vector<Value> l1;
- map<Value, Value> m1;
- values.rewind();
- values >> as<LIST>(l1) >> as<MAP>(m1);
+ vector<proton::value> l1;
+ map<proton::value, proton::value> m1;
+ vv.rewind();
+ vv >> proton::as<proton::LIST>(l1) >> proton::as<proton::MAP>(m1);
cout << "Extracted: " << l1 << ", " << m1 << endl;
}
-// Insert using stream operators (see printNext for example of extracting with stream ops.)
+// Insert using stream operators (see print_next for example of extracting with stream ops.)
void insert_extract_stream_operators() {
cout << endl << "== Insert with stream operators." << endl;
- Values values;
+ proton::values vv;
// Note: array elements must be encoded with the exact type, they are not
// automaticlly converted. Mismatched types for array elements will not
- // be detected until values.encode() is called.
- values << Start::array(INT) << Int(1) << Int(2) << Int(3) << finish();
- print(values);
+ // be detected until vv.encode() is called.
+ vv << proton::start::array(proton::INT) << proton::amqp_int(1) << proton::amqp_int(2) << proton::amqp_int(3) << proton::finish();
+ print(vv);
- values.clear();
- values << Start::list() << Int(42) << false << Symbol("x") << finish();
- print(values);
+ vv.clear();
+ vv << proton::start::list() << proton::amqp_int(42) << false << proton::amqp_symbol("x") << proton::finish();
+ print(vv);
- values.clear();
- values << Start::map() << "k1" << Int(42) << Symbol("k2") << false << finish();
- print(values);
+ vv.clear();
+ vv << proton::start::map() << "k1" << proton::amqp_int(42) << proton::amqp_symbol("k2") << false << proton::finish();
+ print(vv);
}
int main(int, char**) {
@@ -184,80 +181,80 @@ int main(int, char**) {
}
}
-// printNext prints the next value from Values by recursively descending into complex values.
+// print_next prints the next value from values by recursively descending into complex values.
//
-// NOTE this is for example puroses only: There is a built in ostream operator<< for Values.
+// NOTE this is for example puroses only: There is a built in ostream operator<< for values.
//
//
-void printNext(Values& values) {
- TypeId type = values.type();
- Start start;
+void print_next(proton::values& vv) {
+ proton::type_id type = vv.type();
+ proton::start s;
switch (type) {
- case ARRAY: {
- values >> start;
- cout << "array<" << start.element;
- if (start.isDescribed) {
+ case proton::ARRAY: {
+ vv >> s;
+ cout << "array<" << s.element;
+ if (s.is_described) {
cout << ", descriptor=";
- printNext(values);
+ print_next(vv);
}
cout << ">[";
- for (size_t i = 0; i < start.size; ++i) {
+ for (size_t i = 0; i < s.size; ++i) {
if (i) cout << ", ";
- printNext(values);
+ print_next(vv);
}
cout << "]";
- values >> finish();
+ vv >> proton::finish();
break;
}
- case LIST: {
- values >> start;
+ case proton::LIST: {
+ vv >> s;
cout << "list[";
- for (size_t i = 0; i < start.size; ++i) {
+ for (size_t i = 0; i < s.size; ++i) {
if (i) cout << ", ";
- printNext(values);
+ print_next(vv);
}
cout << "]";
- values >> finish();
+ vv >> proton::finish();
break;
}
- case MAP: {
- values >> start;
+ case proton::MAP: {
+ vv >> s;
cout << "map{";
- for (size_t i = 0; i < start.size/2; ++i) {
+ for (size_t i = 0; i < s.size/2; ++i) {
if (i) cout << ", ";
- printNext(values);
+ print_next(vv);
cout << ":"; // key:value
- printNext(values);
+ print_next(vv);
}
cout << "}";
- values >> finish();
+ vv >> proton::finish();
break;
}
- case DESCRIBED: {
- values >> start;
+ case proton::DESCRIBED: {
+ vv >> s;
cout << "described(";
- printNext(values); // Descriptor
- printNext(values); // Value
- values >> finish();
+ print_next(vv); // Descriptor
+ print_next(vv); // value
+ vv >> proton::finish();
break;
}
default:
// A simple type. We could continue the switch for all AMQP types but
- // instead we us the `Value` type which can hold and print any AMQP
+ // instead we us the `value` type which can hold and print any AMQP
// value.
- Value v;
- values >> v;
+ proton::value v;
+ vv >> v;
cout << type << "(" << v << ")";
}
}
-// Print all the values with printNext
-void print(Values& values) {
- values.rewind();
+// Print all the values with print_next
+void print(proton::values& vv) {
+ vv.rewind();
cout << "Values: ";
- while (values.more()) {
- printNext(values);
- if (values.more()) cout << ", ";
+ while (vv.more()) {
+ print_next(vv);
+ if (vv.more()) cout << ", ";
}
cout << endl;
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/examples/cpp/example_test.py
----------------------------------------------------------------------
diff --git a/examples/cpp/example_test.py b/examples/cpp/example_test.py
index 8507be8..8aa321f 100644
--- a/examples/cpp/example_test.py
+++ b/examples/cpp/example_test.py
@@ -28,11 +28,11 @@ def call(*args, **kwargs):
p = Popen(*args, stdout=PIPE, stderr=STDOUT, **kwargs)
out, err = p.communicate()
if p.returncode:
- raise CalledProcessError("""%s exit code %s
-vvvvvvvvvvvvvvvv output of %s exit code %s vvvvvvvvvvvvvvvv
+ raise Exception("""%s exit code %s
+vvvvvvvvvvvvvvvv
%s
-^^^^^^^^^^^^^^^^ output of %s exit code %s ^^^^^^^^^^^^^^^^""" % (
- p.cmd, p.returncode, p.cmd, p.returncode, out, p.cmd, p.returncode))
+^^^^^^^^^^^^^^^^
+""" % (args[0], p.returncode, out))
return out
NULL = open(os.devnull, 'w')
@@ -55,7 +55,7 @@ class Broker(object):
def __init__(self):
self.port = randrange(10000, 20000)
self.addr = ":%s" % self.port
- self.process = Popen(["./broker", self.addr], stdout=NULL, stderr=NULL)
+ self.process = Popen([os.path.abspath("broker"), self.addr], stdout=NULL, stderr=NULL)
# Wait 10 secs for broker to listen
deadline = time.time() + 10
c = None
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/examples/cpp/helloworld.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/helloworld.cpp b/examples/cpp/helloworld.cpp
index 9546218..c00ec8e 100644
--- a/examples/cpp/helloworld.cpp
+++ b/examples/cpp/helloworld.cpp
@@ -19,39 +19,37 @@
*
*/
-#include "proton/Container.hpp"
-#include "proton/MessagingHandler.hpp"
+#include "proton/container.hpp"
+#include "proton/messaging_handler.hpp"
#include <iostream>
-
-using namespace proton;
-using namespace proton::reactor;
-
-class HelloWorld : public MessagingHandler {
+class hello_world : public proton::messaging_handler {
private:
std::string server;
std::string address;
public:
- HelloWorld(const std::string &s, const std::string &addr) : server(s), address(addr) {}
+ hello_world(const std::string &s, const std::string &addr) : server(s), address(addr) {}
- void onStart(Event &e) {
- Connection conn = e.getContainer().connect(server);
- e.getContainer().createReceiver(conn, address);
- e.getContainer().createSender(conn, address);
+ void on_start(proton::event &e) {
+ proton::connection conn = e.container().connect(server);
+ e.container().create_receiver(conn, address);
+ e.container().create_sender(conn, address);
}
- void onSendable(Event &e) {
- Message m;
+ void on_sendable(proton::event &e) {
+ proton::message m;
m.body("Hello World!");
- e.getSender().send(m);
- e.getSender().close();
+ e.sender().send(m);
+ e.sender().close();
}
- void onMessage(Event &e) {
- std::cout << e.getMessage().body().get<String>() << std::endl;
- e.getConnection().close();
+ void on_message(proton::event &e) {
+ std::string s;
+ proton::value v(e.message().body());
+ std::cout << v.get<std::string>() << std::endl;
+ e.connection().close();
}
};
@@ -60,8 +58,8 @@ int main(int argc, char **argv) {
try {
std::string server = argc > 1 ? argv[1] : ":5672";
std::string addr = argc > 2 ? argv[2] : "examples";
- HelloWorld hw(server, addr);
- Container(hw).run();
+ hello_world hw(server, addr);
+ proton::container(hw).run();
} catch (const std::exception& e) {
std::cerr << e.what() << std::endl;
return 1;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/examples/cpp/helloworld_blocking.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/helloworld_blocking.cpp b/examples/cpp/helloworld_blocking.cpp
index b5aee8d..e08e93d 100644
--- a/examples/cpp/helloworld_blocking.cpp
+++ b/examples/cpp/helloworld_blocking.cpp
@@ -19,32 +19,29 @@
*
*/
-#include "proton/Container.hpp"
-#include "proton/MessagingHandler.hpp"
-#include "proton/BlockingSender.hpp"
+#include "proton/container.hpp"
+#include "proton/messaging_handler.hpp"
+#include "proton/blocking_sender.hpp"
#include <iostream>
-
-using namespace proton;
-using namespace proton::reactor;
-
-class HelloWorldBlocking : public MessagingHandler {
+class hello_world_blocking : public proton::messaging_handler {
private:
std::string server;
std::string address;
public:
- HelloWorldBlocking(const std::string &s, const std::string &addr) : server(s), address(addr) {}
+ hello_world_blocking(const std::string &s, const std::string &addr) : server(s), address(addr) {}
- void onStart(Event &e) {
- Connection conn = e.getContainer().connect(server);
- e.getContainer().createReceiver(conn, address);
+ void on_start(proton::event &e) {
+ proton::connection conn = e.container().connect(server);
+ e.container().create_receiver(conn, address);
}
- void onMessage(Event &e) {
- std::cout << e.getMessage().body().get<String>() << std::endl;
- e.getConnection().close();
+ void on_message(proton::event &e) {
+ proton::value v(e.message().body());
+ std::cout << v.get<std::string>() << std::endl;
+ e.connection().close();
}
};
@@ -53,16 +50,16 @@ int main(int argc, char **argv) {
try {
std::string server = argc > 1 ? argv[1] : ":5672";
std::string addr = argc > 2 ? argv[2] : "examples";
- BlockingConnection conn = BlockingConnection(server);
- BlockingSender sender = conn.createSender(addr);
- Message m;
+ proton::blocking_connection conn(server);
+ proton::blocking_sender sender = conn.create_sender(addr);
+ proton::message m;
m.body("Hello World!");
sender.send(m);
conn.close();
// TODO Temporary hack until blocking receiver available
- HelloWorldBlocking hw(server, addr);
- Container(hw).run();
+ hello_world_blocking hw(server, addr);
+ proton::container(hw).run();
} catch (const std::exception& e) {
std::cerr << e.what() << std::endl;
return 1;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/examples/cpp/helloworld_direct.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/helloworld_direct.cpp b/examples/cpp/helloworld_direct.cpp
index 536aba8..1d87037 100644
--- a/examples/cpp/helloworld_direct.cpp
+++ b/examples/cpp/helloworld_direct.cpp
@@ -19,47 +19,46 @@
*
*/
-#include "proton/MessagingHandler.hpp"
-#include "proton/Container.hpp"
+#include "proton/messaging_handler.hpp"
+#include "proton/container.hpp"
-//#include "proton/Acceptor.hpp"
+//#include "proton/acceptor.hpp"
#include <iostream>
-using namespace proton;
-using namespace proton::reactor;
-class HelloWorldDirect : public MessagingHandler {
+class hello_world_direct : public proton::messaging_handler {
private:
- std::string url;
- Acceptor acceptor;
+ std::string url_;
+ proton::acceptor acceptor_;
public:
- HelloWorldDirect(const std::string &u) : url(u) {}
+ hello_world_direct(const std::string &u) : url_(u) {}
- void onStart(Event &e) {
- acceptor = e.getContainer().listen(url);
- e.getContainer().createSender(url);
+ void on_start(proton::event &e) {
+ acceptor_ = e.container().listen(url_);
+ e.container().create_sender(url_);
}
- void onSendable(Event &e) {
- Message m;
+ void on_sendable(proton::event &e) {
+ proton::message m;
m.body("Hello World!");
- e.getSender().send(m);
- e.getSender().close();
+ e.sender().send(m);
+ e.sender().close();
}
- void onMessage(Event &e) {
- std::cout << e.getMessage().body().get<String>() << std::endl;
+ void on_message(proton::event &e) {
+ proton::value v(e.message().body());
+ std::cout << v.get<std::string>() << std::endl;
}
- void onAccepted(Event &e) {
- e.getConnection().close();
+ void on_accepted(proton::event &e) {
+ e.connection().close();
}
- void onConnectionClosed(Event &e) {
- acceptor.close();
+ void on_connection_closed(proton::event &e) {
+ acceptor_.close();
}
};
@@ -67,8 +66,8 @@ class HelloWorldDirect : public MessagingHandler {
int main(int argc, char **argv) {
try {
std::string url = argc > 1 ? argv[1] : ":8888/examples";
- HelloWorldDirect hwd(url);
- Container(hwd).run();
+ hello_world_direct hwd(url);
+ proton::container(hwd).run();
} catch (const std::exception& e) {
std::cerr << e.what() << std::endl;
return 1;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/examples/cpp/simple_recv.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/simple_recv.cpp b/examples/cpp/simple_recv.cpp
index b4572f5..806d928 100644
--- a/examples/cpp/simple_recv.cpp
+++ b/examples/cpp/simple_recv.cpp
@@ -19,9 +19,9 @@
*
*/
-#include "proton/Container.hpp"
-#include "proton/MessagingHandler.hpp"
-#include "proton/Link.hpp"
+#include "proton/container.hpp"
+#include "proton/messaging_handler.hpp"
+#include "proton/link.hpp"
#include <iostream>
#include <map>
@@ -30,27 +30,25 @@
#include <string.h>
-using namespace proton;
-using namespace proton::reactor;
-class Recv : public MessagingHandler {
+class simple_recv : public proton::messaging_handler {
private:
std::string url;
int expected;
int received;
public:
- Recv(const std::string &s, int c) : url(s), expected(c), received(0) {}
+ simple_recv(const std::string &s, int c) : url(s), expected(c), received(0) {}
- void onStart(Event &e) {
- e.getContainer().createReceiver(url);
+ void on_start(proton::event &e) {
+ e.container().create_receiver(url);
std::cout << "simple_recv listening on " << url << std::endl;
}
- void onMessage(Event &e) {
- Message msg = e.getMessage();
- Value id = msg.id();
- if (id.type() == ULONG) {
+ void on_message(proton::event &e) {
+ proton::message msg = e.message();
+ proton::value id = msg.id();
+ if (id.type() == proton::ULONG) {
if (id.get<int>() < received)
return; // ignore duplicate
}
@@ -58,8 +56,8 @@ class Recv : public MessagingHandler {
std::cout << msg.body() << std::endl;
received++;
if (received == expected) {
- e.getReceiver().close();
- e.getConnection().close();
+ e.receiver().close();
+ e.connection().close();
}
}
}
@@ -69,11 +67,11 @@ static void parse_options(int argc, char **argv, int &count, std::string &addr);
int main(int argc, char **argv) {
try {
- int messageCount = 100;
+ int message_count = 100;
std::string address("localhost:5672/examples");
- parse_options(argc, argv, messageCount, address);
- Recv recv(address, messageCount);
- Container(recv).run();
+ parse_options(argc, argv, message_count, address);
+ simple_recv recv(address, message_count);
+ proton::container(recv).run();
} catch (const std::exception& e) {
std::cerr << e.what() << std::endl;
return 1;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/examples/cpp/simple_send.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/simple_send.cpp b/examples/cpp/simple_send.cpp
index f7518c1..703561c 100644
--- a/examples/cpp/simple_send.cpp
+++ b/examples/cpp/simple_send.cpp
@@ -19,9 +19,9 @@
*
*/
-#include "proton/Container.hpp"
-#include "proton/MessagingHandler.hpp"
-#include "proton/Connection.hpp"
+#include "proton/container.hpp"
+#include "proton/messaging_handler.hpp"
+#include "proton/connection.hpp"
#include <iostream>
#include <map>
@@ -30,10 +30,8 @@
#include <stdio.h>
-using namespace proton;
-using namespace proton::reactor;
-class Send : public MessagingHandler {
+class simple_send : public proton::messaging_handler {
private:
std::string url;
int sent;
@@ -41,34 +39,34 @@ class Send : public MessagingHandler {
int total;
public:
- Send(const std::string &s, int c) : url(s), sent(0), confirmed(0), total(c) {}
+ simple_send(const std::string &s, int c) : url(s), sent(0), confirmed(0), total(c) {}
- void onStart(Event &e) {
- e.getContainer().createSender(url);
+ void on_start(proton::event &e) {
+ e.container().create_sender(url);
}
- void onSendable(Event &e) {
- Sender sender = e.getSender();
- while (sender.getCredit() && sent < total) {
- Message msg;
- msg.id(Value(sent + 1));
+ void on_sendable(proton::event &e) {
+ proton::sender sender = e.sender();
+ while (sender.credit() && sent < total) {
+ proton::message msg;
+ msg.id(proton::value(sent + 1));
std::map<std::string, int> m;
m["sequence"] = sent+1;
- msg.body(as<MAP>(m));
+ msg.body(proton::as<proton::MAP>(m));
sender.send(msg);
sent++;
}
}
- void onAccepted(Event &e) {
+ void on_accepted(proton::event &e) {
confirmed++;
if (confirmed == total) {
std::cout << "all messages confirmed" << std::endl;
- e.getConnection().close();
+ e.connection().close();
}
}
- void onDisconnected(Event &e) {
+ void on_disconnected(proton::event &e) {
sent = confirmed;
}
};
@@ -77,11 +75,11 @@ static void parse_options(int argc, char **argv, int &count, std::string &addr);
int main(int argc, char **argv) {
try {
- int messageCount = 100;
+ int message_count = 100;
std::string address("localhost:5672/examples");
- parse_options(argc, argv, messageCount, address);
- Send send(address, messageCount);
- Container(send).run();
+ parse_options(argc, argv, message_count, address);
+ simple_send send(address, message_count);
+ proton::container(send).run();
} catch (const std::exception& e) {
std::cerr << e.what() << std::endl;
return 1;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/CMakeCache.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/CMakeCache.txt b/proton-c/bindings/cpp/CMakeCache.txt
deleted file mode 100644
index 9e6eaeb..0000000
--- a/proton-c/bindings/cpp/CMakeCache.txt
+++ /dev/null
@@ -1,334 +0,0 @@
-# This is the CMakeCache file.
-# For build in directory: /home/aconway/proton/proton-c/bindings/cpp
-# It was generated by CMake: /usr/bin/cmake
-# You can edit this file to change values found and used by cmake.
-# If you do not want to change any of the values, simply exit the editor.
-# If you do want to change a value, simply edit, save, and exit the editor.
-# The syntax for the file is as follows:
-# KEY:TYPE=VALUE
-# KEY is the name of a variable in the cache.
-# TYPE is a hint to GUIs for the type of VALUE, DO NOT EDIT TYPE!.
-# VALUE is the current value for the KEY.
-
-########################
-# EXTERNAL cache entries
-########################
-
-//Build cpp language binding
-BUILD_CPP:BOOL=ON
-
-//Build javascript language binding
-BUILD_JAVASCRIPT:BOOL=OFF
-
-//Path to a program.
-CMAKE_AR:FILEPATH=/usr/bin/ar
-
-//For backwards compatibility, what version of CMake commands and
-// syntax should this version of CMake try to support.
-CMAKE_BACKWARDS_COMPATIBILITY:STRING=2.4
-
-//Choose the type of build, options are: None(CMAKE_CXX_FLAGS or
-// CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.
-CMAKE_BUILD_TYPE:STRING=
-
-//Enable/Disable color output during build.
-CMAKE_COLOR_MAKEFILE:BOOL=ON
-
-//CXX compiler
-CMAKE_CXX_COMPILER:FILEPATH=/usr/lib64/ccache/c++
-
-//Flags used by the compiler during all build types.
-CMAKE_CXX_FLAGS:STRING=
-
-//Flags used by the compiler during debug builds.
-CMAKE_CXX_FLAGS_DEBUG:STRING=-g
-
-//Flags used by the compiler during release builds for minimum
-// size.
-CMAKE_CXX_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG
-
-//Flags used by the compiler during release builds.
-CMAKE_CXX_FLAGS_RELEASE:STRING=-O3 -DNDEBUG
-
-//Flags used by the compiler during release builds with debug info.
-CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG
-
-//C compiler
-CMAKE_C_COMPILER:FILEPATH=/usr/lib64/ccache/cc
-
-//Flags used by the compiler during all build types.
-CMAKE_C_FLAGS:STRING=
-
-//Flags used by the compiler during debug builds.
-CMAKE_C_FLAGS_DEBUG:STRING=-g
-
-//Flags used by the compiler during release builds for minimum
-// size.
-CMAKE_C_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG
-
-//Flags used by the compiler during release builds.
-CMAKE_C_FLAGS_RELEASE:STRING=-O3 -DNDEBUG
-
-//Flags used by the compiler during release builds with debug info.
-CMAKE_C_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG
-
-//Flags used by the linker.
-CMAKE_EXE_LINKER_FLAGS:STRING=
-
-//Flags used by the linker during debug builds.
-CMAKE_EXE_LINKER_FLAGS_DEBUG:STRING=
-
-//Flags used by the linker during release minsize builds.
-CMAKE_EXE_LINKER_FLAGS_MINSIZEREL:STRING=
-
-//Flags used by the linker during release builds.
-CMAKE_EXE_LINKER_FLAGS_RELEASE:STRING=
-
-//Flags used by the linker during Release with Debug Info builds.
-CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO:STRING=
-
-//Enable/Disable output of compile commands during generation.
-CMAKE_EXPORT_COMPILE_COMMANDS:BOOL=OFF
-
-//Install path prefix, prepended onto install directories.
-CMAKE_INSTALL_PREFIX:PATH=/usr/local
-
-//Path to a program.
-CMAKE_LINKER:FILEPATH=/usr/bin/ld
-
-//Path to a program.
-CMAKE_MAKE_PROGRAM:FILEPATH=/usr/bin/gmake
-
-//Flags used by the linker during the creation of modules.
-CMAKE_MODULE_LINKER_FLAGS:STRING=
-
-//Flags used by the linker during debug builds.
-CMAKE_MODULE_LINKER_FLAGS_DEBUG:STRING=
-
-//Flags used by the linker during release minsize builds.
-CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL:STRING=
-
-//Flags used by the linker during release builds.
-CMAKE_MODULE_LINKER_FLAGS_RELEASE:STRING=
-
-//Flags used by the linker during Release with Debug Info builds.
-CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO:STRING=
-
-//Path to a program.
-CMAKE_NM:FILEPATH=/usr/bin/nm
-
-//Path to a program.
-CMAKE_OBJCOPY:FILEPATH=/usr/bin/objcopy
-
-//Path to a program.
-CMAKE_OBJDUMP:FILEPATH=/usr/bin/objdump
-
-//Value Computed by CMake
-CMAKE_PROJECT_NAME:STATIC=Project
-
-//Path to a program.
-CMAKE_RANLIB:FILEPATH=/usr/bin/ranlib
-
-//Flags used by the linker during the creation of dll's.
-CMAKE_SHARED_LINKER_FLAGS:STRING=
-
-//Flags used by the linker during debug builds.
-CMAKE_SHARED_LINKER_FLAGS_DEBUG:STRING=
-
-//Flags used by the linker during release minsize builds.
-CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL:STRING=
-
-//Flags used by the linker during release builds.
-CMAKE_SHARED_LINKER_FLAGS_RELEASE:STRING=
-
-//Flags used by the linker during Release with Debug Info builds.
-CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO:STRING=
-
-//If set, runtime paths are not added when installing shared libraries,
-// but are added when building.
-CMAKE_SKIP_INSTALL_RPATH:BOOL=NO
-
-//If set, runtime paths are not added when using shared libraries.
-CMAKE_SKIP_RPATH:BOOL=NO
-
-//Flags used by the linker during the creation of static libraries.
-CMAKE_STATIC_LINKER_FLAGS:STRING=
-
-//Flags used by the linker during debug builds.
-CMAKE_STATIC_LINKER_FLAGS_DEBUG:STRING=
-
-//Flags used by the linker during release minsize builds.
-CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL:STRING=
-
-//Flags used by the linker during release builds.
-CMAKE_STATIC_LINKER_FLAGS_RELEASE:STRING=
-
-//Flags used by the linker during Release with Debug Info builds.
-CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO:STRING=
-
-//Path to a program.
-CMAKE_STRIP:FILEPATH=/usr/bin/strip
-
-//If true, cmake will use relative paths in makefiles and projects.
-CMAKE_USE_RELATIVE_PATHS:BOOL=OFF
-
-//If this value is on, makefiles will be generated without the
-// .SILENT directive, and all commands will be echoed to the console
-// during the make. This is useful for debugging only. With Visual
-// Studio IDE projects all commands are done without /nologo.
-CMAKE_VERBOSE_MAKEFILE:BOOL=FALSE
-
-//Single output directory for building all executables.
-EXECUTABLE_OUTPUT_PATH:PATH=
-
-//The directory containing a CMake configuration file for Emscripten.
-Emscripten_DIR:PATH=Emscripten_DIR-NOTFOUND
-
-//Single output directory for building all libraries.
-LIBRARY_OUTPUT_PATH:PATH=
-
-//Value Computed by CMake
-Project_BINARY_DIR:STATIC=/home/aconway/proton/proton-c/bindings/cpp
-
-//Value Computed by CMake
-Project_SOURCE_DIR:STATIC=/home/aconway/proton/proton-c/bindings
-
-//Dependencies for the target
-qpid-proton-cpp_LIB_DEPENDS:STATIC=general;qpid-proton;
-
-
-########################
-# INTERNAL cache entries
-########################
-
-//ADVANCED property for variable: CMAKE_AR
-CMAKE_AR-ADVANCED:INTERNAL=1
-//This is the directory where this CMakeCache.txt was created
-CMAKE_CACHEFILE_DIR:INTERNAL=/home/aconway/proton/proton-c/bindings/cpp
-//Major version of cmake used to create the current loaded cache
-CMAKE_CACHE_MAJOR_VERSION:INTERNAL=3
-//Minor version of cmake used to create the current loaded cache
-CMAKE_CACHE_MINOR_VERSION:INTERNAL=2
-//Patch version of cmake used to create the current loaded cache
-CMAKE_CACHE_PATCH_VERSION:INTERNAL=2
-//ADVANCED property for variable: CMAKE_COLOR_MAKEFILE
-CMAKE_COLOR_MAKEFILE-ADVANCED:INTERNAL=1
-//Path to CMake executable.
-CMAKE_COMMAND:INTERNAL=/usr/bin/cmake
-//Path to cpack program executable.
-CMAKE_CPACK_COMMAND:INTERNAL=/usr/bin/cpack
-//Path to ctest program executable.
-CMAKE_CTEST_COMMAND:INTERNAL=/usr/bin/ctest
-//ADVANCED property for variable: CMAKE_CXX_COMPILER
-CMAKE_CXX_COMPILER-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_CXX_FLAGS
-CMAKE_CXX_FLAGS-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_CXX_FLAGS_DEBUG
-CMAKE_CXX_FLAGS_DEBUG-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_CXX_FLAGS_MINSIZEREL
-CMAKE_CXX_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_CXX_FLAGS_RELEASE
-CMAKE_CXX_FLAGS_RELEASE-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_CXX_FLAGS_RELWITHDEBINFO
-CMAKE_CXX_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_C_COMPILER
-CMAKE_C_COMPILER-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_C_FLAGS
-CMAKE_C_FLAGS-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_C_FLAGS_DEBUG
-CMAKE_C_FLAGS_DEBUG-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_C_FLAGS_MINSIZEREL
-CMAKE_C_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_C_FLAGS_RELEASE
-CMAKE_C_FLAGS_RELEASE-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_C_FLAGS_RELWITHDEBINFO
-CMAKE_C_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
-//Path to cache edit program executable.
-CMAKE_EDIT_COMMAND:INTERNAL=/usr/bin/ccmake
-//Executable file format
-CMAKE_EXECUTABLE_FORMAT:INTERNAL=ELF
-//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS
-CMAKE_EXE_LINKER_FLAGS-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_DEBUG
-CMAKE_EXE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_MINSIZEREL
-CMAKE_EXE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELEASE
-CMAKE_EXE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO
-CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_EXPORT_COMPILE_COMMANDS
-CMAKE_EXPORT_COMPILE_COMMANDS-ADVANCED:INTERNAL=1
-//Name of external makefile project generator.
-CMAKE_EXTRA_GENERATOR:INTERNAL=
-//Name of generator.
-CMAKE_GENERATOR:INTERNAL=Unix Makefiles
-//Name of generator platform.
-CMAKE_GENERATOR_PLATFORM:INTERNAL=
-//Name of generator toolset.
-CMAKE_GENERATOR_TOOLSET:INTERNAL=
-//Start directory with the top level CMakeLists.txt file for this
-// project
-CMAKE_HOME_DIRECTORY:INTERNAL=/home/aconway/proton/proton-c/bindings
-//Install .so files without execute permission.
-CMAKE_INSTALL_SO_NO_EXE:INTERNAL=0
-//ADVANCED property for variable: CMAKE_LINKER
-CMAKE_LINKER-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_MAKE_PROGRAM
-CMAKE_MAKE_PROGRAM-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS
-CMAKE_MODULE_LINKER_FLAGS-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_DEBUG
-CMAKE_MODULE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL
-CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELEASE
-CMAKE_MODULE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO
-CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_NM
-CMAKE_NM-ADVANCED:INTERNAL=1
-//number of local generators
-CMAKE_NUMBER_OF_LOCAL_GENERATORS:INTERNAL=2
-//ADVANCED property for variable: CMAKE_OBJCOPY
-CMAKE_OBJCOPY-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_OBJDUMP
-CMAKE_OBJDUMP-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_RANLIB
-CMAKE_RANLIB-ADVANCED:INTERNAL=1
-//Path to CMake installation.
-CMAKE_ROOT:INTERNAL=/usr/share/cmake
-//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS
-CMAKE_SHARED_LINKER_FLAGS-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_DEBUG
-CMAKE_SHARED_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL
-CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELEASE
-CMAKE_SHARED_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO
-CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_SKIP_INSTALL_RPATH
-CMAKE_SKIP_INSTALL_RPATH-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_SKIP_RPATH
-CMAKE_SKIP_RPATH-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS
-CMAKE_STATIC_LINKER_FLAGS-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_DEBUG
-CMAKE_STATIC_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL
-CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_RELEASE
-CMAKE_STATIC_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO
-CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_STRIP
-CMAKE_STRIP-ADVANCED:INTERNAL=1
-//uname command
-CMAKE_UNAME:INTERNAL=/usr/bin/uname
-//ADVANCED property for variable: CMAKE_USE_RELATIVE_PATHS
-CMAKE_USE_RELATIVE_PATHS-ADVANCED:INTERNAL=1
-//ADVANCED property for variable: CMAKE_VERBOSE_MAKEFILE
-CMAKE_VERBOSE_MAKEFILE-ADVANCED:INTERNAL=1
-//Result of TRY_COMPILE
-RESULT:INTERNAL=TRUE
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/CMakeLists.txt b/proton-c/bindings/cpp/CMakeLists.txt
index 462e2bf..c1f286d 100644
--- a/proton-c/bindings/cpp/CMakeLists.txt
+++ b/proton-c/bindings/cpp/CMakeLists.txt
@@ -39,42 +39,42 @@ include_directories(
"${CMAKE_CURRENT_SOURCE_DIR}/src")
set(qpid-proton-cpp-source
- src/Acceptor.cpp
- src/Acking.cpp
- src/Connection.cpp
- src/ConnectionImpl.cpp
- src/Connector.cpp
- src/Container.cpp
- src/ContainerImpl.cpp
- src/Data.cpp
- src/Decoder.cpp
- src/Delivery.cpp
- src/Duration.cpp
- src/Encoder.cpp
- src/Endpoint.cpp
- src/Error.cpp
- src/Event.cpp
- src/Handler.cpp
- src/Link.cpp
- src/Message.cpp
- src/MessagingAdapter.cpp
- src/MessagingEvent.cpp
- src/MessagingHandler.cpp
- src/ProtonEvent.cpp
- src/ProtonHandler.cpp
- src/Receiver.cpp
- src/Sender.cpp
- src/Session.cpp
- src/Terminus.cpp
- src/Transport.cpp
- src/Url.cpp
- src/Value.cpp
- src/Values.cpp
+ src/acceptor.cpp
+ src/acking.cpp
+ src/connection.cpp
+ src/connection_impl.cpp
+ src/connector.cpp
+ src/container.cpp
+ src/container_impl.cpp
+ src/data.cpp
+ src/decoder.cpp
+ src/delivery.cpp
+ src/duration.cpp
+ src/encoder.cpp
+ src/endpoint.cpp
+ src/error.cpp
+ src/event.cpp
+ src/handler.cpp
+ src/link.cpp
+ src/message.cpp
+ src/messaging_adapter.cpp
+ src/messaging_event.cpp
+ src/messaging_handler.cpp
+ src/proton_event.cpp
+ src/proton_handler.cpp
+ src/receiver.cpp
+ src/sender.cpp
+ src/session.cpp
+ src/terminus.cpp
+ src/transport.cpp
+ src/url.cpp
+ src/value.cpp
+ src/values.cpp
src/proton_bits.cpp
- src/BlockingConnection.cpp
- src/BlockingConnectionImpl.cpp
- src/BlockingLink.cpp
- src/BlockingSender.cpp
+ src/blocking_connection.cpp
+ src/blocking_connection_impl.cpp
+ src/blocking_link.cpp
+ src/blocking_sender.cpp
src/contexts.cpp
src/types.cpp
)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/Acceptor.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/Acceptor.hpp b/proton-c/bindings/cpp/include/proton/Acceptor.hpp
deleted file mode 100644
index 5702c10..0000000
--- a/proton-c/bindings/cpp/include/proton/Acceptor.hpp
+++ /dev/null
@@ -1,50 +0,0 @@
-#ifndef PROTON_CPP_ACCEPTOR_H
-#define PROTON_CPP_ACCEPTOR_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/reactor.h"
-#include "proton/export.hpp"
-#include "proton/ProtonHandle.hpp"
-
-struct pn_connection_t;
-
-namespace proton {
-namespace reactor {
-
-class Acceptor : public ProtonHandle<pn_acceptor_t>
-{
- public:
- PN_CPP_EXTERN Acceptor();
- PN_CPP_EXTERN Acceptor(pn_acceptor_t *);
- PN_CPP_EXTERN Acceptor(const Acceptor&);
- PN_CPP_EXTERN Acceptor& operator=(const Acceptor&);
- PN_CPP_EXTERN ~Acceptor();
-
- PN_CPP_EXTERN void close();
- private:
- friend class ProtonImplRef<Acceptor>;
-};
-
-}}
-
-#endif /*!PROTON_CPP_ACCEPTOR_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/Acking.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/Acking.hpp b/proton-c/bindings/cpp/include/proton/Acking.hpp
deleted file mode 100644
index 327f1a1..0000000
--- a/proton-c/bindings/cpp/include/proton/Acking.hpp
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef PROTON_CPP_ACKING_H
-#define PROTON_CPP_ACKING_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/Delivery.hpp"
-
-namespace proton {
-namespace reactor {
-
-
-class Acking
-{
- public:
- PN_CPP_EXTERN virtual void accept(Delivery &d);
- PN_CPP_EXTERN virtual void reject(Delivery &d);
- PN_CPP_EXTERN virtual void release(Delivery &d, bool delivered=true);
- PN_CPP_EXTERN virtual void settle(Delivery &d, Delivery::state s = Delivery::REJECTED);
-};
-
-
-}}
-
-#endif /*!PROTON_CPP_ACKING_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/BlockingConnection.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/BlockingConnection.hpp b/proton-c/bindings/cpp/include/proton/BlockingConnection.hpp
deleted file mode 100644
index 5b01136..0000000
--- a/proton-c/bindings/cpp/include/proton/BlockingConnection.hpp
+++ /dev/null
@@ -1,66 +0,0 @@
-#ifndef PROTON_CPP_BLOCKINGCONNECTION_H
-#define PROTON_CPP_BLOCKINGCONNECTION_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/Handle.hpp"
-#include "proton/Endpoint.hpp"
-#include "proton/Container.hpp"
-#include "proton/Duration.hpp"
-#include "proton/MessagingHandler.hpp"
-#include "proton/types.h"
-#include <string>
-
-struct pn_connection_t;
-
-namespace proton {
-namespace reactor {
-
-class Container;
-class BlockingConnectionImpl;
-class SslDomain;
-class BlockingSender;
-class WaitCondition;
-
-class BlockingConnection : public Handle<BlockingConnectionImpl>
-{
- public:
- PN_CPP_EXTERN BlockingConnection();
- PN_CPP_EXTERN BlockingConnection(const BlockingConnection& c);
- PN_CPP_EXTERN BlockingConnection& operator=(const BlockingConnection& c);
- PN_CPP_EXTERN ~BlockingConnection();
-
- PN_CPP_EXTERN BlockingConnection(std::string &url, Duration = Duration::FOREVER,
- SslDomain *ssld=0, Container *c=0);
- PN_CPP_EXTERN void close();
-
- PN_CPP_EXTERN BlockingSender createSender(std::string &address, Handler *h=0);
- PN_CPP_EXTERN void wait(WaitCondition &condition);
- PN_CPP_EXTERN void wait(WaitCondition &condition, std::string &msg, Duration timeout=Duration::FOREVER);
- PN_CPP_EXTERN Duration getTimeout();
- private:
- friend class PrivateImplRef<BlockingConnection>;
-};
-
-}}
-
-#endif /*!PROTON_CPP_BLOCKINGCONNECTION_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/BlockingLink.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/BlockingLink.hpp b/proton-c/bindings/cpp/include/proton/BlockingLink.hpp
deleted file mode 100644
index b1a5915..0000000
--- a/proton-c/bindings/cpp/include/proton/BlockingLink.hpp
+++ /dev/null
@@ -1,58 +0,0 @@
-#ifndef PROTON_CPP_BLOCKINGLINK_H
-#define PROTON_CPP_BLOCKINGLINK_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/Handle.hpp"
-#include "proton/Endpoint.hpp"
-#include "proton/Container.hpp"
-#include "proton/Duration.hpp"
-#include "proton/MessagingHandler.hpp"
-#include "proton/BlockingConnection.hpp"
-#include "proton/types.h"
-#include <string>
-
-namespace proton {
-namespace reactor {
-
-class BlockingConnection;
-
-class BlockingLink
-{
- public:
- PN_CPP_EXTERN void close();
- PN_CPP_EXTERN ~BlockingLink();
- protected:
- PN_CPP_EXTERN BlockingLink(BlockingConnection *c, pn_link_t *l);
- PN_CPP_EXTERN void waitForClosed(Duration timeout=Duration::SECOND);
- private:
- BlockingConnection connection;
- Link link;
- PN_CPP_EXTERN void checkClosed();
- friend class BlockingConnection;
- friend class BlockingSender;
- friend class BlockingReceiver;
-};
-
-}}
-
-#endif /*!PROTON_CPP_BLOCKINGLINK_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/BlockingSender.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/BlockingSender.hpp b/proton-c/bindings/cpp/include/proton/BlockingSender.hpp
deleted file mode 100644
index 5d95df5..0000000
--- a/proton-c/bindings/cpp/include/proton/BlockingSender.hpp
+++ /dev/null
@@ -1,53 +0,0 @@
-#ifndef PROTON_CPP_BLOCKINGSENDER_H
-#define PROTON_CPP_BLOCKINGSENDER_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/Handle.hpp"
-#include "proton/Endpoint.hpp"
-#include "proton/Container.hpp"
-#include "proton/Duration.hpp"
-#include "proton/MessagingHandler.hpp"
-#include "proton/BlockingLink.hpp"
-#include "proton/types.h"
-#include "proton/delivery.h"
-#include <string>
-
-namespace proton {
-namespace reactor {
-
-class BlockingConnection;
-class BlockingLink;
-
-class BlockingSender : public BlockingLink
-{
- public:
- PN_CPP_EXTERN Delivery send(Message &msg);
- PN_CPP_EXTERN Delivery send(Message &msg, Duration timeout);
- private:
- PN_CPP_EXTERN BlockingSender(BlockingConnection &c, Sender &l);
- friend class BlockingConnection;
-};
-
-}}
-
-#endif /*!PROTON_CPP_BLOCKINGSENDER_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/Connection.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/Connection.hpp b/proton-c/bindings/cpp/include/proton/Connection.hpp
deleted file mode 100644
index c16556b..0000000
--- a/proton-c/bindings/cpp/include/proton/Connection.hpp
+++ /dev/null
@@ -1,69 +0,0 @@
-#ifndef PROTON_CPP_CONNECTION_H
-#define PROTON_CPP_CONNECTION_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/Handle.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;
-
-class Connection : public Endpoint, public Handle<ConnectionImpl>
-{
- public:
- PN_CPP_EXTERN Connection();
- PN_CPP_EXTERN Connection(ConnectionImpl *);
- PN_CPP_EXTERN Connection(const Connection& c);
- PN_CPP_EXTERN Connection& operator=(const Connection& c);
- PN_CPP_EXTERN ~Connection();
-
- PN_CPP_EXTERN Connection(Container &c, Handler *h = 0);
- 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();
- virtual PN_CPP_EXTERN Connection &getConnection();
- PN_CPP_EXTERN Link getLinkHead(Endpoint::State mask);
- private:
- friend class PrivateImplRef<Connection>;
- friend class Connector;
- friend class ConnectionImpl;
-};
-
-}}
-
-#endif /*!PROTON_CPP_CONNECTION_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/Container.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/Container.hpp b/proton-c/bindings/cpp/include/proton/Container.hpp
deleted file mode 100644
index c1ecb65..0000000
--- a/proton-c/bindings/cpp/include/proton/Container.hpp
+++ /dev/null
@@ -1,77 +0,0 @@
-#ifndef PROTON_CPP_CONTAINER_H
-#define PROTON_CPP_CONTAINER_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/Handle.hpp"
-#include "proton/Acceptor.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;
-class MessagingHandler;
-class Sender;
-class Receiver;
-class Link;
- class Handler;
-
-class Container : public Handle<ContainerImpl>
-{
- public:
- PN_CPP_EXTERN Container(ContainerImpl *);
- PN_CPP_EXTERN Container(const Container& c);
- PN_CPP_EXTERN Container& operator=(const Container& c);
- PN_CPP_EXTERN ~Container();
-
- PN_CPP_EXTERN Container();
- PN_CPP_EXTERN Container(MessagingHandler &mhandler);
- PN_CPP_EXTERN Connection connect(std::string &host, Handler *h=0);
- PN_CPP_EXTERN void run();
- PN_CPP_EXTERN void start();
- PN_CPP_EXTERN bool process();
- PN_CPP_EXTERN void stop();
- PN_CPP_EXTERN void wakeup();
- PN_CPP_EXTERN bool isQuiesced();
- PN_CPP_EXTERN pn_reactor_t *getReactor();
- PN_CPP_EXTERN Sender createSender(Connection &connection, std::string &addr, Handler *h=0);
- 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);
- private:
- friend class PrivateImplRef<Container>;
-};
-
-}}
-
-#endif /*!PROTON_CPP_CONTAINER_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/Data.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/Data.hpp b/proton-c/bindings/cpp/include/proton/Data.hpp
deleted file mode 100644
index 77df52f..0000000
--- a/proton-c/bindings/cpp/include/proton/Data.hpp
+++ /dev/null
@@ -1,71 +0,0 @@
-#ifndef DATA_H
-#define DATA_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 <iosfwd>
-
-/**@file
- * Base for classes that hold AMQP data.
- * @internal
- */
-struct pn_data_t;
-
-namespace proton {
-
-/** Base for classes that hold AMQP data. */
-class Data {
- public:
- PN_CPP_EXTERN explicit Data();
- PN_CPP_EXTERN Data(const Data&);
- PN_CPP_EXTERN virtual ~Data();
- PN_CPP_EXTERN Data& operator=(const Data&);
-
- /** Clear the data. */
- PN_CPP_EXTERN void clear();
-
- /** True if there are no values. */
- PN_CPP_EXTERN bool empty() const;
-
- /** The underlying pn_data_t */
- PN_CPP_EXTERN pn_data_t* pnData() { return data; }
-
- /** True if this Data object owns it's own pn_data_t, false if it is acting as a "view" */
- PN_CPP_EXTERN bool own() const { return own_; }
-
- PN_CPP_EXTERN void swap(Data&);
-
- /** Human readable representation of data. */
- friend PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const Data&);
-
- protected:
- /** Does not take ownership, just a view on the data */
- PN_CPP_EXTERN explicit Data(pn_data_t*);
-
- /** Does not take ownership, just a view on the data */
- PN_CPP_EXTERN void view(pn_data_t*);
-
- mutable pn_data_t* data;
- bool own_;
-};
-
-
-}
-#endif // DATA_H
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[5/8] qpid-proton git commit: PROTON-865: Renaming to follow
boost/std library C++ naming conventions.
Posted by ac...@apache.org.
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
[6/8] qpid-proton git commit: PROTON-865: Renaming to follow
boost/std library C++ naming conventions.
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/connection.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/connection.hpp b/proton-c/bindings/cpp/include/proton/connection.hpp
new file mode 100644
index 0000000..15b28fa
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/connection.hpp
@@ -0,0 +1,67 @@
+#ifndef PROTON_CPP_CONNECTION_H
+#define PROTON_CPP_CONNECTION_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/handle.hpp"
+#include "proton/endpoint.hpp"
+#include "proton/container.hpp"
+#include "proton/types.h"
+#include <string>
+
+struct pn_connection_t;
+
+namespace proton {
+
+class handler;
+class transport;
+class connection_impl;
+
+class connection : public endpoint, public handle<connection_impl>
+{
+ public:
+ PN_CPP_EXTERN connection();
+ PN_CPP_EXTERN connection(connection_impl *);
+ PN_CPP_EXTERN connection(const connection& c);
+ PN_CPP_EXTERN connection(class container &c, handler *h = 0);
+ PN_CPP_EXTERN ~connection();
+
+ PN_CPP_EXTERN connection& operator=(const connection& c);
+
+ PN_CPP_EXTERN class transport& transport();
+ PN_CPP_EXTERN handler *override();
+ PN_CPP_EXTERN void override(handler *h);
+ PN_CPP_EXTERN void open();
+ PN_CPP_EXTERN void close();
+ PN_CPP_EXTERN pn_connection_t *pn_connection();
+ PN_CPP_EXTERN class container &container();
+ PN_CPP_EXTERN std::string hostname();
+ PN_CPP_EXTERN link link_head(endpoint::State mask);
+ private:
+ friend class private_impl_ref<connection>;
+ friend class Connector;
+ friend class connection_impl;
+};
+
+}
+
+#endif /*!PROTON_CPP_CONNECTION_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/container.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/container.hpp b/proton-c/bindings/cpp/include/proton/container.hpp
new file mode 100644
index 0000000..0a1eb7a
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/container.hpp
@@ -0,0 +1,76 @@
+#ifndef PROTON_CPP_CONTAINER_H
+#define PROTON_CPP_CONTAINER_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/handle.hpp"
+#include "proton/acceptor.hpp"
+#include "proton/duration.hpp"
+#include <proton/reactor.h>
+#include <string>
+
+namespace proton {
+
+class dispatch_helper;
+class connection;
+class Connector;
+class acceptor;
+class container_impl;
+class messaging_handler;
+class sender;
+class receiver;
+class link;
+ class handler;
+
+class container : public handle<container_impl>
+{
+ public:
+ PN_CPP_EXTERN container(container_impl *);
+ PN_CPP_EXTERN container(const container& c);
+ PN_CPP_EXTERN container& operator=(const container& c);
+ PN_CPP_EXTERN ~container();
+
+ PN_CPP_EXTERN container();
+ PN_CPP_EXTERN container(messaging_handler &mhandler);
+ PN_CPP_EXTERN connection connect(std::string &host, handler *h=0);
+ PN_CPP_EXTERN void run();
+ PN_CPP_EXTERN void start();
+ PN_CPP_EXTERN bool process();
+ PN_CPP_EXTERN void stop();
+ PN_CPP_EXTERN void wakeup();
+ PN_CPP_EXTERN bool is_quiesced();
+ PN_CPP_EXTERN pn_reactor_t *reactor();
+ PN_CPP_EXTERN sender create_sender(connection &connection, std::string &addr, handler *h=0);
+ PN_CPP_EXTERN sender create_sender(std::string &url);
+ PN_CPP_EXTERN receiver create_receiver(connection &connection, std::string &addr);
+ PN_CPP_EXTERN receiver create_receiver(const std::string &url);
+ PN_CPP_EXTERN acceptor listen(const std::string &url);
+ PN_CPP_EXTERN std::string container_id();
+ PN_CPP_EXTERN duration timeout();
+ PN_CPP_EXTERN void timeout(duration timeout);
+ private:
+ friend class private_impl_ref<container>;
+};
+
+}
+
+#endif /*!PROTON_CPP_CONTAINER_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/data.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/data.hpp b/proton-c/bindings/cpp/include/proton/data.hpp
new file mode 100644
index 0000000..c0d3e8c
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/data.hpp
@@ -0,0 +1,70 @@
+#ifndef DATA_H
+#define DATA_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 <iosfwd>
+
+struct pn_data_t;
+
+namespace proton {
+
+/** Base for classes that hold AMQP data. */
+class data {
+ public:
+ PN_CPP_EXTERN explicit data();
+ PN_CPP_EXTERN data(const data&);
+ PN_CPP_EXTERN virtual ~data();
+ PN_CPP_EXTERN data& operator=(const data&);
+
+ /** Clear the data. */
+ PN_CPP_EXTERN void clear();
+
+ /** Rewind to the start of the data. */
+ PN_CPP_EXTERN void rewind();
+
+ /** True if there are no values. */
+ PN_CPP_EXTERN bool empty() const;
+
+ /** The underlying pn_data_t */
+ PN_CPP_EXTERN pn_data_t* pn_data() { return data_; }
+
+ /** True if this data object owns it's own pn_data_t, false if it is acting as a "view" */
+ PN_CPP_EXTERN bool own() const { return own_; }
+
+ PN_CPP_EXTERN void swap(data&);
+
+ /** Human readable representation of data. */
+ friend PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const data&);
+
+ protected:
+ /** Does not take ownership, just a view on the data */
+ PN_CPP_EXTERN explicit data(pn_data_t*);
+
+ /** Does not take ownership, just a view on the data */
+ PN_CPP_EXTERN void view(pn_data_t*);
+
+ mutable pn_data_t* data_;
+ bool own_;
+};
+
+
+}
+#endif // DATA_H
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/decoder.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/decoder.hpp b/proton-c/bindings/cpp/include/proton/decoder.hpp
new file mode 100644
index 0000000..22effe3
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/decoder.hpp
@@ -0,0 +1,230 @@
+#ifndef DECODER_H
+#define DECODER_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/data.hpp"
+#include "proton/error.hpp"
+#include "proton/type_traits.hpp"
+#include "proton/types.hpp"
+#include <iosfwd>
+
+namespace proton {
+
+class value;
+
+/** Raised by decoder operations on error. @ingroup cpp*/
+struct decode_error : public error { PN_CPP_EXTERN explicit decode_error(const std::string&) throw(); };
+
+/** Skips a value with `decoder >> skip()`. @ingroup cpp */
+struct skip{};
+
+/** Rewind the decoder with `decoder >> rewind()`. @ingroup cpp */
+struct rewind{};
+
+/**
+ * Stream-like decoder from AMQP bytes to a stream of C++ values.
+ *
+ * types.h defines C++ types corresponding to AMQP types.
+ *
+ * decoder operator>> will extract AMQP types into corresponding C++ types, and
+ * do simple conversions, e.g. from AMQP integer types to corresponding or
+ * larger C++ integer types.
+ *
+ * You can require an exact AMQP type using the `as<type>(value)` helper. E.g.
+ *
+ * amqp_int i;
+ * decoder >> as<INT>(i): // Will throw if decoder does not contain an INT
+ *
+ * You can also use the `as` helper to extract an AMQP list, array or map into C++ containers.
+ *
+ *
+ * std::vector<amqp_int> v;
+ * decoder >> as<LIST>(v); // Extract a list of INT.
+ *
+ * AMQP maps can be inserted/extracted to any container with pair<X,Y> as
+ * value_type, which includes std::map and std::unordered_map but also for
+ * example std::vector<std::pair<X,Y> >. This allows you to perserve order when
+ * extracting AMQP maps.
+ *
+ * You can also extract container values element-by-element, see decoder::operator>>(decoder&, start&)
+ * @ingroup cpp
+*/
+class decoder : public virtual data {
+ public:
+
+ PN_CPP_EXTERN decoder();
+ PN_CPP_EXTERN ~decoder();
+
+ /** Copy AMQP data from a byte buffer into the decoder. */
+ PN_CPP_EXTERN decoder(const char* buffer, size_t size);
+
+ /** Copy AMQP data from a std::string into the decoder. */
+ PN_CPP_EXTERN decoder(const std::string&);
+
+ /** Decode AMQP data from a byte buffer onto the end of the value stream. */
+ PN_CPP_EXTERN void decode(const char* buffer, size_t size);
+
+ /** Decode AMQP data from bytes in std::string onto the end of the value stream. */
+ PN_CPP_EXTERN void decode(const std::string&);
+
+ /** Return true if there are more values to read at the current level. */
+ PN_CPP_EXTERN bool more() const;
+
+ /** Type of the next value that will be read by operator>>
+ *@throw error if empty().
+ */
+ PN_CPP_EXTERN type_id type() const;
+
+ /** @name Extract simple types
+ * Overloads to extract simple types.
+ * @throw error if the decoder is empty or the current value has an incompatible type.
+ * @{
+ */
+ PN_CPP_EXTERN friend decoder& operator>>(decoder&, amqp_null);
+ PN_CPP_EXTERN friend decoder& operator>>(decoder&, amqp_bool&);
+ PN_CPP_EXTERN friend decoder& operator>>(decoder&, amqp_ubyte&);
+ PN_CPP_EXTERN friend decoder& operator>>(decoder&, amqp_byte&);
+ PN_CPP_EXTERN friend decoder& operator>>(decoder&, amqp_ushort&);
+ PN_CPP_EXTERN friend decoder& operator>>(decoder&, amqp_short&);
+ PN_CPP_EXTERN friend decoder& operator>>(decoder&, amqp_uint&);
+ PN_CPP_EXTERN friend decoder& operator>>(decoder&, amqp_int&);
+ PN_CPP_EXTERN friend decoder& operator>>(decoder&, amqp_char&);
+ PN_CPP_EXTERN friend decoder& operator>>(decoder&, amqp_ulong&);
+ PN_CPP_EXTERN friend decoder& operator>>(decoder&, amqp_long&);
+ PN_CPP_EXTERN friend decoder& operator>>(decoder&, amqp_timestamp&);
+ PN_CPP_EXTERN friend decoder& operator>>(decoder&, amqp_float&);
+ PN_CPP_EXTERN friend decoder& operator>>(decoder&, amqp_double&);
+ PN_CPP_EXTERN friend decoder& operator>>(decoder&, amqp_decimal32&);
+ PN_CPP_EXTERN friend decoder& operator>>(decoder&, amqp_decimal64&);
+ PN_CPP_EXTERN friend decoder& operator>>(decoder&, amqp_decimal128&);
+ PN_CPP_EXTERN friend decoder& operator>>(decoder&, amqp_uuid&);
+ PN_CPP_EXTERN friend decoder& operator>>(decoder&, std::string&);
+ PN_CPP_EXTERN friend decoder& operator>>(decoder&, value&);
+ ///@}
+
+ /** Extract and return a value of type T. */
+ template <class T> T get() { T value; *this >> value; return value; }
+
+ /** Extract and return a value of type T, as AMQP type. */
+ template <class T, type_id A> T get_as() { T value; *this >> as<A>(value); return value; }
+
+ /** Call decoder::start() in constructor, decoder::finish in destructor().
+ * @ingroup cpp
+ */
+ struct scope : public start {
+ decoder& decoder_;
+ scope(decoder& d) : decoder_(d) { d >> *this; }
+ ~scope() { decoder_ >> finish(); }
+ };
+
+ template <type_id A, class T> friend decoder& operator>>(decoder& d, ref<T, A> ref) {
+ d.check_type(A);
+ d >> ref.value;
+ return d;
+ }
+
+ /** start extracting a container value, one of array, list, map, described.
+ * The basic pattern is:
+ *
+ * start s;
+ * decoder >> s;
+ * // check s.type() to see if this is an ARRAY, LIST, MAP or DESCRIBED type.
+ * if (s.described) extract the descriptor...
+ * for (size_t i = 0; i < s.size(); ++i) Extract each element...
+ * decoder >> finish();
+ *
+ * The first value of an ARRAY is a descriptor if start::descriptor is true,
+ * followed by start.size elemets of type start::element.
+ *
+ * A LIST has start.size elements which may be of mixed type.
+ *
+ * A MAP has start.size elements which alternate key, value, key, value...
+ * and may be of mixed type.
+ *
+ * A DESCRIBED contains a descriptor and a single element, so it always has
+ * start.described=true and start.size=1.
+ *
+ * You must always end a complex type by extracting to an instance of `finish`,
+ * the decoder::scope automates this.
+ *
+ *@throw decoder::error if the curent value is not a container type.
+ */
+ PN_CPP_EXTERN friend decoder& operator>>(decoder&, start&);
+
+ /** Finish extracting a container value. */
+ PN_CPP_EXTERN friend decoder& operator>>(decoder&, finish);
+
+ /** Skip a value */
+ PN_CPP_EXTERN friend decoder& operator>>(decoder&, skip);
+
+ /** Rewind to the beginning */
+ PN_CPP_EXTERN friend decoder& operator>>(decoder&, struct rewind);
+
+ private:
+ template <class T> decoder& extract(T& value);
+ PN_CPP_EXTERN void check_type(type_id);
+
+ friend class value;
+ friend class encoder;
+};
+
+// operator >> for integer types that are not covered by the standard overrides.
+template <class T>
+typename std::enable_if<is_unknown_integer<T>::value, decoder&>::type operator>>(decoder& d, T& i) {
+ typename integer_type<sizeof(T), std::is_signed<T>::value>::type v;
+ d >> v; // Extract as a known integer type
+ i = v;
+ return d;
+}
+
+template <class T> decoder& operator>>(decoder& d, ref<T, ARRAY> ref) {
+ decoder::scope s(d);
+ if (s.is_described) d >> skip();
+ ref.value.clear();
+ ref.value.resize(s.size);
+ for (typename T::iterator i = ref.value.begin(); i != ref.value.end(); ++i) {
+ d >> *i;
+ }
+ return d;
+}
+
+template <class T> decoder& operator>>(decoder& d, ref<T, LIST> ref) {
+ decoder::scope s(d);
+ ref.value.clear();
+ ref.value.resize(s.size);
+ for (typename T::iterator i = ref.value.begin(); i != ref.value.end(); ++i)
+ d >> *i;
+ return d;
+}
+
+template <class T> decoder& operator>>(decoder& d, ref<T, MAP> ref) {
+ decoder::scope m(d);
+ ref.value.clear();
+ for (size_t i = 0; i < m.size/2; ++i) {
+ typename T::key_type k;
+ typename T::mapped_type v;
+ d >> k >> v;
+ ref.value[k] = v;
+ }
+ return d;
+}
+
+}
+#endif // DECODER_H
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/delivery.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/delivery.hpp b/proton-c/bindings/cpp/include/proton/delivery.hpp
new file mode 100644
index 0000000..0dc80da
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/delivery.hpp
@@ -0,0 +1,59 @@
+#ifndef PROTON_CPP_DELIVERY_H
+#define PROTON_CPP_DELIVERY_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/proton_handle.hpp"
+
+#include "proton/delivery.h"
+#include "proton/disposition.h"
+
+namespace proton {
+
+class delivery : public proton_handle<pn_delivery_t>
+{
+ public:
+
+ enum state {
+ NONE = 0,
+ RECEIVED = PN_RECEIVED,
+ ACCEPTED = PN_ACCEPTED,
+ REJECTED = PN_REJECTED,
+ RELEASED = PN_RELEASED,
+ MODIFIED = PN_MODIFIED
+ }; // AMQP spec 3.4 delivery State
+
+ PN_CPP_EXTERN delivery(pn_delivery_t *d);
+ PN_CPP_EXTERN delivery();
+ PN_CPP_EXTERN ~delivery();
+ PN_CPP_EXTERN delivery(const delivery&);
+ PN_CPP_EXTERN delivery& operator=(const delivery&);
+ PN_CPP_EXTERN bool settled();
+ PN_CPP_EXTERN void settle();
+ PN_CPP_EXTERN pn_delivery_t *pn_delivery();
+ private:
+ friend class proton_impl_ref<delivery>;
+};
+
+}
+
+#endif /*!PROTON_CPP_DELIVERY_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/duration.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/duration.hpp b/proton-c/bindings/cpp/include/proton/duration.hpp
new file mode 100644
index 0000000..b5bd59b
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/duration.hpp
@@ -0,0 +1,55 @@
+#ifndef PROTON_CPP_DURATION_H
+#define PROTON_CPP_DURATION_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/types.hpp"
+
+namespace proton {
+
+/** @ingroup cpp
+ * A duration is a time in milliseconds.
+ */
+class duration : public comparable<duration>
+{
+ public:
+ std::uint64_t milliseconds;
+ explicit duration(std::uint64_t ms) : milliseconds(ms) {}
+
+ bool operator<(duration d) { return milliseconds < d.milliseconds; }
+ bool operator==(duration d) { return milliseconds == d.milliseconds; }
+
+ PN_CPP_EXTERN static const duration FOREVER;
+ PN_CPP_EXTERN static const duration IMMEDIATE;
+ PN_CPP_EXTERN static const duration SECOND;
+ PN_CPP_EXTERN static const duration MINUTE;
+};
+
+inline duration operator*(duration d, std::uint64_t n) { return duration(d.milliseconds*n); }
+inline duration operator*(std::uint64_t n, duration d) { return d * n; }
+
+inline amqp_timestamp operator+(amqp_timestamp ts, duration d) { return amqp_timestamp(ts.milliseconds+d.milliseconds); }
+inline amqp_timestamp operator+(duration d, amqp_timestamp ts) { return ts + d; }
+}
+
+#endif /*!PROTON_CPP_DURATION_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/encoder.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/encoder.hpp b/proton-c/bindings/cpp/include/proton/encoder.hpp
new file mode 100644
index 0000000..3f4ee0d
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/encoder.hpp
@@ -0,0 +1,198 @@
+#ifndef ENCODER_H
+#define ENCODER_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/data.hpp"
+#include "proton/error.hpp"
+#include "proton/types.hpp"
+#include "proton/type_traits.hpp"
+#include <iosfwd>
+
+#include <iostream> // FIXME aconway 2015-06-18:
+
+struct pn_data_t;
+
+namespace proton {
+
+class value;
+class values;
+
+/** Raised by encoder operations on error */
+struct encode_error : public error { PN_CPP_EXTERN explicit encode_error(const std::string&) throw(); };
+
+/**
+ * Stream C++ data values into an AMQP encoder using operator<<.
+ *
+ * types.h defines C++ typedefs and types for AMQP each type. These types insert
+ * as the corresponding AMQP type. Conversion rules apply to other types:
+ *
+ * - Integer types insert as the AMQP integer of matching size and signedness.
+ * - std::string or char* insert as AMQP strings.
+ *
+ * C++ containers can be inserted as AMQP containers with the as() helper
+ * functions. For example:
+ *
+ * std::vector<amqp_symbol> v;
+ * encoder << as<amqp_list>(v);
+ *
+ * AMQP maps can be inserted from any container with std::pair<X,Y> as the
+ * value_type. That includes std::map and std::unordered_map but also for
+ * example std::vector<std::pair<X,Y> >. This allows you to control the order
+ * of elements when inserting AMQP maps.
+ *
+ * You can also insert containers element-by-element, see operator<<(encoder&, const start&)
+ *
+ *@throw decoder::error if the curent value is not a container type.
+ *@ingroup cpp
+ */
+class encoder : public virtual data {
+ public:
+ PN_CPP_EXTERN encoder();
+ PN_CPP_EXTERN ~encoder();
+
+ /**
+ * Encode the current values into buffer and update size to reflect the number of bytes encoded.
+ *
+ * Clears the encoder.
+ *
+ *@return if buffer==0 or size is too small then return false and size to the required size.
+ *Otherwise return true and set size to the number of bytes encoded.
+ */
+ PN_CPP_EXTERN bool encode(char* buffer, size_t& size);
+
+ /** Encode the current values into a std::string, resize the string if necessary.
+ *
+ * Clears the encoder.
+ */
+ PN_CPP_EXTERN void encode(std::string&);
+
+ /** Encode the current values into a std::string. Clears the encoder. */
+ PN_CPP_EXTERN std::string encode();
+
+ /** @name Insert simple types.
+ *@{
+ */
+ friend PN_CPP_EXTERN encoder& operator<<(encoder&, amqp_null);
+ friend PN_CPP_EXTERN encoder& operator<<(encoder&, amqp_bool);
+ friend PN_CPP_EXTERN encoder& operator<<(encoder&, amqp_ubyte);
+ friend PN_CPP_EXTERN encoder& operator<<(encoder&, amqp_byte);
+ friend PN_CPP_EXTERN encoder& operator<<(encoder&, amqp_ushort);
+ friend PN_CPP_EXTERN encoder& operator<<(encoder&, amqp_short);
+ friend PN_CPP_EXTERN encoder& operator<<(encoder&, amqp_uint);
+ friend PN_CPP_EXTERN encoder& operator<<(encoder&, amqp_int);
+ friend PN_CPP_EXTERN encoder& operator<<(encoder&, amqp_char);
+ friend PN_CPP_EXTERN encoder& operator<<(encoder&, amqp_ulong);
+ friend PN_CPP_EXTERN encoder& operator<<(encoder&, amqp_long);
+ friend PN_CPP_EXTERN encoder& operator<<(encoder&, amqp_timestamp);
+ friend PN_CPP_EXTERN encoder& operator<<(encoder&, amqp_float);
+ friend PN_CPP_EXTERN encoder& operator<<(encoder&, amqp_double);
+ friend PN_CPP_EXTERN encoder& operator<<(encoder&, amqp_decimal32);
+ friend PN_CPP_EXTERN encoder& operator<<(encoder&, amqp_decimal64);
+ friend PN_CPP_EXTERN encoder& operator<<(encoder&, amqp_decimal128);
+ friend PN_CPP_EXTERN encoder& operator<<(encoder&, amqp_uuid);
+ friend PN_CPP_EXTERN encoder& operator<<(encoder&, amqp_string);
+ friend PN_CPP_EXTERN encoder& operator<<(encoder&, amqp_symbol);
+ friend PN_CPP_EXTERN encoder& operator<<(encoder&, amqp_binary);
+ friend PN_CPP_EXTERN encoder& operator<<(encoder&, const value&);
+ friend PN_CPP_EXTERN encoder& operator<<(encoder&, const values&);
+ ///@}
+
+ /**
+ * Start a container type.
+ *
+ * Use one of the static functions start::array(), start::list(),
+ * start::map() or start::described() to create an appropriate start value
+ * and inser it into the encoder, followed by the contained elements. For
+ * example:
+ *
+ * encoder << start::list() << amqp_int(1) << amqp_symbol("two") << 3.0 << finish();
+ */
+ friend PN_CPP_EXTERN encoder& operator<<(encoder&, const start&);
+
+ /** Finish a container type. See operator<<(encoder&, const start&) */
+ friend PN_CPP_EXTERN encoder& operator<<(encoder& e, finish);
+
+
+ /**@name Insert values returned by the as<type_id> helper.
+ *@{
+ */
+ template <class T, type_id A> friend PN_CPP_EXTERN encoder& operator<<(encoder&, cref<T, A>);
+ template <class T> friend encoder& operator<<(encoder&, cref<T, ARRAY>);
+ template <class T> friend encoder& operator<<(encoder&, cref<T, LIST>);
+ template <class T> friend encoder& operator<<(encoder&, cref<T, MAP>);
+ // TODO aconway 2015-06-16: DESCRIBED.
+ ///@}
+
+ /** Copy data from a raw pn_data_t */
+ friend PN_CPP_EXTERN encoder& operator<<(encoder&, pn_data_t*);
+
+ private:
+ PN_CPP_EXTERN encoder(pn_data_t* pd);
+
+ friend class value;
+};
+
+// Need to disambiguate char* conversion to bool and std::string as amqp_string.
+inline encoder& operator<<(encoder& e, char* s) { return e << amqp_string(s); }
+inline encoder& operator<<(encoder& e, const char* s) { return e << amqp_string(s); }
+inline encoder& operator<<(encoder& e, const std::string& s) { return e << amqp_string(s); }
+
+// operator << for integer types that are not covered by the standard overrides.
+template <class T>
+typename std::enable_if<is_unknown_integer<T>::value, encoder&>::type operator<<(encoder& e, T i) {
+ typename integer_type<sizeof(T), std::is_signed<T>::value>::type v = i;
+ return e << v; // Insert as a known integer type
+}
+
+// TODO aconway 2015-06-16: described array insertion.
+
+template <class T> encoder& operator<<(encoder& e, cref<T, ARRAY> a) {
+ e << start::array(type_idOf<typename T::value_type>::value);
+ for (typename T::const_iterator i = a.value.begin(); i != a.value.end(); ++i)
+ e << *i;
+ e << finish();
+ return e;
+}
+
+template <class T> encoder& operator<<(encoder& e, cref<T, LIST> l) {
+ e << start::list();
+ for (typename T::const_iterator i = l.value.begin(); i != l.value.end(); ++i)
+ e << *i;
+ e << finish();
+ return e;
+}
+
+template <class T> encoder& operator<<(encoder& e, cref<T, MAP> m){
+ e << start::map();
+ for (typename T::const_iterator i = m.value.begin(); i != m.value.end(); ++i) {
+ e << i->first;
+ e << i->second;
+ }
+ e << finish();
+ return e;
+}
+//@internal Convert a ref to a cref.
+template <class T, type_id A> encoder& operator<<(encoder& e, ref<T, A> ref) {
+ return e << cref<T,A>(ref);
+}
+
+
+}
+#endif // ENCODER_H
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/endpoint.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/endpoint.hpp b/proton-c/bindings/cpp/include/proton/endpoint.hpp
new file mode 100644
index 0000000..195a010
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/endpoint.hpp
@@ -0,0 +1,58 @@
+#ifndef PROTON_CPP_ENDPOINT_H
+#define PROTON_CPP_ENDPOINT_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/connection.h"
+
+namespace proton {
+
+class handler;
+class connection;
+class transport;
+
+class endpoint
+{
+ public:
+ enum {
+ LOCAL_UNINIT = PN_LOCAL_UNINIT,
+ REMOTE_UNINIT = PN_REMOTE_UNINIT,
+ LOCAL_ACTIVE = PN_LOCAL_ACTIVE,
+ REMOTE_ACTIVE = PN_REMOTE_ACTIVE,
+ LOCAL_CLOSED = PN_LOCAL_CLOSED,
+ REMOTE_CLOSED = PN_REMOTE_CLOSED
+ };
+ typedef int State;
+
+ PN_CPP_EXTERN virtual class connection &connection();
+ PN_CPP_EXTERN virtual class transport &transport();
+
+ // TODO: condition, remote_condition, update_condition, get/handler
+protected:
+ PN_CPP_EXTERN endpoint();
+ PN_CPP_EXTERN ~endpoint();
+};
+
+
+}
+
+#endif /*!PROTON_CPP_ENDPOINT_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/error.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/error.hpp b/proton-c/bindings/cpp/include/proton/error.hpp
new file mode 100644
index 0000000..2e2ac17
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/error.hpp
@@ -0,0 +1,44 @@
+#ifndef PROTON_CPP_EXCEPTIONS_H
+#define PROTON_CPP_EXCEPTIONS_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 <stdexcept>
+#include <string>
+#include "proton/export.hpp"
+
+namespace proton {
+
+/** @ingroup cpp
+ * Functions in the proton namespace throw a subclass of proton::error on error.
+ */
+struct error : public std::runtime_error { PN_CPP_EXTERN explicit error(const std::string&) throw(); };
+
+/** Raised if a message is rejected */
+struct message_reject : public error { PN_CPP_EXTERN explicit message_reject(const std::string&) throw(); };
+
+/** Raised if a message is released */
+struct message_release : public error { PN_CPP_EXTERN explicit message_release(const std::string&) throw(); };
+
+
+}
+
+#endif /*!PROTON_CPP_EXCEPTIONS_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/event.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/event.hpp b/proton-c/bindings/cpp/include/proton/event.hpp
new file mode 100644
index 0000000..2feff2b
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/event.hpp
@@ -0,0 +1,58 @@
+#ifndef PROTON_CPP_EVENT_H
+#define PROTON_CPP_EVENT_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/link.hpp"
+#include "proton/connection.hpp"
+#include "proton/message.hpp"
+#include <vector>
+
+
+namespace proton {
+
+class handler;
+class container;
+class connection;
+
+class event
+{
+ public:
+ virtual PN_CPP_EXTERN void dispatch(handler &h) = 0;
+ virtual PN_CPP_EXTERN class container &container();
+ virtual PN_CPP_EXTERN class connection &connection();
+ virtual PN_CPP_EXTERN class sender sender();
+ virtual PN_CPP_EXTERN class receiver receiver();
+ virtual PN_CPP_EXTERN class link link();
+ virtual PN_CPP_EXTERN class message message();
+ virtual PN_CPP_EXTERN void message(class message &);
+ virtual PN_CPP_EXTERN ~event();
+ protected:
+ PN_CPP_EXTERN event();
+ private:
+ event(const event&);
+ event& operator=(const event&);
+};
+
+}
+
+#endif /*!PROTON_CPP_EVENT_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/handle.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/handle.hpp b/proton-c/bindings/cpp/include/proton/handle.hpp
new file mode 100644
index 0000000..0a23b01
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/handle.hpp
@@ -0,0 +1,78 @@
+#ifndef PROTON_CPP_HANDLE_H
+#define PROTON_CPP_HANDLE_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 {
+
+template <class> class private_impl_ref;
+template <class> class proton_impl_ref;
+
+// FIXME aconway 2015-06-09: don't need handle, get rid of it.
+
+/**
+ * A handle is like a pointer: refers to an underlying implementation object.
+ * Copying the handle does not copy the object.
+ *
+ * Handles can be null, like a 0 pointer. Use is_valid(), is_null() or the
+ * conversion to bool to test for a null handle.
+ */
+template <class T> class handle {
+ public:
+
+ /**@return true if handle is valid, i.e. not null. */
+ bool is_valid() const { return impl_; }
+
+ /**@return true if handle is null. It is an error to call any function on a null handle. */
+ bool is_null() const { return !impl_; }
+
+ /** Conversion to bool supports idiom if (handle) { handle->... } */
+ operator bool() const { return impl_; }
+
+ /** Operator ! supports idiom if (!handle) { do_if_handle_is_null(); } */
+ bool operator !() const { return !impl_; }
+
+ /** Operator == equal if they point to same non-null object*/
+ bool operator ==(const handle<T>& other) const { return impl_ == other.impl_; }
+ bool operator !=(const handle<T>& other) const { return impl_ != other.impl_; }
+
+ void swap(handle<T>& h) { T* t = h.impl_; h.impl_ = impl_; impl_ = t; }
+
+ private:
+ // Not implemented, subclasses must implement.
+ handle(const handle&);
+ handle& operator=(const handle&);
+
+ protected:
+ typedef T Impl;
+ handle() : impl_() {}
+
+ mutable Impl* impl_;
+
+ friend class private_impl_ref<T>;
+};
+
+}
+
+#endif /*!PROTON_CPP_HANDLE_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/handler.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/handler.hpp b/proton-c/bindings/cpp/include/proton/handler.hpp
new file mode 100644
index 0000000..eb019e3
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/handler.hpp
@@ -0,0 +1,43 @@
+#ifndef PROTON_CPP_HANDLER_H
+#define PROTON_CPP_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/export.hpp"
+#include "proton/event.hpp"
+#include "proton/event.h"
+#include <vector>
+
+namespace proton {
+
+class handler : public std::vector<handler*> {
+ public:
+ PN_CPP_EXTERN handler();
+ PN_CPP_EXTERN virtual ~handler();
+
+ PN_CPP_EXTERN virtual void on_unhandled(event &e);
+
+ PN_CPP_EXTERN virtual void add_child_handler(handler &e);
+};
+
+}
+
+#endif /*!PROTON_CPP_HANDLER_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/index.md
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/index.md b/proton-c/bindings/cpp/include/proton/index.md
new file mode 100644
index 0000000..d82ab8a
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/index.md
@@ -0,0 +1,7 @@
+@defgroup cpp C++ API
+
+Proton C++ API
+==============
+
+Provides a C++ object-oriented wrappers for the C proton API and stream-based
+operators to convert between C++ and AMQP data types.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/link.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/link.hpp b/proton-c/bindings/cpp/include/proton/link.hpp
new file mode 100644
index 0000000..6af20a9
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/link.hpp
@@ -0,0 +1,69 @@
+#ifndef PROTON_CPP_LINK_H
+#define PROTON_CPP_LINK_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/proton_handle.hpp"
+#include "proton/endpoint.hpp"
+#include "proton/terminus.hpp"
+#include "proton/types.h"
+#include <string>
+
+struct pn_connection_t;
+
+namespace proton {
+
+class link : public endpoint, public proton_handle<pn_link_t>
+{
+ public:
+ PN_CPP_EXTERN link(pn_link_t *);
+ PN_CPP_EXTERN link();
+ PN_CPP_EXTERN ~link();
+ PN_CPP_EXTERN link(const link&);
+ PN_CPP_EXTERN link& operator=(const link&);
+ PN_CPP_EXTERN void open();
+ PN_CPP_EXTERN void close();
+ PN_CPP_EXTERN bool is_sender();
+ PN_CPP_EXTERN bool is_receiver();
+ PN_CPP_EXTERN int credit();
+ PN_CPP_EXTERN terminus source();
+ PN_CPP_EXTERN terminus target();
+ PN_CPP_EXTERN terminus remote_source();
+ PN_CPP_EXTERN terminus remote_target();
+ PN_CPP_EXTERN std::string name();
+ PN_CPP_EXTERN pn_link_t *pn_link() const;
+ PN_CPP_EXTERN link next(endpoint::State mask);
+ class connection &connection();
+
+ protected:
+ PN_CPP_EXTERN virtual void verify_type(pn_link_t *l);
+ private:
+ friend class proton_impl_ref<link>;
+ bool sender_link;
+};
+
+}
+
+#include "proton/sender.hpp"
+#include "proton/receiver.hpp"
+
+#endif /*!PROTON_CPP_LINK_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/message.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/message.hpp b/proton-c/bindings/cpp/include/proton/message.hpp
new file mode 100644
index 0000000..0667337
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/message.hpp
@@ -0,0 +1,112 @@
+#ifndef PROTON_CPP_MESSAGE_H
+#define PROTON_CPP_MESSAGE_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/proton_handle.hpp"
+#include "proton/value.hpp"
+#include "proton/message.hpp"
+#include <string>
+
+struct pn_message_t;
+struct pn_data_t;
+
+namespace proton {
+
+// FIXME aconway 2015-06-17: documentation of properties.
+class message : public proton_handle<pn_message_t>
+{
+ public:
+ PN_CPP_EXTERN message();
+ PN_CPP_EXTERN message(pn_message_t *);
+ PN_CPP_EXTERN message(const message&);
+ PN_CPP_EXTERN message& operator=(const message&);
+ PN_CPP_EXTERN ~message();
+
+ PN_CPP_EXTERN pn_message_t *pn_message() const;
+
+ PN_CPP_EXTERN void id(const value& id);
+ PN_CPP_EXTERN value id() const;
+
+ PN_CPP_EXTERN void user(const std::string &user);
+ PN_CPP_EXTERN std::string user() const;
+
+ PN_CPP_EXTERN void address(const std::string &addr);
+ PN_CPP_EXTERN std::string address() const;
+
+ PN_CPP_EXTERN void subject(const std::string &s);
+ PN_CPP_EXTERN std::string subject() const;
+
+ PN_CPP_EXTERN void reply_to(const std::string &s);
+ PN_CPP_EXTERN std::string reply_to() const;
+
+ PN_CPP_EXTERN void correlation_id(const value&);
+ PN_CPP_EXTERN value correlation_id() const;
+
+ PN_CPP_EXTERN void content_type(const std::string &s);
+ PN_CPP_EXTERN std::string content_type() const;
+
+ PN_CPP_EXTERN void content_encoding(const std::string &s);
+ PN_CPP_EXTERN std::string content_encoding() const;
+
+ PN_CPP_EXTERN void expiry(amqp_timestamp t);
+ PN_CPP_EXTERN amqp_timestamp expiry() const;
+
+ PN_CPP_EXTERN void creation_time(amqp_timestamp t);
+ PN_CPP_EXTERN amqp_timestamp creation_time() const;
+
+ PN_CPP_EXTERN void group_id(const std::string &s);
+ PN_CPP_EXTERN std::string group_id() const;
+
+ PN_CPP_EXTERN void reply_togroup_id(const std::string &s);
+ PN_CPP_EXTERN std::string reply_togroup_id() const;
+
+ /** Set the body to an AMQP value. */
+ PN_CPP_EXTERN void body(const value&);
+
+ /** Template to convert any type to a value and set as the body */
+ template <class T> void body(const T& v) { body(value(v)); }
+
+ /** Set the body to a sequence of sections containing AMQP values. */
+ PN_CPP_EXTERN void body(const values&);
+
+ PN_CPP_EXTERN const values& body() const;
+
+ PN_CPP_EXTERN values& body(); ///< Allows in-place modification of body sections.
+
+ // FIXME aconway 2015-06-17: consistent and flexible treatment of buffers.
+ // Allow convenient std::string encoding/decoding (with re-use of existing
+ // string capacity) but also need to allow encoding/decoding of non-string
+ // buffers. Introduce a buffer type with begin/end pointers?
+
+ PN_CPP_EXTERN void encode(std::string &data);
+ PN_CPP_EXTERN std::string encode();
+ PN_CPP_EXTERN void decode(const std::string &data);
+
+ private:
+ mutable values body_;
+ friend class proton_impl_ref<message>;
+};
+
+}
+
+#endif /*!PROTON_CPP_MESSAGE_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/messaging_adapter.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/messaging_adapter.hpp b/proton-c/bindings/cpp/include/proton/messaging_adapter.hpp
new file mode 100644
index 0000000..3486b97
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/messaging_adapter.hpp
@@ -0,0 +1,76 @@
+#ifndef PROTON_CPP_MESSAGING_ADAPTER_H
+#define PROTON_CPP_MESSAGING_ADAPTER_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/proton_handler.hpp"
+#include "proton/messaging_handler.hpp"
+
+#include "proton/messaging_event.hpp"
+#include "proton/event.h"
+#include "proton/reactor.h"
+
+namespace proton {
+
+// Combine's Python's: endpoint_state_handler, incoming_message_handler, outgoing_message_handler
+
+class messaging_adapter : public messaging_handler
+{
+ public:
+ PN_CPP_EXTERN messaging_adapter(messaging_handler &delegate);
+ PN_CPP_EXTERN virtual ~messaging_adapter();
+ PN_CPP_EXTERN virtual void on_reactor_init(event &e);
+ PN_CPP_EXTERN virtual void on_link_flow(event &e);
+ PN_CPP_EXTERN virtual void on_delivery(event &e);
+ PN_CPP_EXTERN virtual void on_unhandled(event &e);
+ PN_CPP_EXTERN virtual void on_connection_closed(event &e);
+ PN_CPP_EXTERN virtual void on_connection_closing(event &e);
+ PN_CPP_EXTERN virtual void on_connection_error(event &e);
+ PN_CPP_EXTERN virtual void on_connection_local_open(event &e);
+ PN_CPP_EXTERN virtual void on_connection_remote_open(event &e);
+ PN_CPP_EXTERN virtual void on_connection_remote_close(event &e);
+ PN_CPP_EXTERN virtual void on_connection_opened(event &e);
+ PN_CPP_EXTERN virtual void on_connection_opening(event &e);
+ PN_CPP_EXTERN virtual void on_session_closed(event &e);
+ PN_CPP_EXTERN virtual void on_session_closing(event &e);
+ PN_CPP_EXTERN virtual void on_session_error(event &e);
+ PN_CPP_EXTERN virtual void on_session_local_open(event &e);
+ PN_CPP_EXTERN virtual void on_session_remote_open(event &e);
+ PN_CPP_EXTERN virtual void on_session_remote_close(event &e);
+ PN_CPP_EXTERN virtual void on_session_opened(event &e);
+ PN_CPP_EXTERN virtual void on_session_opening(event &e);
+ PN_CPP_EXTERN virtual void on_link_closed(event &e);
+ PN_CPP_EXTERN virtual void on_link_closing(event &e);
+ PN_CPP_EXTERN virtual void on_link_error(event &e);
+ PN_CPP_EXTERN virtual void on_link_local_open(event &e);
+ PN_CPP_EXTERN virtual void on_link_remote_open(event &e);
+ PN_CPP_EXTERN virtual void on_link_remote_close(event &e);
+ PN_CPP_EXTERN virtual void on_link_opened(event &e);
+ PN_CPP_EXTERN virtual void on_link_opening(event &e);
+ PN_CPP_EXTERN virtual void on_transport_tail_closed(event &e);
+ private:
+ messaging_handler &delegate_; // The handler for generated messaging_event's
+};
+
+}
+
+#endif /*!PROTON_CPP_MESSAGING_ADAPTER_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/messaging_event.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/messaging_event.hpp b/proton-c/bindings/cpp/include/proton/messaging_event.hpp
new file mode 100644
index 0000000..62f0160
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/messaging_event.hpp
@@ -0,0 +1,98 @@
+#ifndef PROTON_CPP_MESSAGINGEVENT_H
+#define PROTON_CPP_MESSAGINGEVENT_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/proton_event.hpp"
+#include "proton/link.hpp"
+
+namespace proton {
+
+class handler;
+class container;
+class connection;
+
+typedef enum {
+ PN_MESSAGING_PROTON = 0, // Wrapped pn_event_t
+ // Covenience events for C++ messaging_handlers
+ PN_MESSAGING_ABORT,
+ PN_MESSAGING_ACCEPTED,
+ PN_MESSAGING_COMMIT,
+ PN_MESSAGING_CONNECTION_CLOSED,
+ PN_MESSAGING_CONNECTION_CLOSING,
+ PN_MESSAGING_CONNECTION_ERROR,
+ PN_MESSAGING_CONNECTION_OPENED,
+ PN_MESSAGING_CONNECTION_OPENING,
+ PN_MESSAGING_DISCONNECTED,
+ PN_MESSAGING_FETCH,
+ PN_MESSAGING_Id_LOADED,
+ PN_MESSAGING_LINK_CLOSED,
+ PN_MESSAGING_LINK_CLOSING,
+ PN_MESSAGING_LINK_OPENED,
+ PN_MESSAGING_LINK_OPENING,
+ PN_MESSAGING_LINK_ERROR,
+ PN_MESSAGING_MESSAGE,
+ PN_MESSAGING_QUIT,
+ PN_MESSAGING_RECORD_INSERTED,
+ PN_MESSAGING_RECORDS_LOADED,
+ PN_MESSAGING_REJECTED,
+ PN_MESSAGING_RELEASED,
+ PN_MESSAGING_REQUEST,
+ PN_MESSAGING_RESPONSE,
+ PN_MESSAGING_SENDABLE,
+ PN_MESSAGING_SESSION_CLOSED,
+ PN_MESSAGING_SESSION_CLOSING,
+ PN_MESSAGING_SESSION_OPENED,
+ PN_MESSAGING_SESSION_OPENING,
+ PN_MESSAGING_SESSION_ERROR,
+ PN_MESSAGING_SETTLED,
+ PN_MESSAGING_START,
+ PN_MESSAGING_TIMER,
+ PN_MESSAGING_TRANSACTION_ABORTED,
+ PN_MESSAGING_TRANSACTION_COMMITTED,
+ PN_MESSAGING_TRANSACTION_DECLARED,
+ PN_MESSAGING_TRANSPORT_CLOSED
+} messaging_event_type_t;
+
+class messaging_event : public proton_event
+{
+ public:
+ messaging_event(pn_event_t *ce, pn_event_type_t t, class container &c);
+ messaging_event(messaging_event_type_t t, proton_event &parent);
+ ~messaging_event();
+ virtual PN_CPP_EXTERN void dispatch(handler &h);
+ virtual PN_CPP_EXTERN class connection &connection();
+ virtual PN_CPP_EXTERN class sender sender();
+ virtual PN_CPP_EXTERN class receiver receiver();
+ virtual PN_CPP_EXTERN class link link();
+ virtual PN_CPP_EXTERN class message message();
+ virtual PN_CPP_EXTERN void message(class message &);
+ private:
+ messaging_event_type_t messaging_type_;
+ proton_event *parent_event_;
+ class message *message_;
+ messaging_event operator=(const messaging_event&);
+ messaging_event(const messaging_event&);
+};
+
+}
+
+#endif /*!PROTON_CPP_MESSAGINGEVENT_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/messaging_handler.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/messaging_handler.hpp b/proton-c/bindings/cpp/include/proton/messaging_handler.hpp
new file mode 100644
index 0000000..9380755
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/messaging_handler.hpp
@@ -0,0 +1,96 @@
+#ifndef PROTON_CPP_MESSAGING_HANDLER_H
+#define PROTON_CPP_MESSAGING_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/proton_handler.hpp"
+#include "proton/acking.hpp"
+#include "proton/event.h"
+
+namespace proton {
+
+class event;
+class messaging_adapter;
+
+class messaging_handler : public proton_handler , public acking
+{
+ public:
+ PN_CPP_EXTERN messaging_handler(int prefetch=10, bool auto_accept=true, bool auto_settle=true,
+ bool peer_close_isError=false);
+ PN_CPP_EXTERN virtual ~messaging_handler();
+
+ PN_CPP_EXTERN virtual void on_abort(event &e);
+ PN_CPP_EXTERN virtual void on_accepted(event &e);
+ PN_CPP_EXTERN virtual void on_commit(event &e);
+ PN_CPP_EXTERN virtual void on_connection_closed(event &e);
+ PN_CPP_EXTERN virtual void on_connection_closing(event &e);
+ PN_CPP_EXTERN virtual void on_connection_error(event &e);
+ PN_CPP_EXTERN virtual void on_connection_opening(event &e);
+ PN_CPP_EXTERN virtual void on_connection_opened(event &e);
+ PN_CPP_EXTERN virtual void on_disconnected(event &e);
+ PN_CPP_EXTERN virtual void on_fetch(event &e);
+ PN_CPP_EXTERN virtual void on_idLoaded(event &e);
+ PN_CPP_EXTERN virtual void on_link_closed(event &e);
+ PN_CPP_EXTERN virtual void on_link_closing(event &e);
+ PN_CPP_EXTERN virtual void on_link_error(event &e);
+ PN_CPP_EXTERN virtual void on_link_opened(event &e);
+ PN_CPP_EXTERN virtual void on_link_opening(event &e);
+ PN_CPP_EXTERN virtual void on_message(event &e);
+ PN_CPP_EXTERN virtual void on_quit(event &e);
+ PN_CPP_EXTERN virtual void on_record_inserted(event &e);
+ PN_CPP_EXTERN virtual void on_records_loaded(event &e);
+ PN_CPP_EXTERN virtual void on_rejected(event &e);
+ PN_CPP_EXTERN virtual void on_released(event &e);
+ PN_CPP_EXTERN virtual void on_request(event &e);
+ PN_CPP_EXTERN virtual void on_response(event &e);
+ PN_CPP_EXTERN virtual void on_sendable(event &e);
+ PN_CPP_EXTERN virtual void on_session_closed(event &e);
+ PN_CPP_EXTERN virtual void on_session_closing(event &e);
+ PN_CPP_EXTERN virtual void on_session_error(event &e);
+ PN_CPP_EXTERN virtual void on_session_opened(event &e);
+ PN_CPP_EXTERN virtual void on_session_opening(event &e);
+ PN_CPP_EXTERN virtual void on_settled(event &e);
+ PN_CPP_EXTERN virtual void on_start(event &e);
+ PN_CPP_EXTERN virtual void on_timer(event &e);
+ PN_CPP_EXTERN virtual void on_transaction_aborted(event &e);
+ PN_CPP_EXTERN virtual void on_transaction_committed(event &e);
+ PN_CPP_EXTERN virtual void on_transaction_declared(event &e);
+ PN_CPP_EXTERN virtual void on_transport_closed(event &e);
+
+ private:
+ int prefetch_;
+ bool auto_accept_;
+ bool auto_settle_;
+ bool peer_close_iserror_;
+ messaging_adapter *messaging_adapter_;
+ handler *flow_controller_;
+ PN_CPP_EXTERN messaging_handler(
+ bool raw_handler, int prefetch=10, bool auto_accept=true,
+ bool auto_settle=true, bool peer_close_isError=false);
+ friend class container_impl;
+ friend class messaging_adapter;
+ PN_CPP_EXTERN void create_helpers();
+};
+
+}
+
+#endif /*!PROTON_CPP_MESSAGING_HANDLER_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/proton_event.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/proton_event.hpp b/proton-c/bindings/cpp/include/proton/proton_event.hpp
new file mode 100644
index 0000000..c4bd5e8
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/proton_event.hpp
@@ -0,0 +1,55 @@
+#ifndef PROTON_CPP_PROTONEVENT_H
+#define PROTON_CPP_PROTONEVENT_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/event.hpp"
+#include "proton/link.hpp"
+
+namespace proton {
+
+class handler;
+class container;
+class connection;
+class container;
+
+class proton_event : public event
+{
+ public:
+ virtual PN_CPP_EXTERN void dispatch(handler &h);
+ virtual PN_CPP_EXTERN class container &container();
+ virtual PN_CPP_EXTERN class connection &connection();
+ virtual PN_CPP_EXTERN class sender sender();
+ virtual PN_CPP_EXTERN class receiver receiver();
+ virtual PN_CPP_EXTERN class link link();
+ PN_CPP_EXTERN int type();
+ PN_CPP_EXTERN pn_event_t* pn_event();
+ protected:
+ PN_CPP_EXTERN proton_event(pn_event_t *ce, pn_event_type_t t, class container &c);
+ private:
+ pn_event_t *pn_event_;
+ int type_;
+ class container &container_;
+};
+
+}
+
+#endif /*!PROTON_CPP_PROTONEVENT_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/proton_handle.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/proton_handle.hpp b/proton-c/bindings/cpp/include/proton/proton_handle.hpp
new file mode 100644
index 0000000..5799bf6
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/proton_handle.hpp
@@ -0,0 +1,67 @@
+#ifndef PROTON_CPP_PROTONHANDLE_H
+#define PROTON_CPP_PROTONHANDLE_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 {
+
+template <class> class proton_impl_ref;
+
+/**
+ * See handle.h. Similar but for lightly wrapped Proton pn_object_t targets.
+ */
+template <class T> class proton_handle {
+ public:
+
+ /**@return true if handle is valid, i.e. not null. */
+ bool is_valid() const { return impl_; }
+
+ /**@return true if handle is null. It is an error to call any function on a null handle. */
+ bool is_null() const { return !impl_; }
+
+ /** Conversion to bool supports idiom if (handle) { handle->... } */
+ operator bool() const { return impl_; }
+
+ /** Operator ! supports idiom if (!handle) { do_if_handle_is_null(); } */
+ bool operator !() const { return !impl_; }
+
+ void swap(proton_handle<T>& h) { T* t = h.impl_; h.impl_ = impl_; impl_ = t; }
+
+ private:
+ // Not implemented, subclasses must implement.
+ proton_handle(const proton_handle&);
+ proton_handle& operator=(const proton_handle&);
+
+ protected:
+ typedef T Impl;
+ proton_handle() : impl_() {}
+
+ mutable Impl* impl_;
+
+ friend class proton_impl_ref<T>;
+};
+
+}
+
+#endif /*!PROTON_CPP_PROTONHANDLE_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/proton_handler.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/proton_handler.hpp b/proton-c/bindings/cpp/include/proton/proton_handler.hpp
new file mode 100644
index 0000000..24384a8
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/proton_handler.hpp
@@ -0,0 +1,81 @@
+#ifndef PROTON_CPP_PROTONHANDLER_H
+#define PROTON_CPP_PROTONHANDLER_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/handler.hpp"
+
+namespace proton {
+
+class event;
+class proton_event;
+
+class proton_handler : public handler
+{
+ public:
+ PN_CPP_EXTERN proton_handler();
+ PN_CPP_EXTERN virtual void on_reactor_init(event &e);
+ PN_CPP_EXTERN virtual void on_reactor_quiesced(event &e);
+ PN_CPP_EXTERN virtual void on_reactor_final(event &e);
+ PN_CPP_EXTERN virtual void on_timer_task(event &e);
+ PN_CPP_EXTERN virtual void on_connection_init(event &e);
+ PN_CPP_EXTERN virtual void on_connection_bound(event &e);
+ PN_CPP_EXTERN virtual void on_connection_unbound(event &e);
+ PN_CPP_EXTERN virtual void on_connection_local_open(event &e);
+ PN_CPP_EXTERN virtual void on_connection_local_close(event &e);
+ PN_CPP_EXTERN virtual void on_connection_remote_open(event &e);
+ PN_CPP_EXTERN virtual void on_connection_remote_close(event &e);
+ PN_CPP_EXTERN virtual void on_connection_final(event &e);
+ PN_CPP_EXTERN virtual void on_session_init(event &e);
+ PN_CPP_EXTERN virtual void on_session_local_open(event &e);
+ PN_CPP_EXTERN virtual void on_session_local_close(event &e);
+ PN_CPP_EXTERN virtual void on_session_remote_open(event &e);
+ PN_CPP_EXTERN virtual void on_session_remote_close(event &e);
+ PN_CPP_EXTERN virtual void on_session_final(event &e);
+ PN_CPP_EXTERN virtual void on_link_init(event &e);
+ PN_CPP_EXTERN virtual void on_link_local_open(event &e);
+ PN_CPP_EXTERN virtual void on_link_local_close(event &e);
+ PN_CPP_EXTERN virtual void on_link_local_detach(event &e);
+ PN_CPP_EXTERN virtual void on_link_remote_open(event &e);
+ PN_CPP_EXTERN virtual void on_link_remote_close(event &e);
+ PN_CPP_EXTERN virtual void on_link_remote_detach(event &e);
+ PN_CPP_EXTERN virtual void on_link_flow(event &e);
+ PN_CPP_EXTERN virtual void on_link_final(event &e);
+ PN_CPP_EXTERN virtual void on_delivery(event &e);
+ PN_CPP_EXTERN virtual void on_transport(event &e);
+ PN_CPP_EXTERN virtual void on_transport_error(event &e);
+ PN_CPP_EXTERN virtual void on_transport_head_closed(event &e);
+ PN_CPP_EXTERN virtual void on_transport_tail_closed(event &e);
+ PN_CPP_EXTERN virtual void on_transport_closed(event &e);
+ PN_CPP_EXTERN virtual void on_selectable_init(event &e);
+ PN_CPP_EXTERN virtual void on_selectable_updated(event &e);
+ PN_CPP_EXTERN virtual void on_selectable_readable(event &e);
+ PN_CPP_EXTERN virtual void on_selectable_writable(event &e);
+ PN_CPP_EXTERN virtual void on_selectable_expired(event &e);
+ PN_CPP_EXTERN virtual void on_selectable_error(event &e);
+ PN_CPP_EXTERN virtual void on_selectable_final(event &e);
+
+ PN_CPP_EXTERN virtual void on_unhandled(event &e);
+};
+
+}
+
+#endif /*!PROTON_CPP_PROTONHANDLER_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/receiver.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/receiver.hpp b/proton-c/bindings/cpp/include/proton/receiver.hpp
new file mode 100644
index 0000000..be19358
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/receiver.hpp
@@ -0,0 +1,46 @@
+#ifndef PROTON_CPP_RECEIVER_H
+#define PROTON_CPP_RECEIVER_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/link.hpp"
+#include "proton/types.h"
+#include <string>
+
+struct pn_connection_t;
+
+namespace proton {
+
+class receiver : public link
+{
+ public:
+ PN_CPP_EXTERN receiver(pn_link_t *lnk);
+ PN_CPP_EXTERN receiver();
+ PN_CPP_EXTERN receiver(const link& c);
+ protected:
+ PN_CPP_EXTERN virtual void verify_type(pn_link_t *l);
+};
+
+}
+
+#endif /*!PROTON_CPP_RECEIVER_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/sender.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/sender.hpp b/proton-c/bindings/cpp/include/proton/sender.hpp
new file mode 100644
index 0000000..1d35c42
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/sender.hpp
@@ -0,0 +1,51 @@
+#ifndef PROTON_CPP_SENDER_H
+#define PROTON_CPP_SENDER_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/delivery.hpp"
+#include "proton/link.hpp"
+#include "proton/message.hpp"
+
+#include "proton/types.h"
+#include <string>
+
+struct pn_connection_t;
+
+namespace proton {
+
+
+class sender : public link
+{
+ public:
+ PN_CPP_EXTERN sender(pn_link_t *lnk=0);
+ PN_CPP_EXTERN sender(const link& c);
+ PN_CPP_EXTERN delivery send(message &m);
+
+ protected:
+ PN_CPP_EXTERN virtual void verify_type(pn_link_t *l);
+};
+
+
+}
+
+#endif /*!PROTON_CPP_SENDER_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/session.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/session.hpp b/proton-c/bindings/cpp/include/proton/session.hpp
new file mode 100644
index 0000000..b0117c0
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/session.hpp
@@ -0,0 +1,60 @@
+#ifndef PROTON_CPP_SESSION_H
+#define PROTON_CPP_SESSION_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/link.hpp"
+
+#include "proton/types.h"
+#include "proton/link.h"
+#include <string>
+
+struct pn_connection_t;
+
+namespace proton {
+
+class container;
+class handler;
+class transport;
+
+ class session : public endpoint, public proton_handle<pn_session_t>
+{
+ public:
+ PN_CPP_EXTERN session(pn_session_t *s);
+ PN_CPP_EXTERN session();
+ PN_CPP_EXTERN ~session();
+ PN_CPP_EXTERN void open();
+ PN_CPP_EXTERN session(const session&);
+ PN_CPP_EXTERN session& operator=(const session&);
+ PN_CPP_EXTERN void close();
+ PN_CPP_EXTERN pn_session_t *pn_session();
+ PN_CPP_EXTERN virtual class connection &connection();
+ PN_CPP_EXTERN receiver create_receiver(std::string name);
+ PN_CPP_EXTERN sender create_sender(std::string name);
+ private:
+ friend class proton_impl_ref<session>;
+};
+
+}
+
+#endif /*!PROTON_CPP_SESSION_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/terminus.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/terminus.hpp b/proton-c/bindings/cpp/include/proton/terminus.hpp
new file mode 100644
index 0000000..22c61d0
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/terminus.hpp
@@ -0,0 +1,83 @@
+#ifndef PROTON_CPP_TERMINUS_H
+#define PROTON_CPP_TERMINUS_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/link.hpp"
+
+#include "proton/link.h"
+#include <string>
+
+namespace proton {
+
+class link;
+
+class terminus : public proton_handle<pn_terminus_t>
+{
+ public:
+ enum type_t {
+ TYPE_UNSPECIFIED = PN_UNSPECIFIED,
+ SOURCE = PN_SOURCE,
+ TARGET = PN_TARGET,
+ COORDINATOR = PN_COORDINATOR
+ };
+
+ enum expiry_policy_t {
+ NONDURABLE = PN_NONDURABLE,
+ CONFIGURATION = PN_CONFIGURATION,
+ DELIVERIES = PN_DELIVERIES
+ };
+
+ enum distribution_mode_t {
+ MODE_UNSPECIFIED = PN_DIST_MODE_UNSPECIFIED,
+ COPY = PN_DIST_MODE_COPY,
+ MOVE = PN_DIST_MODE_MOVE
+ };
+
+
+ PN_CPP_EXTERN terminus();
+ PN_CPP_EXTERN ~terminus();
+ PN_CPP_EXTERN terminus(const terminus&);
+ PN_CPP_EXTERN terminus& operator=(const terminus&);
+ PN_CPP_EXTERN pn_terminus_t *pn_terminus();
+ PN_CPP_EXTERN type_t type();
+ PN_CPP_EXTERN void type(type_t);
+ PN_CPP_EXTERN expiry_policy_t expiry_policy();
+ PN_CPP_EXTERN void expiry_policy(expiry_policy_t);
+ PN_CPP_EXTERN distribution_mode_t distribution_mode();
+ PN_CPP_EXTERN void distribution_mode(distribution_mode_t);
+ PN_CPP_EXTERN std::string address();
+ PN_CPP_EXTERN void address(std::string &);
+ PN_CPP_EXTERN bool is_dynamic();
+ PN_CPP_EXTERN void dynamic(bool);
+
+ private:
+ link *link_;
+ PN_CPP_EXTERN terminus(pn_terminus_t *, link *);
+ friend class link;
+ friend class proton_impl_ref<terminus>;
+};
+
+
+}
+
+#endif /*!PROTON_CPP_TERMINUS_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/transport.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/transport.hpp b/proton-c/bindings/cpp/include/proton/transport.hpp
new file mode 100644
index 0000000..8d0774f
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/transport.hpp
@@ -0,0 +1,52 @@
+#ifndef PROTON_CPP_TRANSPORT_H
+#define PROTON_CPP_TRANSPORT_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/transport.h"
+#include <string>
+
+struct pn_connection_t;
+
+namespace proton {
+
+class connection;
+
+class transport
+{
+ public:
+ PN_CPP_EXTERN transport();
+ PN_CPP_EXTERN ~transport();
+ PN_CPP_EXTERN void bind(connection &c);
+
+ class connection* connection() const { return connection_; }
+ pn_transport_t* pn_transport() const { return pn_transport_; }
+
+ private:
+ class connection *connection_;
+ pn_transport_t *pn_transport_;
+};
+
+
+}
+
+#endif /*!PROTON_CPP_TRANSPORT_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/include/proton/type_traits.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/type_traits.hpp b/proton-c/bindings/cpp/include/proton/type_traits.hpp
index f635128..f30d980 100644
--- a/proton-c/bindings/cpp/include/proton/type_traits.hpp
+++ b/proton-c/bindings/cpp/include/proton/type_traits.hpp
@@ -1,5 +1,5 @@
-#ifndef ENABLE_IF_HPP
-#define ENABLE_IF_HPP
+#ifndef ENABLE_If_HPP
+#define ENABLE_If_HPP
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -21,10 +21,6 @@
#include "proton/types.hpp"
-/**@file
- * Type traits used for type conversions.
- * @internal
- */
#if defined(__cplusplus) && __cplusplus >= 201100
#include <type_traits>
#else
@@ -68,49 +64,49 @@ template <> struct is_signed<signed long> : public true_type {};
namespace proton {
// Metafunction returning exact AMQP type associated with a C++ type
-template <class T> struct TypeIdOf;
-template<> struct TypeIdOf<Null> { static const TypeId value=NULL_; };
-template<> struct TypeIdOf<Bool> { static const TypeId value=BOOL; };
-template<> struct TypeIdOf<Ubyte> { static const TypeId value=UBYTE; };
-template<> struct TypeIdOf<Byte> { static const TypeId value=BYTE; };
-template<> struct TypeIdOf<Ushort> { static const TypeId value=USHORT; };
-template<> struct TypeIdOf<Short> { static const TypeId value=SHORT; };
-template<> struct TypeIdOf<Uint> { static const TypeId value=UINT; };
-template<> struct TypeIdOf<Int> { static const TypeId value=INT; };
-template<> struct TypeIdOf<Char> { static const TypeId value=CHAR; };
-template<> struct TypeIdOf<Ulong> { static const TypeId value=ULONG; };
-template<> struct TypeIdOf<Long> { static const TypeId value=LONG; };
-template<> struct TypeIdOf<Timestamp> { static const TypeId value=TIMESTAMP; };
-template<> struct TypeIdOf<Float> { static const TypeId value=FLOAT; };
-template<> struct TypeIdOf<Double> { static const TypeId value=DOUBLE; };
-template<> struct TypeIdOf<Decimal32> { static const TypeId value=DECIMAL32; };
-template<> struct TypeIdOf<Decimal64> { static const TypeId value=DECIMAL64; };
-template<> struct TypeIdOf<Decimal128> { static const TypeId value=DECIMAL128; };
-template<> struct TypeIdOf<Uuid> { static const TypeId value=UUID; };
-template<> struct TypeIdOf<Binary> { static const TypeId value=BINARY; };
-template<> struct TypeIdOf<String> { static const TypeId value=STRING; };
-template<> struct TypeIdOf<Symbol> { static const TypeId value=SYMBOL; };
-
-template <class T, class Enable=void> struct HasTypeId { static const bool value = false; };
-template <class T> struct HasTypeId<T, typename std::enable_if<TypeIdOf<T>::value>::type> {
+template <class T> struct type_idOf;
+template<> struct type_idOf<amqp_null> { static const type_id value=NULl_; };
+template<> struct type_idOf<amqp_bool> { static const type_id value=BOOL; };
+template<> struct type_idOf<amqp_ubyte> { static const type_id value=UBYTE; };
+template<> struct type_idOf<amqp_byte> { static const type_id value=BYTE; };
+template<> struct type_idOf<amqp_ushort> { static const type_id value=USHORT; };
+template<> struct type_idOf<amqp_short> { static const type_id value=SHORT; };
+template<> struct type_idOf<amqp_uint> { static const type_id value=UINT; };
+template<> struct type_idOf<amqp_int> { static const type_id value=INT; };
+template<> struct type_idOf<amqp_char> { static const type_id value=CHAR; };
+template<> struct type_idOf<amqp_ulong> { static const type_id value=ULONG; };
+template<> struct type_idOf<amqp_long> { static const type_id value=LONG; };
+template<> struct type_idOf<amqp_timestamp> { static const type_id value=TIMESTAMP; };
+template<> struct type_idOf<amqp_float> { static const type_id value=FLOAT; };
+template<> struct type_idOf<amqp_double> { static const type_id value=DOUBLE; };
+template<> struct type_idOf<amqp_decimal32> { static const type_id value=DECIMAL32; };
+template<> struct type_idOf<amqp_decimal64> { static const type_id value=DECIMAL64; };
+template<> struct type_idOf<amqp_decimal128> { static const type_id value=DECIMAL128; };
+template<> struct type_idOf<amqp_uuid> { static const type_id value=UUID; };
+template<> struct type_idOf<amqp_binary> { static const type_id value=BINARY; };
+template<> struct type_idOf<amqp_string> { static const type_id value=STRING; };
+template<> struct type_idOf<amqp_symbol> { static const type_id value=SYMBOL; };
+
+template <class T, class Enable=void> struct has_type_id { static const bool value = false; };
+template <class T> struct has_type_id<T, typename std::enable_if<type_idOf<T>::value>::type> {
static const bool value = true;
};
-// Map to known integer types by sizeof and signedness.
-template<size_t N, bool S> struct IntegerType;
-template<> struct IntegerType<1, true> { typedef Byte type; };
-template<> struct IntegerType<2, true> { typedef Short type; };
-template<> struct IntegerType<4, true> { typedef Int type; };
-template<> struct IntegerType<8, true> { typedef Long type; };
-template<> struct IntegerType<1, false> { typedef Ubyte type; };
-template<> struct IntegerType<2, false> { typedef Ushort type; };
-template<> struct IntegerType<4, false> { typedef Uint type; };
-template<> struct IntegerType<8, false> { typedef Ulong type; };
-
-// True if T is an integer type that does not have a TypeId mapping.
-template <class T> struct IsUnknownInteger {
- static const bool value = !HasTypeId<T>::value && std::is_integral<T>::value;
+// amqp_map to known integer types by sizeof and signedness.
+template<size_t N, bool S> struct integer_type;
+template<> struct integer_type<1, true> { typedef amqp_byte type; };
+template<> struct integer_type<2, true> { typedef amqp_short type; };
+template<> struct integer_type<4, true> { typedef amqp_int type; };
+template<> struct integer_type<8, true> { typedef amqp_long type; };
+template<> struct integer_type<1, false> { typedef amqp_ubyte type; };
+template<> struct integer_type<2, false> { typedef amqp_ushort type; };
+template<> struct integer_type<4, false> { typedef amqp_uint type; };
+template<> struct integer_type<8, false> { typedef amqp_ulong type; };
+
+// True if T is an integer type that does not have a type_id mapping.
+template <class T> struct is_unknown_integer {
+ static const bool value = !has_type_id<T>::value && std::is_integral<T>::value;
};
}
-#endif // ENABLE_IF_HPP
+#endif // ENABLE_If_HPP
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[4/8] qpid-proton git commit: PROTON-865: Renaming to follow
boost/std library C++ naming conventions.
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/Delivery.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Delivery.cpp b/proton-c/bindings/cpp/src/Delivery.cpp
deleted file mode 100644
index 60cd0d3..0000000
--- a/proton-c/bindings/cpp/src/Delivery.cpp
+++ /dev/null
@@ -1,58 +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/Delivery.hpp"
-#include "proton/delivery.h"
-#include "ProtonImplRef.hpp"
-
-namespace proton {
-namespace reactor {
-
-template class ProtonHandle<pn_delivery_t>;
-typedef ProtonImplRef<Delivery> PI;
-
-Delivery::Delivery(pn_delivery_t *p) {
- PI::ctor(*this, p);
-}
-Delivery::Delivery() {
- PI::ctor(*this, 0);
-}
-Delivery::Delivery(const Delivery& c) : ProtonHandle<pn_delivery_t>() {
- PI::copy(*this, c);
-}
-Delivery& Delivery::operator=(const Delivery& c) {
- return PI::assign(*this, c);
-}
-Delivery::~Delivery() {
- PI::dtor(*this);
-}
-
-bool Delivery::settled() {
- return pn_delivery_settled(impl);
-}
-
-void Delivery::settle() {
- pn_delivery_settle(impl);
-}
-
-pn_delivery_t *Delivery::getPnDelivery() { return impl; }
-
-}} // namespace proton::reactor
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/Duration.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Duration.cpp b/proton-c/bindings/cpp/src/Duration.cpp
deleted file mode 100644
index b14be50..0000000
--- a/proton-c/bindings/cpp/src/Duration.cpp
+++ /dev/null
@@ -1,31 +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/Duration.hpp"
-#include <limits>
-
-namespace proton {
-
-const Duration Duration::FOREVER(std::numeric_limits<std::uint64_t>::max());
-const Duration Duration::IMMEDIATE(0);
-const Duration Duration::SECOND(1000);
-const Duration Duration::MINUTE(SECOND * 60);
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/Encoder.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Encoder.cpp b/proton-c/bindings/cpp/src/Encoder.cpp
deleted file mode 100644
index 551a21a..0000000
--- a/proton-c/bindings/cpp/src/Encoder.cpp
+++ /dev/null
@@ -1,160 +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/Encoder.hpp"
-#include "proton/Value.hpp"
-#include <proton/codec.h>
-#include "proton_bits.hpp"
-#include "Msg.hpp"
-
-namespace proton {
-
-Encoder::Encoder() {}
-Encoder::~Encoder() {}
-
-static const std::string prefix("encode: ");
-EncodeError::EncodeError(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; }
-};
-
-void check(int result, pn_data_t* data) {
- if (result < 0)
- throw EncodeError(errorStr(pn_data_error(data), result));
-}
-}
-
-bool Encoder::encode(char* buffer, size_t& size) {
- SaveState ss(data); // In case of error
- ssize_t result = pn_data_encode(data, buffer, size);
- if (result == PN_OVERFLOW) {
- result = pn_data_encoded_size(data);
- if (result >= 0) {
- size = result;
- return false;
- }
- }
- check(result, data);
- size = result;
- ss.cancel(); // Don't restore state, all is well.
- pn_data_clear(data);
- return true;
-}
-
-void Encoder::encode(std::string& s) {
- size_t size = s.size();
- if (!encode(&s[0], size)) {
- s.resize(size);
- encode(&s[0], size);
- }
-}
-
-std::string Encoder::encode() {
- std::string s;
- encode(s);
- return s;
-}
-
-Encoder& operator<<(Encoder& e, const Start& s) {
- switch (s.type) {
- case ARRAY: pn_data_put_array(e.data, s.isDescribed, pn_type_t(s.element)); break;
- case MAP: pn_data_put_map(e.data); break;
- case LIST: pn_data_put_list(e.data); break;
- case DESCRIBED: pn_data_put_described(e.data); break;
- default:
- throw EncodeError(MSG("" << s.type << " is not a container type"));
- }
- pn_data_enter(e.data);
- return e;
-}
-
-Encoder& operator<<(Encoder& e, Finish) {
- pn_data_exit(e.data);
- return e;
-}
-
-namespace {
-template <class T, class U>
-Encoder& insert(Encoder& e, pn_data_t* data, T& value, int (*put)(pn_data_t*, U)) {
- SaveState ss(data); // Save state in case of error.
- check(put(data, value), data);
- ss.cancel(); // Don't restore state, all is good.
- return e;
-}
-}
-
-Encoder& operator<<(Encoder& e, Null) { pn_data_put_null(e.data); return e; }
-Encoder& operator<<(Encoder& e, Bool value) { return insert(e, e.data, value, pn_data_put_bool); }
-Encoder& operator<<(Encoder& e, Ubyte value) { return insert(e, e.data, value, pn_data_put_ubyte); }
-Encoder& operator<<(Encoder& e, Byte value) { return insert(e, e.data, value, pn_data_put_byte); }
-Encoder& operator<<(Encoder& e, Ushort value) { return insert(e, e.data, value, pn_data_put_ushort); }
-Encoder& operator<<(Encoder& e, Short value) { return insert(e, e.data, value, pn_data_put_short); }
-Encoder& operator<<(Encoder& e, Uint value) { return insert(e, e.data, value, pn_data_put_uint); }
-Encoder& operator<<(Encoder& e, Int value) { return insert(e, e.data, value, pn_data_put_int); }
-Encoder& operator<<(Encoder& e, Char value) { return insert(e, e.data, value, pn_data_put_char); }
-Encoder& operator<<(Encoder& e, Ulong value) { return insert(e, e.data, value, pn_data_put_ulong); }
-Encoder& operator<<(Encoder& e, Long value) { return insert(e, e.data, value, pn_data_put_long); }
-Encoder& operator<<(Encoder& e, Timestamp value) { return insert(e, e.data, value, pn_data_put_timestamp); }
-Encoder& operator<<(Encoder& e, Float value) { return insert(e, e.data, value, pn_data_put_float); }
-Encoder& operator<<(Encoder& e, Double value) { return insert(e, e.data, value, pn_data_put_double); }
-Encoder& operator<<(Encoder& e, Decimal32 value) { return insert(e, e.data, value, pn_data_put_decimal32); }
-Encoder& operator<<(Encoder& e, Decimal64 value) { return insert(e, e.data, value, pn_data_put_decimal64); }
-Encoder& operator<<(Encoder& e, Decimal128 value) { return insert(e, e.data, value, pn_data_put_decimal128); }
-Encoder& operator<<(Encoder& e, Uuid value) { return insert(e, e.data, value, pn_data_put_uuid); }
-Encoder& operator<<(Encoder& e, String value) { return insert(e, e.data, value, pn_data_put_string); }
-Encoder& operator<<(Encoder& e, Symbol value) { return insert(e, e.data, value, pn_data_put_symbol); }
-Encoder& operator<<(Encoder& e, Binary value) { return insert(e, e.data, value, pn_data_put_binary); }
-
-// Meta-function to get the class from the type ID.
-template <TypeId A> struct ClassOf {};
-template<> struct ClassOf<NULL_> { typedef Null ValueType; };
-template<> struct ClassOf<BOOL> { typedef Bool ValueType; };
-template<> struct ClassOf<UBYTE> { typedef Ubyte ValueType; };
-template<> struct ClassOf<BYTE> { typedef Byte ValueType; };
-template<> struct ClassOf<USHORT> { typedef Ushort ValueType; };
-template<> struct ClassOf<SHORT> { typedef Short ValueType; };
-template<> struct ClassOf<UINT> { typedef Uint ValueType; };
-template<> struct ClassOf<INT> { typedef Int ValueType; };
-template<> struct ClassOf<CHAR> { typedef Char ValueType; };
-template<> struct ClassOf<ULONG> { typedef Ulong ValueType; };
-template<> struct ClassOf<LONG> { typedef Long ValueType; };
-template<> struct ClassOf<TIMESTAMP> { typedef Timestamp ValueType; };
-template<> struct ClassOf<FLOAT> { typedef Float ValueType; };
-template<> struct ClassOf<DOUBLE> { typedef Double ValueType; };
-template<> struct ClassOf<DECIMAL32> { typedef Decimal32 ValueType; };
-template<> struct ClassOf<DECIMAL64> { typedef Decimal64 ValueType; };
-template<> struct ClassOf<DECIMAL128> { typedef Decimal128 ValueType; };
-template<> struct ClassOf<UUID> { typedef Uuid ValueType; };
-template<> struct ClassOf<BINARY> { typedef Binary ValueType; };
-template<> struct ClassOf<STRING> { typedef String ValueType; };
-template<> struct ClassOf<SYMBOL> { typedef Symbol ValueType; };
-
-Encoder& operator<<(Encoder& e, const Value& v) {
- if (e.data == v.values.data) throw EncodeError("cannot insert into self");
- check(pn_data_appendn(e.data, v.values.data, 1), e.data);
- return e;
-}
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/Endpoint.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Endpoint.cpp b/proton-c/bindings/cpp/src/Endpoint.cpp
deleted file mode 100644
index ad96e0a..0000000
--- a/proton-c/bindings/cpp/src/Endpoint.cpp
+++ /dev/null
@@ -1,37 +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/Endpoint.hpp"
-#include "proton/Connection.hpp"
-#include "proton/Transport.hpp"
-
-namespace proton {
-namespace reactor {
-
-Endpoint::Endpoint() {}
-
-Endpoint::~Endpoint() {}
-
-Transport &Endpoint::getTransport() {
- return getConnection().getTransport();
-}
-
-}} // namespace proton::reactor
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/Error.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Error.cpp b/proton-c/bindings/cpp/src/Error.cpp
deleted file mode 100644
index 4fd7f43..0000000
--- a/proton-c/bindings/cpp/src/Error.cpp
+++ /dev/null
@@ -1,32 +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/Error.hpp"
-
-namespace proton {
-
-static const std::string prefix("proton: ");
-
-Error::Error(const std::string& msg) throw() : std::runtime_error(prefix+msg) {}
-
-MessageReject::MessageReject(const std::string& msg) throw() : Error(msg) {}
-
-MessageRelease::MessageRelease(const std::string& msg) throw() : Error(msg) {}
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/Event.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Event.cpp b/proton-c/bindings/cpp/src/Event.cpp
deleted file mode 100644
index 69825a8..0000000
--- a/proton-c/bindings/cpp/src/Event.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/reactor.h"
-#include "proton/event.h"
-
-#include "proton/Event.hpp"
-#include "proton/Handler.hpp"
-#include "proton/Error.hpp"
-
-#include "Msg.hpp"
-#include "contexts.hpp"
-
-namespace proton {
-namespace reactor {
-
-Event::Event() {}
-
-Event::~Event() {}
-
-
-Container &Event::getContainer() {
- // Subclasses to override as appropriate
- throw Error(MSG("No container context for event"));
-}
-
-Connection &Event::getConnection() {
- throw Error(MSG("No connection context for Event"));
-}
-
-Sender Event::getSender() {
- throw Error(MSG("No Sender context for event"));
-}
-
-Receiver Event::getReceiver() {
- throw Error(MSG("No Receiver context for event"));
-}
-
-Link Event::getLink() {
- throw Error(MSG("No Link context for event"));
-}
-
-Message Event::getMessage() {
- throw Error(MSG("No message associated with event"));
-}
-
-void Event::setMessage(Message &) {
- throw Error(MSG("Operation not supported for this type of event"));
-}
-
-
-
-}} // namespace proton::reactor
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/Handler.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Handler.cpp b/proton-c/bindings/cpp/src/Handler.cpp
deleted file mode 100644
index 235bff7..0000000
--- a/proton-c/bindings/cpp/src/Handler.cpp
+++ /dev/null
@@ -1,44 +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/Handler.hpp"
-#include "proton/Event.hpp"
-
-namespace proton {
-namespace reactor {
-
-Handler::Handler() {}
-Handler::~Handler() {}
-
-void Handler::onUnhandled(Event &e) {}
-
-void Handler::addChildHandler(Handler &e) {
- childHandlers.push_back(&e);
-}
-
-std::vector<Handler *>::iterator Handler::childHandlersBegin() {
- return childHandlers.begin();
-}
-
-std::vector<Handler *>::iterator Handler::childHandlersEnd() {
- return childHandlers.end();
-}
-
-}} // namespace proton::reactor
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/Link.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Link.cpp b/proton-c/bindings/cpp/src/Link.cpp
deleted file mode 100644
index 76c100c..0000000
--- a/proton-c/bindings/cpp/src/Link.cpp
+++ /dev/null
@@ -1,114 +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/Link.hpp"
-#include "proton/Error.hpp"
-#include "proton/Connection.hpp"
-#include "ConnectionImpl.hpp"
-#include "Msg.hpp"
-#include "contexts.hpp"
-#include "ProtonImplRef.hpp"
-
-#include "proton/connection.h"
-#include "proton/session.h"
-#include "proton/link.h"
-
-namespace proton {
-namespace reactor {
-
-template class ProtonHandle<pn_link_t>;
-typedef ProtonImplRef<Link> PI;
-
-Link::Link(pn_link_t* p) {
- verifyType(p);
- PI::ctor(*this, p);
- if (p) senderLink = pn_link_is_sender(p);
-}
-Link::Link() {
- PI::ctor(*this, 0);
-}
-Link::Link(const Link& c) : ProtonHandle<pn_link_t>() {
- verifyType(impl);
- PI::copy(*this, c);
- senderLink = c.senderLink;
-}
-Link& Link::operator=(const Link& c) {
- verifyType(impl);
- senderLink = c.senderLink;
- return PI::assign(*this, c);
-}
-Link::~Link() { PI::dtor(*this); }
-
-void Link::verifyType(pn_link_t *l) {} // Generic link can be sender or receiver
-
-pn_link_t *Link::getPnLink() const { return impl; }
-
-void Link::open() {
- pn_link_open(impl);
-}
-
-void Link::close() {
- pn_link_close(impl);
-}
-
-bool Link::isSender() {
- return impl && senderLink;
-}
-
-bool Link::isReceiver() {
- return impl && !senderLink;
-}
-
-int Link::getCredit() {
- return pn_link_credit(impl);
-}
-
-Terminus Link::getSource() {
- return Terminus(pn_link_source(impl), this);
-}
-
-Terminus Link::getTarget() {
- return Terminus(pn_link_target(impl), this);
-}
-
-Terminus Link::getRemoteSource() {
- return Terminus(pn_link_remote_source(impl), this);
-}
-
-Terminus Link::getRemoteTarget() {
- return Terminus(pn_link_remote_target(impl), this);
-}
-
-std::string Link::getName() {
- return std::string(pn_link_name(impl));
-}
-
-Connection &Link::getConnection() {
- pn_session_t *s = pn_link_session(impl);
- pn_connection_t *c = pn_session_connection(s);
- return ConnectionImpl::getReactorReference(c);
-}
-
-Link Link::getNext(Endpoint::State mask) {
-
- return Link(pn_link_next(impl, (pn_state_t) mask));
-}
-
-}} // namespace proton::reactor
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/Message.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Message.cpp b/proton-c/bindings/cpp/src/Message.cpp
deleted file mode 100644
index 540ba15..0000000
--- a/proton-c/bindings/cpp/src/Message.cpp
+++ /dev/null
@@ -1,253 +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/Message.hpp"
-#include "proton/Error.hpp"
-#include "proton/message.h"
-#include "Msg.hpp"
-#include "proton_bits.hpp"
-#include "ProtonImplRef.hpp"
-
-#include <cstring>
-
-namespace proton {
-
-namespace reactor {
-template class ProtonHandle<pn_message_t>;
-}
-typedef reactor::ProtonImplRef<Message> PI;
-
-Message::Message() : body_(0) {
- PI::ctor(*this, 0);
-}
-Message::Message(pn_message_t *p) : body_(0) {
- PI::ctor(*this, p);
-}
-Message::Message(const Message& m) : ProtonHandle<pn_message_t>(), body_(0) {
- PI::copy(*this, m);
-}
-
-// FIXME aconway 2015-06-17: Message should be a value type, needs to own pn_message_t
-// and do appropriate _copy and _free operations.
-Message& Message::operator=(const Message& m) {
- return PI::assign(*this, m);
-}
-Message::~Message() { PI::dtor(*this); }
-
-namespace {
-void confirm(pn_message_t * const& p) {
- if (p) return;
- const_cast<pn_message_t*&>(p) = pn_message(); // Correct refcount of 1
- if (!p)
- throw Error(MSG("No memory"));
-}
-
-void check(int err) {
- if (err) throw Error(errorStr(err));
-}
-
-void setValue(pn_data_t* d, const Value& v) {
- Values values(d);
- values.clear();
- values << v;
-}
-
-Value getValue(pn_data_t* d) {
- Values values(d);
- values.rewind();
- return values.get<Value>();
-}
-} // namespace
-
-void Message::id(const Value& id) {
- confirm(impl);
- setValue(pn_message_id(impl), id);
-}
-
-Value Message::id() const {
- confirm(impl);
- return getValue(pn_message_id(impl));
-}
-void Message::user(const std::string &id) {
- confirm(impl);
- check(pn_message_set_user_id(impl, pn_bytes(id)));
-}
-
-std::string Message::user() const {
- confirm(impl);
- return str(pn_message_get_user_id(impl));
-}
-
-void Message::address(const std::string &addr) {
- confirm(impl);
- check(pn_message_set_address(impl, addr.c_str()));
-}
-
-std::string Message::address() const {
- confirm(impl);
- const char* addr = pn_message_get_address(impl);
- return addr ? std::string(addr) : std::string();
-}
-
-void Message::subject(const std::string &s) {
- confirm(impl);
- check(pn_message_set_subject(impl, s.c_str()));
-}
-
-std::string Message::subject() const {
- confirm(impl);
- const char* s = pn_message_get_subject(impl);
- return s ? std::string(s) : std::string();
-}
-
-void Message::replyTo(const std::string &s) {
- confirm(impl);
- check(pn_message_set_reply_to(impl, s.c_str()));
-}
-
-std::string Message::replyTo() const {
- confirm(impl);
- const char* s = pn_message_get_reply_to(impl);
- return s ? std::string(s) : std::string();
-}
-
-void Message::correlationId(const Value& id) {
- confirm(impl);
- setValue(pn_message_correlation_id(impl), id);
-}
-
-Value Message::correlationId() const {
- confirm(impl);
- return getValue(pn_message_correlation_id(impl));
-}
-
-void Message::contentType(const std::string &s) {
- confirm(impl);
- check(pn_message_set_content_type(impl, s.c_str()));
-}
-
-std::string Message::contentType() const {
- confirm(impl);
- const char* s = pn_message_get_content_type(impl);
- return s ? std::string(s) : std::string();
-}
-
-void Message::contentEncoding(const std::string &s) {
- confirm(impl);
- check(pn_message_set_content_encoding(impl, s.c_str()));
-}
-
-std::string Message::contentEncoding() const {
- confirm(impl);
- const char* s = pn_message_get_content_encoding(impl);
- return s ? std::string(s) : std::string();
-}
-
-void Message::expiry(Timestamp t) {
- confirm(impl);
- pn_message_set_expiry_time(impl, t.milliseconds);
-}
-Timestamp Message::expiry() const {
- confirm(impl);
- return Timestamp(pn_message_get_expiry_time(impl));
-}
-
-void Message::creationTime(Timestamp t) {
- confirm(impl);
- pn_message_set_creation_time(impl, t);
-}
-Timestamp Message::creationTime() const {
- confirm(impl);
- return pn_message_get_creation_time(impl);
-}
-
-void Message::groupId(const std::string &s) {
- confirm(impl);
- check(pn_message_set_group_id(impl, s.c_str()));
-}
-
-std::string Message::groupId() const {
- confirm(impl);
- const char* s = pn_message_get_group_id(impl);
- return s ? std::string(s) : std::string();
-}
-
-void Message::replyToGroupId(const std::string &s) {
- confirm(impl);
- check(pn_message_set_reply_to_group_id(impl, s.c_str()));
-}
-
-std::string Message::replyToGroupId() const {
- confirm(impl);
- const char* s = pn_message_get_reply_to_group_id(impl);
- return s ? std::string(s) : std::string();
-}
-
-void Message::body(const Value& v) {
- confirm(impl);
- setValue(pn_message_body(impl), v);
-}
-
-void Message::body(const Values& v) {
- confirm(impl);
- pn_data_copy(pn_message_body(impl), v.data);
-}
-
-const Values& Message::body() const {
- confirm(impl);
- body_.view(pn_message_body(impl));
- return body_;
-}
-
-Values& Message::body() {
- confirm(impl);
- body_.view(pn_message_body(impl));
- return body_;
-}
-
-void Message::encode(std::string &s) {
- confirm(impl);
- size_t sz = s.capacity();
- if (sz < 512) sz = 512;
- while (true) {
- s.resize(sz);
- int err = pn_message_encode(impl, (char *) s.data(), &sz);
- if (err) {
- if (err != PN_OVERFLOW)
- check(err);
- } else {
- s.resize(sz);
- return;
- }
- sz *= 2;
- }
-}
-
-void Message::decode(const std::string &s) {
- confirm(impl);
- check(pn_message_decode(impl, s.data(), s.size()));
-}
-
-pn_message_t *Message::pnMessage() const {
- return impl;
-}
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/MessagingAdapter.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/MessagingAdapter.cpp b/proton-c/bindings/cpp/src/MessagingAdapter.cpp
deleted file mode 100644
index 90ad510..0000000
--- a/proton-c/bindings/cpp/src/MessagingAdapter.cpp
+++ /dev/null
@@ -1,412 +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/MessagingAdapter.hpp"
-#include "proton/MessagingEvent.hpp"
-#include "proton/Sender.hpp"
-#include "proton/Error.hpp"
-#include "Msg.hpp"
-
-#include "proton/link.h"
-#include "proton/handlers.h"
-#include "proton/delivery.h"
-#include "proton/connection.h"
-#include "proton/session.h"
-
-namespace proton {
-namespace reactor {
-MessagingAdapter::MessagingAdapter(MessagingHandler &delegate_) :
- MessagingHandler(true, delegate_.prefetch, delegate_.autoSettle, delegate_.autoAccept, delegate_.peerCloseIsError),
- delegate(delegate_)
-{}
-
-
-MessagingAdapter::~MessagingAdapter(){}
-
-
-void MessagingAdapter::onReactorInit(Event &e) {
- ProtonEvent *pe = dynamic_cast<ProtonEvent*>(&e);
- if (pe) {
- MessagingEvent mevent(PN_MESSAGING_START, *pe);
- delegate.onStart(mevent);
- }
-}
-
-void MessagingAdapter::onLinkFlow(Event &e) {
- ProtonEvent *pe = dynamic_cast<ProtonEvent*>(&e);
- if (pe) {
- pn_event_t *pne = pe->getPnEvent();
- pn_link_t *lnk = pn_event_link(pne);
- if (lnk && pn_link_is_sender(lnk) && pn_link_credit(lnk) > 0) {
- // create onMessage extended event
- MessagingEvent mevent(PN_MESSAGING_SENDABLE, *pe);
- delegate.onSendable(mevent);;
- }
- }
-}
-
-namespace {
-Message receiveMessage(pn_link_t *lnk, pn_delivery_t *dlv) {
- std::string buf;
- size_t sz = pn_delivery_pending(dlv);
- buf.resize(sz);
- ssize_t n = pn_link_recv(lnk, (char *) buf.data(), sz);
- if (n != (ssize_t) sz)
- throw Error(MSG("link read failure"));
- Message m;
- m. decode(buf);
- pn_link_advance(lnk);
- return m;
-}
-} // namespace
-
-void MessagingAdapter::onDelivery(Event &e) {
- ProtonEvent *pe = dynamic_cast<ProtonEvent*>(&e);
- if (pe) {
- pn_event_t *cevent = pe->getPnEvent();
- pn_link_t *lnk = pn_event_link(cevent);
- pn_delivery_t *dlv = pn_event_delivery(cevent);
-
- if (pn_link_is_receiver(lnk)) {
- if (!pn_delivery_partial(dlv) && pn_delivery_readable(dlv)) {
- // generate onMessage
- MessagingEvent mevent(PN_MESSAGING_MESSAGE, *pe);
- Message m(receiveMessage(lnk, dlv));
- mevent.setMessage(m);
- if (pn_link_state(lnk) & PN_LOCAL_CLOSED) {
- if (autoAccept) {
- pn_delivery_update(dlv, PN_RELEASED);
- pn_delivery_settle(dlv);
- }
- }
- else {
- try {
- delegate.onMessage(mevent);
- if (autoAccept) {
- pn_delivery_update(dlv, PN_ACCEPTED);
- pn_delivery_settle(dlv);
- }
- }
- catch (MessageReject &) {
- pn_delivery_update(dlv, PN_REJECTED);
- pn_delivery_settle(dlv);
- }
- catch (MessageRelease &) {
- pn_delivery_update(dlv, PN_REJECTED);
- pn_delivery_settle(dlv);
- }
- }
- }
- else if (pn_delivery_updated(dlv) && pn_delivery_settled(dlv)) {
- MessagingEvent mevent(PN_MESSAGING_SETTLED, *pe);
- delegate.onSettled(mevent);
- }
- } else {
- // Sender
- if (pn_delivery_updated(dlv)) {
- std::uint64_t rstate = pn_delivery_remote_state(dlv);
- if (rstate == PN_ACCEPTED) {
- MessagingEvent mevent(PN_MESSAGING_ACCEPTED, *pe);
- delegate.onAccepted(mevent);
- }
- else if (rstate == PN_REJECTED) {
- MessagingEvent mevent(PN_MESSAGING_REJECTED, *pe);
- delegate.onRejected(mevent);
- }
- else if (rstate == PN_RELEASED || rstate == PN_MODIFIED) {
- MessagingEvent mevent(PN_MESSAGING_RELEASED, *pe);
- delegate.onReleased(mevent);
- }
-
- if (pn_delivery_settled(dlv)) {
- MessagingEvent mevent(PN_MESSAGING_SETTLED, *pe);
- delegate.onSettled(mevent);
- }
- if (autoSettle)
- pn_delivery_settle(dlv);
- }
- }
- }
-}
-
-namespace {
-
-bool isLocalOpen(pn_state_t state) {
- return state & PN_LOCAL_ACTIVE;
-}
-
-bool isLocalUnititialised(pn_state_t state) {
- return state & PN_LOCAL_UNINIT;
-}
-
-bool isLocalClosed(pn_state_t state) {
- return state & PN_LOCAL_CLOSED;
-}
-
-bool isRemoteOpen(pn_state_t state) {
- return state & PN_REMOTE_ACTIVE;
-}
-
-} // namespace
-
-void MessagingAdapter::onLinkRemoteClose(Event &e) {
- ProtonEvent *pe = dynamic_cast<ProtonEvent*>(&e);
- if (pe) {
- pn_event_t *cevent = pe->getPnEvent();
- pn_link_t *lnk = pn_event_link(cevent);
- pn_state_t state = pn_link_state(lnk);
- if (pn_condition_is_set(pn_link_remote_condition(lnk))) {
- MessagingEvent mevent(PN_MESSAGING_LINK_ERROR, *pe);
- onLinkError(mevent);
- }
- else if (isLocalClosed(state)) {
- MessagingEvent mevent(PN_MESSAGING_LINK_CLOSED, *pe);
- onLinkClosed(mevent);
- }
- else {
- MessagingEvent mevent(PN_MESSAGING_LINK_CLOSING, *pe);
- onLinkClosing(mevent);
- }
- pn_link_close(lnk);
- }
-}
-
-void MessagingAdapter::onSessionRemoteClose(Event &e) {
- ProtonEvent *pe = dynamic_cast<ProtonEvent*>(&e);
- if (pe) {
- pn_event_t *cevent = pe->getPnEvent();
- pn_session_t *session = pn_event_session(cevent);
- pn_state_t state = pn_session_state(session);
- if (pn_condition_is_set(pn_session_remote_condition(session))) {
- MessagingEvent mevent(PN_MESSAGING_SESSION_ERROR, *pe);
- onSessionError(mevent);
- }
- else if (isLocalClosed(state)) {
- MessagingEvent mevent(PN_MESSAGING_SESSION_CLOSED, *pe);
- onSessionClosed(mevent);
- }
- else {
- MessagingEvent mevent(PN_MESSAGING_SESSION_CLOSING, *pe);
- onSessionClosing(mevent);
- }
- pn_session_close(session);
- }
-}
-
-void MessagingAdapter::onConnectionRemoteClose(Event &e) {
- ProtonEvent *pe = dynamic_cast<ProtonEvent*>(&e);
- if (pe) {
- pn_event_t *cevent = pe->getPnEvent();
- pn_connection_t *connection = pn_event_connection(cevent);
- pn_state_t state = pn_connection_state(connection);
- if (pn_condition_is_set(pn_connection_remote_condition(connection))) {
- MessagingEvent mevent(PN_MESSAGING_CONNECTION_ERROR, *pe);
- onConnectionError(mevent);
- }
- else if (isLocalClosed(state)) {
- MessagingEvent mevent(PN_MESSAGING_CONNECTION_CLOSED, *pe);
- onConnectionClosed(mevent);
- }
- else {
- MessagingEvent mevent(PN_MESSAGING_CONNECTION_CLOSING, *pe);
- onConnectionClosing(mevent);
- }
- pn_connection_close(connection);
- }
-}
-
-void MessagingAdapter::onConnectionLocalOpen(Event &e) {
- ProtonEvent *pe = dynamic_cast<ProtonEvent*>(&e);
- if (pe) {
- pn_connection_t *connection = pn_event_connection(pe->getPnEvent());
- if (isRemoteOpen(pn_connection_state(connection))) {
- MessagingEvent mevent(PN_MESSAGING_CONNECTION_OPENED, *pe);
- onConnectionOpened(mevent);
- }
- }
-}
-
-void MessagingAdapter::onConnectionRemoteOpen(Event &e) {
- ProtonEvent *pe = dynamic_cast<ProtonEvent*>(&e);
- if (pe) {
- pn_connection_t *connection = pn_event_connection(pe->getPnEvent());
- if (isLocalOpen(pn_connection_state(connection))) {
- MessagingEvent mevent(PN_MESSAGING_CONNECTION_OPENED, *pe);
- onConnectionOpened(mevent);
- }
- else if (isLocalUnititialised(pn_connection_state(connection))) {
- MessagingEvent mevent(PN_MESSAGING_CONNECTION_OPENING, *pe);
- onConnectionOpening(mevent);
- pn_connection_open(connection);
- }
- }
-}
-
-void MessagingAdapter::onSessionLocalOpen(Event &e) {
- ProtonEvent *pe = dynamic_cast<ProtonEvent*>(&e);
- if (pe) {
- pn_session_t *session = pn_event_session(pe->getPnEvent());
- if (isRemoteOpen(pn_session_state(session))) {
- MessagingEvent mevent(PN_MESSAGING_SESSION_OPENED, *pe);
- onSessionOpened(mevent);
- }
- }
-}
-
-void MessagingAdapter::onSessionRemoteOpen(Event &e) {
- ProtonEvent *pe = dynamic_cast<ProtonEvent*>(&e);
- if (pe) {
- pn_session_t *session = pn_event_session(pe->getPnEvent());
- if (isLocalOpen(pn_session_state(session))) {
- MessagingEvent mevent(PN_MESSAGING_SESSION_OPENED, *pe);
- onSessionOpened(mevent);
- }
- else if (isLocalUnititialised(pn_session_state(session))) {
- MessagingEvent mevent(PN_MESSAGING_SESSION_OPENING, *pe);
- onSessionOpening(mevent);
- pn_session_open(session);
- }
- }
-}
-
-void MessagingAdapter::onLinkLocalOpen(Event &e) {
- ProtonEvent *pe = dynamic_cast<ProtonEvent*>(&e);
- if (pe) {
- pn_link_t *link = pn_event_link(pe->getPnEvent());
- if (isRemoteOpen(pn_link_state(link))) {
- MessagingEvent mevent(PN_MESSAGING_LINK_OPENED, *pe);
- onLinkOpened(mevent);
- }
- }
-}
-
-void MessagingAdapter::onLinkRemoteOpen(Event &e) {
- ProtonEvent *pe = dynamic_cast<ProtonEvent*>(&e);
- if (pe) {
- pn_link_t *link = pn_event_link(pe->getPnEvent());
- if (isLocalOpen(pn_link_state(link))) {
- MessagingEvent mevent(PN_MESSAGING_LINK_OPENED, *pe);
- onLinkOpened(mevent);
- }
- else if (isLocalUnititialised(pn_link_state(link))) {
- MessagingEvent mevent(PN_MESSAGING_LINK_OPENING, *pe);
- onLinkOpening(mevent);
- pn_link_open(link);
- }
- }
-}
-
-void MessagingAdapter::onTransportTailClosed(Event &e) {
- ProtonEvent *pe = dynamic_cast<ProtonEvent*>(&e);
- if (pe) {
- pn_connection_t *conn = pn_event_connection(pe->getPnEvent());
- if (conn && isLocalOpen(pn_connection_state(conn))) {
- MessagingEvent mevent(PN_MESSAGING_DISCONNECTED, *pe);
- delegate.onDisconnected(mevent);
- }
- }
-}
-
-
-void MessagingAdapter::onConnectionOpened(Event &e) {
- delegate.onConnectionOpened(e);
-}
-
-void MessagingAdapter::onSessionOpened(Event &e) {
- delegate.onSessionOpened(e);
-}
-
-void MessagingAdapter::onLinkOpened(Event &e) {
- delegate.onLinkOpened(e);
-}
-
-void MessagingAdapter::onConnectionOpening(Event &e) {
- delegate.onConnectionOpening(e);
-}
-
-void MessagingAdapter::onSessionOpening(Event &e) {
- delegate.onSessionOpening(e);
-}
-
-void MessagingAdapter::onLinkOpening(Event &e) {
- delegate.onLinkOpening(e);
-}
-
-void MessagingAdapter::onConnectionError(Event &e) {
- delegate.onConnectionError(e);
- ProtonEvent *pe = dynamic_cast<ProtonEvent*>(&e);
- if (pe) {
- pn_connection_t *connection = pn_event_connection(pe->getPnEvent());
- pn_connection_close(connection);
- }
-}
-
-void MessagingAdapter::onSessionError(Event &e) {
- delegate.onSessionError(e);
- ProtonEvent *pe = dynamic_cast<ProtonEvent*>(&e);
- if (pe) {
- pn_session_t *session = pn_event_session(pe->getPnEvent());
- pn_session_close(session);
- }
-}
-
-void MessagingAdapter::onLinkError(Event &e) {
- delegate.onLinkError(e);
- ProtonEvent *pe = dynamic_cast<ProtonEvent*>(&e);
- if (pe) {
- pn_link_t *link = pn_event_link(pe->getPnEvent());
- pn_link_close(link);
- }
-}
-
-void MessagingAdapter::onConnectionClosed(Event &e) {
- delegate.onConnectionClosed(e);
-}
-
-void MessagingAdapter::onSessionClosed(Event &e) {
- delegate.onSessionClosed(e);
-}
-
-void MessagingAdapter::onLinkClosed(Event &e) {
- delegate.onLinkClosed(e);
-}
-
-void MessagingAdapter::onConnectionClosing(Event &e) {
- delegate.onConnectionClosing(e);
- if (peerCloseIsError)
- onConnectionError(e);
-}
-
-void MessagingAdapter::onSessionClosing(Event &e) {
- delegate.onSessionClosing(e);
- if (peerCloseIsError)
- onSessionError(e);
-}
-
-void MessagingAdapter::onLinkClosing(Event &e) {
- delegate.onLinkClosing(e);
- if (peerCloseIsError)
- onLinkError(e);
-}
-
-void MessagingAdapter::onUnhandled(Event &e) {
-}
-
-}} // namespace proton::reactor
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/MessagingEvent.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/MessagingEvent.cpp b/proton-c/bindings/cpp/src/MessagingEvent.cpp
deleted file mode 100644
index 083180a..0000000
--- a/proton-c/bindings/cpp/src/MessagingEvent.cpp
+++ /dev/null
@@ -1,150 +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/reactor.h"
-#include "proton/event.h"
-#include "proton/link.h"
-
-#include "proton/MessagingEvent.hpp"
-#include "proton/Message.hpp"
-#include "proton/ProtonHandler.hpp"
-#include "proton/MessagingHandler.hpp"
-#include "proton/Error.hpp"
-#include "Msg.hpp"
-#include "contexts.hpp"
-
-namespace proton {
-namespace reactor {
-
-MessagingEvent::MessagingEvent(pn_event_t *ce, pn_event_type_t t, Container &c) :
- ProtonEvent(ce, t, c), messagingType(PN_MESSAGING_PROTON), parentEvent(0), message(0)
-{}
-
-MessagingEvent::MessagingEvent(MessagingEventType_t t, ProtonEvent &p) :
- ProtonEvent(NULL, PN_EVENT_NONE, p.getContainer()), messagingType(t), parentEvent(&p), message(0) {
- if (messagingType == PN_MESSAGING_PROTON)
- throw Error(MSG("invalid messaging event type"));
-}
-
-MessagingEvent::~MessagingEvent() {
- delete message;
-}
-
-Connection &MessagingEvent::getConnection() {
- if (messagingType == PN_MESSAGING_PROTON)
- return ProtonEvent::getConnection();
- if (parentEvent)
- return parentEvent->getConnection();
- throw Error(MSG("No connection context for event"));
-}
-
-Sender MessagingEvent::getSender() {
- if (messagingType == PN_MESSAGING_PROTON)
- return ProtonEvent::getSender();
- if (parentEvent)
- return parentEvent->getSender();
- throw Error(MSG("No sender context for event"));
-}
-
-Receiver MessagingEvent::getReceiver() {
- if (messagingType == PN_MESSAGING_PROTON)
- return ProtonEvent::getReceiver();
- if (parentEvent)
- return parentEvent->getReceiver();
- throw Error(MSG("No receiver context for event"));
-}
-
-Link MessagingEvent::getLink() {
- if (messagingType == PN_MESSAGING_PROTON)
- return ProtonEvent::getLink();
- if (parentEvent)
- return parentEvent->getLink();
- throw Error(MSG("No link context for event"));
-}
-
-Message MessagingEvent::getMessage() {
- if (parentEvent) {
- pn_message_t *m = getEventContext(parentEvent->getPnEvent());
- if (m)
- return Message(m);
- }
- throw Error(MSG("No message context for event"));
-}
-
-void MessagingEvent::setMessage(Message &m) {
- if (messagingType != PN_MESSAGING_MESSAGE || !parentEvent)
- throw Error(MSG("Event type does not provide message"));
- setEventContext(parentEvent->getPnEvent(), m.pnMessage());
-}
-
-void MessagingEvent::dispatch(Handler &h) {
- if (messagingType == PN_MESSAGING_PROTON) {
- ProtonEvent::dispatch(h);
- return;
- }
-
- MessagingHandler *handler = dynamic_cast<MessagingHandler*>(&h);
- if (handler) {
- switch(messagingType) {
-
- case PN_MESSAGING_START: handler->onStart(*this); break;
- case PN_MESSAGING_SENDABLE: handler->onSendable(*this); break;
- case PN_MESSAGING_MESSAGE: handler->onMessage(*this); break;
- case PN_MESSAGING_ACCEPTED: handler->onAccepted(*this); break;
- case PN_MESSAGING_REJECTED: handler->onRejected(*this); break;
- case PN_MESSAGING_RELEASED: handler->onReleased(*this); break;
- case PN_MESSAGING_SETTLED: handler->onSettled(*this); break;
-
- case PN_MESSAGING_CONNECTION_CLOSING: handler->onConnectionClosing(*this); break;
- case PN_MESSAGING_CONNECTION_CLOSED: handler->onConnectionClosed(*this); break;
- case PN_MESSAGING_CONNECTION_ERROR: handler->onConnectionError(*this); break;
- case PN_MESSAGING_CONNECTION_OPENING: handler->onConnectionOpening(*this); break;
- case PN_MESSAGING_CONNECTION_OPENED: handler->onConnectionOpened(*this); break;
-
- case PN_MESSAGING_LINK_CLOSED: handler->onLinkClosed(*this); break;
- case PN_MESSAGING_LINK_CLOSING: handler->onLinkClosing(*this); break;
- case PN_MESSAGING_LINK_ERROR: handler->onLinkError(*this); break;
- case PN_MESSAGING_LINK_OPENING: handler->onLinkOpening(*this); break;
- case PN_MESSAGING_LINK_OPENED: handler->onLinkOpened(*this); break;
-
- case PN_MESSAGING_SESSION_CLOSED: handler->onSessionClosed(*this); break;
- case PN_MESSAGING_SESSION_CLOSING: handler->onSessionClosing(*this); break;
- case PN_MESSAGING_SESSION_ERROR: handler->onSessionError(*this); break;
- case PN_MESSAGING_SESSION_OPENING: handler->onSessionOpening(*this); break;
- case PN_MESSAGING_SESSION_OPENED: handler->onSessionOpened(*this); break;
-
- case PN_MESSAGING_TRANSPORT_CLOSED: handler->onTransportClosed(*this); break;
- default:
- throw Error(MSG("Unkown messaging event type " << messagingType));
- break;
- }
- } else {
- h.onUnhandled(*this);
- }
-
- // recurse through children
- for (std::vector<Handler *>::iterator child = h.childHandlersBegin();
- child != h.childHandlersEnd(); ++child) {
- dispatch(**child);
- }
-}
-
-}} // namespace proton::reactor
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/MessagingHandler.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/MessagingHandler.cpp b/proton-c/bindings/cpp/src/MessagingHandler.cpp
deleted file mode 100644
index 9076014..0000000
--- a/proton-c/bindings/cpp/src/MessagingHandler.cpp
+++ /dev/null
@@ -1,126 +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/MessagingHandler.hpp"
-#include "proton/ProtonEvent.hpp"
-#include "proton/MessagingAdapter.hpp"
-#include "proton/handlers.h"
-
-namespace proton {
-namespace reactor {
-
-namespace {
-class CFlowController : public ProtonHandler
-{
- public:
- pn_handler_t *flowcontroller;
-
- CFlowController(int window) : flowcontroller(pn_flowcontroller(window)) {}
- ~CFlowController() {
- pn_decref(flowcontroller);
- }
-
- void redirect(Event &e) {
- ProtonEvent *pne = dynamic_cast<ProtonEvent *>(&e);
- pn_handler_dispatch(flowcontroller, pne->getPnEvent(), (pn_event_type_t) pne->getType());
- }
-
- virtual void onLinkLocalOpen(Event &e) { redirect(e); }
- virtual void onLinkRemoteOpen(Event &e) { redirect(e); }
- virtual void onLinkFlow(Event &e) { redirect(e); }
- virtual void onDelivery(Event &e) { redirect(e); }
-};
-
-} // namespace
-
-
-
-
-MessagingHandler::MessagingHandler(int prefetch0, bool autoAccept0, bool autoSettle0, bool peerCloseIsError0) :
- prefetch(prefetch0), autoAccept(autoAccept0), autoSettle(autoSettle0), peerCloseIsError(peerCloseIsError0)
-{
- createHelpers();
-}
-
-MessagingHandler::MessagingHandler(bool rawHandler, int prefetch0, bool autoAccept0, bool autoSettle0,
- bool peerCloseIsError0) :
- prefetch(prefetch0), autoAccept(autoAccept0), autoSettle(autoSettle0), peerCloseIsError(peerCloseIsError0)
-{
- if (rawHandler) {
- flowController = 0;
- messagingAdapter = 0;
- } else {
- createHelpers();
- }
-}
-
-void MessagingHandler::createHelpers() {
- if (prefetch > 0) {
- flowController = new CFlowController(prefetch);
- addChildHandler(*flowController);
- }
- messagingAdapter = new MessagingAdapter(*this);
- addChildHandler(*messagingAdapter);
-}
-
-MessagingHandler::~MessagingHandler(){
- delete flowController;
- delete messagingAdapter;
-}
-
-void MessagingHandler::onAbort(Event &e) { onUnhandled(e); }
-void MessagingHandler::onAccepted(Event &e) { onUnhandled(e); }
-void MessagingHandler::onCommit(Event &e) { onUnhandled(e); }
-void MessagingHandler::onConnectionClosed(Event &e) { onUnhandled(e); }
-void MessagingHandler::onConnectionClosing(Event &e) { onUnhandled(e); }
-void MessagingHandler::onConnectionError(Event &e) { onUnhandled(e); }
-void MessagingHandler::onConnectionOpened(Event &e) { onUnhandled(e); }
-void MessagingHandler::onConnectionOpening(Event &e) { onUnhandled(e); }
-void MessagingHandler::onDisconnected(Event &e) { onUnhandled(e); }
-void MessagingHandler::onFetch(Event &e) { onUnhandled(e); }
-void MessagingHandler::onIdLoaded(Event &e) { onUnhandled(e); }
-void MessagingHandler::onLinkClosed(Event &e) { onUnhandled(e); }
-void MessagingHandler::onLinkClosing(Event &e) { onUnhandled(e); }
-void MessagingHandler::onLinkError(Event &e) { onUnhandled(e); }
-void MessagingHandler::onLinkOpened(Event &e) { onUnhandled(e); }
-void MessagingHandler::onLinkOpening(Event &e) { onUnhandled(e); }
-void MessagingHandler::onMessage(Event &e) { onUnhandled(e); }
-void MessagingHandler::onQuit(Event &e) { onUnhandled(e); }
-void MessagingHandler::onRecordInserted(Event &e) { onUnhandled(e); }
-void MessagingHandler::onRecordsLoaded(Event &e) { onUnhandled(e); }
-void MessagingHandler::onRejected(Event &e) { onUnhandled(e); }
-void MessagingHandler::onReleased(Event &e) { onUnhandled(e); }
-void MessagingHandler::onRequest(Event &e) { onUnhandled(e); }
-void MessagingHandler::onResponse(Event &e) { onUnhandled(e); }
-void MessagingHandler::onSendable(Event &e) { onUnhandled(e); }
-void MessagingHandler::onSessionClosed(Event &e) { onUnhandled(e); }
-void MessagingHandler::onSessionClosing(Event &e) { onUnhandled(e); }
-void MessagingHandler::onSessionError(Event &e) { onUnhandled(e); }
-void MessagingHandler::onSessionOpened(Event &e) { onUnhandled(e); }
-void MessagingHandler::onSessionOpening(Event &e) { onUnhandled(e); }
-void MessagingHandler::onSettled(Event &e) { onUnhandled(e); }
-void MessagingHandler::onStart(Event &e) { onUnhandled(e); }
-void MessagingHandler::onTimer(Event &e) { onUnhandled(e); }
-void MessagingHandler::onTransactionAborted(Event &e) { onUnhandled(e); }
-void MessagingHandler::onTransactionCommitted(Event &e) { onUnhandled(e); }
-void MessagingHandler::onTransactionDeclared(Event &e) { onUnhandled(e); }
-void MessagingHandler::onTransportClosed(Event &e) { onUnhandled(e); }
-
-}} // namespace proton::reactor
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/Msg.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Msg.hpp b/proton-c/bindings/cpp/src/Msg.hpp
deleted file mode 100644
index 2b4c6da..0000000
--- a/proton-c/bindings/cpp/src/Msg.hpp
+++ /dev/null
@@ -1,59 +0,0 @@
-#ifndef PROTON_MSG_H
-#define PROTON_MSG_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 <sstream>
-#include <iostream>
-
-namespace proton {
-namespace reactor {
-
-/** A simple wrapper for std::ostringstream that allows
- * in place construction of a message and automatic conversion
- * to string.
- * E.g.
- *@code
- * void foo(const std::string&);
- * foo(Msg() << "hello " << 32);
- *@endcode
- * Will construct the string "hello 32" and pass it to foo()
- */
-struct Msg {
- std::ostringstream os;
- Msg() {}
- Msg(const Msg& m) : os(m.str()) {}
- std::string str() const { return os.str(); }
- operator std::string() const { return str(); }
- template <class T> Msg& operator<<(const T& t) { os <<t; return *this; }
-};
-
-inline std::ostream& operator<<(std::ostream& o, const Msg& m) { return o << m.str(); }
-
-/** Construct a message using operator << and append (file:line) */
-#define QUOTE_(x) #x
-#define QUOTE(x) QUOTE_(x)
-#define MSG(message) (::proton::reactor::Msg() << message)
-
-}} // namespace proton::reactor
-
-#endif /*!PROTON_MSG_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/PrivateImplRef.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/PrivateImplRef.hpp b/proton-c/bindings/cpp/src/PrivateImplRef.hpp
deleted file mode 100644
index 560e740..0000000
--- a/proton-c/bindings/cpp/src/PrivateImplRef.hpp
+++ /dev/null
@@ -1,97 +0,0 @@
-#ifndef PROTON_CPP_PRIVATEIMPL_H
-#define PROTON_CPP_PRIVATEIMPL_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 {
-namespace reactor {
-
-// Modified from qpid::messaging version to work without
-// boost::intrusive_ptr but integrate with Proton's pn_class_t
-// reference counting. Thread safety currently absent but fluid in
-// intention...
-
-
-/**
- * Helper class to implement a class with a private, reference counted
- * implementation and reference semantics.
- *
- * Such classes are used in the public API to hide implementation, they
- * should. Example of use:
- *
- * === Foo.h
- *
- * template <class T> PrivateImplRef;
- * class FooImpl;
- *
- * Foo : public Handle<FooImpl> {
- * public:
- * Foo(FooImpl* = 0);
- * Foo(const Foo&);
- * ~Foo();
- * Foo& operator=(const Foo&);
- *
- * int fooDo(); // and other Foo functions...
- *
- * private:
- * typedef FooImpl Impl;
- * Impl* impl;
- * friend class PrivateImplRef<Foo>;
- *
- * === Foo.cpp
- *
- * typedef PrivateImplRef<Foo> PI;
- * Foo::Foo(FooImpl* p) { PI::ctor(*this, p); }
- * Foo::Foo(const Foo& c) : Handle<FooImpl>() { PI::copy(*this, c); }
- * Foo::~Foo() { PI::dtor(*this); }
- * Foo& Foo::operator=(const Foo& c) { return PI::assign(*this, c); }
- *
- * int foo::fooDo() { return impl->fooDo(); }
- *
- */
-template <class T> class PrivateImplRef {
- public:
- typedef typename T::Impl Impl;
-
- /** Get the implementation pointer from a handle */
- static Impl* get(const T& t) { return t.impl; }
-
- /** Set the implementation pointer in a handle */
- static void set(T& t, const Impl* p) {
- if (t.impl == p) return;
- if (t.impl) Impl::decref(t.impl);
- t.impl = const_cast<Impl *>(p);
- if (t.impl) Impl::incref(t.impl);
- }
-
- // Helper functions to implement the ctor, dtor, copy, assign
- static void ctor(T& t, Impl* p) { t.impl = p; if (p) Impl::incref(p); }
- static void copy(T& t, const T& x) { if (&t == &x) return; t.impl = 0; assign(t, x); }
- static void dtor(T& t) { if(t.impl) Impl::decref(t.impl); }
- static T& assign(T& t, const T& x) { set(t, get(x)); return t;}
-};
-
-}} // namespace proton::reactor
-
-#endif /*!PROTON_CPP_PRIVATEIMPL_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/ProtonEvent.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ProtonEvent.cpp b/proton-c/bindings/cpp/src/ProtonEvent.cpp
deleted file mode 100644
index 8d32f35..0000000
--- a/proton-c/bindings/cpp/src/ProtonEvent.cpp
+++ /dev/null
@@ -1,153 +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/reactor.h"
-#include "proton/event.h"
-#include "proton/link.h"
-
-#include "proton/ProtonEvent.hpp"
-#include "proton/ProtonHandler.hpp"
-#include "proton/Error.hpp"
-#include "proton/Container.hpp"
-
-#include "ConnectionImpl.hpp"
-#include "Msg.hpp"
-#include "contexts.hpp"
-
-namespace proton {
-namespace reactor {
-
-ProtonEvent::ProtonEvent(pn_event_t *ce, pn_event_type_t t, Container &c) :
- pnEvent(ce),
- type((int) t),
- container(c)
-{}
-
-int ProtonEvent::getType() { return type; }
-
-pn_event_t *ProtonEvent::getPnEvent() { return pnEvent; }
-
-Container &ProtonEvent::getContainer() { return container; }
-
-Connection &ProtonEvent::getConnection() {
- pn_connection_t *conn = pn_event_connection(getPnEvent());
- if (!conn)
- throw Error(MSG("No connection context for this event"));
- return ConnectionImpl::getReactorReference(conn);
-}
-
-Sender ProtonEvent::getSender() {
- pn_link_t *lnk = pn_event_link(getPnEvent());
- if (lnk && pn_link_is_sender(lnk))
- return Sender(lnk);
- throw Error(MSG("No sender context for this event"));
-}
-
-Receiver ProtonEvent::getReceiver() {
- pn_link_t *lnk = pn_event_link(getPnEvent());
- if (lnk && pn_link_is_receiver(lnk))
- return Receiver(lnk);
- throw Error(MSG("No receiver context for this event"));
-}
-
-Link ProtonEvent::getLink() {
- pn_link_t *lnk = pn_event_link(getPnEvent());
- if (lnk) {
- if (pn_link_is_sender(lnk))
- return Sender(lnk);
- else
- return Receiver(lnk);
- }
- throw Error(MSG("No link context for this event"));
-}
-
-
-
-
-void ProtonEvent::dispatch(Handler &h) {
- ProtonHandler *handler = dynamic_cast<ProtonHandler*>(&h);
-
- if (handler) {
- switch(type) {
-
- case PN_REACTOR_INIT: handler->onReactorInit(*this); break;
- case PN_REACTOR_QUIESCED: handler->onReactorQuiesced(*this); break;
- case PN_REACTOR_FINAL: handler->onReactorFinal(*this); break;
-
- case PN_TIMER_TASK: handler->onTimerTask(*this); break;
-
- case PN_CONNECTION_INIT: handler->onConnectionInit(*this); break;
- case PN_CONNECTION_BOUND: handler->onConnectionBound(*this); break;
- case PN_CONNECTION_UNBOUND: handler->onConnectionUnbound(*this); break;
- case PN_CONNECTION_LOCAL_OPEN: handler->onConnectionLocalOpen(*this); break;
- case PN_CONNECTION_LOCAL_CLOSE: handler->onConnectionLocalClose(*this); break;
- case PN_CONNECTION_REMOTE_OPEN: handler->onConnectionRemoteOpen(*this); break;
- case PN_CONNECTION_REMOTE_CLOSE: handler->onConnectionRemoteClose(*this); break;
- case PN_CONNECTION_FINAL: handler->onConnectionFinal(*this); break;
-
- case PN_SESSION_INIT: handler->onSessionInit(*this); break;
- case PN_SESSION_LOCAL_OPEN: handler->onSessionLocalOpen(*this); break;
- case PN_SESSION_LOCAL_CLOSE: handler->onSessionLocalClose(*this); break;
- case PN_SESSION_REMOTE_OPEN: handler->onSessionRemoteOpen(*this); break;
- case PN_SESSION_REMOTE_CLOSE: handler->onSessionRemoteClose(*this); break;
- case PN_SESSION_FINAL: handler->onSessionFinal(*this); break;
-
- case PN_LINK_INIT: handler->onLinkInit(*this); break;
- case PN_LINK_LOCAL_OPEN: handler->onLinkLocalOpen(*this); break;
- case PN_LINK_LOCAL_CLOSE: handler->onLinkLocalClose(*this); break;
- case PN_LINK_LOCAL_DETACH: handler->onLinkLocalDetach(*this); break;
- case PN_LINK_REMOTE_OPEN: handler->onLinkRemoteOpen(*this); break;
- case PN_LINK_REMOTE_CLOSE: handler->onLinkRemoteClose(*this); break;
- case PN_LINK_REMOTE_DETACH: handler->onLinkRemoteDetach(*this); break;
- case PN_LINK_FLOW: handler->onLinkFlow(*this); break;
- case PN_LINK_FINAL: handler->onLinkFinal(*this); break;
-
- case PN_DELIVERY: handler->onDelivery(*this); break;
-
- case PN_TRANSPORT: handler->onTransport(*this); break;
- case PN_TRANSPORT_ERROR: handler->onTransportError(*this); break;
- case PN_TRANSPORT_HEAD_CLOSED: handler->onTransportHeadClosed(*this); break;
- case PN_TRANSPORT_TAIL_CLOSED: handler->onTransportTailClosed(*this); break;
- case PN_TRANSPORT_CLOSED: handler->onTransportClosed(*this); break;
-
- case PN_SELECTABLE_INIT: handler->onSelectableInit(*this); break;
- case PN_SELECTABLE_UPDATED: handler->onSelectableUpdated(*this); break;
- case PN_SELECTABLE_READABLE: handler->onSelectableReadable(*this); break;
- case PN_SELECTABLE_WRITABLE: handler->onSelectableWritable(*this); break;
- case PN_SELECTABLE_EXPIRED: handler->onSelectableExpired(*this); break;
- case PN_SELECTABLE_ERROR: handler->onSelectableError(*this); break;
- case PN_SELECTABLE_FINAL: handler->onSelectableFinal(*this); break;
- default:
- throw Error(MSG("Invalid Proton event type " << type));
- break;
- }
- } else {
- h.onUnhandled(*this);
- }
-
- // recurse through children
- for (std::vector<Handler *>::iterator child = h.childHandlersBegin();
- child != h.childHandlersEnd(); ++child) {
- dispatch(**child);
- }
-}
-
-}} // namespace proton::reactor
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/ProtonHandler.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ProtonHandler.cpp b/proton-c/bindings/cpp/src/ProtonHandler.cpp
deleted file mode 100644
index d4705d5..0000000
--- a/proton-c/bindings/cpp/src/ProtonHandler.cpp
+++ /dev/null
@@ -1,74 +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/ProtonHandler.hpp"
-#include "proton/ProtonEvent.hpp"
-
-namespace proton {
-namespace reactor {
-
-ProtonHandler::ProtonHandler(){}
-
-// Everything goes to onUnhandled() unless overriden by subclass
-
-void ProtonHandler::onReactorInit(Event &e) { onUnhandled(e); }
-void ProtonHandler::onReactorQuiesced(Event &e) { onUnhandled(e); }
-void ProtonHandler::onReactorFinal(Event &e) { onUnhandled(e); }
-void ProtonHandler::onTimerTask(Event &e) { onUnhandled(e); }
-void ProtonHandler::onConnectionInit(Event &e) { onUnhandled(e); }
-void ProtonHandler::onConnectionBound(Event &e) { onUnhandled(e); }
-void ProtonHandler::onConnectionUnbound(Event &e) { onUnhandled(e); }
-void ProtonHandler::onConnectionLocalOpen(Event &e) { onUnhandled(e); }
-void ProtonHandler::onConnectionLocalClose(Event &e) { onUnhandled(e); }
-void ProtonHandler::onConnectionRemoteOpen(Event &e) { onUnhandled(e); }
-void ProtonHandler::onConnectionRemoteClose(Event &e) { onUnhandled(e); }
-void ProtonHandler::onConnectionFinal(Event &e) { onUnhandled(e); }
-void ProtonHandler::onSessionInit(Event &e) { onUnhandled(e); }
-void ProtonHandler::onSessionLocalOpen(Event &e) { onUnhandled(e); }
-void ProtonHandler::onSessionLocalClose(Event &e) { onUnhandled(e); }
-void ProtonHandler::onSessionRemoteOpen(Event &e) { onUnhandled(e); }
-void ProtonHandler::onSessionRemoteClose(Event &e) { onUnhandled(e); }
-void ProtonHandler::onSessionFinal(Event &e) { onUnhandled(e); }
-void ProtonHandler::onLinkInit(Event &e) { onUnhandled(e); }
-void ProtonHandler::onLinkLocalOpen(Event &e) { onUnhandled(e); }
-void ProtonHandler::onLinkLocalClose(Event &e) { onUnhandled(e); }
-void ProtonHandler::onLinkLocalDetach(Event &e) { onUnhandled(e); }
-void ProtonHandler::onLinkRemoteOpen(Event &e) { onUnhandled(e); }
-void ProtonHandler::onLinkRemoteClose(Event &e) { onUnhandled(e); }
-void ProtonHandler::onLinkRemoteDetach(Event &e) { onUnhandled(e); }
-void ProtonHandler::onLinkFlow(Event &e) { onUnhandled(e); }
-void ProtonHandler::onLinkFinal(Event &e) { onUnhandled(e); }
-void ProtonHandler::onDelivery(Event &e) { onUnhandled(e); }
-void ProtonHandler::onTransport(Event &e) { onUnhandled(e); }
-void ProtonHandler::onTransportError(Event &e) { onUnhandled(e); }
-void ProtonHandler::onTransportHeadClosed(Event &e) { onUnhandled(e); }
-void ProtonHandler::onTransportTailClosed(Event &e) { onUnhandled(e); }
-void ProtonHandler::onTransportClosed(Event &e) { onUnhandled(e); }
-void ProtonHandler::onSelectableInit(Event &e) { onUnhandled(e); }
-void ProtonHandler::onSelectableUpdated(Event &e) { onUnhandled(e); }
-void ProtonHandler::onSelectableReadable(Event &e) { onUnhandled(e); }
-void ProtonHandler::onSelectableWritable(Event &e) { onUnhandled(e); }
-void ProtonHandler::onSelectableExpired(Event &e) { onUnhandled(e); }
-void ProtonHandler::onSelectableError(Event &e) { onUnhandled(e); }
-void ProtonHandler::onSelectableFinal(Event &e) { onUnhandled(e); }
-
-void ProtonHandler::onUnhandled(Event &e) {}
-
-}} // namespace proton::reactor
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/ProtonImplRef.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ProtonImplRef.hpp b/proton-c/bindings/cpp/src/ProtonImplRef.hpp
deleted file mode 100644
index 426fb6d..0000000
--- a/proton-c/bindings/cpp/src/ProtonImplRef.hpp
+++ /dev/null
@@ -1,66 +0,0 @@
-#ifndef PROTON_CPP_PROTONIMPL_H
-#define PROTON_CPP_PROTONIMPL_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/object.h"
-
-namespace proton {
-namespace reactor {
-
-// Modified from qpid::messaging version to work without
-// boost::intrusive_ptr but integrate with Proton's pn_class_t
-// reference counting. Thread safety currently absent but fluid in
-// intention...
-
-
-/**
- * See PrivateImplRef.h This is for lightly wrapped Proton pn_object_t targets.
- * class Foo : ProtonHandle<pn_foo_t> {...}
- */
-
-template <class T> class ProtonImplRef {
- public:
- typedef typename T::Impl Impl;
-
- /** Get the implementation pointer from a handle */
- static Impl* get(const T& t) { return t.impl; }
-
- /** Set the implementation pointer in a handle */
- static void set(T& t, const Impl* p) {
- if (t.impl == p) return;
- if (t.impl) pn_decref(t.impl);
- t.impl = const_cast<Impl *>(p);
- if (t.impl) pn_incref(t.impl);
- }
-
- // Helper functions to implement the ctor, dtor, copy, assign
- static void ctor(T& t, Impl* p) { t.impl = p; if (p) pn_incref(p); }
- static void copy(T& t, const T& x) { if (&t == &x) return; t.impl = 0; assign(t, x); }
- static void dtor(T& t) { if(t.impl) pn_decref(t.impl); }
- static T& assign(T& t, const T& x) { set(t, get(x)); return t;}
-};
-
-}} // namespace proton::reactor
-
-#endif /*!PROTON_CPP_PROTONIMPL_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/Receiver.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Receiver.cpp b/proton-c/bindings/cpp/src/Receiver.cpp
deleted file mode 100644
index b46ab87..0000000
--- a/proton-c/bindings/cpp/src/Receiver.cpp
+++ /dev/null
@@ -1,45 +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/Link.hpp"
-#include "proton/Receiver.hpp"
-#include "proton/Error.hpp"
-#include "Msg.hpp"
-
-#include "proton/connection.h"
-#include "proton/session.h"
-#include "proton/link.h"
-
-namespace proton {
-namespace reactor {
-
-
-Receiver::Receiver(pn_link_t *lnk) : Link(lnk) {}
-Receiver::Receiver() : Link(0) {}
-
-Receiver::Receiver(const Link& c) : Link(c.getPnLink()) {}
-
-void Receiver::verifyType(pn_link_t *lnk) {
- if (lnk && pn_link_is_sender(lnk))
- throw Error(MSG("Creating receiver with sender context"));
-}
-
-
-}} // namespace proton::reactor
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/Sender.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Sender.cpp b/proton-c/bindings/cpp/src/Sender.cpp
deleted file mode 100644
index 3998d62..0000000
--- a/proton-c/bindings/cpp/src/Sender.cpp
+++ /dev/null
@@ -1,72 +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/Link.hpp"
-#include "proton/Sender.hpp"
-#include "proton/Error.hpp"
-#include "Msg.hpp"
-#include "contexts.hpp"
-
-#include "proton/connection.h"
-#include "proton/session.h"
-#include "proton/link.h"
-#include "proton/types.h"
-#include "proton/codec.h"
-#include "proton/message.h"
-#include "proton/delivery.h"
-#include <stdlib.h>
-#include <string.h>
-
-namespace proton {
-namespace reactor {
-
-
-Sender::Sender(pn_link_t *lnk) : Link(lnk) {}
-
-void Sender::verifyType(pn_link_t *lnk) {
- if (lnk && pn_link_is_receiver(lnk))
- throw Error(MSG("Creating sender with receiver context"));
-}
-
-Sender::Sender(const Link& c) : Link(c.getPnLink()) {}
-
-
-namespace{
-// revisit if thread safety required
-std::uint64_t tagCounter = 0;
-}
-
-Delivery Sender::send(Message &message) {
- char tag[8];
- void *ptr = &tag;
- std::uint64_t id = ++tagCounter;
- *((std::uint64_t *) ptr) = id;
- pn_delivery_t *dlv = pn_delivery(getPnLink(), pn_dtag(tag, 8));
- std::string buf;
- message.encode(buf);
- pn_link_t *link = getPnLink();
- pn_link_send(link, buf.data(), buf.size());
- pn_link_advance(link);
- if (pn_link_snd_settle_mode(link) == PN_SND_SETTLED)
- pn_delivery_settle(dlv);
- return Delivery(dlv);
-}
-
-}} // namespace proton::reactor
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/Session.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Session.cpp b/proton-c/bindings/cpp/src/Session.cpp
deleted file mode 100644
index 594d192..0000000
--- a/proton-c/bindings/cpp/src/Session.cpp
+++ /dev/null
@@ -1,74 +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/Session.hpp"
-#include "contexts.hpp"
-
-#include "proton/connection.h"
-#include "proton/session.h"
-#include "proton/Session.hpp"
-#include "proton/Connection.hpp"
-#include "ConnectionImpl.hpp"
-#include "ProtonImplRef.hpp"
-
-namespace proton {
-namespace reactor {
-
-template class ProtonHandle<pn_session_t>;
-typedef ProtonImplRef<Session> PI;
-
-Session::Session(pn_session_t *p) {
- PI::ctor(*this, p);
-}
-Session::Session() {
- PI::ctor(*this, 0);
-}
-Session::Session(const Session& c) : ProtonHandle<pn_session_t>() {
- PI::copy(*this, c);
-}
-Session& Session::operator=(const Session& c) {
- return PI::assign(*this, c);
-}
-Session::~Session() {
- PI::dtor(*this);
-}
-
-pn_session_t *Session::getPnSession() { return impl; }
-
-void Session::open() {
- pn_session_open(impl);
-}
-
-Connection &Session::getConnection() {
- pn_connection_t *c = pn_session_connection(impl);
- return ConnectionImpl::getReactorReference(c);
-}
-
-Receiver Session::createReceiver(std::string name) {
- pn_link_t *link = pn_receiver(impl, name.c_str());
- return Receiver(link);
-}
-
-Sender Session::createSender(std::string name) {
- pn_link_t *link = pn_sender(impl, name.c_str());
- return Sender(link);
-}
-
-}} // namespace proton::reactor
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/Terminus.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Terminus.cpp b/proton-c/bindings/cpp/src/Terminus.cpp
deleted file mode 100644
index 0022805..0000000
--- a/proton-c/bindings/cpp/src/Terminus.cpp
+++ /dev/null
@@ -1,102 +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/Link.hpp"
-#include "proton/link.h"
-
-namespace proton {
-namespace reactor {
-
-template class ProtonHandle<pn_terminus_t>;
-typedef ProtonImplRef<Terminus> PI;
-
-// Note: the pn_terminus_t is not ref counted. We count the parent link.
-
-Terminus::Terminus() : link(0) {
- impl = 0;
-}
-
-Terminus::Terminus(pn_terminus_t *p, Link *l) : link(l) {
- impl = p;
- pn_incref(link->getPnLink());
-}
-Terminus::Terminus(const Terminus& c) : ProtonHandle<pn_terminus_t>() {
- impl = c.impl;
- link = c.link;
- pn_incref(link->getPnLink());
-}
-Terminus& Terminus::operator=(const Terminus& c) {
- if (impl == c.impl) return *this;
- if (impl) pn_decref(link->getPnLink());
- impl = c.impl;
- link = c.link;
- pn_incref(link->getPnLink());
- return *this;
-}
-Terminus::~Terminus() {
- if (impl)
- pn_decref(link->getPnLink());
-}
-
-pn_terminus_t *Terminus::getPnTerminus() { return impl; }
-
-Terminus::Type Terminus::getType() {
- return (Type) pn_terminus_get_type(impl);
-}
-
-void Terminus::setType(Type type) {
- pn_terminus_set_type(impl, (pn_terminus_type_t) type);
-}
-
-Terminus::ExpiryPolicy Terminus::getExpiryPolicy() {
- return (ExpiryPolicy) pn_terminus_get_type(impl);
-}
-
-void Terminus::setExpiryPolicy(ExpiryPolicy policy) {
- pn_terminus_set_expiry_policy(impl, (pn_expiry_policy_t) policy);
-}
-
-Terminus::DistributionMode Terminus::getDistributionMode() {
- return (DistributionMode) pn_terminus_get_type(impl);
-}
-
-void Terminus::setDistributionMode(DistributionMode mode) {
- pn_terminus_set_distribution_mode(impl, (pn_distribution_mode_t) mode);
-}
-
-std::string Terminus::getAddress() {
- const char *addr = pn_terminus_get_address(impl);
- return addr ? std::string(addr) : std::string();
-}
-
-void Terminus::setAddress(std::string &addr) {
- pn_terminus_set_address(impl, addr.c_str());
-}
-
-bool Terminus::isDynamic() {
- return (Type) pn_terminus_is_dynamic(impl);
-}
-
-void Terminus::setDynamic(bool d) {
- pn_terminus_set_dynamic(impl, d);
-}
-
-}} // namespace proton::reactor
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/Transport.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Transport.cpp b/proton-c/bindings/cpp/src/Transport.cpp
deleted file mode 100644
index 98f03f5..0000000
--- a/proton-c/bindings/cpp/src/Transport.cpp
+++ /dev/null
@@ -1,39 +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/Transport.hpp"
-#include "proton/Connection.hpp"
-
-#include "proton/transport.h"
-
-namespace proton {
-namespace reactor {
-
-
-Transport::Transport() : connection(0), pnTransport(pn_transport()) {}
-
-Transport::~Transport() { pn_decref(pnTransport); }
-
-void Transport::bind(Connection &c) {
- connection = &c;
- pn_transport_bind(pnTransport, c.getPnConnection());
-}
-
-}} // namespace proton::reactor
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/Url.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Url.cpp b/proton-c/bindings/cpp/src/Url.cpp
deleted file mode 100644
index 60ab58d..0000000
--- a/proton-c/bindings/cpp/src/Url.cpp
+++ /dev/null
@@ -1,77 +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/Error.hpp"
-#include "Url.hpp"
-#include "ProtonImplRef.hpp"
-#include "Msg.hpp"
-
-namespace proton {
-namespace reactor {
-
-template class ProtonHandle<pn_url_t>;
-typedef ProtonImplRef<Url> PI;
-
-
-Url::Url(const std::string &url) {
- pn_url_t *up = pn_url_parse(url.c_str());
- // refcount is 1, no need to incref
- if (!up)
- throw Error(MSG("invalid URL: " << url));
- impl = up;
-}
-
-Url::~Url() { PI::dtor(*this); }
-
-Url::Url(const Url& c) : ProtonHandle<pn_url_t>() {
- PI::copy(*this, c);
-}
-
-Url& Url::operator=(const Url& c) {
- return PI::assign(*this, c);
-}
-
-std::string Url::getPort() {
- const char *p = pn_url_get_port(impl);
- if (!p)
- return std::string("5672");
- else
- return std::string(p);
-}
-
-std::string Url::getHost() {
- const char *p = pn_url_get_host(impl);
- if (!p)
- return std::string("0.0.0.0");
- else
- return std::string(p);
-}
-
-std::string Url::getPath() {
- const char *p = pn_url_get_path(impl);
- if (!p)
- return std::string("");
- else
- return std::string(p);
-}
-
-
-}} // namespace proton::reactor
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[2/8] qpid-proton git commit: PROTON-865: Renaming to follow
boost/std library C++ naming conventions.
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/endpoint.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/endpoint.cpp b/proton-c/bindings/cpp/src/endpoint.cpp
new file mode 100644
index 0000000..2e656c9
--- /dev/null
+++ b/proton-c/bindings/cpp/src/endpoint.cpp
@@ -0,0 +1,40 @@
+/*
+ *
+ * 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/endpoint.hpp"
+#include "proton/connection.hpp"
+#include "proton/transport.hpp"
+
+namespace proton {
+
+endpoint::endpoint() {}
+
+endpoint::~endpoint() {}
+
+class connection &endpoint::connection() {
+ return dynamic_cast<class connection&>(*this);
+}
+
+class transport &endpoint::transport() {
+ return connection().transport();
+}
+
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/error.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/error.cpp b/proton-c/bindings/cpp/src/error.cpp
new file mode 100644
index 0000000..18aaa7c
--- /dev/null
+++ b/proton-c/bindings/cpp/src/error.cpp
@@ -0,0 +1,32 @@
+/*
+ * 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/error.hpp"
+
+namespace proton {
+
+static const std::string prefix("proton: ");
+
+error::error(const std::string& msg) throw() : std::runtime_error(prefix+msg) {}
+
+message_reject::message_reject(const std::string& msg) throw() : error(msg) {}
+
+message_release::message_release(const std::string& msg) throw() : error(msg) {}
+
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/event.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/event.cpp b/proton-c/bindings/cpp/src/event.cpp
new file mode 100644
index 0000000..e12d19c
--- /dev/null
+++ b/proton-c/bindings/cpp/src/event.cpp
@@ -0,0 +1,70 @@
+/*
+ *
+ * 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/reactor.h"
+#include "proton/event.h"
+
+#include "proton/event.hpp"
+#include "proton/handler.hpp"
+#include "proton/error.hpp"
+
+#include "msg.hpp"
+#include "contexts.hpp"
+
+namespace proton {
+
+event::event() {}
+
+event::~event() {}
+
+
+class container &event::container() {
+ // Subclasses to override as appropriate
+ throw error(MSG("No container context for event"));
+}
+
+class connection &event::connection() {
+ throw error(MSG("No connection context for event"));
+}
+
+class sender event::sender() {
+ throw error(MSG("No sender context for event"));
+}
+
+class receiver event::receiver() {
+ throw error(MSG("No receiver context for event"));
+}
+
+class link event::link() {
+ throw error(MSG("No link context for event"));
+}
+
+class message event::message() {
+ throw error(MSG("No message associated with event"));
+}
+
+void event::message(class message &) {
+ throw error(MSG("Operation not supported for this type of event"));
+}
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/handler.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/handler.cpp b/proton-c/bindings/cpp/src/handler.cpp
new file mode 100644
index 0000000..8e0f675
--- /dev/null
+++ b/proton-c/bindings/cpp/src/handler.cpp
@@ -0,0 +1,35 @@
+/*
+ *
+ * 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/handler.hpp"
+#include "proton/event.hpp"
+
+namespace proton {
+
+handler::handler() {}
+handler::~handler() {}
+
+void handler::on_unhandled(event &e) {}
+
+void handler::add_child_handler(handler &e) {
+ push_back(&e);
+}
+
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/interop_test.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/interop_test.cpp b/proton-c/bindings/cpp/src/interop_test.cpp
index 0b05566..1d8a871 100644
--- a/proton-c/bindings/cpp/src/interop_test.cpp
+++ b/proton-c/bindings/cpp/src/interop_test.cpp
@@ -17,10 +17,10 @@
* under the License.
*/
-#include "proton/Decoder.hpp"
-#include "proton/Encoder.hpp"
-#include "proton/Value.hpp"
-#include "Msg.hpp"
+#include "proton/decoder.hpp"
+#include "proton/encoder.hpp"
+#include "proton/value.hpp"
+#include "msg.hpp"
#include <stdexcept>
#include <string>
#include <sstream>
@@ -30,9 +30,8 @@
using namespace std;
using namespace proton;
-using namespace proton::reactor;
-std::string testsDir;
+std::string tests_dir;
struct Fail : public logic_error { Fail(const string& what) : logic_error(what) {} };
#define FAIL(WHAT) throw Fail(MSG(__FILE__ << ":" << __LINE__ << ": " << WHAT))
@@ -42,13 +41,13 @@ struct Fail : public logic_error { Fail(const string& what) : logic_error(what)
string read(string filename) {
- filename = testsDir+string("/interop/")+filename+string(".amqp");
+ filename = tests_dir+string("/interop/")+filename+string(".amqp");
ifstream ifs(filename.c_str());
if (!ifs.good()) FAIL("Can't open " << filename);
return string(istreambuf_iterator<char>(ifs), istreambuf_iterator<char>());
}
-template <class T> T get(Decoder& d) { return d.getAs<T, TypeIdOf<T>::value>(); }
+template <class T> T get(decoder& d) { return d.get_as<T, type_idOf<T>::value>(); }
template <class T> std::string str(const T& value) {
ostringstream oss;
@@ -56,39 +55,39 @@ template <class T> std::string str(const T& value) {
return oss.str();
}
-// Test Data ostream operator
-void testDataOstream() {
- Decoder d(read("primitives"));
+// Test data ostream operator
+void test_data_ostream() {
+ decoder d(read("primitives"));
ASSERT_EQUAL("true, false, 42, 42, -42, 12345, -12345, 12345, -12345, 0.125, 0.125", str(d));
}
// Test extracting to exact AMQP types works corectly, extrating to invalid types fails.
-void testDecoderPrimitvesExact() {
- Decoder d(read("primitives"));
+void test_decoder_primitves_exact() {
+ decoder d(read("primitives"));
ASSERT(d.more());
- try { get<std::int8_t>(d); FAIL("got bool as byte"); } catch(DecodeError){}
+ try { get<std::int8_t>(d); FAIL("got bool as byte"); } catch(decode_error){}
ASSERT_EQUAL(true, get<bool>(d));
ASSERT_EQUAL(false, get<bool>(d));
- try { get<std::int8_t>(d); FAIL("got ubyte as byte"); } catch(DecodeError){}
+ try { get<std::int8_t>(d); FAIL("got ubyte as byte"); } catch(decode_error){}
ASSERT_EQUAL(42, get<std::uint8_t>(d));
- try { get<std::int32_t>(d); FAIL("got uint as ushort"); } catch(DecodeError){}
+ try { get<std::int32_t>(d); FAIL("got uint as ushort"); } catch(decode_error){}
ASSERT_EQUAL(42, get<std::uint16_t>(d));
- try { get<std::uint16_t>(d); FAIL("got short as ushort"); } catch(DecodeError){}
+ try { get<std::uint16_t>(d); FAIL("got short as ushort"); } catch(decode_error){}
ASSERT_EQUAL(-42, get<std::int16_t>(d));
ASSERT_EQUAL(12345, get<std::uint32_t>(d));
ASSERT_EQUAL(-12345, get<std::int32_t>(d));
ASSERT_EQUAL(12345, get<std::uint64_t>(d));
ASSERT_EQUAL(-12345, get<std::int64_t>(d));
- try { get<double>(d); FAIL("got float as double"); } catch(DecodeError){}
+ try { get<double>(d); FAIL("got float as double"); } catch(decode_error){}
ASSERT_EQUAL(0.125, get<float>(d));
- try { get<float>(d); FAIL("got double as float"); } catch(DecodeError){}
+ try { get<float>(d); FAIL("got double as float"); } catch(decode_error){}
ASSERT_EQUAL(0.125, get<double>(d));
ASSERT(!d.more());
}
// Test inserting primitive sand encoding as AMQP.
-void testEncoderPrimitives() {
- Encoder e;
+void test_encoder_primitives() {
+ encoder e;
e << true << false;
e << std::uint8_t(42);
e << std::uint16_t(42) << std::int16_t(-42);
@@ -101,16 +100,16 @@ void testEncoderPrimitives() {
}
// Test type conversions.
-void testValueConversions() {
- Value v;
+void test_value_conversions() {
+ value v;
ASSERT_EQUAL(true, bool(v = true));
- ASSERT_EQUAL(2, int(v=Byte(2)));
- ASSERT_EQUAL(3, long(v=Byte(3)));
- ASSERT_EQUAL(3, long(v=Byte(3)));
- ASSERT_EQUAL(1.0, double(v=Float(1.0)));
- ASSERT_EQUAL(1.0, float(v=Double(1.0)));
- try { bool(v = Byte(1)); FAIL("got byte as bool"); } catch (DecodeError) {}
- try { float(v = true); FAIL("got bool as float"); } catch (DecodeError) {}
+ ASSERT_EQUAL(2, int(v=amqp_byte(2)));
+ ASSERT_EQUAL(3, long(v=amqp_byte(3)));
+ ASSERT_EQUAL(3, long(v=amqp_byte(3)));
+ ASSERT_EQUAL(1.0, double(v=amqp_float(1.0)));
+ ASSERT_EQUAL(1.0, float(v=amqp_double(1.0)));
+ try { bool(v = amqp_byte(1)); FAIL("got byte as bool"); } catch (decode_error) {}
+ try { float(v = true); FAIL("got bool as float"); } catch (decode_error) {}
}
int run_test(void (*testfn)(), const char* name) {
@@ -132,11 +131,11 @@ int run_test(void (*testfn)(), const char* name) {
int main(int argc, char** argv) {
int failed = 0;
if (argc != 2) FAIL("Usage: " << argv[0] << " tests-dir");
- testsDir = argv[1];
+ tests_dir = argv[1];
- failed += RUN_TEST(testDataOstream);
- failed += RUN_TEST(testDecoderPrimitvesExact);
- failed += RUN_TEST(testEncoderPrimitives);
- failed += RUN_TEST(testValueConversions);
+ failed += RUN_TEST(test_data_ostream);
+ failed += RUN_TEST(test_decoder_primitves_exact);
+ failed += RUN_TEST(test_encoder_primitives);
+ failed += RUN_TEST(test_value_conversions);
return failed;
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/link.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/link.cpp b/proton-c/bindings/cpp/src/link.cpp
new file mode 100644
index 0000000..2470510
--- /dev/null
+++ b/proton-c/bindings/cpp/src/link.cpp
@@ -0,0 +1,113 @@
+/*
+ *
+ * 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/link.hpp"
+#include "proton/error.hpp"
+#include "proton/connection.hpp"
+#include "connection_impl.hpp"
+#include "msg.hpp"
+#include "contexts.hpp"
+#include "proton_impl_ref.hpp"
+
+#include "proton/connection.h"
+#include "proton/session.h"
+#include "proton/link.h"
+
+namespace proton {
+
+template class proton_handle<pn_link_t>;
+typedef proton_impl_ref<link> PI;
+
+link::link(pn_link_t* p) {
+ verify_type(p);
+ PI::ctor(*this, p);
+ if (p) sender_link = pn_link_is_sender(p);
+}
+link::link() {
+ PI::ctor(*this, 0);
+}
+link::link(const link& c) : proton_handle<pn_link_t>() {
+ verify_type(impl_);
+ PI::copy(*this, c);
+ sender_link = c.sender_link;
+}
+link& link::operator=(const link& c) {
+ verify_type(impl_);
+ sender_link = c.sender_link;
+ return PI::assign(*this, c);
+}
+link::~link() { PI::dtor(*this); }
+
+void link::verify_type(pn_link_t *l) {} // Generic link can be sender or receiver
+
+pn_link_t *link::pn_link() const { return impl_; }
+
+void link::open() {
+ pn_link_open(impl_);
+}
+
+void link::close() {
+ pn_link_close(impl_);
+}
+
+bool link::is_sender() {
+ return impl_ && sender_link;
+}
+
+bool link::is_receiver() {
+ return impl_ && !sender_link;
+}
+
+int link::credit() {
+ return pn_link_credit(impl_);
+}
+
+terminus link::source() {
+ return terminus(pn_link_source(impl_), this);
+}
+
+terminus link::target() {
+ return terminus(pn_link_target(impl_), this);
+}
+
+terminus link::remote_source() {
+ return terminus(pn_link_remote_source(impl_), this);
+}
+
+terminus link::remote_target() {
+ return terminus(pn_link_remote_target(impl_), this);
+}
+
+std::string link::name() {
+ return std::string(pn_link_name(impl_));
+}
+
+class connection &link::connection() {
+ pn_session_t *s = pn_link_session(impl_);
+ pn_connection_t *c = pn_session_connection(s);
+ return connection_impl::reactor_reference(c);
+}
+
+link link::next(endpoint::State mask) {
+
+ return link(pn_link_next(impl_, (pn_state_t) mask));
+}
+
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/message.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/message.cpp b/proton-c/bindings/cpp/src/message.cpp
new file mode 100644
index 0000000..62dca4d
--- /dev/null
+++ b/proton-c/bindings/cpp/src/message.cpp
@@ -0,0 +1,252 @@
+/*
+ *
+ * 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/message.hpp"
+#include "proton/error.hpp"
+#include "proton/message.h"
+#include "msg.hpp"
+#include "proton_bits.hpp"
+#include "proton_impl_ref.hpp"
+
+#include <cstring>
+
+namespace proton {
+
+template class proton_handle<pn_message_t>;
+
+typedef proton_impl_ref<message> PI;
+
+message::message() : body_(0) {
+ PI::ctor(*this, 0);
+}
+message::message(pn_message_t *p) : body_(0) {
+ PI::ctor(*this, p);
+}
+message::message(const message& m) : proton_handle<pn_message_t>(), body_(0) {
+ PI::copy(*this, m);
+}
+
+// FIXME aconway 2015-06-17: message should be a value type, needs to own pn_message_t
+// and do appropriate _copy and _free operations.
+message& message::operator=(const message& m) {
+ return PI::assign(*this, m);
+}
+message::~message() { PI::dtor(*this); }
+
+namespace {
+void confirm(pn_message_t * const& p) {
+ if (p) return;
+ const_cast<pn_message_t*&>(p) = pn_message(); // Correct refcount of 1
+ if (!p)
+ throw error(MSG("No memory"));
+}
+
+void check(int err) {
+ if (err) throw error(error_str(err));
+}
+
+void set_value(pn_data_t* d, const value& v) {
+ values values(d);
+ values.clear();
+ values << v;
+}
+
+value get_value(pn_data_t* d) {
+ values values(d);
+ values.rewind();
+ return values.get<value>();
+}
+} // namespace
+
+void message::id(const value& id) {
+ confirm(impl_);
+ set_value(pn_message_id(impl_), id);
+}
+
+value message::id() const {
+ confirm(impl_);
+ return get_value(pn_message_id(impl_));
+}
+void message::user(const std::string &id) {
+ confirm(impl_);
+ check(pn_message_set_user_id(impl_, pn_bytes(id)));
+}
+
+std::string message::user() const {
+ confirm(impl_);
+ return str(pn_message_get_user_id(impl_));
+}
+
+void message::address(const std::string &addr) {
+ confirm(impl_);
+ check(pn_message_set_address(impl_, addr.c_str()));
+}
+
+std::string message::address() const {
+ confirm(impl_);
+ const char* addr = pn_message_get_address(impl_);
+ return addr ? std::string(addr) : std::string();
+}
+
+void message::subject(const std::string &s) {
+ confirm(impl_);
+ check(pn_message_set_subject(impl_, s.c_str()));
+}
+
+std::string message::subject() const {
+ confirm(impl_);
+ const char* s = pn_message_get_subject(impl_);
+ return s ? std::string(s) : std::string();
+}
+
+void message::reply_to(const std::string &s) {
+ confirm(impl_);
+ check(pn_message_set_reply_to(impl_, s.c_str()));
+}
+
+std::string message::reply_to() const {
+ confirm(impl_);
+ const char* s = pn_message_get_reply_to(impl_);
+ return s ? std::string(s) : std::string();
+}
+
+void message::correlation_id(const value& id) {
+ confirm(impl_);
+ set_value(pn_message_correlation_id(impl_), id);
+}
+
+value message::correlation_id() const {
+ confirm(impl_);
+ return get_value(pn_message_correlation_id(impl_));
+}
+
+void message::content_type(const std::string &s) {
+ confirm(impl_);
+ check(pn_message_set_content_type(impl_, s.c_str()));
+}
+
+std::string message::content_type() const {
+ confirm(impl_);
+ const char* s = pn_message_get_content_type(impl_);
+ return s ? std::string(s) : std::string();
+}
+
+void message::content_encoding(const std::string &s) {
+ confirm(impl_);
+ check(pn_message_set_content_encoding(impl_, s.c_str()));
+}
+
+std::string message::content_encoding() const {
+ confirm(impl_);
+ const char* s = pn_message_get_content_encoding(impl_);
+ return s ? std::string(s) : std::string();
+}
+
+void message::expiry(amqp_timestamp t) {
+ confirm(impl_);
+ pn_message_set_expiry_time(impl_, t.milliseconds);
+}
+amqp_timestamp message::expiry() const {
+ confirm(impl_);
+ return amqp_timestamp(pn_message_get_expiry_time(impl_));
+}
+
+void message::creation_time(amqp_timestamp t) {
+ confirm(impl_);
+ pn_message_set_creation_time(impl_, t);
+}
+amqp_timestamp message::creation_time() const {
+ confirm(impl_);
+ return pn_message_get_creation_time(impl_);
+}
+
+void message::group_id(const std::string &s) {
+ confirm(impl_);
+ check(pn_message_set_group_id(impl_, s.c_str()));
+}
+
+std::string message::group_id() const {
+ confirm(impl_);
+ const char* s = pn_message_get_group_id(impl_);
+ return s ? std::string(s) : std::string();
+}
+
+void message::reply_togroup_id(const std::string &s) {
+ confirm(impl_);
+ check(pn_message_set_reply_to_group_id(impl_, s.c_str()));
+}
+
+std::string message::reply_togroup_id() const {
+ confirm(impl_);
+ const char* s = pn_message_get_reply_to_group_id(impl_);
+ return s ? std::string(s) : std::string();
+}
+
+void message::body(const value& v) {
+ confirm(impl_);
+ set_value(pn_message_body(impl_), v);
+}
+
+void message::body(const values& v) {
+ confirm(impl_);
+ pn_data_copy(pn_message_body(impl_), v.data_);
+}
+
+const values& message::body() const {
+ confirm(impl_);
+ body_.view(pn_message_body(impl_));
+ return body_;
+}
+
+values& message::body() {
+ confirm(impl_);
+ body_.view(pn_message_body(impl_));
+ return body_;
+}
+
+void message::encode(std::string &s) {
+ confirm(impl_);
+ size_t sz = s.capacity();
+ if (sz < 512) sz = 512;
+ while (true) {
+ s.resize(sz);
+ int err = pn_message_encode(impl_, (char *) s.data(), &sz);
+ if (err) {
+ if (err != PN_OVERFLOW)
+ check(err);
+ } else {
+ s.resize(sz);
+ return;
+ }
+ sz *= 2;
+ }
+}
+
+void message::decode(const std::string &s) {
+ confirm(impl_);
+ check(pn_message_decode(impl_, s.data(), s.size()));
+}
+
+pn_message_t *message::pn_message() const {
+ return impl_;
+}
+
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/messaging_adapter.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/messaging_adapter.cpp b/proton-c/bindings/cpp/src/messaging_adapter.cpp
new file mode 100644
index 0000000..433b254
--- /dev/null
+++ b/proton-c/bindings/cpp/src/messaging_adapter.cpp
@@ -0,0 +1,411 @@
+/*
+ *
+ * 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/messaging_adapter.hpp"
+#include "proton/messaging_event.hpp"
+#include "proton/sender.hpp"
+#include "proton/error.hpp"
+#include "msg.hpp"
+
+#include "proton/link.h"
+#include "proton/handlers.h"
+#include "proton/delivery.h"
+#include "proton/connection.h"
+#include "proton/session.h"
+
+namespace proton {
+messaging_adapter::messaging_adapter(messaging_handler &delegate_) :
+ messaging_handler(true, delegate_.prefetch_, delegate_.auto_settle_, delegate_.auto_accept_, delegate_.peer_close_iserror_),
+ delegate_(delegate_)
+{}
+
+
+messaging_adapter::~messaging_adapter(){}
+
+
+void messaging_adapter::on_reactor_init(event &e) {
+ proton_event *pe = dynamic_cast<proton_event*>(&e);
+ if (pe) {
+ messaging_event mevent(PN_MESSAGING_START, *pe);
+ delegate_.on_start(mevent);
+ }
+}
+
+void messaging_adapter::on_link_flow(event &e) {
+ proton_event *pe = dynamic_cast<proton_event*>(&e);
+ if (pe) {
+ pn_event_t *pne = pe->pn_event();
+ pn_link_t *lnk = pn_event_link(pne);
+ if (lnk && pn_link_is_sender(lnk) && pn_link_credit(lnk) > 0) {
+ // create on_message extended event
+ messaging_event mevent(PN_MESSAGING_SENDABLE, *pe);
+ delegate_.on_sendable(mevent);;
+ }
+ }
+}
+
+namespace {
+message receive_message(pn_link_t *lnk, pn_delivery_t *dlv) {
+ std::string buf;
+ size_t sz = pn_delivery_pending(dlv);
+ buf.resize(sz);
+ ssize_t n = pn_link_recv(lnk, (char *) buf.data(), sz);
+ if (n != (ssize_t) sz)
+ throw error(MSG("link read failure"));
+ message m;
+ m. decode(buf);
+ pn_link_advance(lnk);
+ return m;
+}
+} // namespace
+
+void messaging_adapter::on_delivery(event &e) {
+ proton_event *pe = dynamic_cast<proton_event*>(&e);
+ if (pe) {
+ pn_event_t *cevent = pe->pn_event();
+ pn_link_t *lnk = pn_event_link(cevent);
+ pn_delivery_t *dlv = pn_event_delivery(cevent);
+
+ if (pn_link_is_receiver(lnk)) {
+ if (!pn_delivery_partial(dlv) && pn_delivery_readable(dlv)) {
+ // generate on_message
+ messaging_event mevent(PN_MESSAGING_MESSAGE, *pe);
+ message m(receive_message(lnk, dlv));
+ mevent.message(m);
+ if (pn_link_state(lnk) & PN_LOCAL_CLOSED) {
+ if (auto_accept_) {
+ pn_delivery_update(dlv, PN_RELEASED);
+ pn_delivery_settle(dlv);
+ }
+ }
+ else {
+ try {
+ delegate_.on_message(mevent);
+ if (auto_accept_) {
+ pn_delivery_update(dlv, PN_ACCEPTED);
+ pn_delivery_settle(dlv);
+ }
+ }
+ catch (message_reject &) {
+ pn_delivery_update(dlv, PN_REJECTED);
+ pn_delivery_settle(dlv);
+ }
+ catch (message_release &) {
+ pn_delivery_update(dlv, PN_REJECTED);
+ pn_delivery_settle(dlv);
+ }
+ }
+ }
+ else if (pn_delivery_updated(dlv) && pn_delivery_settled(dlv)) {
+ messaging_event mevent(PN_MESSAGING_SETTLED, *pe);
+ delegate_.on_settled(mevent);
+ }
+ } else {
+ // sender
+ if (pn_delivery_updated(dlv)) {
+ std::uint64_t rstate = pn_delivery_remote_state(dlv);
+ if (rstate == PN_ACCEPTED) {
+ messaging_event mevent(PN_MESSAGING_ACCEPTED, *pe);
+ delegate_.on_accepted(mevent);
+ }
+ else if (rstate == PN_REJECTED) {
+ messaging_event mevent(PN_MESSAGING_REJECTED, *pe);
+ delegate_.on_rejected(mevent);
+ }
+ else if (rstate == PN_RELEASED || rstate == PN_MODIFIED) {
+ messaging_event mevent(PN_MESSAGING_RELEASED, *pe);
+ delegate_.on_released(mevent);
+ }
+
+ if (pn_delivery_settled(dlv)) {
+ messaging_event mevent(PN_MESSAGING_SETTLED, *pe);
+ delegate_.on_settled(mevent);
+ }
+ if (auto_settle_)
+ pn_delivery_settle(dlv);
+ }
+ }
+ }
+}
+
+namespace {
+
+bool is_local_open(pn_state_t state) {
+ return state & PN_LOCAL_ACTIVE;
+}
+
+bool is_local_unititialised(pn_state_t state) {
+ return state & PN_LOCAL_UNINIT;
+}
+
+bool is_local_closed(pn_state_t state) {
+ return state & PN_LOCAL_CLOSED;
+}
+
+bool is_remote_open(pn_state_t state) {
+ return state & PN_REMOTE_ACTIVE;
+}
+
+} // namespace
+
+void messaging_adapter::on_link_remote_close(event &e) {
+ proton_event *pe = dynamic_cast<proton_event*>(&e);
+ if (pe) {
+ pn_event_t *cevent = pe->pn_event();
+ pn_link_t *lnk = pn_event_link(cevent);
+ pn_state_t state = pn_link_state(lnk);
+ if (pn_condition_is_set(pn_link_remote_condition(lnk))) {
+ messaging_event mevent(PN_MESSAGING_LINK_ERROR, *pe);
+ on_link_error(mevent);
+ }
+ else if (is_local_closed(state)) {
+ messaging_event mevent(PN_MESSAGING_LINK_CLOSED, *pe);
+ on_link_closed(mevent);
+ }
+ else {
+ messaging_event mevent(PN_MESSAGING_LINK_CLOSING, *pe);
+ on_link_closing(mevent);
+ }
+ pn_link_close(lnk);
+ }
+}
+
+void messaging_adapter::on_session_remote_close(event &e) {
+ proton_event *pe = dynamic_cast<proton_event*>(&e);
+ if (pe) {
+ pn_event_t *cevent = pe->pn_event();
+ pn_session_t *session = pn_event_session(cevent);
+ pn_state_t state = pn_session_state(session);
+ if (pn_condition_is_set(pn_session_remote_condition(session))) {
+ messaging_event mevent(PN_MESSAGING_SESSION_ERROR, *pe);
+ on_session_error(mevent);
+ }
+ else if (is_local_closed(state)) {
+ messaging_event mevent(PN_MESSAGING_SESSION_CLOSED, *pe);
+ on_session_closed(mevent);
+ }
+ else {
+ messaging_event mevent(PN_MESSAGING_SESSION_CLOSING, *pe);
+ on_session_closing(mevent);
+ }
+ pn_session_close(session);
+ }
+}
+
+void messaging_adapter::on_connection_remote_close(event &e) {
+ proton_event *pe = dynamic_cast<proton_event*>(&e);
+ if (pe) {
+ pn_event_t *cevent = pe->pn_event();
+ pn_connection_t *connection = pn_event_connection(cevent);
+ pn_state_t state = pn_connection_state(connection);
+ if (pn_condition_is_set(pn_connection_remote_condition(connection))) {
+ messaging_event mevent(PN_MESSAGING_CONNECTION_ERROR, *pe);
+ on_connection_error(mevent);
+ }
+ else if (is_local_closed(state)) {
+ messaging_event mevent(PN_MESSAGING_CONNECTION_CLOSED, *pe);
+ on_connection_closed(mevent);
+ }
+ else {
+ messaging_event mevent(PN_MESSAGING_CONNECTION_CLOSING, *pe);
+ on_connection_closing(mevent);
+ }
+ pn_connection_close(connection);
+ }
+}
+
+void messaging_adapter::on_connection_local_open(event &e) {
+ proton_event *pe = dynamic_cast<proton_event*>(&e);
+ if (pe) {
+ pn_connection_t *connection = pn_event_connection(pe->pn_event());
+ if (is_remote_open(pn_connection_state(connection))) {
+ messaging_event mevent(PN_MESSAGING_CONNECTION_OPENED, *pe);
+ on_connection_opened(mevent);
+ }
+ }
+}
+
+void messaging_adapter::on_connection_remote_open(event &e) {
+ proton_event *pe = dynamic_cast<proton_event*>(&e);
+ if (pe) {
+ pn_connection_t *connection = pn_event_connection(pe->pn_event());
+ if (is_local_open(pn_connection_state(connection))) {
+ messaging_event mevent(PN_MESSAGING_CONNECTION_OPENED, *pe);
+ on_connection_opened(mevent);
+ }
+ else if (is_local_unititialised(pn_connection_state(connection))) {
+ messaging_event mevent(PN_MESSAGING_CONNECTION_OPENING, *pe);
+ on_connection_opening(mevent);
+ pn_connection_open(connection);
+ }
+ }
+}
+
+void messaging_adapter::on_session_local_open(event &e) {
+ proton_event *pe = dynamic_cast<proton_event*>(&e);
+ if (pe) {
+ pn_session_t *session = pn_event_session(pe->pn_event());
+ if (is_remote_open(pn_session_state(session))) {
+ messaging_event mevent(PN_MESSAGING_SESSION_OPENED, *pe);
+ on_session_opened(mevent);
+ }
+ }
+}
+
+void messaging_adapter::on_session_remote_open(event &e) {
+ proton_event *pe = dynamic_cast<proton_event*>(&e);
+ if (pe) {
+ pn_session_t *session = pn_event_session(pe->pn_event());
+ if (is_local_open(pn_session_state(session))) {
+ messaging_event mevent(PN_MESSAGING_SESSION_OPENED, *pe);
+ on_session_opened(mevent);
+ }
+ else if (is_local_unititialised(pn_session_state(session))) {
+ messaging_event mevent(PN_MESSAGING_SESSION_OPENING, *pe);
+ on_session_opening(mevent);
+ pn_session_open(session);
+ }
+ }
+}
+
+void messaging_adapter::on_link_local_open(event &e) {
+ proton_event *pe = dynamic_cast<proton_event*>(&e);
+ if (pe) {
+ pn_link_t *link = pn_event_link(pe->pn_event());
+ if (is_remote_open(pn_link_state(link))) {
+ messaging_event mevent(PN_MESSAGING_LINK_OPENED, *pe);
+ on_link_opened(mevent);
+ }
+ }
+}
+
+void messaging_adapter::on_link_remote_open(event &e) {
+ proton_event *pe = dynamic_cast<proton_event*>(&e);
+ if (pe) {
+ pn_link_t *link = pn_event_link(pe->pn_event());
+ if (is_local_open(pn_link_state(link))) {
+ messaging_event mevent(PN_MESSAGING_LINK_OPENED, *pe);
+ on_link_opened(mevent);
+ }
+ else if (is_local_unititialised(pn_link_state(link))) {
+ messaging_event mevent(PN_MESSAGING_LINK_OPENING, *pe);
+ on_link_opening(mevent);
+ pn_link_open(link);
+ }
+ }
+}
+
+void messaging_adapter::on_transport_tail_closed(event &e) {
+ proton_event *pe = dynamic_cast<proton_event*>(&e);
+ if (pe) {
+ pn_connection_t *conn = pn_event_connection(pe->pn_event());
+ if (conn && is_local_open(pn_connection_state(conn))) {
+ messaging_event mevent(PN_MESSAGING_DISCONNECTED, *pe);
+ delegate_.on_disconnected(mevent);
+ }
+ }
+}
+
+
+void messaging_adapter::on_connection_opened(event &e) {
+ delegate_.on_connection_opened(e);
+}
+
+void messaging_adapter::on_session_opened(event &e) {
+ delegate_.on_session_opened(e);
+}
+
+void messaging_adapter::on_link_opened(event &e) {
+ delegate_.on_link_opened(e);
+}
+
+void messaging_adapter::on_connection_opening(event &e) {
+ delegate_.on_connection_opening(e);
+}
+
+void messaging_adapter::on_session_opening(event &e) {
+ delegate_.on_session_opening(e);
+}
+
+void messaging_adapter::on_link_opening(event &e) {
+ delegate_.on_link_opening(e);
+}
+
+void messaging_adapter::on_connection_error(event &e) {
+ delegate_.on_connection_error(e);
+ proton_event *pe = dynamic_cast<proton_event*>(&e);
+ if (pe) {
+ pn_connection_t *connection = pn_event_connection(pe->pn_event());
+ pn_connection_close(connection);
+ }
+}
+
+void messaging_adapter::on_session_error(event &e) {
+ delegate_.on_session_error(e);
+ proton_event *pe = dynamic_cast<proton_event*>(&e);
+ if (pe) {
+ pn_session_t *session = pn_event_session(pe->pn_event());
+ pn_session_close(session);
+ }
+}
+
+void messaging_adapter::on_link_error(event &e) {
+ delegate_.on_link_error(e);
+ proton_event *pe = dynamic_cast<proton_event*>(&e);
+ if (pe) {
+ pn_link_t *link = pn_event_link(pe->pn_event());
+ pn_link_close(link);
+ }
+}
+
+void messaging_adapter::on_connection_closed(event &e) {
+ delegate_.on_connection_closed(e);
+}
+
+void messaging_adapter::on_session_closed(event &e) {
+ delegate_.on_session_closed(e);
+}
+
+void messaging_adapter::on_link_closed(event &e) {
+ delegate_.on_link_closed(e);
+}
+
+void messaging_adapter::on_connection_closing(event &e) {
+ delegate_.on_connection_closing(e);
+ if (peer_close_iserror_)
+ on_connection_error(e);
+}
+
+void messaging_adapter::on_session_closing(event &e) {
+ delegate_.on_session_closing(e);
+ if (peer_close_iserror_)
+ on_session_error(e);
+}
+
+void messaging_adapter::on_link_closing(event &e) {
+ delegate_.on_link_closing(e);
+ if (peer_close_iserror_)
+ on_link_error(e);
+}
+
+void messaging_adapter::on_unhandled(event &e) {
+}
+
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/messaging_event.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/messaging_event.cpp b/proton-c/bindings/cpp/src/messaging_event.cpp
new file mode 100644
index 0000000..b5da375
--- /dev/null
+++ b/proton-c/bindings/cpp/src/messaging_event.cpp
@@ -0,0 +1,148 @@
+/*
+ *
+ * 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/reactor.h"
+#include "proton/event.h"
+#include "proton/link.h"
+
+#include "proton/messaging_event.hpp"
+#include "proton/message.hpp"
+#include "proton/proton_handler.hpp"
+#include "proton/messaging_handler.hpp"
+#include "proton/error.hpp"
+#include "msg.hpp"
+#include "contexts.hpp"
+
+namespace proton {
+
+messaging_event::messaging_event(pn_event_t *ce, pn_event_type_t t, class container &c) :
+ proton_event(ce, t, c), messaging_type_(PN_MESSAGING_PROTON), parent_event_(0), message_(0)
+{}
+
+messaging_event::messaging_event(messaging_event_type_t t, proton_event &p) :
+ proton_event(NULL, PN_EVENT_NONE, p.container()), messaging_type_(t), parent_event_(&p), message_(0) {
+ if (messaging_type_ == PN_MESSAGING_PROTON)
+ throw error(MSG("invalid messaging event type"));
+}
+
+messaging_event::~messaging_event() {
+ delete message_;
+}
+
+connection &messaging_event::connection() {
+ if (messaging_type_ == PN_MESSAGING_PROTON)
+ return proton_event::connection();
+ if (parent_event_)
+ return parent_event_->connection();
+ throw error(MSG("No connection context for event"));
+}
+
+sender messaging_event::sender() {
+ if (messaging_type_ == PN_MESSAGING_PROTON)
+ return proton_event::sender();
+ if (parent_event_)
+ return parent_event_->sender();
+ throw error(MSG("No sender context for event"));
+}
+
+receiver messaging_event::receiver() {
+ if (messaging_type_ == PN_MESSAGING_PROTON)
+ return proton_event::receiver();
+ if (parent_event_)
+ return parent_event_->receiver();
+ throw error(MSG("No receiver context for event"));
+}
+
+link messaging_event::link() {
+ if (messaging_type_ == PN_MESSAGING_PROTON)
+ return proton_event::link();
+ if (parent_event_)
+ return parent_event_->link();
+ throw error(MSG("No link context for event"));
+}
+
+message messaging_event::message() {
+ if (parent_event_) {
+ pn_message_t *m = event_context(parent_event_->pn_event());
+ if (m)
+ return proton::message(m);
+ }
+ throw error(MSG("No message context for event"));
+}
+
+void messaging_event::message(class message &m) {
+ if (messaging_type_ != PN_MESSAGING_MESSAGE || !parent_event_)
+ throw error(MSG("event type does not provide message"));
+ event_context(parent_event_->pn_event(), m.pn_message());
+}
+
+void messaging_event::dispatch(handler &h) {
+ if (messaging_type_ == PN_MESSAGING_PROTON) {
+ proton_event::dispatch(h);
+ return;
+ }
+
+ messaging_handler *handler = dynamic_cast<messaging_handler*>(&h);
+ if (handler) {
+ switch(messaging_type_) {
+
+ case PN_MESSAGING_START: handler->on_start(*this); break;
+ case PN_MESSAGING_SENDABLE: handler->on_sendable(*this); break;
+ case PN_MESSAGING_MESSAGE: handler->on_message(*this); break;
+ case PN_MESSAGING_ACCEPTED: handler->on_accepted(*this); break;
+ case PN_MESSAGING_REJECTED: handler->on_rejected(*this); break;
+ case PN_MESSAGING_RELEASED: handler->on_released(*this); break;
+ case PN_MESSAGING_SETTLED: handler->on_settled(*this); break;
+
+ case PN_MESSAGING_CONNECTION_CLOSING: handler->on_connection_closing(*this); break;
+ case PN_MESSAGING_CONNECTION_CLOSED: handler->on_connection_closed(*this); break;
+ case PN_MESSAGING_CONNECTION_ERROR: handler->on_connection_error(*this); break;
+ case PN_MESSAGING_CONNECTION_OPENING: handler->on_connection_opening(*this); break;
+ case PN_MESSAGING_CONNECTION_OPENED: handler->on_connection_opened(*this); break;
+
+ case PN_MESSAGING_LINK_CLOSED: handler->on_link_closed(*this); break;
+ case PN_MESSAGING_LINK_CLOSING: handler->on_link_closing(*this); break;
+ case PN_MESSAGING_LINK_ERROR: handler->on_link_error(*this); break;
+ case PN_MESSAGING_LINK_OPENING: handler->on_link_opening(*this); break;
+ case PN_MESSAGING_LINK_OPENED: handler->on_link_opened(*this); break;
+
+ case PN_MESSAGING_SESSION_CLOSED: handler->on_session_closed(*this); break;
+ case PN_MESSAGING_SESSION_CLOSING: handler->on_session_closing(*this); break;
+ case PN_MESSAGING_SESSION_ERROR: handler->on_session_error(*this); break;
+ case PN_MESSAGING_SESSION_OPENING: handler->on_session_opening(*this); break;
+ case PN_MESSAGING_SESSION_OPENED: handler->on_session_opened(*this); break;
+
+ case PN_MESSAGING_TRANSPORT_CLOSED: handler->on_transport_closed(*this); break;
+ default:
+ throw error(MSG("Unkown messaging event type " << messaging_type_));
+ break;
+ }
+ } else {
+ h.on_unhandled(*this);
+ }
+
+ // recurse through children
+ for (handler::iterator child = h.begin(); child != h.end(); ++child) {
+ dispatch(**child);
+ }
+}
+
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/messaging_handler.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/messaging_handler.cpp b/proton-c/bindings/cpp/src/messaging_handler.cpp
new file mode 100644
index 0000000..184cc9e
--- /dev/null
+++ b/proton-c/bindings/cpp/src/messaging_handler.cpp
@@ -0,0 +1,125 @@
+/*
+ *
+ * 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/messaging_handler.hpp"
+#include "proton/proton_event.hpp"
+#include "proton/messaging_adapter.hpp"
+#include "proton/handlers.h"
+
+namespace proton {
+
+namespace {
+class Cflow_controller : public proton_handler
+{
+ public:
+ pn_handler_t *flowcontroller;
+
+ Cflow_controller(int window) : flowcontroller(pn_flowcontroller(window)) {}
+ ~Cflow_controller() {
+ pn_decref(flowcontroller);
+ }
+
+ void redirect(event &e) {
+ proton_event *pne = dynamic_cast<proton_event *>(&e);
+ pn_handler_dispatch(flowcontroller, pne->pn_event(), (pn_event_type_t) pne->type());
+ }
+
+ virtual void on_link_local_open(event &e) { redirect(e); }
+ virtual void on_link_remote_open(event &e) { redirect(e); }
+ virtual void on_link_flow(event &e) { redirect(e); }
+ virtual void on_delivery(event &e) { redirect(e); }
+};
+
+} // namespace
+
+
+
+
+messaging_handler::messaging_handler(int prefetch0, bool auto_accept0, bool auto_settle0, bool peer_close_isError0) :
+ prefetch_(prefetch0), auto_accept_(auto_accept0), auto_settle_(auto_settle0), peer_close_iserror_(peer_close_isError0)
+{
+ create_helpers();
+}
+
+messaging_handler::messaging_handler(bool raw_handler, int prefetch0, bool auto_accept0, bool auto_settle0,
+ bool peer_close_isError0) :
+ prefetch_(prefetch0), auto_accept_(auto_accept0), auto_settle_(auto_settle0), peer_close_iserror_(peer_close_isError0)
+{
+ if (raw_handler) {
+ flow_controller_ = 0;
+ messaging_adapter_ = 0;
+ } else {
+ create_helpers();
+ }
+}
+
+void messaging_handler::create_helpers() {
+ if (prefetch_ > 0) {
+ flow_controller_ = new Cflow_controller(prefetch_);
+ add_child_handler(*flow_controller_);
+ }
+ messaging_adapter_ = new messaging_adapter(*this);
+ add_child_handler(*messaging_adapter_);
+}
+
+messaging_handler::~messaging_handler(){
+ delete flow_controller_;
+ delete messaging_adapter_;
+}
+
+void messaging_handler::on_abort(event &e) { on_unhandled(e); }
+void messaging_handler::on_accepted(event &e) { on_unhandled(e); }
+void messaging_handler::on_commit(event &e) { on_unhandled(e); }
+void messaging_handler::on_connection_closed(event &e) { on_unhandled(e); }
+void messaging_handler::on_connection_closing(event &e) { on_unhandled(e); }
+void messaging_handler::on_connection_error(event &e) { on_unhandled(e); }
+void messaging_handler::on_connection_opened(event &e) { on_unhandled(e); }
+void messaging_handler::on_connection_opening(event &e) { on_unhandled(e); }
+void messaging_handler::on_disconnected(event &e) { on_unhandled(e); }
+void messaging_handler::on_fetch(event &e) { on_unhandled(e); }
+void messaging_handler::on_idLoaded(event &e) { on_unhandled(e); }
+void messaging_handler::on_link_closed(event &e) { on_unhandled(e); }
+void messaging_handler::on_link_closing(event &e) { on_unhandled(e); }
+void messaging_handler::on_link_error(event &e) { on_unhandled(e); }
+void messaging_handler::on_link_opened(event &e) { on_unhandled(e); }
+void messaging_handler::on_link_opening(event &e) { on_unhandled(e); }
+void messaging_handler::on_message(event &e) { on_unhandled(e); }
+void messaging_handler::on_quit(event &e) { on_unhandled(e); }
+void messaging_handler::on_record_inserted(event &e) { on_unhandled(e); }
+void messaging_handler::on_records_loaded(event &e) { on_unhandled(e); }
+void messaging_handler::on_rejected(event &e) { on_unhandled(e); }
+void messaging_handler::on_released(event &e) { on_unhandled(e); }
+void messaging_handler::on_request(event &e) { on_unhandled(e); }
+void messaging_handler::on_response(event &e) { on_unhandled(e); }
+void messaging_handler::on_sendable(event &e) { on_unhandled(e); }
+void messaging_handler::on_session_closed(event &e) { on_unhandled(e); }
+void messaging_handler::on_session_closing(event &e) { on_unhandled(e); }
+void messaging_handler::on_session_error(event &e) { on_unhandled(e); }
+void messaging_handler::on_session_opened(event &e) { on_unhandled(e); }
+void messaging_handler::on_session_opening(event &e) { on_unhandled(e); }
+void messaging_handler::on_settled(event &e) { on_unhandled(e); }
+void messaging_handler::on_start(event &e) { on_unhandled(e); }
+void messaging_handler::on_timer(event &e) { on_unhandled(e); }
+void messaging_handler::on_transaction_aborted(event &e) { on_unhandled(e); }
+void messaging_handler::on_transaction_committed(event &e) { on_unhandled(e); }
+void messaging_handler::on_transaction_declared(event &e) { on_unhandled(e); }
+void messaging_handler::on_transport_closed(event &e) { on_unhandled(e); }
+
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/msg.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/msg.hpp b/proton-c/bindings/cpp/src/msg.hpp
new file mode 100644
index 0000000..b5d2a51
--- /dev/null
+++ b/proton-c/bindings/cpp/src/msg.hpp
@@ -0,0 +1,58 @@
+#ifndef PROTON_MSG_H
+#define PROTON_MSG_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 <sstream>
+#include <iostream>
+
+namespace proton {
+
+/** A simple wrapper for std::ostringstream that allows
+ * in place construction of a message and automatic conversion
+ * to string.
+ * E.g.
+ *@code
+ * void foo(const std::string&);
+ * foo(msg() << "hello " << 32);
+ *@endcode
+ * Will construct the string "hello 32" and pass it to foo()
+ */
+struct msg {
+ std::ostringstream os;
+ msg() {}
+ msg(const msg& m) : os(m.str()) {}
+ std::string str() const { return os.str(); }
+ operator std::string() const { return str(); }
+ template <class T> msg& operator<<(const T& t) { os <<t; return *this; }
+};
+
+inline std::ostream& operator<<(std::ostream& o, const msg& m) { return o << m.str(); }
+
+/** Construct a message using operator << and append (file:line) */
+#define QUOTe_(x) #x
+#define QUOTE(x) QUOTe_(x)
+#define MSG(message) (::proton::msg() << message)
+
+}
+
+#endif /*!PROTON_MSG_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/private_impl_ref.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/private_impl_ref.hpp b/proton-c/bindings/cpp/src/private_impl_ref.hpp
new file mode 100644
index 0000000..2935d79
--- /dev/null
+++ b/proton-c/bindings/cpp/src/private_impl_ref.hpp
@@ -0,0 +1,96 @@
+#ifndef PROTON_CPP_PRIVATEIMPL_H
+#define PROTON_CPP_PRIVATEIMPL_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 {
+
+// Modified from qpid::messaging version to work without
+// boost::intrusive_ptr but integrate with Proton's pn_class_t
+// reference counting. Thread safety currently absent but fluid in
+// intention...
+
+
+/**
+ * Helper class to implement a class with a private, reference counted
+ * implementation and reference semantics.
+ *
+ * Such classes are used in the public API to hide implementation, they
+ * should. Example of use:
+ *
+ * === Foo.h
+ *
+ * template <class T> private_impl_ref;
+ * class foo_impl;
+ *
+ * Foo : public handle<foo_impl> {
+ * public:
+ * Foo(foo_impl* = 0);
+ * Foo(const Foo&);
+ * ~Foo();
+ * Foo& operator=(const Foo&);
+ *
+ * int foo_do(); // and other Foo functions...
+ *
+ * private:
+ * typedef foo_impl Impl;
+ * Impl* impl_;
+ * friend class private_impl_ref<Foo>;
+ *
+ * === Foo.cpp
+ *
+ * typedef private_impl_ref<Foo> PI;
+ * Foo::Foo(foo_impl* p) { PI::ctor(*this, p); }
+ * Foo::Foo(const Foo& c) : handle<foo_impl>() { PI::copy(*this, c); }
+ * Foo::~Foo() { PI::dtor(*this); }
+ * Foo& Foo::operator=(const Foo& c) { return PI::assign(*this, c); }
+ *
+ * int foo::foo_do() { return impl_->foo_do(); }
+ *
+ */
+template <class T> class private_impl_ref {
+ public:
+ typedef typename T::Impl Impl;
+
+ /** Get the implementation pointer from a handle */
+ static Impl* get(const T& t) { return t.impl_; }
+
+ /** Set the implementation pointer in a handle */
+ static void set(T& t, const Impl* p) {
+ if (t.impl_ == p) return;
+ if (t.impl_) Impl::decref(t.impl_);
+ t.impl_ = const_cast<Impl *>(p);
+ if (t.impl_) Impl::incref(t.impl_);
+ }
+
+ // Helper functions to implement the ctor, dtor, copy, assign
+ static void ctor(T& t, Impl* p) { t.impl_ = p; if (p) Impl::incref(p); }
+ static void copy(T& t, const T& x) { if (&t == &x) return; t.impl_ = 0; assign(t, x); }
+ static void dtor(T& t) { if(t.impl_) Impl::decref(t.impl_); }
+ static T& assign(T& t, const T& x) { set(t, get(x)); return t;}
+};
+
+}
+
+#endif /*!PROTON_CPP_PRIVATEIMPL_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/proton_bits.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/proton_bits.cpp b/proton-c/bindings/cpp/src/proton_bits.cpp
index e06589c..aea18a3 100644
--- a/proton-c/bindings/cpp/src/proton_bits.cpp
+++ b/proton-c/bindings/cpp/src/proton_bits.cpp
@@ -23,7 +23,7 @@
#include <proton/object.h>
#include "proton_bits.hpp"
-std::string errorStr(int code) {
+std::string error_str(int code) {
switch (code)
{
case 0: return "ok";
@@ -39,15 +39,15 @@ std::string errorStr(int code) {
}
}
-std::string errorStr(pn_error_t* err, int code) {
+std::string error_str(pn_error_t* err, int code) {
if (err && pn_error_code(err)) {
const char* text = pn_error_text(err);
- return text ? std::string(text) : errorStr(pn_error_code(err));
+ return text ? std::string(text) : error_str(pn_error_code(err));
}
- return errorStr(code);
+ return error_str(code);
}
-std::ostream& operator<<(std::ostream& o, const PnObject& object) {
+std::ostream& operator<<(std::ostream& o, const pn_object& object) {
pn_string_t* str = pn_string("");
pn_inspect(object.value, str);
o << pn_string_get(str);
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/proton_bits.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/proton_bits.hpp b/proton-c/bindings/cpp/src/proton_bits.hpp
index 803dae1..4dd9ad4 100644
--- a/proton-c/bindings/cpp/src/proton_bits.hpp
+++ b/proton-c/bindings/cpp/src/proton_bits.hpp
@@ -28,16 +28,16 @@
* Assorted internal proton utilities.
*/
-std::string errorStr(int code);
+std::string error_str(int code);
/** Print the error string from pn_error_t, or from code if pn_error_t has no error. */
-std::string errorStr(pn_error_t*, int code=0);
+std::string error_str(pn_error_t*, int code=0);
/** Wrapper for a proton object pointer. */
-struct PnObject { void* value; PnObject(void* o) : value(o) {} };
+struct pn_object { void* value; pn_object(void* o) : value(o) {} };
/** Stream a proton object via pn_inspect. */
-std::ostream& operator<<(std::ostream& o, const PnObject& object);
+std::ostream& operator<<(std::ostream& o, const pn_object& object);
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/proton_event.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/proton_event.cpp b/proton-c/bindings/cpp/src/proton_event.cpp
new file mode 100644
index 0000000..2d2f7d5
--- /dev/null
+++ b/proton-c/bindings/cpp/src/proton_event.cpp
@@ -0,0 +1,151 @@
+/*
+ *
+ * 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/reactor.h"
+#include "proton/event.h"
+#include "proton/link.h"
+
+#include "proton/proton_event.hpp"
+#include "proton/proton_handler.hpp"
+#include "proton/error.hpp"
+#include "proton/container.hpp"
+
+#include "connection_impl.hpp"
+#include "msg.hpp"
+#include "contexts.hpp"
+
+namespace proton {
+
+proton_event::proton_event(pn_event_t *ce, pn_event_type_t t, class container &c) :
+ pn_event_(ce),
+ type_((int) t),
+ container_(c)
+{}
+
+int proton_event::type() { return type_; }
+
+pn_event_t *proton_event::pn_event() { return pn_event_; }
+
+container &proton_event::container() { return container_; }
+
+connection &proton_event::connection() {
+ pn_connection_t *conn = pn_event_connection(pn_event());
+ if (!conn)
+ throw error(MSG("No connection context for this event"));
+ return connection_impl::reactor_reference(conn);
+}
+
+sender proton_event::sender() {
+ pn_link_t *lnk = pn_event_link(pn_event());
+ if (lnk && pn_link_is_sender(lnk))
+ return proton::sender(lnk);
+ throw error(MSG("No sender context for this event"));
+}
+
+receiver proton_event::receiver() {
+ pn_link_t *lnk = pn_event_link(pn_event());
+ if (lnk && pn_link_is_receiver(lnk))
+ return proton::receiver(lnk);
+ throw error(MSG("No receiver context for this event"));
+}
+
+link proton_event::link() {
+ pn_link_t *lnk = pn_event_link(pn_event());
+ if (lnk) {
+ if (pn_link_is_sender(lnk))
+ return proton::sender(lnk);
+ else
+ return proton::receiver(lnk);
+ }
+ throw error(MSG("No link context for this event"));
+}
+
+
+
+
+void proton_event::dispatch(handler &h) {
+ proton_handler *handler = dynamic_cast<proton_handler*>(&h);
+
+ if (handler) {
+ switch(type_) {
+
+ case PN_REACTOR_INIT: handler->on_reactor_init(*this); break;
+ case PN_REACTOR_QUIESCED: handler->on_reactor_quiesced(*this); break;
+ case PN_REACTOR_FINAL: handler->on_reactor_final(*this); break;
+
+ case PN_TIMER_TASK: handler->on_timer_task(*this); break;
+
+ case PN_CONNECTION_INIT: handler->on_connection_init(*this); break;
+ case PN_CONNECTION_BOUND: handler->on_connection_bound(*this); break;
+ case PN_CONNECTION_UNBOUND: handler->on_connection_unbound(*this); break;
+ case PN_CONNECTION_LOCAL_OPEN: handler->on_connection_local_open(*this); break;
+ case PN_CONNECTION_LOCAL_CLOSE: handler->on_connection_local_close(*this); break;
+ case PN_CONNECTION_REMOTE_OPEN: handler->on_connection_remote_open(*this); break;
+ case PN_CONNECTION_REMOTE_CLOSE: handler->on_connection_remote_close(*this); break;
+ case PN_CONNECTION_FINAL: handler->on_connection_final(*this); break;
+
+ case PN_SESSION_INIT: handler->on_session_init(*this); break;
+ case PN_SESSION_LOCAL_OPEN: handler->on_session_local_open(*this); break;
+ case PN_SESSION_LOCAL_CLOSE: handler->on_session_local_close(*this); break;
+ case PN_SESSION_REMOTE_OPEN: handler->on_session_remote_open(*this); break;
+ case PN_SESSION_REMOTE_CLOSE: handler->on_session_remote_close(*this); break;
+ case PN_SESSION_FINAL: handler->on_session_final(*this); break;
+
+ case PN_LINK_INIT: handler->on_link_init(*this); break;
+ case PN_LINK_LOCAL_OPEN: handler->on_link_local_open(*this); break;
+ case PN_LINK_LOCAL_CLOSE: handler->on_link_local_close(*this); break;
+ case PN_LINK_LOCAL_DETACH: handler->on_link_local_detach(*this); break;
+ case PN_LINK_REMOTE_OPEN: handler->on_link_remote_open(*this); break;
+ case PN_LINK_REMOTE_CLOSE: handler->on_link_remote_close(*this); break;
+ case PN_LINK_REMOTE_DETACH: handler->on_link_remote_detach(*this); break;
+ case PN_LINK_FLOW: handler->on_link_flow(*this); break;
+ case PN_LINK_FINAL: handler->on_link_final(*this); break;
+
+ case PN_DELIVERY: handler->on_delivery(*this); break;
+
+ case PN_TRANSPORT: handler->on_transport(*this); break;
+ case PN_TRANSPORT_ERROR: handler->on_transport_error(*this); break;
+ case PN_TRANSPORT_HEAD_CLOSED: handler->on_transport_head_closed(*this); break;
+ case PN_TRANSPORT_TAIL_CLOSED: handler->on_transport_tail_closed(*this); break;
+ case PN_TRANSPORT_CLOSED: handler->on_transport_closed(*this); break;
+
+ case PN_SELECTABLE_INIT: handler->on_selectable_init(*this); break;
+ case PN_SELECTABLE_UPDATED: handler->on_selectable_updated(*this); break;
+ case PN_SELECTABLE_READABLE: handler->on_selectable_readable(*this); break;
+ case PN_SELECTABLE_WRITABLE: handler->on_selectable_writable(*this); break;
+ case PN_SELECTABLE_EXPIRED: handler->on_selectable_expired(*this); break;
+ case PN_SELECTABLE_ERROR: handler->on_selectable_error(*this); break;
+ case PN_SELECTABLE_FINAL: handler->on_selectable_final(*this); break;
+ default:
+ throw error(MSG("Invalid Proton event type " << type_));
+ break;
+ }
+ } else {
+ h.on_unhandled(*this);
+ }
+
+ // recurse through children
+ for (handler::iterator child = h.begin(); child != h.end(); ++child) {
+ dispatch(**child);
+ }
+}
+
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/proton_handler.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/proton_handler.cpp b/proton-c/bindings/cpp/src/proton_handler.cpp
new file mode 100644
index 0000000..d7c2da4
--- /dev/null
+++ b/proton-c/bindings/cpp/src/proton_handler.cpp
@@ -0,0 +1,73 @@
+/*
+ *
+ * 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/proton_handler.hpp"
+#include "proton/proton_event.hpp"
+
+namespace proton {
+
+proton_handler::proton_handler(){}
+
+// Everything goes to on_unhandled() unless overriden by subclass
+
+void proton_handler::on_reactor_init(event &e) { on_unhandled(e); }
+void proton_handler::on_reactor_quiesced(event &e) { on_unhandled(e); }
+void proton_handler::on_reactor_final(event &e) { on_unhandled(e); }
+void proton_handler::on_timer_task(event &e) { on_unhandled(e); }
+void proton_handler::on_connection_init(event &e) { on_unhandled(e); }
+void proton_handler::on_connection_bound(event &e) { on_unhandled(e); }
+void proton_handler::on_connection_unbound(event &e) { on_unhandled(e); }
+void proton_handler::on_connection_local_open(event &e) { on_unhandled(e); }
+void proton_handler::on_connection_local_close(event &e) { on_unhandled(e); }
+void proton_handler::on_connection_remote_open(event &e) { on_unhandled(e); }
+void proton_handler::on_connection_remote_close(event &e) { on_unhandled(e); }
+void proton_handler::on_connection_final(event &e) { on_unhandled(e); }
+void proton_handler::on_session_init(event &e) { on_unhandled(e); }
+void proton_handler::on_session_local_open(event &e) { on_unhandled(e); }
+void proton_handler::on_session_local_close(event &e) { on_unhandled(e); }
+void proton_handler::on_session_remote_open(event &e) { on_unhandled(e); }
+void proton_handler::on_session_remote_close(event &e) { on_unhandled(e); }
+void proton_handler::on_session_final(event &e) { on_unhandled(e); }
+void proton_handler::on_link_init(event &e) { on_unhandled(e); }
+void proton_handler::on_link_local_open(event &e) { on_unhandled(e); }
+void proton_handler::on_link_local_close(event &e) { on_unhandled(e); }
+void proton_handler::on_link_local_detach(event &e) { on_unhandled(e); }
+void proton_handler::on_link_remote_open(event &e) { on_unhandled(e); }
+void proton_handler::on_link_remote_close(event &e) { on_unhandled(e); }
+void proton_handler::on_link_remote_detach(event &e) { on_unhandled(e); }
+void proton_handler::on_link_flow(event &e) { on_unhandled(e); }
+void proton_handler::on_link_final(event &e) { on_unhandled(e); }
+void proton_handler::on_delivery(event &e) { on_unhandled(e); }
+void proton_handler::on_transport(event &e) { on_unhandled(e); }
+void proton_handler::on_transport_error(event &e) { on_unhandled(e); }
+void proton_handler::on_transport_head_closed(event &e) { on_unhandled(e); }
+void proton_handler::on_transport_tail_closed(event &e) { on_unhandled(e); }
+void proton_handler::on_transport_closed(event &e) { on_unhandled(e); }
+void proton_handler::on_selectable_init(event &e) { on_unhandled(e); }
+void proton_handler::on_selectable_updated(event &e) { on_unhandled(e); }
+void proton_handler::on_selectable_readable(event &e) { on_unhandled(e); }
+void proton_handler::on_selectable_writable(event &e) { on_unhandled(e); }
+void proton_handler::on_selectable_expired(event &e) { on_unhandled(e); }
+void proton_handler::on_selectable_error(event &e) { on_unhandled(e); }
+void proton_handler::on_selectable_final(event &e) { on_unhandled(e); }
+
+void proton_handler::on_unhandled(event &e) {}
+
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/proton_impl_ref.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/proton_impl_ref.hpp b/proton-c/bindings/cpp/src/proton_impl_ref.hpp
new file mode 100644
index 0000000..795754a
--- /dev/null
+++ b/proton-c/bindings/cpp/src/proton_impl_ref.hpp
@@ -0,0 +1,65 @@
+#ifndef PROTON_CPP_PROTONIMPL_H
+#define PROTON_CPP_PROTONIMPL_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/object.h"
+
+namespace proton {
+
+// Modified from qpid::messaging version to work without
+// boost::intrusive_ptr but integrate with Proton's pn_class_t
+// reference counting. Thread safety currently absent but fluid in
+// intention...
+
+
+/**
+ * See private_impl_ref.h This is for lightly wrapped Proton pn_object_t targets.
+ * class Foo : proton_handle<pn_foo_t> {...}
+ */
+
+template <class T> class proton_impl_ref {
+ public:
+ typedef typename T::Impl Impl;
+
+ /** Get the implementation pointer from a handle */
+ static Impl* get(const T& t) { return t.impl_; }
+
+ /** Set the implementation pointer in a handle */
+ static void set(T& t, const Impl* p) {
+ if (t.impl_ == p) return;
+ if (t.impl_) pn_decref(t.impl_);
+ t.impl_ = const_cast<Impl *>(p);
+ if (t.impl_) pn_incref(t.impl_);
+ }
+
+ // Helper functions to implement the ctor, dtor, copy, assign
+ static void ctor(T& t, Impl* p) { t.impl_ = p; if (p) pn_incref(p); }
+ static void copy(T& t, const T& x) { if (&t == &x) return; t.impl_ = 0; assign(t, x); }
+ static void dtor(T& t) { if(t.impl_) pn_decref(t.impl_); }
+ static T& assign(T& t, const T& x) { set(t, get(x)); return t;}
+};
+
+}
+
+#endif /*!PROTON_CPP_PROTONIMPL_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/receiver.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/receiver.cpp b/proton-c/bindings/cpp/src/receiver.cpp
new file mode 100644
index 0000000..84412e6
--- /dev/null
+++ b/proton-c/bindings/cpp/src/receiver.cpp
@@ -0,0 +1,44 @@
+/*
+ *
+ * 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/link.hpp"
+#include "proton/receiver.hpp"
+#include "proton/error.hpp"
+#include "msg.hpp"
+
+#include "proton/connection.h"
+#include "proton/session.h"
+#include "proton/link.h"
+
+namespace proton {
+
+
+receiver::receiver(pn_link_t *lnk) : link(lnk) {}
+receiver::receiver() : link(0) {}
+
+receiver::receiver(const link& c) : link(c.pn_link()) {}
+
+void receiver::verify_type(pn_link_t *lnk) {
+ if (lnk && pn_link_is_sender(lnk))
+ throw error(MSG("Creating receiver with sender context"));
+}
+
+
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/sender.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/sender.cpp b/proton-c/bindings/cpp/src/sender.cpp
new file mode 100644
index 0000000..85d79da
--- /dev/null
+++ b/proton-c/bindings/cpp/src/sender.cpp
@@ -0,0 +1,71 @@
+/*
+ *
+ * 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/link.hpp"
+#include "proton/sender.hpp"
+#include "proton/error.hpp"
+#include "msg.hpp"
+#include "contexts.hpp"
+
+#include "proton/connection.h"
+#include "proton/session.h"
+#include "proton/link.h"
+#include "proton/types.h"
+#include "proton/codec.h"
+#include "proton/message.h"
+#include "proton/delivery.h"
+#include <stdlib.h>
+#include <string.h>
+
+namespace proton {
+
+
+sender::sender(pn_link_t *lnk) : link(lnk) {}
+
+void sender::verify_type(pn_link_t *lnk) {
+ if (lnk && pn_link_is_receiver(lnk))
+ throw error(MSG("Creating sender with receiver context"));
+}
+
+sender::sender(const link& c) : link(c.pn_link()) {}
+
+
+namespace{
+// revisit if thread safety required
+std::uint64_t tag_counter = 0;
+}
+
+delivery sender::send(message &message) {
+ char tag[8];
+ void *ptr = &tag;
+ std::uint64_t id = ++tag_counter;
+ *((std::uint64_t *) ptr) = id;
+ pn_delivery_t *dlv = pn_delivery(pn_link(), pn_dtag(tag, 8));
+ std::string buf;
+ message.encode(buf);
+ pn_link_t *link = pn_link();
+ pn_link_send(link, buf.data(), buf.size());
+ pn_link_advance(link);
+ if (pn_link_snd_settle_mode(link) == PN_SND_SETTLED)
+ pn_delivery_settle(dlv);
+ return delivery(dlv);
+}
+
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/session.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/session.cpp b/proton-c/bindings/cpp/src/session.cpp
new file mode 100644
index 0000000..283b085
--- /dev/null
+++ b/proton-c/bindings/cpp/src/session.cpp
@@ -0,0 +1,73 @@
+/*
+ *
+ * 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/session.hpp"
+#include "contexts.hpp"
+
+#include "proton/connection.h"
+#include "proton/session.h"
+#include "proton/session.hpp"
+#include "proton/connection.hpp"
+#include "connection_impl.hpp"
+#include "proton_impl_ref.hpp"
+
+namespace proton {
+
+template class proton_handle<pn_session_t>;
+typedef proton_impl_ref<session> PI;
+
+session::session(pn_session_t *p) {
+ PI::ctor(*this, p);
+}
+session::session() {
+ PI::ctor(*this, 0);
+}
+session::session(const session& c) : proton_handle<pn_session_t>() {
+ PI::copy(*this, c);
+}
+session& session::operator=(const session& c) {
+ return PI::assign(*this, c);
+}
+session::~session() {
+ PI::dtor(*this);
+}
+
+pn_session_t *session::pn_session() { return impl_; }
+
+void session::open() {
+ pn_session_open(impl_);
+}
+
+connection &session::connection() {
+ pn_connection_t *c = pn_session_connection(impl_);
+ return connection_impl::reactor_reference(c);
+}
+
+receiver session::create_receiver(std::string name) {
+ pn_link_t *link = pn_receiver(impl_, name.c_str());
+ return receiver(link);
+}
+
+sender session::create_sender(std::string name) {
+ pn_link_t *link = pn_sender(impl_, name.c_str());
+ return sender(link);
+}
+
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/terminus.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/terminus.cpp b/proton-c/bindings/cpp/src/terminus.cpp
new file mode 100644
index 0000000..6db09d0
--- /dev/null
+++ b/proton-c/bindings/cpp/src/terminus.cpp
@@ -0,0 +1,101 @@
+/*
+ *
+ * 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/link.hpp"
+#include "proton/link.h"
+
+namespace proton {
+
+template class proton_handle<pn_terminus_t>;
+typedef proton_impl_ref<terminus> PI;
+
+// Note: the pn_terminus_t is not ref counted. We count the parent link.
+
+terminus::terminus() : link_(0) {
+ impl_ = 0;
+}
+
+terminus::terminus(pn_terminus_t *p, link *l) : link_(l) {
+ impl_ = p;
+ pn_incref(link_->pn_link());
+}
+terminus::terminus(const terminus& c) : proton_handle<pn_terminus_t>() {
+ impl_ = c.impl_;
+ link_ = c.link_;
+ pn_incref(link_->pn_link());
+}
+terminus& terminus::operator=(const terminus& c) {
+ if (impl_ == c.impl_) return *this;
+ if (impl_) pn_decref(link_->pn_link());
+ impl_ = c.impl_;
+ link_ = c.link_;
+ pn_incref(link_->pn_link());
+ return *this;
+}
+terminus::~terminus() {
+ if (impl_)
+ pn_decref(link_->pn_link());
+}
+
+pn_terminus_t *terminus::pn_terminus() { return impl_; }
+
+terminus::type_t terminus::type() {
+ return (type_t) pn_terminus_get_type(impl_);
+}
+
+void terminus::type(type_t type) {
+ pn_terminus_set_type(impl_, (pn_terminus_type_t) type);
+}
+
+terminus::expiry_policy_t terminus::expiry_policy() {
+ return (expiry_policy_t) pn_terminus_get_type(impl_);
+}
+
+void terminus::expiry_policy(expiry_policy_t policy) {
+ pn_terminus_set_expiry_policy(impl_, (pn_expiry_policy_t) policy);
+}
+
+terminus::distribution_mode_t terminus::distribution_mode() {
+ return (distribution_mode_t) pn_terminus_get_type(impl_);
+}
+
+void terminus::distribution_mode(distribution_mode_t mode) {
+ pn_terminus_set_distribution_mode(impl_, (pn_distribution_mode_t) mode);
+}
+
+std::string terminus::address() {
+ const char *addr = pn_terminus_get_address(impl_);
+ return addr ? std::string(addr) : std::string();
+}
+
+void terminus::address(std::string &addr) {
+ pn_terminus_set_address(impl_, addr.c_str());
+}
+
+bool terminus::is_dynamic() {
+ return (type_t) pn_terminus_is_dynamic(impl_);
+}
+
+void terminus::dynamic(bool d) {
+ pn_terminus_set_dynamic(impl_, d);
+}
+
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/transport.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/transport.cpp b/proton-c/bindings/cpp/src/transport.cpp
new file mode 100644
index 0000000..b386f7b
--- /dev/null
+++ b/proton-c/bindings/cpp/src/transport.cpp
@@ -0,0 +1,38 @@
+/*
+ *
+ * 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/transport.hpp"
+#include "proton/connection.hpp"
+
+#include "proton/transport.h"
+
+namespace proton {
+
+
+transport::transport() : connection_(0), pn_transport_(::pn_transport()) {}
+
+transport::~transport() { ::pn_decref(pn_transport_); }
+
+void transport::bind(class connection &c) {
+ connection_ = &c;
+ pn_transport_bind(pn_transport_, c.pn_connection());
+}
+
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/types.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/types.cpp b/proton-c/bindings/cpp/src/types.cpp
index b34567b..dcebc6f 100644
--- a/proton-c/bindings/cpp/src/types.cpp
+++ b/proton-c/bindings/cpp/src/types.cpp
@@ -24,45 +24,28 @@
namespace proton {
-Uuid::Uuid() { std::fill(bytes, bytes+SIZE, 0); }
-Uuid::Uuid(const pn_uuid_t& u) { std::copy(u.bytes, u.bytes+SIZE, bytes); }
-
-Uuid::operator pn_uuid_t() const {
- pn_uuid_t u;
- std::copy(begin(), end(), u.bytes);
- return u;
-}
-
-bool Uuid::operator==(const Uuid& x) const {
- return std::equal(begin(), end(), x.begin());
-}
-
-bool Uuid::operator<(const Uuid& x) const {
- return std::lexicographical_compare(begin(), end(), x.begin(), x.end()) < 0;
-}
-
namespace {
-inline std::ostream& printSegment(std::ostream& o, const Uuid& u, size_t begin, size_t end, const char* sep="") {
+inline std::ostream& print_segment(std::ostream& o, const amqp_uuid& u, size_t begin, size_t end, const char* sep="") {
for (const char* p = &u[begin]; p < &u[end]; ++p) o << *p;
return o << sep;
}
}
-std::ostream& operator<<(std::ostream& o, const Uuid& u) {
+std::ostream& operator<<(std::ostream& o, const amqp_uuid& u) {
std::ios_base::fmtflags ff = o.flags();
o.flags(std::ios_base::hex);
- printSegment(o, u, 0, 4, "-");
- printSegment(o, u, 4, 6, "-");
- printSegment(o, u, 6, 8, "-");
- printSegment(o, u, 8, 10, "-");
- printSegment(o, u, 10, 16);
+ print_segment(o, u, 0, 4, "-");
+ print_segment(o, u, 4, 6, "-");
+ print_segment(o, u, 6, 8, "-");
+ print_segment(o, u, 8, 10, "-");
+ print_segment(o, u, 10, 16);
o.flags(ff);
return o;
}
-std::string typeName(TypeId t) {
+std::string type_name(type_id t) {
switch (t) {
- case NULL_: return "null";
+ case NULl_: return "null";
case BOOL: return "bool";
case UBYTE: return "ubyte";
case BYTE: return "byte";
@@ -91,9 +74,9 @@ std::string typeName(TypeId t) {
}
}
-std::ostream& operator<<(std::ostream& o,TypeId t) { return o << typeName(t); }
+std::ostream& operator<<(std::ostream& o,type_id t) { return o << type_name(t); }
-PN_CPP_EXTERN bool isContainer(TypeId t) {
+PN_CPP_EXTERN bool is_container(type_id t) {
return (t == LIST || t == MAP || t == ARRAY || t == DESCRIBED);
}
@@ -104,10 +87,10 @@ pn_bytes_t pn_bytes(const std::string& s) {
std::string str(const pn_bytes_t& b) { return std::string(b.start, b.size); }
-Start::Start(TypeId t, TypeId e, bool d, size_t s) : type(t), element(e), isDescribed(d), size(s) {}
-Start Start::array(TypeId element, bool described) { return Start(ARRAY, element, described); }
-Start Start::list() { return Start(LIST); }
-Start Start::map() { return Start(MAP); }
-Start Start::described() { return Start(DESCRIBED, NULL_, true); }
+start::start(type_id t, type_id e, bool d, size_t s) : type(t), element(e), is_described(d), size(s) {}
+start start::array(type_id element, bool described) { return start(ARRAY, element, described); }
+start start::list() { return start(LIST); }
+start start::map() { return start(MAP); }
+start start::described() { return start(DESCRIBED, NULl_, true); }
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/url.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/url.cpp b/proton-c/bindings/cpp/src/url.cpp
new file mode 100644
index 0000000..5744f49
--- /dev/null
+++ b/proton-c/bindings/cpp/src/url.cpp
@@ -0,0 +1,76 @@
+/*
+ *
+ * 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/error.hpp"
+#include "url.hpp"
+#include "proton_impl_ref.hpp"
+#include "msg.hpp"
+
+namespace proton {
+
+template class proton_handle<pn_url_t>;
+typedef proton_impl_ref<Url> PI;
+
+
+Url::Url(const std::string &url) {
+ pn_url_t *up = pn_url_parse(url.c_str());
+ // refcount is 1, no need to incref
+ if (!up)
+ throw error(MSG("invalid URL: " << url));
+ impl_ = up;
+}
+
+Url::~Url() { PI::dtor(*this); }
+
+Url::Url(const Url& c) : proton_handle<pn_url_t>() {
+ PI::copy(*this, c);
+}
+
+Url& Url::operator=(const Url& c) {
+ return PI::assign(*this, c);
+}
+
+std::string Url::port() {
+ const char *p = pn_url_get_port(impl_);
+ if (!p)
+ return std::string("5672");
+ else
+ return std::string(p);
+}
+
+std::string Url::host() {
+ const char *p = pn_url_get_host(impl_);
+ if (!p)
+ return std::string("0.0.0.0");
+ else
+ return std::string(p);
+}
+
+std::string Url::path() {
+ const char *p = pn_url_get_path(impl_);
+ if (!p)
+ return std::string("");
+ else
+ return std::string(p);
+}
+
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[3/8] qpid-proton git commit: PROTON-865: Renaming to follow
boost/std library C++ naming conventions.
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/Url.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Url.hpp b/proton-c/bindings/cpp/src/Url.hpp
deleted file mode 100644
index 3c2e450..0000000
--- a/proton-c/bindings/cpp/src/Url.hpp
+++ /dev/null
@@ -1,49 +0,0 @@
-#ifndef PROTON_CPP_URL_H
-#define PROTON_CPP_URL_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/ProtonHandle.hpp"
-#include "proton/url.h"
-#include <string>
-
-namespace proton {
-namespace reactor {
-
-class Url : public ProtonHandle<pn_url_t>
-{
- public:
- PN_CPP_EXTERN Url(const std::string &url);
- PN_CPP_EXTERN ~Url();
- PN_CPP_EXTERN Url(const Url&);
- PN_CPP_EXTERN Url& operator=(const Url&);
- PN_CPP_EXTERN std::string getHost();
- PN_CPP_EXTERN std::string getPort();
- PN_CPP_EXTERN std::string getPath();
- private:
- friend class ProtonImplRef<Url>;
-};
-
-
-}} // namespace proton::reactor
-
-#endif /*!PROTON_CPP_URL_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/Value.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Value.cpp b/proton-c/bindings/cpp/src/Value.cpp
deleted file mode 100644
index cf41175..0000000
--- a/proton-c/bindings/cpp/src/Value.cpp
+++ /dev/null
@@ -1,136 +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/Value.hpp"
-#include "proton_bits.hpp"
-#include <proton/codec.h>
-#include <ostream>
-#include <algorithm>
-
-namespace proton {
-
-Value::Value() { *this = Null(); }
-Value::Value(const Value& v) { *this = v; }
-Value::~Value() {}
-
-Value& Value::operator=(const Value& v) { values = v.values; return *this; }
-
-TypeId Value::type() const {
- const_cast<Values&>(values).rewind();
- return values.type();
-}
-
-namespace {
-template <class T> T check(T result) {
- if (result < 0)
- throw EncodeError("encode: " + errorStr(result));
- return result;
-}
-}
-
-std::ostream& operator<<(std::ostream& o, const Value& v) {
- return o << v.values;
-}
-
-namespace {
-
-// Compare nodes, return -1 if a<b, 0 if a==b, +1 if a>b
-// Forward-declare so we can use it recursively.
-int compareNext(Values& a, Values& b);
-
-template <class T> int compare(const T& a, const T& b) {
- if (a < b) return -1;
- else if (a > b) return +1;
- else return 0;
-}
-
-int compareContainer(Values& a, Values& b) {
- Decoder::Scope sa(a), sb(b);
- // Compare described vs. not-described.
- int cmp = compare(sa.isDescribed, sb.isDescribed);
- if (cmp) return cmp;
- // Lexical sort (including descriptor if there is one)
- size_t minSize = std::min(sa.size, sb.size) + int(sa.isDescribed);
- for (size_t i = 0; i < minSize; ++i) {
- cmp = compareNext(a, b);
- if (cmp) return cmp;
- }
- return compare(sa.size, sb.size);
-}
-
-template <class T> int compareSimple(Values& a, Values& b) {
- T va, vb;
- a >> va;
- b >> vb;
- return compare(va, vb);
-}
-
-int compareNext(Values& a, Values& b) {
- // Sort by TypeId first.
- TypeId ta = a.type(), tb = b.type();
- int cmp = compare(ta, tb);
- if (cmp) return cmp;
-
- switch (ta) {
- case NULL_: return 0;
- case ARRAY:
- case LIST:
- case MAP:
- case DESCRIBED:
- return compareContainer(a, b);
- case BOOL: return compareSimple<Bool>(a, b);
- case UBYTE: return compareSimple<Ubyte>(a, b);
- case BYTE: return compareSimple<Byte>(a, b);
- case USHORT: return compareSimple<Ushort>(a, b);
- case SHORT: return compareSimple<Short>(a, b);
- case UINT: return compareSimple<Uint>(a, b);
- case INT: return compareSimple<Int>(a, b);
- case CHAR: return compareSimple<Char>(a, b);
- case ULONG: return compareSimple<Ulong>(a, b);
- case LONG: return compareSimple<Long>(a, b);
- case TIMESTAMP: return compareSimple<Timestamp>(a, b);
- case FLOAT: return compareSimple<Float>(a, b);
- case DOUBLE: return compareSimple<Double>(a, b);
- case DECIMAL32: return compareSimple<Decimal32>(a, b);
- case DECIMAL64: return compareSimple<Decimal64>(a, b);
- case DECIMAL128: return compareSimple<Decimal128>(a, b);
- case UUID: return compareSimple<Uuid>(a, b);
- case BINARY: return compareSimple<Binary>(a, b);
- case STRING: return compareSimple<String>(a, b);
- case SYMBOL: return compareSimple<Symbol>(a, b);
- }
- // Invalid but equal TypeId, treat as equal.
- return 0;
-}
-
-} // namespace
-
-bool Value::operator==(const Value& v) const {
- values.rewind();
- v.values.rewind();
- return compareNext(values, v.values) == 0;
-}
-
-bool Value::operator<(const Value& v) const {
- values.rewind();
- v.values.rewind();
- return compareNext(values, v.values) < 0;
-}
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/Values.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Values.cpp b/proton-c/bindings/cpp/src/Values.cpp
deleted file mode 100644
index 95e5784..0000000
--- a/proton-c/bindings/cpp/src/Values.cpp
+++ /dev/null
@@ -1,40 +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/Value.hpp"
-#include "proton_bits.hpp"
-#include <proton/codec.h>
-#include <ostream>
-
-namespace proton {
-
-Values::Values() {}
-Values::Values(const Values& v) { *this = v; }
-Values::Values(pn_data_t* d) : Data(d) {}
-
-Values::~Values() {}
-Values& Values::operator=(const Values& v) { Data::operator=(v); return *this; }
-
-Values& Values::rewind() { pn_data_rewind(data); return *this; }
-
-std::ostream& operator<<(std::ostream& o, const Values& v) {
- return o << static_cast<const Encoder&>(v);
-}
-
-}
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
new file mode 100644
index 0000000..990bfc3
--- /dev/null
+++ b/proton-c/bindings/cpp/src/acceptor.cpp
@@ -0,0 +1,55 @@
+/*
+ *
+ * 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 "proton_impl_ref.hpp"
+#include "msg.hpp"
+
+namespace proton {
+
+template class proton_handle<pn_acceptor_t>;
+typedef proton_impl_ref<acceptor> PI;
+
+acceptor::acceptor() {}
+
+acceptor::acceptor(pn_acceptor_t *a)
+{
+ PI::ctor(*this, a);
+}
+
+acceptor::~acceptor() { PI::dtor(*this); }
+
+
+acceptor::acceptor(const acceptor& a) : proton_handle<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_);
+}
+
+}
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
new file mode 100644
index 0000000..5738257
--- /dev/null
+++ b/proton-c/bindings/cpp/src/acking.cpp
@@ -0,0 +1,48 @@
+/*
+ *
+ * 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 {
+
+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.pn_delivery(), state);
+ d.settle();
+}
+
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/blocking_connection.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/blocking_connection.cpp b/proton-c/bindings/cpp/src/blocking_connection.cpp
new file mode 100644
index 0000000..5bd790b
--- /dev/null
+++ b/proton-c/bindings/cpp/src/blocking_connection.cpp
@@ -0,0 +1,61 @@
+/*
+ *
+ * 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/blocking_connection.hpp"
+#include "proton/blocking_sender.hpp"
+#include "proton/messaging_handler.hpp"
+#include "proton/error.hpp"
+#include "msg.hpp"
+#include "blocking_connection_impl.hpp"
+#include "private_impl_ref.hpp"
+
+namespace proton {
+
+template class handle<blocking_connection_impl>;
+typedef private_impl_ref<blocking_connection> PI;
+
+blocking_connection::blocking_connection() {PI::ctor(*this, 0); }
+
+blocking_connection::blocking_connection(const blocking_connection& c) : handle<blocking_connection_impl>() { PI::copy(*this, c); }
+
+blocking_connection& blocking_connection::operator=(const blocking_connection& c) { return PI::assign(*this, c); }
+blocking_connection::~blocking_connection() { PI::dtor(*this); }
+
+blocking_connection::blocking_connection(std::string &url, duration d, ssl_domain *ssld, container *c) {
+ blocking_connection_impl *cimpl = new blocking_connection_impl(url, d,ssld, c);
+ PI::ctor(*this, cimpl);
+}
+
+void blocking_connection::close() { impl_->close(); }
+
+void blocking_connection::wait(wait_condition &cond) { return impl_->wait(cond); }
+void blocking_connection::wait(wait_condition &cond, std::string &msg, duration timeout) {
+ return impl_->wait(cond, msg, timeout);
+}
+
+blocking_sender blocking_connection::create_sender(std::string &address, handler *h) {
+ sender sender = impl_->container_.create_sender(impl_->connection_, address, h);
+ return blocking_sender(*this, sender);
+}
+
+duration blocking_connection::timeout() { return impl_->timeout(); }
+
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/blocking_connection_impl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/blocking_connection_impl.cpp b/proton-c/bindings/cpp/src/blocking_connection_impl.cpp
new file mode 100644
index 0000000..0cc824f
--- /dev/null
+++ b/proton-c/bindings/cpp/src/blocking_connection_impl.cpp
@@ -0,0 +1,123 @@
+/*
+ *
+ * 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/messaging_handler.hpp"
+#include "proton/duration.hpp"
+#include "proton/error.hpp"
+#include "proton/wait_condition.hpp"
+#include "blocking_connection_impl.hpp"
+#include "msg.hpp"
+#include "contexts.hpp"
+
+#include "proton/connection.h"
+
+namespace proton {
+
+wait_condition::~wait_condition() {}
+
+
+void blocking_connection_impl::incref(blocking_connection_impl *impl_) {
+ impl_->refcount_++;
+}
+
+void blocking_connection_impl::decref(blocking_connection_impl *impl_) {
+ impl_->refcount_--;
+ if (impl_->refcount_ == 0)
+ delete impl_;
+}
+
+namespace {
+struct connection_opening : public wait_condition {
+ connection_opening(pn_connection_t *c) : pn_connection(c) {}
+ bool achieved() { return (pn_connection_state(pn_connection) & PN_REMOTE_UNINIT); }
+ pn_connection_t *pn_connection;
+};
+
+struct connection_closed : public wait_condition {
+ connection_closed(pn_connection_t *c) : pn_connection(c) {}
+ bool achieved() { return !(pn_connection_state(pn_connection) & PN_REMOTE_ACTIVE); }
+ pn_connection_t *pn_connection;
+};
+
+}
+
+
+blocking_connection_impl::blocking_connection_impl(std::string &u, duration timeout0, ssl_domain *ssld, container *c)
+ : url_(u), timeout_(timeout0), refcount_(0)
+{
+ if (c)
+ container_ = *c;
+ container_.start();
+ container_.timeout(timeout_);
+ // Create connection and send the connection events here
+ connection_ = container_.connect(url_, static_cast<handler *>(this));
+ connection_opening cond(connection_.pn_connection());
+ wait(cond);
+}
+
+blocking_connection_impl::~blocking_connection_impl() {
+ container_ = container();
+}
+
+void blocking_connection_impl::close() {
+ connection_.close();
+ connection_closed cond(connection_.pn_connection());
+ wait(cond);
+}
+
+void blocking_connection_impl::wait(wait_condition &condition) {
+ std::string empty;
+ wait(condition, empty, timeout_);
+}
+
+void blocking_connection_impl::wait(wait_condition &condition, std::string &msg, duration wait_timeout) {
+ if (wait_timeout == duration::FOREVER) {
+ while (!condition.achieved()) {
+ container_.process();
+ }
+ }
+
+ pn_reactor_t *reactor = container_.reactor();
+ pn_millis_t orig_timeout = pn_reactor_get_timeout(reactor);
+ pn_reactor_set_timeout(reactor, wait_timeout.milliseconds);
+ try {
+ pn_timestamp_t now = pn_reactor_mark(reactor);
+ pn_timestamp_t deadline = now + wait_timeout.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, orig_timeout);
+ throw;
+ }
+ pn_reactor_set_timeout(reactor, orig_timeout);
+}
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/blocking_connection_impl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/blocking_connection_impl.hpp b/proton-c/bindings/cpp/src/blocking_connection_impl.hpp
new file mode 100644
index 0000000..02305ba
--- /dev/null
+++ b/proton-c/bindings/cpp/src/blocking_connection_impl.hpp
@@ -0,0 +1,62 @@
+#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 {
+
+class handler;
+class container;
+class ssl_domain;
+
+ class blocking_connection_impl : public messaging_handler
+{
+ public:
+ PN_CPP_EXTERN blocking_connection_impl(std::string &url, duration d, ssl_domain *ssld, container *c);
+ PN_CPP_EXTERN ~blocking_connection_impl();
+ PN_CPP_EXTERN void close();
+ PN_CPP_EXTERN void wait(wait_condition &condition);
+ PN_CPP_EXTERN void wait(wait_condition &condition, std::string &msg, duration timeout);
+ PN_CPP_EXTERN pn_connection_t *pn_blocking_connection();
+ duration timeout() { return timeout_; }
+ static void incref(blocking_connection_impl *);
+ static void decref(blocking_connection_impl *);
+ private:
+ friend class blocking_connection;
+ container container_;
+ connection connection_;
+ std::string url_;
+ duration timeout_;
+ int refcount_;
+};
+
+
+}
+
+#endif /*!PROTON_CPP_CONNECTIONIMPL_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/blocking_link.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/blocking_link.cpp b/proton-c/bindings/cpp/src/blocking_link.cpp
new file mode 100644
index 0000000..b9f23c4
--- /dev/null
+++ b/proton-c/bindings/cpp/src/blocking_link.cpp
@@ -0,0 +1,85 @@
+/*
+ *
+ * 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/blocking_link.hpp"
+#include "proton/blocking_connection.hpp"
+#include "proton/messaging_handler.hpp"
+#include "proton/wait_condition.hpp"
+#include "proton/error.hpp"
+#include "msg.hpp"
+
+
+namespace proton {
+
+namespace {
+struct link_opened : public wait_condition {
+ link_opened(pn_link_t *l) : pn_link(l) {}
+ bool achieved() { return !(pn_link_state(pn_link) & PN_REMOTE_UNINIT); }
+ pn_link_t *pn_link;
+};
+
+struct link_closed : public wait_condition {
+ link_closed(pn_link_t *l) : pn_link(l) {}
+ bool achieved() { return (pn_link_state(pn_link) & PN_REMOTE_CLOSED); }
+ pn_link_t *pn_link;
+};
+
+struct link_not_open : public wait_condition {
+ link_not_open(pn_link_t *l) : pn_link(l) {}
+ bool achieved() { return !(pn_link_state(pn_link) & PN_REMOTE_ACTIVE); }
+ pn_link_t *pn_link;
+};
+
+
+} // namespace
+
+
+blocking_link::blocking_link(blocking_connection *c, pn_link_t *pnl) : connection_(*c), link_(pnl) {
+ std::string msg = "Opening link " + link_.name();
+ link_opened link_opened(link_.pn_link());
+ connection_.wait(link_opened, msg);
+}
+
+blocking_link::~blocking_link() {}
+
+void blocking_link::wait_for_closed(duration timeout) {
+ std::string msg = "Closing link " + link_.name();
+ link_closed link_closed(link_.pn_link());
+ connection_.wait(link_closed, msg);
+ check_closed();
+}
+
+void blocking_link::check_closed() {
+ pn_link_t * pn_link = link_.pn_link();
+ if (pn_link_state(pn_link) & PN_REMOTE_CLOSED) {
+ link_.close();
+ // TODO: link_detached exception
+ throw error(MSG("link detached"));
+ }
+}
+
+void blocking_link::close() {
+ link_.close();
+ std::string msg = "Closing link " + link_.name();
+ link_not_open link_not_open(link_.pn_link());
+ connection_.wait(link_not_open, msg);
+}
+
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/blocking_sender.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/blocking_sender.cpp b/proton-c/bindings/cpp/src/blocking_sender.cpp
new file mode 100644
index 0000000..2ab1ef1
--- /dev/null
+++ b/proton-c/bindings/cpp/src/blocking_sender.cpp
@@ -0,0 +1,65 @@
+/*
+ *
+ * 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/blocking_sender.hpp"
+#include "proton/blocking_connection.hpp"
+#include "proton/wait_condition.hpp"
+#include "proton/error.hpp"
+#include "msg.hpp"
+
+
+namespace proton {
+
+namespace {
+struct delivery_settled : public wait_condition {
+ delivery_settled(pn_delivery_t *d) : pn_delivery(d) {}
+ bool achieved() { return pn_delivery_settled(pn_delivery); }
+ pn_delivery_t *pn_delivery;
+};
+
+} // namespace
+
+
+blocking_sender::blocking_sender(blocking_connection &c, sender &l) : blocking_link(&c, l.pn_link()) {
+ std::string ta = link_.target().address();
+ std::string rta = link_.remote_target().address();
+ if (ta.empty() || ta.compare(rta) != 0) {
+ wait_for_closed();
+ link_.close();
+ std::string txt = "Failed to open sender " + link_.name() + ", target does not match";
+ throw error(MSG("container not started"));
+ }
+}
+
+delivery blocking_sender::send(message &msg, duration timeout) {
+ sender snd = link_;
+ delivery dlv = snd.send(msg);
+ std::string txt = "Sending on sender " + link_.name();
+ delivery_settled cond(dlv.pn_delivery());
+ connection_.wait(cond, txt, timeout);
+ return dlv;
+}
+
+delivery blocking_sender::send(message &msg) {
+ // Use default timeout
+ return send(msg, connection_.timeout());
+}
+
+}
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
new file mode 100644
index 0000000..6c21fdd
--- /dev/null
+++ b/proton-c/bindings/cpp/src/connection.cpp
@@ -0,0 +1,68 @@
+/*
+ *
+ * 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 "connection_impl.hpp"
+#include "private_impl_ref.hpp"
+
+#include "proton/connection.h"
+
+namespace proton {
+
+template class handle<connection_impl>;
+typedef private_impl_ref<connection> PI;
+
+connection::connection() {PI::ctor(*this, 0); }
+connection::connection(connection_impl* p) { PI::ctor(*this, p); }
+connection::connection(const connection& c) : handle<connection_impl>() { PI::copy(*this, c); }
+
+connection& connection::operator=(const connection& c) { return PI::assign(*this, c); }
+connection::~connection() { PI::dtor(*this); }
+
+connection::connection(class container &c, handler *h) {
+ connection_impl *cimpl = new connection_impl(c, h);
+ PI::ctor(*this, cimpl);
+}
+
+transport &connection::transport() { return impl_->transport(); }
+
+handler* connection::override() { return impl_->override(); }
+void connection::override(handler *h) { impl_->override(h); }
+
+void connection::open() { impl_->open(); }
+
+void connection::close() { impl_->close(); }
+
+pn_connection_t *connection::pn_connection() { return impl_->pn_connection(); }
+
+std::string connection::hostname() { return impl_->hostname(); }
+
+class container &connection::container() { return impl_->container(); }
+
+link connection::link_head(endpoint::State mask) {
+ return impl_->link_head(mask);
+}
+
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/connection_impl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/connection_impl.cpp b/proton-c/bindings/cpp/src/connection_impl.cpp
new file mode 100644
index 0000000..e515d78
--- /dev/null
+++ b/proton-c/bindings/cpp/src/connection_impl.cpp
@@ -0,0 +1,136 @@
+/*
+ *
+ * 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 "connection_impl.hpp"
+#include "proton/transport.hpp"
+#include "msg.hpp"
+#include "contexts.hpp"
+#include "private_impl_ref.hpp"
+#include "container_impl.hpp"
+
+#include "proton/connection.h"
+
+namespace proton {
+
+void connection_impl::incref(connection_impl *impl_) {
+ impl_->refcount_++;
+}
+
+void connection_impl::decref(connection_impl *impl_) {
+ impl_->refcount_--;
+ if (impl_->refcount_ == 0)
+ delete impl_;
+}
+
+connection_impl::connection_impl(class container &c, pn_connection_t &pn_conn)
+ : container_(c), refcount_(0), override_(0), transport_(0), default_session_(0),
+ pn_connection_(&pn_conn), reactor_reference_(this)
+{
+ connection_context(pn_connection_, this);
+}
+
+connection_impl::connection_impl(class container &c, handler *handler)
+ : container_(c), refcount_(0), override_(0), transport_(0), default_session_(0),
+ reactor_reference_(this)
+{
+ pn_handler_t *chandler = 0;
+ if (handler) {
+ container_impl *container_impl = private_impl_ref<class container>::get(c);
+ chandler = container_impl->wrap_handler(handler);
+ }
+ pn_connection_ = pn_reactor_connection(container_.reactor(), chandler);
+ if (chandler)
+ pn_decref(chandler);
+ connection_context(pn_connection_, this);
+}
+
+connection_impl::~connection_impl() {
+ delete transport_;
+ delete override_;
+}
+
+transport &connection_impl::transport() {
+ if (transport_)
+ return *transport_;
+ throw error(MSG("connection has no transport"));
+}
+
+handler* connection_impl::override() { return override_; }
+void connection_impl::override(handler *h) {
+ if (override_)
+ delete override_;
+ override_ = h;
+}
+
+void connection_impl::open() {
+ pn_connection_open(pn_connection_);
+}
+
+void connection_impl::close() {
+ pn_connection_close(pn_connection_);
+}
+
+pn_connection_t *connection_impl::pn_connection() { return pn_connection_; }
+
+std::string connection_impl::hostname() {
+ return std::string(pn_connection_get_hostname(pn_connection_));
+}
+
+connection &connection_impl::connection() {
+ // endpoint interface. Should be implemented in the connection object.
+ throw error(MSG("Internal error"));
+}
+
+container &connection_impl::container() { return (container_); }
+
+void connection_impl::reactor_detach() {
+ // "save" goes out of scope last, preventing possible recursive destructor
+ // confusion with reactor_reference.
+ class connection save(reactor_reference_);
+ if (reactor_reference_)
+ reactor_reference_ = proton::connection();
+ pn_connection_ = 0;
+}
+
+connection &connection_impl::reactor_reference(pn_connection_t *conn) {
+ if (!conn)
+ throw error(MSG("amqp_null Proton connection"));
+ connection_impl *impl_ = connection_context(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"));
+ class container container(container_context(reactor));
+ if (!container) // can't be one created by our container
+ throw error(MSG("Unknown Proton connection specifier"));
+ impl_ = new connection_impl(container, *conn);
+ }
+ return impl_->reactor_reference_;
+}
+
+link connection_impl::link_head(endpoint::State mask) {
+ return link(pn_link_head(pn_connection_, mask));
+}
+
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/connection_impl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/connection_impl.hpp b/proton-c/bindings/cpp/src/connection_impl.hpp
new file mode 100644
index 0000000..02c47b4
--- /dev/null
+++ b/proton-c/bindings/cpp/src/connection_impl.hpp
@@ -0,0 +1,74 @@
+#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 {
+
+class handler;
+class transport;
+class container;
+
+class connection_impl : public endpoint
+{
+ public:
+ PN_CPP_EXTERN connection_impl(class container &c, pn_connection_t &pn_conn);
+ PN_CPP_EXTERN connection_impl(class container &c, handler *h = 0);
+ PN_CPP_EXTERN virtual ~connection_impl();
+ PN_CPP_EXTERN class transport &transport();
+ PN_CPP_EXTERN handler *override();
+ PN_CPP_EXTERN void override(handler *h);
+ PN_CPP_EXTERN void open();
+ PN_CPP_EXTERN void close();
+ PN_CPP_EXTERN pn_connection_t *pn_connection();
+ PN_CPP_EXTERN class container &container();
+ PN_CPP_EXTERN std::string hostname();
+ PN_CPP_EXTERN link link_head(endpoint::State mask);
+ virtual PN_CPP_EXTERN class connection &connection();
+ static class connection &reactor_reference(pn_connection_t *);
+ static connection_impl *impl(const class connection &c) { return c.impl_; }
+ void reactor_detach();
+ static void incref(connection_impl *);
+ static void decref(connection_impl *);
+ private:
+ friend class Connector;
+ friend class container_impl;
+ class container container_;
+ int refcount_;
+ handler *override_;
+ class transport *transport_;
+ pn_session_t *default_session_; // Temporary, for session_per_connection style policy.
+ pn_connection_t *pn_connection_;
+ class connection reactor_reference_; // Keep-alive reference, until PN_CONNECTION_FINAL.
+};
+
+
+}
+
+#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
new file mode 100644
index 0000000..2b1b935
--- /dev/null
+++ b/proton-c/bindings/cpp/src/connector.cpp
@@ -0,0 +1,70 @@
+/*
+ *
+ * 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 "connection_impl.hpp"
+#include "url.hpp"
+
+namespace proton {
+
+Connector::Connector(connection &c) : connection_(c), transport_(0) {}
+
+Connector::~Connector() {}
+
+void Connector::address(const std::string &a) {
+ address_ = a;
+}
+
+void Connector::connect() {
+ pn_connection_t *conn = connection_.pn_connection();
+ pn_connection_set_container(conn, connection_.container().container_id().c_str());
+ Url url(address_);
+ std::string hostname = url.host() + ":" + url.port();
+ pn_connection_set_hostname(conn, hostname.c_str());
+ transport_ = new transport();
+ transport_->bind(connection_);
+ connection_.impl_->transport_ = transport_;
+}
+
+
+void Connector::on_connection_local_open(event &e) {
+ connect();
+}
+
+void Connector::on_connection_remote_open(event &e) {}
+
+void Connector::on_connection_init(event &e) {
+}
+
+void Connector::on_transport_closed(event &e) {
+ // TODO: prepend with reconnect logic
+ pn_connection_release(connection_.impl_->pn_connection_);
+ // No more interaction, so drop our counted reference.
+ connection_ = connection();
+}
+
+
+}
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
new file mode 100644
index 0000000..29e3326
--- /dev/null
+++ b/proton-c/bindings/cpp/src/connector.hpp
@@ -0,0 +1,58 @@
+#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/proton_handler.hpp"
+#include "proton/event.h"
+#include "proton/reactor.h"
+#include <string>
+
+
+namespace proton {
+
+class event;
+class connection;
+class transport;
+
+class Connector : public proton_handler
+{
+ public:
+ Connector(connection &c);
+ ~Connector();
+ void address(const std::string &host);
+ void connect();
+ virtual void on_connection_local_open(event &e);
+ virtual void on_connection_remote_open(event &e);
+ virtual void on_connection_init(event &e);
+ virtual void on_transport_closed(event &e);
+
+ private:
+ connection connection_;
+ std::string address_;
+ transport *transport_;
+};
+
+
+}
+
+#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
new file mode 100644
index 0000000..750300b
--- /dev/null
+++ b/proton-c/bindings/cpp/src/container.cpp
@@ -0,0 +1,96 @@
+/*
+ *
+ * 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/messaging_event.hpp"
+#include "proton/connection.hpp"
+#include "proton/session.hpp"
+#include "proton/messaging_adapter.hpp"
+#include "proton/acceptor.hpp"
+#include "proton/error.hpp"
+#include "container_impl.hpp"
+#include "private_impl_ref.hpp"
+
+#include "connector.hpp"
+#include "contexts.hpp"
+#include "url.hpp"
+
+#include "proton/connection.h"
+#include "proton/session.h"
+
+namespace proton {
+
+template class handle<container_impl>;
+typedef private_impl_ref<container> PI;
+
+container::container(container_impl* p) { PI::ctor(*this, p); }
+container::container(const container& c) : handle<container_impl>() { PI::copy(*this, c); }
+container& container::operator=(const container& c) { return PI::assign(*this, c); }
+container::~container() { PI::dtor(*this); }
+
+container::container(messaging_handler &mhandler) {
+ container_impl *cimpl = new container_impl(mhandler);
+ PI::ctor(*this, cimpl);
+}
+
+container::container() {
+ container_impl *cimpl = new container_impl();
+ PI::ctor(*this, cimpl);
+}
+
+connection container::connect(std::string &host, handler *h) { return impl_->connect(host, h); }
+
+pn_reactor_t *container::reactor() { return impl_->reactor(); }
+
+std::string container::container_id() { return impl_->container_id(); }
+
+duration container::timeout() { return impl_->timeout(); }
+void container::timeout(duration timeout) { impl_->timeout(timeout); }
+
+
+sender container::create_sender(connection &connection, std::string &addr, handler *h) {
+ return impl_->create_sender(connection, addr, h);
+}
+
+sender container::create_sender(std::string &url_string) {
+ return impl_->create_sender(url_string);
+}
+
+receiver container::create_receiver(connection &connection, std::string &addr) {
+ return impl_->create_receiver(connection, addr);
+}
+
+receiver container::create_receiver(const std::string &url) {
+ return impl_->create_receiver(url);
+}
+
+acceptor container::listen(const std::string &url_string) {
+ return impl_->listen(url_string);
+}
+
+
+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::is_quiesced() { return impl_->is_quiesced(); }
+
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/container_impl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/container_impl.cpp b/proton-c/bindings/cpp/src/container_impl.cpp
new file mode 100644
index 0000000..3ce6e25
--- /dev/null
+++ b/proton-c/bindings/cpp/src/container_impl.cpp
@@ -0,0 +1,361 @@
+/*
+ *
+ * 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/messaging_event.hpp"
+#include "proton/connection.hpp"
+#include "proton/session.hpp"
+#include "proton/messaging_adapter.hpp"
+#include "proton/acceptor.hpp"
+#include "proton/error.hpp"
+
+#include "msg.hpp"
+#include "container_impl.hpp"
+#include "connection_impl.hpp"
+#include "connector.hpp"
+#include "contexts.hpp"
+#include "url.hpp"
+#include "private_impl_ref.hpp"
+
+#include "proton/connection.h"
+#include "proton/session.h"
+#include "proton/handlers.h"
+
+namespace proton {
+
+namespace {
+
+connection_impl *impl(const connection &c) {
+ return private_impl_ref<connection>::get(c);
+}
+
+} // namespace
+
+
+class CHandler : public handler
+{
+ public:
+ CHandler(pn_handler_t *h) : pn_handler_(h) {
+ pn_incref(pn_handler_);
+ }
+ ~CHandler() {
+ pn_decref(pn_handler_);
+ }
+ pn_handler_t *pn_handler() { return pn_handler_; }
+
+ virtual void on_unhandled(event &e) {
+ proton_event *pne = dynamic_cast<proton_event *>(&e);
+ if (!pne) return;
+ int type = pne->type();
+ if (!type) return; // Not from the reactor
+ pn_handler_dispatch(pn_handler_, pne->pn_event(), (pn_event_type_t) type);
+ }
+
+ private:
+ pn_handler_t *pn_handler_;
+};
+
+
+// Used to sniff for Connector events before the reactor's global handler sees them.
+class override_handler : public handler
+{
+ public:
+ pn_handler_t *base_handler;
+
+ override_handler(pn_handler_t *h) : base_handler(h) {
+ pn_incref(base_handler);
+ }
+ ~override_handler() {
+ pn_decref(base_handler);
+ }
+
+
+ virtual void on_unhandled(event &e) {
+ proton_event *pne = dynamic_cast<proton_event *>(&e);
+ // If not a Proton reactor event, nothing to override, nothing to pass along.
+ if (!pne) return;
+ int type = pne->type();
+ if (!type) return; // Also not from the reactor
+
+ pn_event_t *cevent = pne->pn_event();
+ pn_connection_t *conn = pn_event_connection(cevent);
+ if (conn && type != PN_CONNECTION_INIT) {
+ // send to override handler first
+ connection_impl *connection = connection_context(conn);
+ if (connection) {
+ handler *override = connection->override();
+ if (override) {
+ e.dispatch(*override);
+ }
+ }
+ }
+
+ pn_handler_dispatch(base_handler, 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.
+ connection_impl *cimpl = connection_context(conn);
+ if (cimpl)
+ cimpl->reactor_detach();
+ // TODO: remember all connections and do reactor_detach of zombie connections
+ // not yet pn_connection_release'd at PN_REACTOR_FINAL.
+ }
+ }
+};
+
+
+namespace {
+
+// TODO: configurable policy. session_per_connection for now.
+session default_session(pn_connection_t *conn, pn_session_t **ses) {
+ if (!*ses) {
+ *ses = pn_session(conn);
+ pn_session_open(*ses);
+ }
+ return session(*ses);
+}
+
+struct inbound_context {
+ static inbound_context* get(pn_handler_t* h) {
+ return reinterpret_cast<inbound_context*>(pn_handler_mem(h));
+ }
+ container_impl *container_impl_;
+ handler *cpp_handler_;
+};
+
+void cpp_handler_dispatch(pn_handler_t *c_handler, pn_event_t *cevent, pn_event_type_t type)
+{
+ // Ref counted per event, but when is the last event if stop() never called?
+ container c(inbound_context::get(c_handler)->container_impl_);
+ messaging_event mevent(cevent, type, c);
+ mevent.dispatch(*inbound_context::get(c_handler)->cpp_handler_);
+}
+
+void cpp_handler_cleanup(pn_handler_t *c_handler)
+{
+}
+
+pn_handler_t *cpp_handler(container_impl *c, handler *h)
+{
+ pn_handler_t *handler = pn_handler_new(cpp_handler_dispatch, sizeof(struct inbound_context), cpp_handler_cleanup);
+ inbound_context *ctxt = inbound_context::get(handler);
+ ctxt->container_impl_ = c;
+ ctxt->cpp_handler_ = h;
+ return handler;
+}
+
+
+} // namespace
+
+
+void container_impl::incref(container_impl *impl_) {
+ impl_->refcount_++;
+}
+
+void container_impl::decref(container_impl *impl_) {
+ impl_->refcount_--;
+ if (impl_->refcount_ == 0)
+ delete impl_;
+}
+
+container_impl::container_impl(handler &h) :
+ reactor_(0), handler_(&h), messaging_adapter_(0),
+ override_handler_(0), flow_controller_(0), container_id_(),
+ refcount_(0)
+{}
+
+container_impl::container_impl() :
+ reactor_(0), handler_(0), messaging_adapter_(0),
+ override_handler_(0), flow_controller_(0), container_id_(),
+ refcount_(0)
+{}
+
+container_impl::~container_impl() {
+ delete override_handler_;
+ delete flow_controller_;
+ delete messaging_adapter_;
+ pn_reactor_free(reactor_);
+}
+
+connection container_impl::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->address(host); // TODO: url vector
+ connection.override(connector);
+ connection.open();
+ return connection;
+}
+
+pn_reactor_t *container_impl::reactor() { return reactor_; }
+
+
+std::string container_impl::container_id() { return container_id_; }
+
+duration container_impl::timeout() {
+ pn_millis_t tmo = pn_reactor_get_timeout(reactor_);
+ if (tmo == PN_MILLIS_MAX)
+ return duration::FOREVER;
+ return duration(tmo);
+}
+
+void container_impl::timeout(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 container_impl::create_sender(connection &connection, std::string &addr, handler *h) {
+ if (!reactor_) throw error(MSG("container not started"));
+ session session = default_session(connection.pn_connection(), &impl(connection)->default_session_);
+ sender snd = session.create_sender(container_id_ + '-' + addr);
+ pn_link_t *lnk = snd.pn_link();
+ 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, wrap_handler(h));
+ }
+ snd.open();
+ return snd;
+}
+
+sender container_impl::create_sender(std::string &url_string) {
+ if (!reactor_) throw error(MSG("container not started"));
+ connection conn = connect(url_string, 0);
+ session session = default_session(conn.pn_connection(), &impl(conn)->default_session_);
+ std::string path = Url(url_string).path();
+ sender snd = session.create_sender(container_id_ + '-' + path);
+ pn_terminus_set_address(pn_link_target(snd.pn_link()), path.c_str());
+ snd.open();
+ return snd;
+}
+
+receiver container_impl::create_receiver(connection &connection, std::string &addr) {
+ if (!reactor_) throw error(MSG("container not started"));
+ connection_impl *conn_impl = impl(connection);
+ session session = default_session(conn_impl->pn_connection_, &conn_impl->default_session_);
+ receiver rcv = session.create_receiver(container_id_ + '-' + addr);
+ pn_terminus_set_address(pn_link_source(rcv.pn_link()), addr.c_str());
+ rcv.open();
+ return rcv;
+}
+
+receiver container_impl::create_receiver(const std::string &url_string) {
+ if (!reactor_) throw error(MSG("container not started"));
+ // TODO: const cleanup of API
+ connection conn = connect(const_cast<std::string &>(url_string), 0);
+ session session = default_session(conn.pn_connection(), &impl(conn)->default_session_);
+ std::string path = Url(url_string).path();
+ receiver rcv = session.create_receiver(container_id_ + '-' + path);
+ pn_terminus_set_address(pn_link_source(rcv.pn_link()), path.c_str());
+ rcv.open();
+ return rcv;
+}
+
+class acceptor container_impl::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 proton::acceptor(acptr);
+ else
+ throw error(MSG("accept fail: " << pn_error_text(pn_io_error(pn_reactor_io(reactor_))) << "(" << host << ":" << port << ")"));
+}
+
+acceptor container_impl::listen(const std::string &url_string) {
+ if (!reactor_) throw error(MSG("container not started"));
+ Url url(url_string);
+ // TODO: SSL
+ return acceptor(url.host(), url.port());
+}
+
+
+pn_handler_t *container_impl::wrap_handler(handler *h) {
+ return cpp_handler(this, h);
+}
+
+
+void container_impl::initialize_reactor() {
+ if (reactor_) throw error(MSG("container already running"));
+ reactor_ = pn_reactor();
+
+ // Set our context on the reactor
+ container_context(reactor_, this);
+
+ if (handler_) {
+ pn_handler_t *pn_handler = cpp_handler(this, handler_);
+ pn_reactor_set_handler(reactor_, pn_handler);
+ pn_decref(pn_handler);
+ }
+
+ // Set our own global handler that "subclasses" the existing one
+ pn_handler_t *global_handler = pn_reactor_get_global_handler(reactor_);
+ override_handler_ = new override_handler(global_handler);
+ pn_handler_t *cpp_global_handler = cpp_handler(this, override_handler_);
+ pn_reactor_set_global_handler(reactor_, cpp_global_handler);
+ pn_decref(cpp_global_handler);
+
+ // Note: we have just set up the following 4/5 handlers that see events in this order:
+ // messaging_handler (Proton C events), pn_flowcontroller (optional), messaging_adapter,
+ // messaging_handler (Messaging events from the messaging_adapter, i.e. the delegate),
+ // connector override, the reactor's default globalhandler (pn_iohandler)
+}
+
+void container_impl::run() {
+ initialize_reactor();
+ pn_reactor_run(reactor_);
+}
+
+void container_impl::start() {
+ initialize_reactor();
+ pn_reactor_start(reactor_);
+}
+
+bool container_impl::process() {
+ if (!reactor_) throw error(MSG("container not started"));
+ bool result = pn_reactor_process(reactor_);
+ // TODO: check errors
+ return result;
+}
+
+void container_impl::stop() {
+ if (!reactor_) throw error(MSG("container not started"));
+ pn_reactor_stop(reactor_);
+ // TODO: check errors
+}
+
+void container_impl::wakeup() {
+ if (!reactor_) throw error(MSG("container not started"));
+ pn_reactor_wakeup(reactor_);
+ // TODO: check errors
+}
+
+bool container_impl::is_quiesced() {
+ if (!reactor_) throw error(MSG("container not started"));
+ return pn_reactor_quiesced(reactor_);
+}
+
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/container_impl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/container_impl.hpp b/proton-c/bindings/cpp/src/container_impl.hpp
new file mode 100644
index 0000000..4507ab6
--- /dev/null
+++ b/proton-c/bindings/cpp/src/container_impl.hpp
@@ -0,0 +1,81 @@
+#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/messaging_handler.hpp"
+#include "proton/connection.hpp"
+#include "proton/link.hpp"
+#include "proton/duration.hpp"
+
+#include "proton/reactor.h"
+
+#include <string>
+namespace proton {
+
+class dispatch_helper;
+class connection;
+class connector;
+class acceptor;
+
+class container_impl
+{
+ public:
+ PN_CPP_EXTERN container_impl(handler &h);
+ PN_CPP_EXTERN container_impl();
+ PN_CPP_EXTERN ~container_impl();
+ PN_CPP_EXTERN connection connect(std::string &host, handler *h);
+ PN_CPP_EXTERN void run();
+ PN_CPP_EXTERN pn_reactor_t *reactor();
+ PN_CPP_EXTERN sender create_sender(connection &connection, std::string &addr, handler *h);
+ PN_CPP_EXTERN sender create_sender(std::string &url);
+ PN_CPP_EXTERN receiver create_receiver(connection &connection, std::string &addr);
+ PN_CPP_EXTERN receiver create_receiver(const std::string &url);
+ PN_CPP_EXTERN class acceptor listen(const std::string &url);
+ PN_CPP_EXTERN std::string container_id();
+ PN_CPP_EXTERN duration timeout();
+ PN_CPP_EXTERN void timeout(duration timeout);
+ void start();
+ bool process();
+ void stop();
+ void wakeup();
+ bool is_quiesced();
+ pn_handler_t *wrap_handler(handler *h);
+ static void incref(container_impl *);
+ static void decref(container_impl *);
+ private:
+ void dispatch(pn_event_t *event, pn_event_type_t type);
+ class acceptor acceptor(const std::string &host, const std::string &port);
+ void initialize_reactor();
+ pn_reactor_t *reactor_;
+ handler *handler_;
+ messaging_adapter *messaging_adapter_;
+ handler *override_handler_;
+ handler *flow_controller_;
+ std::string container_id_;
+ int refcount_;
+};
+
+
+}
+
+#endif /*!PROTON_CPP_CONTAINERIMPL_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/contexts.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/contexts.cpp b/proton-c/bindings/cpp/src/contexts.cpp
index fd2f3e1..98c502b 100644
--- a/proton-c/bindings/cpp/src/contexts.cpp
+++ b/proton-c/bindings/cpp/src/contexts.cpp
@@ -20,8 +20,8 @@
*/
#include "contexts.hpp"
-#include "proton/Error.hpp"
-#include "Msg.hpp"
+#include "proton/error.hpp"
+#include "msg.hpp"
#include "proton/object.h"
#include "proton/message.h"
#include "proton/session.h"
@@ -32,44 +32,43 @@ PN_HANDLE(PNI_CPP_CONTAINER_CONTEXT)
PN_HANDLE(PNI_CPP_EVENT_CONTEXT)
namespace proton {
-namespace reactor {
-void setConnectionContext(pn_connection_t *pnConnection, ConnectionImpl *connection) {
- pn_record_t *record = pn_connection_attachments(pnConnection);
+void connection_context(pn_connection_t *pn_connection, connection_impl *connection) {
+ pn_record_t *record = pn_connection_attachments(pn_connection);
pn_record_def(record, PNI_CPP_CONNECTION_CONTEXT, PN_VOID);
pn_record_set(record, PNI_CPP_CONNECTION_CONTEXT, connection);
}
-ConnectionImpl *getConnectionContext(pn_connection_t *pnConnection) {
- if (!pnConnection) return NULL;
- pn_record_t *record = pn_connection_attachments(pnConnection);
- ConnectionImpl *p = (ConnectionImpl *) pn_record_get(record, PNI_CPP_CONNECTION_CONTEXT);
+connection_impl *connection_context(pn_connection_t *pn_connection) {
+ if (!pn_connection) return NULL;
+ pn_record_t *record = pn_connection_attachments(pn_connection);
+ connection_impl *p = (connection_impl *) pn_record_get(record, PNI_CPP_CONNECTION_CONTEXT);
return p;
}
-void setContainerContext(pn_reactor_t *pnReactor, ContainerImpl *container) {
- pn_record_t *record = pn_reactor_attachments(pnReactor);
+void container_context(pn_reactor_t *pn_reactor, container_impl *container) {
+ pn_record_t *record = pn_reactor_attachments(pn_reactor);
pn_record_def(record, PNI_CPP_CONTAINER_CONTEXT, PN_VOID);
pn_record_set(record, PNI_CPP_CONTAINER_CONTEXT, container);
}
-ContainerImpl *getContainerContext(pn_reactor_t *pnReactor) {
- pn_record_t *record = pn_reactor_attachments(pnReactor);
- ContainerImpl *p = (ContainerImpl *) pn_record_get(record, PNI_CPP_CONTAINER_CONTEXT);
- if (!p) throw Error(MSG("Reactor has no C++ container context"));
+container_impl *container_context(pn_reactor_t *pn_reactor) {
+ pn_record_t *record = pn_reactor_attachments(pn_reactor);
+ container_impl *p = (container_impl *) pn_record_get(record, PNI_CPP_CONTAINER_CONTEXT);
+ if (!p) throw error(MSG("Reactor has no C++ container context"));
return p;
}
-void setEventContext(pn_event_t *pnEvent, pn_message_t *m) {
- pn_record_t *record = pn_event_attachments(pnEvent);
+void event_context(pn_event_t *pn_event, pn_message_t *m) {
+ pn_record_t *record = pn_event_attachments(pn_event);
pn_record_def(record, PNI_CPP_EVENT_CONTEXT, PN_OBJECT); // refcount it for life of the event
pn_record_set(record, PNI_CPP_EVENT_CONTEXT, m);
}
-pn_message_t *getEventContext(pn_event_t *pnEvent) {
- if (!pnEvent) return NULL;
- pn_record_t *record = pn_event_attachments(pnEvent);
+pn_message_t *event_context(pn_event_t *pn_event) {
+ if (!pn_event) return NULL;
+ pn_record_t *record = pn_event_attachments(pn_event);
pn_message_t *p = (pn_message_t *) pn_record_get(record, PNI_CPP_EVENT_CONTEXT);
return p;
}
-}} // namespace proton::reactor
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/contexts.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/contexts.hpp b/proton-c/bindings/cpp/src/contexts.hpp
index e1b5f24..4830044 100644
--- a/proton-c/bindings/cpp/src/contexts.hpp
+++ b/proton-c/bindings/cpp/src/contexts.hpp
@@ -26,27 +26,26 @@
#include "proton/message.h"
namespace proton {
-namespace reactor {
-class ConnectionImpl;
-void setConnectionContext(pn_connection_t *pnConnection, ConnectionImpl *connection);
-ConnectionImpl *getConnectionContext(pn_connection_t *pnConnection);
+class connection_impl;
+void connection_context(pn_connection_t *pn_connection, connection_impl *connection);
+connection_impl *connection_context(pn_connection_t *pn_connection);
-class Session;
-void setSessionContext(pn_session_t *pnSession, Session *session);
-Session *getSessionContext(pn_session_t *pnSession);
+class session;
+void session_context(pn_session_t *pn_session, session *session);
+session *session_context(pn_session_t *pn_session);
-class Link;
-void setLinkContext(pn_link_t *pnLink, Link *link);
-Link *getLinkContext(pn_link_t *pnLink);
+class link;
+void link_context(pn_link_t *pn_link, link *link);
+link *link_context(pn_link_t *pn_link);
-class ContainerImpl;
-void setContainerContext(pn_reactor_t *pnReactor, ContainerImpl *container);
-ContainerImpl *getContainerContext(pn_reactor_t *pnReactor);
+class container_impl;
+void container_context(pn_reactor_t *pn_reactor, container_impl *container);
+container_impl *container_context(pn_reactor_t *pn_reactor);
-void setEventContext(pn_event_t *pnEvent, pn_message_t *m);
-pn_message_t *getEventContext(pn_event_t *pnEvent);
+void event_context(pn_event_t *pn_event, pn_message_t *m);
+pn_message_t *event_context(pn_event_t *pn_event);
-}} // namespace proton::reactor
+}
#endif /*!PROTON_CPP_CONTEXTS_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
new file mode 100644
index 0000000..51a9dde
--- /dev/null
+++ b/proton-c/bindings/cpp/src/data.cpp
@@ -0,0 +1,67 @@
+/*
+ * 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* new_data) {
+ if (data_ && own_) pn_data_free(data_);
+ data_ = new_data;
+ 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_); }
+
+void data::rewind() { ::pn_data_rewind(data_); }
+
+bool data::empty() const { return ::pn_data_size(data_) == 0; }
+
+std::ostream& operator<<(std::ostream& o, const data& d) { return o << pn_object(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
new file mode 100644
index 0000000..d1f17cf
--- /dev/null
+++ b/proton-c/bindings/cpp/src/decoder.cpp
@@ -0,0 +1,329 @@
+/*
+ * 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: ");
+decode_error::decode_error(const std::string& msg) throw() : error(prefix+msg) {}
+
+namespace {
+struct save_state {
+ pn_data_t* data;
+ pn_handle_t handle;
+ save_state(pn_data_t* d) : data(d), handle(pn_data_point(d)) {}
+ ~save_state() { 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 decode_error("" + error_str(result));
+ return result;
+}
+
+}
+
+void decoder::decode(const char* i, size_t size) {
+ save_state 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 {
+ save_state ss(data_);
+ return pn_data_next(data_);
+}
+
+namespace {
+
+void bad_type(type_id want, type_id got) {
+ if (want != got)
+ throw decode_error("expected "+type_name(want)+" found "+type_name(got));
+}
+
+type_id pre_get(pn_data_t* data) {
+ if (!pn_data_next(data)) throw decode_error("no more data");
+ type_id t = type_id(pn_data_type(data));
+ if (t < 0) throw decode_error("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*)) {
+ save_state ss(data);
+ bad_type(type_idOf<T>::value, pre_get(data));
+ value = get(data);
+ ss.cancel(); // No error, no rewind
+}
+
+}
+
+void decoder::check_type(type_id want) {
+ type_id got = type();
+ if (want != got) bad_type(want, got);
+}
+
+type_id decoder::type() const {
+ save_state ss(data_);
+ return pre_get(data_);
+}
+
+decoder& operator>>(decoder& d, start& s) {
+ save_state ss(d.data_);
+ s.type = pre_get(d.data_);
+ switch (s.type) {
+ case ARRAY:
+ s.size = pn_data_get_array(d.data_);
+ s.element = type_id(pn_data_get_array_type(d.data_));
+ s.is_described = 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.is_described = true;
+ s.size = 1;
+ break;
+ default:
+ throw decode_error(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, rewind) { d.rewind(); return d; }
+
+decoder& operator>>(decoder& d, value& v) {
+ if (d.data_ == v.values_.data_) throw decode_error("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 decode_error("no more data");
+ return d;
+}
+
+
+decoder& operator>>(decoder& d, amqp_null) {
+ save_state ss(d.data_);
+ bad_type(NULl_, pre_get(d.data_));
+ return d;
+}
+
+decoder& operator>>(decoder& d, amqp_bool& value) {
+ extract(d.data_, value, pn_data_get_bool);
+ return d;
+}
+
+decoder& operator>>(decoder& d, amqp_ubyte& value) {
+ save_state ss(d.data_);
+ switch (pre_get(d.data_)) {
+ case UBYTE: value = pn_data_get_ubyte(d.data_); break;
+ default: bad_type(UBYTE, type_id(type_id(pn_data_type(d.data_))));
+ }
+ ss.cancel();
+ return d;
+}
+
+decoder& operator>>(decoder& d, amqp_byte& value) {
+ save_state ss(d.data_);
+ switch (pre_get(d.data_)) {
+ case BYTE: value = pn_data_get_byte(d.data_); break;
+ default: bad_type(BYTE, type_id(type_id(pn_data_type(d.data_))));
+ }
+ ss.cancel();
+ return d;
+}
+
+decoder& operator>>(decoder& d, amqp_ushort& value) {
+ save_state ss(d.data_);
+ switch (pre_get(d.data_)) {
+ case UBYTE: value = pn_data_get_ubyte(d.data_); break;
+ case USHORT: value = pn_data_get_ushort(d.data_); break;
+ default: bad_type(USHORT, type_id(type_id(pn_data_type(d.data_))));
+ }
+ ss.cancel();
+ return d;
+}
+
+decoder& operator>>(decoder& d, amqp_short& value) {
+ save_state ss(d.data_);
+ switch (pre_get(d.data_)) {
+ case BYTE: value = pn_data_get_byte(d.data_); break;
+ case SHORT: value = pn_data_get_short(d.data_); break;
+ default: bad_type(SHORT, type_id(pn_data_type(d.data_)));
+ }
+ ss.cancel();
+ return d;
+}
+
+decoder& operator>>(decoder& d, amqp_uint& value) {
+ save_state ss(d.data_);
+ switch (pre_get(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: bad_type(UINT, type_id(pn_data_type(d.data_)));
+ }
+ ss.cancel();
+ return d;
+}
+
+decoder& operator>>(decoder& d, amqp_int& value) {
+ save_state ss(d.data_);
+ switch (pre_get(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: bad_type(INT, type_id(pn_data_type(d.data_)));
+ }
+ ss.cancel();
+ return d;
+}
+
+decoder& operator>>(decoder& d, amqp_ulong& value) {
+ save_state ss(d.data_);
+ switch (pre_get(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: bad_type(ULONG, type_id(pn_data_type(d.data_)));
+ }
+ ss.cancel();
+ return d;
+}
+
+decoder& operator>>(decoder& d, amqp_long& value) {
+ save_state ss(d.data_);
+ switch (pre_get(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: bad_type(LONG, type_id(pn_data_type(d.data_)));
+ }
+ ss.cancel();
+ return d;
+}
+
+decoder& operator>>(decoder& d, amqp_char& value) {
+ extract(d.data_, value, pn_data_get_char);
+ return d;
+}
+
+decoder& operator>>(decoder& d, amqp_timestamp& value) {
+ extract(d.data_, value, pn_data_get_timestamp);
+ return d;
+}
+
+decoder& operator>>(decoder& d, amqp_float& value) {
+ save_state ss(d.data_);
+ switch (pre_get(d.data_)) {
+ case FLOAT: value = pn_data_get_float(d.data_); break;
+ case DOUBLE: value = pn_data_get_double(d.data_); break;
+ default: bad_type(FLOAT, type_id(pn_data_type(d.data_)));
+ }
+ ss.cancel();
+ return d;
+}
+
+decoder& operator>>(decoder& d, amqp_double& value) {
+ save_state ss(d.data_);
+ switch (pre_get(d.data_)) {
+ case FLOAT: value = pn_data_get_float(d.data_); break;
+ case DOUBLE: value = pn_data_get_double(d.data_); break;
+ default: bad_type(DOUBLE, type_id(pn_data_type(d.data_)));
+ }
+ ss.cancel();
+ return d;
+}
+
+// TODO aconway 2015-06-11: decimal conversions.
+decoder& operator>>(decoder& d, amqp_decimal32& value) {
+ extract(d.data_, value, pn_data_get_decimal32);
+ return d;
+}
+
+decoder& operator>>(decoder& d, amqp_decimal64& value) {
+ extract(d.data_, value, pn_data_get_decimal64);
+ return d;
+}
+
+decoder& operator>>(decoder& d, amqp_decimal128& value) {
+ extract(d.data_, value, pn_data_get_decimal128);
+ return d;
+}
+
+decoder& operator>>(decoder& d, amqp_uuid& value) {
+ extract(d.data_, value, pn_data_get_uuid);
+ return d;
+}
+
+decoder& operator>>(decoder& d, std::string& value) {
+ save_state ss(d.data_);
+ switch (pre_get(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: bad_type(STRING, type_id(pn_data_type(d.data_)));
+ }
+ ss.cancel();
+ return d;
+}
+
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/delivery.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/delivery.cpp b/proton-c/bindings/cpp/src/delivery.cpp
new file mode 100644
index 0000000..7ff596f
--- /dev/null
+++ b/proton-c/bindings/cpp/src/delivery.cpp
@@ -0,0 +1,57 @@
+/*
+ *
+ * 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/delivery.hpp"
+#include "proton/delivery.h"
+#include "proton_impl_ref.hpp"
+
+namespace proton {
+
+template class proton_handle<pn_delivery_t>;
+typedef proton_impl_ref<delivery> PI;
+
+delivery::delivery(pn_delivery_t *p) {
+ PI::ctor(*this, p);
+}
+delivery::delivery() {
+ PI::ctor(*this, 0);
+}
+delivery::delivery(const delivery& c) : proton_handle<pn_delivery_t>() {
+ PI::copy(*this, c);
+}
+delivery& delivery::operator=(const delivery& c) {
+ return PI::assign(*this, c);
+}
+delivery::~delivery() {
+ PI::dtor(*this);
+}
+
+bool delivery::settled() {
+ return pn_delivery_settled(impl_);
+}
+
+void delivery::settle() {
+ pn_delivery_settle(impl_);
+}
+
+pn_delivery_t *delivery::pn_delivery() { return impl_; }
+
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/duration.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/duration.cpp b/proton-c/bindings/cpp/src/duration.cpp
new file mode 100644
index 0000000..137fb5b
--- /dev/null
+++ b/proton-c/bindings/cpp/src/duration.cpp
@@ -0,0 +1,31 @@
+/*
+ *
+ * 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/duration.hpp"
+#include <limits>
+
+namespace proton {
+
+const duration duration::FOREVER(std::numeric_limits<std::uint64_t>::max());
+const duration duration::IMMEDIATE(0);
+const duration duration::SECOND(1000);
+const duration duration::MINUTE(SECOND * 60);
+
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69783099/proton-c/bindings/cpp/src/encoder.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/encoder.cpp b/proton-c/bindings/cpp/src/encoder.cpp
new file mode 100644
index 0000000..9c32f58
--- /dev/null
+++ b/proton-c/bindings/cpp/src/encoder.cpp
@@ -0,0 +1,142 @@
+/*
+ * 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/value.hpp"
+#include <proton/codec.h>
+#include "proton_bits.hpp"
+#include "msg.hpp"
+
+namespace proton {
+
+encoder::encoder() {}
+encoder::~encoder() {}
+
+static const std::string prefix("encode: ");
+encode_error::encode_error(const std::string& msg) throw() : error(prefix+msg) {}
+
+namespace {
+struct save_state {
+ pn_data_t* data;
+ pn_handle_t handle;
+ save_state(pn_data_t* d) : data(d), handle(pn_data_point(d)) {}
+ ~save_state() { if (data) pn_data_restore(data, handle); }
+ void cancel() { data = 0; }
+};
+
+void check(int result, pn_data_t* data) {
+ if (result < 0)
+ throw encode_error(error_str(pn_data_error(data), result));
+}
+}
+
+bool encoder::encode(char* buffer, size_t& size) {
+ save_state ss(data_); // In case of error
+ ssize_t result = pn_data_encode(data_, buffer, size);
+ if (result == PN_OVERFLOW) {
+ result = pn_data_encoded_size(data_);
+ if (result >= 0) {
+ size = result;
+ return false;
+ }
+ }
+ check(result, data_);
+ size = result;
+ ss.cancel(); // Don't restore state, all is well.
+ pn_data_clear(data_);
+ return true;
+}
+
+void encoder::encode(std::string& s) {
+ size_t size = s.size();
+ if (!encode(&s[0], size)) {
+ s.resize(size);
+ encode(&s[0], size);
+ }
+}
+
+std::string encoder::encode() {
+ std::string s;
+ encode(s);
+ return s;
+}
+
+encoder& operator<<(encoder& e, const start& s) {
+ switch (s.type) {
+ case ARRAY: pn_data_put_array(e.data_, s.is_described, pn_type_t(s.element)); break;
+ case MAP: pn_data_put_map(e.data_); break;
+ case LIST: pn_data_put_list(e.data_); break;
+ case DESCRIBED: pn_data_put_described(e.data_); break;
+ default:
+ throw encode_error(MSG("" << s.type << " is not a container type"));
+ }
+ pn_data_enter(e.data_);
+ return e;
+}
+
+encoder& operator<<(encoder& e, finish) {
+ pn_data_exit(e.data_);
+ return e;
+}
+
+namespace {
+template <class T, class U>
+encoder& insert(encoder& e, pn_data_t* data, T& value, int (*put)(pn_data_t*, U)) {
+ save_state ss(data); // Save state in case of error.
+ check(put(data, value), data);
+ ss.cancel(); // Don't restore state, all is good.
+ return e;
+}
+}
+
+encoder& operator<<(encoder& e, amqp_null) { pn_data_put_null(e.data_); return e; }
+encoder& operator<<(encoder& e, amqp_bool value) { return insert(e, e.data_, value, pn_data_put_bool); }
+encoder& operator<<(encoder& e, amqp_ubyte value) { return insert(e, e.data_, value, pn_data_put_ubyte); }
+encoder& operator<<(encoder& e, amqp_byte value) { return insert(e, e.data_, value, pn_data_put_byte); }
+encoder& operator<<(encoder& e, amqp_ushort value) { return insert(e, e.data_, value, pn_data_put_ushort); }
+encoder& operator<<(encoder& e, amqp_short value) { return insert(e, e.data_, value, pn_data_put_short); }
+encoder& operator<<(encoder& e, amqp_uint value) { return insert(e, e.data_, value, pn_data_put_uint); }
+encoder& operator<<(encoder& e, amqp_int value) { return insert(e, e.data_, value, pn_data_put_int); }
+encoder& operator<<(encoder& e, amqp_char value) { return insert(e, e.data_, value, pn_data_put_char); }
+encoder& operator<<(encoder& e, amqp_ulong value) { return insert(e, e.data_, value, pn_data_put_ulong); }
+encoder& operator<<(encoder& e, amqp_long value) { return insert(e, e.data_, value, pn_data_put_long); }
+encoder& operator<<(encoder& e, amqp_timestamp value) { return insert(e, e.data_, value, pn_data_put_timestamp); }
+encoder& operator<<(encoder& e, amqp_float value) { return insert(e, e.data_, value, pn_data_put_float); }
+encoder& operator<<(encoder& e, amqp_double value) { return insert(e, e.data_, value, pn_data_put_double); }
+encoder& operator<<(encoder& e, amqp_decimal32 value) { return insert(e, e.data_, value, pn_data_put_decimal32); }
+encoder& operator<<(encoder& e, amqp_decimal64 value) { return insert(e, e.data_, value, pn_data_put_decimal64); }
+encoder& operator<<(encoder& e, amqp_decimal128 value) { return insert(e, e.data_, value, pn_data_put_decimal128); }
+encoder& operator<<(encoder& e, amqp_uuid value) { return insert(e, e.data_, value, pn_data_put_uuid); }
+encoder& operator<<(encoder& e, amqp_string value) { return insert(e, e.data_, value, pn_data_put_string); }
+encoder& operator<<(encoder& e, amqp_symbol value) { return insert(e, e.data_, value, pn_data_put_symbol); }
+encoder& operator<<(encoder& e, amqp_binary value) { return insert(e, e.data_, value, pn_data_put_binary); }
+
+encoder& operator<<(encoder& e, const value& v) {
+ if (e.data_ == v.values_.data_) throw encode_error("cannot insert into self");
+ check(pn_data_appendn(e.data_, v.values_.data_, 1), e.data_);
+ return e;
+}
+
+encoder& operator<<(encoder& e, const values& v) {
+ if (e.data_ == v.data_) throw encode_error("cannot insert into self");
+ check(pn_data_append(e.data_, v.data_), e.data_);
+ return e;
+}
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org