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/03 19:26:08 UTC
[45/50] [abbrv] qpid-proton git commit: PROTON-865: new
cjansen-cpp-client branch for fledgling C++ client code using the event
reactor
PROTON-865: new cjansen-cpp-client branch for fledgling C++ client code using the event reactor
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/ad7c9778
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/ad7c9778
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/ad7c9778
Branch: refs/heads/cjansen-cpp-client
Commit: ad7c9778f4ea33a6ca982ac4fea5178b0320b24d
Parents: 2386173
Author: Clifford Jansen <cl...@apache.org>
Authored: Thu Apr 30 11:22:03 2015 -0700
Committer: Alan Conway <ac...@redhat.com>
Committed: Tue Jun 2 14:46:14 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/CMakeLists.txt | 7 +-
proton-c/bindings/cpp/CMakeLists.txt | 116 +++++++
proton-c/bindings/cpp/examples/HelloWorld.cpp | 62 ++++
.../bindings/cpp/examples/HelloWorldDirect.cpp | 70 +++++
.../bindings/cpp/include/proton/cpp/Acceptor.h | 50 +++
.../cpp/include/proton/cpp/Connection.h | 69 +++++
.../bindings/cpp/include/proton/cpp/Container.h | 67 +++++
.../bindings/cpp/include/proton/cpp/Endpoint.h | 47 +++
.../bindings/cpp/include/proton/cpp/Event.h | 60 ++++
.../bindings/cpp/include/proton/cpp/Handle.h | 72 +++++
.../bindings/cpp/include/proton/cpp/Handler.h | 50 +++
.../cpp/include/proton/cpp/ImportExport.h | 50 +++
proton-c/bindings/cpp/include/proton/cpp/Link.h | 63 ++++
.../bindings/cpp/include/proton/cpp/Message.h | 53 ++++
.../cpp/include/proton/cpp/MessagingAdapter.h | 57 ++++
.../cpp/include/proton/cpp/MessagingEvent.h | 92 ++++++
.../cpp/include/proton/cpp/MessagingHandler.h | 73 +++++
.../cpp/include/proton/cpp/ProtonEvent.h | 57 ++++
.../cpp/include/proton/cpp/ProtonHandle.h | 68 +++++
.../cpp/include/proton/cpp/ProtonHandler.h | 83 +++++
.../bindings/cpp/include/proton/cpp/Receiver.h | 47 +++
.../bindings/cpp/include/proton/cpp/Sender.h | 50 +++
.../bindings/cpp/include/proton/cpp/Session.h | 59 ++++
.../bindings/cpp/include/proton/cpp/Transport.h | 48 +++
.../cpp/include/proton/cpp/exceptions.h | 56 ++++
proton-c/bindings/cpp/src/Acceptor.cpp | 56 ++++
proton-c/bindings/cpp/src/Connection.cpp | 69 +++++
proton-c/bindings/cpp/src/ConnectionImpl.cpp | 113 +++++++
proton-c/bindings/cpp/src/ConnectionImpl.h | 73 +++++
proton-c/bindings/cpp/src/Connector.cpp | 77 +++++
proton-c/bindings/cpp/src/Connector.h | 59 ++++
proton-c/bindings/cpp/src/Container.cpp | 86 ++++++
proton-c/bindings/cpp/src/ContainerImpl.cpp | 301 +++++++++++++++++++
proton-c/bindings/cpp/src/ContainerImpl.h | 69 +++++
proton-c/bindings/cpp/src/Endpoint.cpp | 37 +++
proton-c/bindings/cpp/src/Event.cpp | 71 +++++
proton-c/bindings/cpp/src/Handler.cpp | 44 +++
proton-c/bindings/cpp/src/Link.cpp | 99 ++++++
proton-c/bindings/cpp/src/LogInternal.h | 51 ++++
proton-c/bindings/cpp/src/Logger.cpp | 56 ++++
proton-c/bindings/cpp/src/Message.cpp | 92 ++++++
proton-c/bindings/cpp/src/MessagingAdapter.cpp | 191 ++++++++++++
proton-c/bindings/cpp/src/MessagingEvent.cpp | 133 ++++++++
proton-c/bindings/cpp/src/MessagingHandler.cpp | 60 ++++
proton-c/bindings/cpp/src/Msg.h | 79 +++++
proton-c/bindings/cpp/src/PrivateImplRef.h | 97 ++++++
proton-c/bindings/cpp/src/ProtonEvent.cpp | 152 ++++++++++
proton-c/bindings/cpp/src/ProtonHandler.cpp | 74 +++++
proton-c/bindings/cpp/src/ProtonImplRef.h | 66 ++++
proton-c/bindings/cpp/src/Receiver.cpp | 43 +++
proton-c/bindings/cpp/src/Sender.cpp | 69 +++++
proton-c/bindings/cpp/src/Session.cpp | 64 ++++
proton-c/bindings/cpp/src/Transport.cpp | 39 +++
proton-c/bindings/cpp/src/Url.cpp | 77 +++++
proton-c/bindings/cpp/src/Url.h | 49 +++
proton-c/bindings/cpp/src/contexts.cpp | 92 ++++++
proton-c/bindings/cpp/src/contexts.h | 48 +++
proton-c/bindings/cpp/src/exceptions.cpp | 33 ++
proton-c/bindings/cpp/src/platform.cpp | 79 +++++
proton-c/bindings/cpp/src/platform.h | 39 +++
60 files changed, 4362 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/CMakeLists.txt b/proton-c/bindings/CMakeLists.txt
index 5df4682..f426ef3 100644
--- a/proton-c/bindings/CMakeLists.txt
+++ b/proton-c/bindings/CMakeLists.txt
@@ -20,7 +20,7 @@
include(UseSWIG)
# Add any new bindings here - the directory name must be the same as the binding name
-set (BINDINGS python ruby php perl javascript)
+set (BINDINGS python ruby php perl javascript cpp)
# All swig modules should include ${PROTON_HEADERS} in SWIG_MODULE_<name>_EXTRA_DEPS
file(GLOB PROTON_HEADERS "${CMAKE_SOURCE_DIR}/proton-c/include/proton/*.h")
@@ -109,6 +109,11 @@ if (EMSCRIPTEN_FOUND)
set (DEFAULT_JAVASCRIPT ON)
endif (EMSCRIPTEN_FOUND)
+# C++ client: very experimental. To try, change this to "ON"
+# or provide -DBUILD_CPP=ON to CMake
+set (DEFAULT_CPP OFF)
+
+
# Shouldn't need to modify below here when adding new language binding
foreach(BINDING ${BINDINGS})
string(TOUPPER ${BINDING} UBINDING)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/CMakeLists.txt b/proton-c/bindings/cpp/CMakeLists.txt
new file mode 100644
index 0000000..7e456a5
--- /dev/null
+++ b/proton-c/bindings/cpp/CMakeLists.txt
@@ -0,0 +1,116 @@
+#
+# 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.
+#
+
+project (Proton C CXX)
+
+include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/src")
+include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/include")
+
+set (qpid-proton-cpp-platform
+ "src/platform"
+ )
+
+set (qpid-proton-cpp-core
+ src/Connection.cpp
+ src/ConnectionImpl.cpp
+ src/Connector.cpp
+ src/Connector.h
+ src/Container.cpp
+ src/ContainerImpl.cpp
+ src/Endpoint.cpp
+ src/Event.cpp
+ src/Handler.cpp
+ src/Link.cpp
+ src/Acceptor.cpp
+ src/Url.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/Transport.cpp
+ src/Logger.cpp
+ src/contexts.cpp
+ src/exceptions.cpp
+ )
+
+#set_source_files_properties (
+# ${qpid-proton-cpp-core}
+# PROPERTIES
+# COMPILE_FLAGS "${COMPILE_WARNING_FLAGS} ${COMPILE_LANGUAGE_FLAGS}"
+# )
+
+set_source_files_properties (${qpid-proton-cpp-platform} PROPERTIES LANGUAGE CXX)
+set_source_files_properties (
+ ${qpid-proton-cpp-platform}
+ PROPERTIES
+ COMPILE_FLAGS "${COMPILE_PLATFORM_FLAGS}"
+ COMPILE_DEFINITIONS "${PLATFORM_DEFINITIONS}"
+ )
+
+
+
+add_library (
+ qpid-proton-cpp SHARED
+
+ ${qpid-proton-cpp-core}
+ ${qpid-proton-cpp-platform}
+
+ )
+
+target_link_libraries (qpid-proton-cpp ${PLATFORM_LIBS} qpid-proton)
+
+set_target_properties (
+ qpid-proton-cpp
+ PROPERTIES
+ LINKER_LANGUAGE CXX
+ VERSION "${PN_LIB_SOMAJOR}.${PN_LIB_SOMINOR}"
+ SOVERSION "${PN_LIB_SOMAJOR}"
+ LINK_FLAGS "${CATCH_UNDEFINED}"
+ )
+
+add_executable (HelloWorld examples/HelloWorld.cpp)
+target_link_libraries (HelloWorld qpid-proton-cpp)
+add_executable (HelloWorldDirect examples/HelloWorldDirect.cpp)
+target_link_libraries (HelloWorldDirect qpid-proton-cpp)
+
+install (TARGETS qpid-proton-cpp
+ EXPORT proton
+ ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
+ LIBRARY DESTINATION ${LIB_INSTALL_DIR})
+
+# Install windows qpid-proton-cpp pdb files
+if (MSVC)
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Debug/qpid-proton${CMAKE_DEBUG_POSTFIX}.pdb
+ DESTINATION bin
+ CONFIGURATIONS Debug
+ OPTIONAL)
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo/qpid-proton.pdb
+ DESTINATION bin
+ CONFIGURATIONS RelWithDebInfo
+ OPTIONAL)
+endif (MSVC)
+
+# Install header files
+file(GLOB headers "include/proton/cpp/*.h")
+install (FILES ${headers} DESTINATION ${INCLUDE_INSTALL_DIR}/proton/cpp)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/examples/HelloWorld.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/examples/HelloWorld.cpp b/proton-c/bindings/cpp/examples/HelloWorld.cpp
new file mode 100644
index 0000000..1fc124b
--- /dev/null
+++ b/proton-c/bindings/cpp/examples/HelloWorld.cpp
@@ -0,0 +1,62 @@
+/*
+ *
+ * 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/cpp/Container.h"
+#include "proton/cpp/MessagingHandler.h"
+
+#include <iostream>
+
+
+using namespace proton::reactor;
+
+class HelloWorld : public MessagingHandler {
+ private:
+ std::string server;
+ std::string address;
+ public:
+
+ HelloWorld(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 onSendable(Event &e) {
+ Message m;
+ m.setBody("Hello World!");
+ e.getSender().send(m);
+ e.getSender().close();
+ }
+
+ void onMessage(Event &e) {
+ std::string body = e.getMessage().getBody();
+ std::cout << body << std::endl;
+ e.getConnection().close();
+ }
+
+};
+
+int main(int argc, char **argv) {
+ HelloWorld hw("localhost:5672", "examples");
+ Container(hw).run();
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/examples/HelloWorldDirect.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/examples/HelloWorldDirect.cpp b/proton-c/bindings/cpp/examples/HelloWorldDirect.cpp
new file mode 100644
index 0000000..a695dd0
--- /dev/null
+++ b/proton-c/bindings/cpp/examples/HelloWorldDirect.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/cpp/MessagingHandler.h"
+#include "proton/cpp/Container.h"
+
+//#include "proton/cpp/Acceptor.h"
+#include <iostream>
+
+
+using namespace proton::reactor;
+
+
+class HelloWorldDirect : public MessagingHandler {
+ private:
+ std::string url;
+ Acceptor acceptor;
+ public:
+
+ HelloWorldDirect(const std::string &u) : url(u) {}
+
+ void onStart(Event &e) {
+ acceptor = e.getContainer().listen(url);
+ e.getContainer().createSender(url);
+ }
+
+ void onSendable(Event &e) {
+ Message m;
+ m.setBody("Hello World!");
+ e.getSender().send(m);
+ e.getSender().close();
+ }
+
+ void onMessage(Event &e) {
+ std::string body = e.getMessage().getBody();
+ std::cout << body << std::endl;
+ }
+
+ void onAccepted(Event &e) {
+ e.getConnection().close();
+ }
+
+ void onConnectionClosed(Event &e) {
+ acceptor.close();
+ }
+
+};
+
+int main(int argc, char **argv) {
+ HelloWorldDirect hwd("localhost:8888/examples");
+ Container(hwd).run();
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/Acceptor.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Acceptor.h b/proton-c/bindings/cpp/include/proton/cpp/Acceptor.h
new file mode 100644
index 0000000..852ca97
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/Acceptor.h
@@ -0,0 +1,50 @@
+#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/cpp/ImportExport.h"
+#include "proton/cpp/ProtonHandle.h"
+#include "proton/reactor.h"
+
+struct pn_connection_t;
+
+namespace proton {
+namespace reactor {
+
+class Acceptor : public ProtonHandle<pn_acceptor_t>
+{
+ public:
+ PROTON_CPP_EXTERN Acceptor();
+ PROTON_CPP_EXTERN Acceptor(pn_acceptor_t *);
+ PROTON_CPP_EXTERN Acceptor(const Acceptor&);
+ PROTON_CPP_EXTERN Acceptor& operator=(const Acceptor&);
+ PROTON_CPP_EXTERN ~Acceptor();
+
+ PROTON_CPP_EXTERN void close();
+ private:
+ friend class ProtonImplRef<Acceptor>;
+};
+
+
+}} // namespace proton::reactor
+
+#endif /*!PROTON_CPP_ACCEPTOR_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/Connection.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Connection.h b/proton-c/bindings/cpp/include/proton/cpp/Connection.h
new file mode 100644
index 0000000..7d97ebb
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/Connection.h
@@ -0,0 +1,69 @@
+#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/cpp/ImportExport.h"
+#include "proton/cpp/Handle.h"
+#include "proton/cpp/Endpoint.h"
+#include "proton/cpp/Container.h"
+#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:
+ PROTON_CPP_EXTERN Connection();
+ PROTON_CPP_EXTERN Connection(ConnectionImpl *);
+ PROTON_CPP_EXTERN Connection(const Connection& c);
+ PROTON_CPP_EXTERN Connection& operator=(const Connection& c);
+ PROTON_CPP_EXTERN ~Connection();
+
+ PROTON_CPP_EXTERN Connection(Container &c);
+ PROTON_CPP_EXTERN Transport &getTransport();
+ PROTON_CPP_EXTERN Handler *getOverride();
+ PROTON_CPP_EXTERN void setOverride(Handler *h);
+ PROTON_CPP_EXTERN void open();
+ PROTON_CPP_EXTERN void close();
+ PROTON_CPP_EXTERN pn_connection_t *getPnConnection();
+ PROTON_CPP_EXTERN Container &getContainer();
+ PROTON_CPP_EXTERN std::string getHostname();
+ virtual PROTON_CPP_EXTERN Connection &getConnection();
+ private:
+ friend class PrivateImplRef<Connection>;
+ friend class Connector;
+ friend class ConnectionImpl;
+};
+
+
+}} // namespace proton::reactor
+
+#endif /*!PROTON_CPP_CONNECTION_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/Container.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Container.h b/proton-c/bindings/cpp/include/proton/cpp/Container.h
new file mode 100644
index 0000000..fbb1a83
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/Container.h
@@ -0,0 +1,67 @@
+#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/cpp/ImportExport.h"
+#include "proton/cpp/Handle.h"
+#include "proton/cpp/Acceptor.h"
+#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 Container : public Handle<ContainerImpl>
+{
+ public:
+ PROTON_CPP_EXTERN Container(ContainerImpl *);
+ PROTON_CPP_EXTERN Container(const Container& c);
+ PROTON_CPP_EXTERN Container& operator=(const Container& c);
+ PROTON_CPP_EXTERN ~Container();
+
+ PROTON_CPP_EXTERN Container(MessagingHandler &mhandler);
+ PROTON_CPP_EXTERN Connection connect(std::string &host);
+ PROTON_CPP_EXTERN void run();
+ PROTON_CPP_EXTERN pn_reactor_t *getReactor();
+ PROTON_CPP_EXTERN pn_handler_t *getGlobalHandler();
+ PROTON_CPP_EXTERN Sender createSender(Connection &connection, std::string &addr);
+ PROTON_CPP_EXTERN Sender createSender(std::string &url);
+ PROTON_CPP_EXTERN Receiver createReceiver(Connection &connection, std::string &addr);
+ PROTON_CPP_EXTERN Acceptor listen(const std::string &url);
+ PROTON_CPP_EXTERN std::string getContainerId();
+ private:
+ friend class PrivateImplRef<Container>;
+};
+
+}} // namespace proton::reactor
+
+#endif /*!PROTON_CPP_CONTAINER_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/Endpoint.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Endpoint.h b/proton-c/bindings/cpp/include/proton/cpp/Endpoint.h
new file mode 100644
index 0000000..9992eff
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/Endpoint.h
@@ -0,0 +1,47 @@
+#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/cpp/ImportExport.h"
+
+namespace proton {
+namespace reactor {
+
+class Handler;
+class Connection;
+class Transport;
+
+class Endpoint
+{
+ public:
+ // TODO: getCondition, getRemoteCondition, updateCondition, get/setHandler
+ virtual PROTON_CPP_EXTERN Connection &getConnection() = 0;
+ Transport PROTON_CPP_EXTERN &getTransport();
+ protected:
+ Endpoint();
+ ~Endpoint();
+};
+
+
+}} // namespace proton::reactor
+
+#endif /*!PROTON_CPP_ENDPOINT_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/Event.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Event.h b/proton-c/bindings/cpp/include/proton/cpp/Event.h
new file mode 100644
index 0000000..47aee2d
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/Event.h
@@ -0,0 +1,60 @@
+#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/cpp/ImportExport.h"
+#include "proton/cpp/Link.h"
+#include "proton/cpp/Connection.h"
+#include "proton/cpp/Message.h"
+#include <vector>
+
+
+namespace proton {
+namespace reactor {
+
+class Handler;
+class Container;
+class Connection;
+
+class Event
+{
+ public:
+ virtual PROTON_CPP_EXTERN void dispatch(Handler &h) = 0;
+ virtual PROTON_CPP_EXTERN Container &getContainer();
+ virtual PROTON_CPP_EXTERN Connection &getConnection();
+ virtual PROTON_CPP_EXTERN Sender getSender();
+ virtual PROTON_CPP_EXTERN Receiver getReceiver();
+ virtual PROTON_CPP_EXTERN Link getLink();
+ virtual PROTON_CPP_EXTERN Message getMessage();
+ virtual PROTON_CPP_EXTERN void setMessage(Message &);
+ virtual PROTON_CPP_EXTERN ~Event();
+ protected:
+ PROTON_CPP_EXTERN PROTON_CPP_EXTERN Event();
+ private:
+ PROTON_CPP_EXTERN Event(const Event&);
+ PROTON_CPP_EXTERN Event& operator=(const Event&);
+};
+
+
+}} // namespace proton::reactor
+
+#endif /*!PROTON_CPP_EVENT_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/Handle.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Handle.h b/proton-c/bindings/cpp/include/proton/cpp/Handle.h
new file mode 100644
index 0000000..632e30e
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/Handle.h
@@ -0,0 +1,72 @@
+#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/cpp/ImportExport.h"
+
+namespace proton {
+namespace reactor {
+
+template <class> class PrivateImplRef;
+
+/**
+ * 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. */
+ PROTON_CPP_INLINE_EXTERN bool isValid() const { return impl; }
+
+ /**@return true if handle is null. It is an error to call any function on a null handle. */
+ PROTON_CPP_INLINE_EXTERN bool isNull() const { return !impl; }
+
+ /** Conversion to bool supports idiom if (handle) { handle->... } */
+ PROTON_CPP_INLINE_EXTERN operator bool() const { return impl; }
+
+ /** Operator ! supports idiom if (!handle) { do_if_handle_is_null(); } */
+ PROTON_CPP_INLINE_EXTERN bool operator !() const { return !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;
+ PROTON_CPP_INLINE_EXTERN Handle() :impl() {}
+
+ Impl* impl;
+
+ friend class PrivateImplRef<T>;
+};
+
+}} // namespace proton::reactor
+
+#endif /*!PROTON_CPP_HANDLE_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/Handler.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Handler.h b/proton-c/bindings/cpp/include/proton/cpp/Handler.h
new file mode 100644
index 0000000..231942f
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/Handler.h
@@ -0,0 +1,50 @@
+#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/cpp/ImportExport.h"
+#include "proton/cpp/Event.h"
+#include "proton/event.h"
+#include <vector>
+
+namespace proton {
+namespace reactor {
+
+class PROTON_CPP_EXTERN Handler
+{
+ public:
+ PROTON_CPP_EXTERN Handler();
+ PROTON_CPP_EXTERN virtual ~Handler();
+
+ PROTON_CPP_EXTERN virtual void onUnhandled(Event &e);
+
+ PROTON_CPP_EXTERN virtual void addChildHandler(Handler &e);
+ PROTON_CPP_EXTERN std::vector<Handler *>::iterator childHandlersBegin();
+ PROTON_CPP_EXTERN std::vector<Handler *>::iterator childHandlersEnd();
+ protected:
+ std::vector<Handler *>childHandlers;
+};
+
+
+}} // namespace proton::reactor
+
+#endif /*!PROTON_CPP_HANDLER_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/ImportExport.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/ImportExport.h b/proton-c/bindings/cpp/include/proton/cpp/ImportExport.h
new file mode 100644
index 0000000..4a88576
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/ImportExport.h
@@ -0,0 +1,50 @@
+#ifndef PROTON_CPP_IMPORTEXPORT_H
+#define PROTON_CPP_IMPORTEXPORT_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.
+ *
+ */
+#if defined(WIN32) && !defined(PROTON_CPP_DECLARE_STATIC)
+ //
+ // Import and Export definitions for Windows:
+ //
+# define PROTON_CPP_EXPORT __declspec(dllexport)
+# define PROTON_CPP_IMPORT __declspec(dllimport)
+#else
+ //
+ // Non-Windows (Linux, etc.) definitions:
+ //
+# define PROTON_CPP_EXPORT
+# define PROTON_CPP_IMPORT
+#endif
+
+
+// For c++ library symbols
+
+#ifdef protoncpp_EXPORTS
+# define PROTON_CPP_EXTERN PROTON_CPP_EXPORT
+#else
+# define PROTON_CPP_EXTERN PROTON_CPP_IMPORT
+#endif
+
+// TODO:
+#define PROTON_CPP_INLINE_EXTERN
+
+#endif /*!PROTON_CPP_IMPORTEXPORT_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/Link.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Link.h b/proton-c/bindings/cpp/include/proton/cpp/Link.h
new file mode 100644
index 0000000..21b1ca2
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/Link.h
@@ -0,0 +1,63 @@
+#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/cpp/ImportExport.h"
+#include "proton/cpp/ProtonHandle.h"
+#include "proton/cpp/Endpoint.h"
+#include "proton/types.h"
+#include <string>
+
+struct pn_connection_t;
+
+namespace proton {
+namespace reactor {
+
+class Link : public Endpoint, public ProtonHandle<pn_link_t>
+{
+ public:
+ PROTON_CPP_EXTERN Link(pn_link_t *);
+ PROTON_CPP_EXTERN Link();
+ PROTON_CPP_EXTERN ~Link();
+ PROTON_CPP_EXTERN Link(const Link&);
+ PROTON_CPP_EXTERN Link& operator=(const Link&);
+ PROTON_CPP_EXTERN void open();
+ PROTON_CPP_EXTERN void close();
+ PROTON_CPP_EXTERN bool isSender();
+ PROTON_CPP_EXTERN bool isReceiver();
+ PROTON_CPP_EXTERN int getCredit();
+ PROTON_CPP_EXTERN pn_link_t *getPnLink() const;
+ virtual PROTON_CPP_EXTERN Connection &getConnection();
+ protected:
+ virtual void verifyType(pn_link_t *l);
+ private:
+ friend class ProtonImplRef<Link>;
+ bool senderLink;
+};
+
+
+}} // namespace proton::reactor
+
+#include "proton/cpp/Sender.h"
+#include "proton/cpp/Receiver.h"
+
+#endif /*!PROTON_CPP_LINK_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/Message.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Message.h b/proton-c/bindings/cpp/include/proton/cpp/Message.h
new file mode 100644
index 0000000..51ca731
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/Message.h
@@ -0,0 +1,53 @@
+#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/cpp/ImportExport.h"
+#include "proton/message.h"
+#include <string>
+
+
+namespace proton {
+namespace reactor {
+
+class Message
+{
+ public:
+ PROTON_CPP_EXTERN Message();
+ PROTON_CPP_EXTERN ~Message();
+ PROTON_CPP_EXTERN Message(const Message&);
+ PROTON_CPP_EXTERN Message& operator=(const Message&);
+
+ PROTON_CPP_EXTERN pn_message_t *getPnMessage();
+ PROTON_CPP_EXTERN void setBody(const std::string &data);
+ PROTON_CPP_EXTERN std::string getBody();
+ PROTON_CPP_EXTERN void encode(std::string &data);
+ PROTON_CPP_EXTERN void decode(const std::string &data);
+
+ private:
+ pn_message_t *pnMessage;
+};
+
+
+}} // namespace proton::reactor
+
+#endif /*!PROTON_CPP_MESSAGE_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/MessagingAdapter.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/MessagingAdapter.h b/proton-c/bindings/cpp/include/proton/cpp/MessagingAdapter.h
new file mode 100644
index 0000000..8551c9c
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/MessagingAdapter.h
@@ -0,0 +1,57 @@
+#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/cpp/ProtonHandler.h"
+#include "proton/cpp/MessagingHandler.h"
+
+#include "proton/cpp/MessagingEvent.h"
+#include "proton/event.h"
+#include "proton/reactor.h"
+
+namespace proton {
+namespace reactor {
+
+// For now, stands in for Python's: EndpointStateHandler, IncomingMessageHandler, OutgoingMessageHandler
+
+
+class MessagingAdapter : public ProtonHandler
+{
+ public:
+ PROTON_CPP_EXTERN MessagingAdapter(MessagingHandler &delegate);
+ PROTON_CPP_EXTERN virtual ~MessagingAdapter();
+ PROTON_CPP_EXTERN virtual void onReactorInit(Event &e);
+ PROTON_CPP_EXTERN virtual void onLinkFlow(Event &e);
+ PROTON_CPP_EXTERN virtual void onDelivery(Event &e);
+ PROTON_CPP_EXTERN virtual void onUnhandled(Event &e);
+ PROTON_CPP_EXTERN virtual void onConnectionRemoteClose(Event &e);
+ PROTON_CPP_EXTERN virtual void onLinkRemoteOpen(Event &e);
+ private:
+ MessagingHandler &delegate; // The actual MessagingHandler
+ pn_handler_t *handshaker;
+};
+
+
+}} // namespace proton::reactor
+
+#endif /*!PROTON_CPP_MESSAGING_ADAPTER_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/MessagingEvent.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/MessagingEvent.h b/proton-c/bindings/cpp/include/proton/cpp/MessagingEvent.h
new file mode 100644
index 0000000..d8d5c7f
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/MessagingEvent.h
@@ -0,0 +1,92 @@
+#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/cpp/ProtonEvent.h"
+#include "proton/cpp/Link.h"
+
+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_CLOSE,
+ PN_MESSAGING_CONNECTION_CLOSED,
+ PN_MESSAGING_CONNECTION_CLOSING,
+ PN_MESSAGING_CONNECTION_OPEN,
+ PN_MESSAGING_CONNECTION_OPENED,
+ PN_MESSAGING_DISCONNECTED,
+ PN_MESSAGING_FETCH,
+ PN_MESSAGING_ID_LOADED,
+ PN_MESSAGING_LINK_CLOSING,
+ PN_MESSAGING_LINK_OPENED,
+ PN_MESSAGING_LINK_OPENING,
+ 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_SETTLED,
+ PN_MESSAGING_START,
+ PN_MESSAGING_TIMER,
+ PN_MESSAGING_TRANSACTION_ABORTED,
+ PN_MESSAGING_TRANSACTION_COMMITTED,
+ PN_MESSAGING_TRANSACTION_DECLARED
+} 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, Container &c);
+ ~MessagingEvent();
+ virtual PROTON_CPP_EXTERN void dispatch(Handler &h);
+ virtual PROTON_CPP_EXTERN Connection &getConnection();
+ virtual PROTON_CPP_EXTERN Sender getSender();
+ virtual PROTON_CPP_EXTERN Receiver getReceiver();
+ virtual PROTON_CPP_EXTERN Link getLink();
+ virtual PROTON_CPP_EXTERN Message getMessage();
+ virtual PROTON_CPP_EXTERN void setMessage(Message &);
+ private:
+ MessagingEventType_t messagingType;
+ ProtonEvent *parentEvent;
+ Message *message;
+ MessagingEvent operator=(const MessagingEvent&);
+ MessagingEvent(const MessagingEvent&);
+};
+
+
+}} // namespace proton::reactor
+
+#endif /*!PROTON_CPP_MESSAGINGEVENT_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/MessagingHandler.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/MessagingHandler.h b/proton-c/bindings/cpp/include/proton/cpp/MessagingHandler.h
new file mode 100644
index 0000000..875af43
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/MessagingHandler.h
@@ -0,0 +1,73 @@
+#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/cpp/ProtonHandler.h"
+#include "proton/event.h"
+
+namespace proton {
+namespace reactor {
+
+class Event;
+
+class PROTON_CPP_EXTERN MessagingHandler : public ProtonHandler
+{
+ public:
+ PROTON_CPP_EXTERN MessagingHandler();
+ virtual ~MessagingHandler();
+
+ virtual void onAbort(Event &e);
+ virtual void onAccepted(Event &e);
+ virtual void onCommit(Event &e);
+ virtual void onConnectionClose(Event &e);
+ virtual void onConnectionClosed(Event &e);
+ virtual void onConnectionClosing(Event &e);
+ virtual void onConnectionOpen(Event &e);
+ virtual void onConnectionOpened(Event &e);
+ virtual void onDisconnected(Event &e);
+ virtual void onFetch(Event &e);
+ virtual void onIdLoaded(Event &e);
+ virtual void onLinkClosing(Event &e);
+ virtual void onLinkOpened(Event &e);
+ virtual void onLinkOpening(Event &e);
+ virtual void onMessage(Event &e);
+ virtual void onQuit(Event &e);
+ virtual void onRecordInserted(Event &e);
+ virtual void onRecordsLoaded(Event &e);
+ virtual void onRejected(Event &e);
+ virtual void onReleased(Event &e);
+ virtual void onRequest(Event &e);
+ virtual void onResponse(Event &e);
+ virtual void onSendable(Event &e);
+ virtual void onSettled(Event &e);
+ virtual void onStart(Event &e);
+ virtual void onTimer(Event &e);
+ virtual void onTransactionAborted(Event &e);
+ virtual void onTransactionCommitted(Event &e);
+ virtual void onTransactionDeclared(Event &e);
+};
+
+
+}} // namespace proton::reactor
+
+#endif /*!PROTON_CPP_MESSAGING_HANDLER_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/ProtonEvent.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/ProtonEvent.h b/proton-c/bindings/cpp/include/proton/cpp/ProtonEvent.h
new file mode 100644
index 0000000..9e5e9f3
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/ProtonEvent.h
@@ -0,0 +1,57 @@
+#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/cpp/Event.h"
+#include "proton/cpp/Link.h"
+
+namespace proton {
+namespace reactor {
+
+class Handler;
+class Container;
+class Connection;
+class Container;
+
+class ProtonEvent : public Event
+{
+ public:
+ virtual PROTON_CPP_EXTERN void dispatch(Handler &h);
+ virtual PROTON_CPP_EXTERN Container &getContainer();
+ virtual PROTON_CPP_EXTERN Connection &getConnection();
+ virtual PROTON_CPP_EXTERN Sender getSender();
+ virtual PROTON_CPP_EXTERN Receiver getReceiver();
+ virtual PROTON_CPP_EXTERN Link getLink();
+ PROTON_CPP_EXTERN int getType();
+ PROTON_CPP_EXTERN pn_event_t* getPnEvent();
+ protected:
+ PROTON_CPP_EXTERN ProtonEvent(pn_event_t *ce, pn_event_type_t t, Container &c);
+ private:
+ pn_event_t *pnEvent;
+ int type;
+ Container &container;
+};
+
+
+}} // namespace proton::reactor
+
+#endif /*!PROTON_CPP_PROTONEVENT_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/ProtonHandle.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/ProtonHandle.h b/proton-c/bindings/cpp/include/proton/cpp/ProtonHandle.h
new file mode 100644
index 0000000..8fe6f4c
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/ProtonHandle.h
@@ -0,0 +1,68 @@
+#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/cpp/ImportExport.h"
+
+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. */
+ PROTON_CPP_INLINE_EXTERN bool isValid() const { return impl; }
+
+ /**@return true if handle is null. It is an error to call any function on a null handle. */
+ PROTON_CPP_INLINE_EXTERN bool isNull() const { return !impl; }
+
+ /** Conversion to bool supports idiom if (handle) { handle->... } */
+ PROTON_CPP_INLINE_EXTERN operator bool() const { return impl; }
+
+ /** Operator ! supports idiom if (!handle) { do_if_handle_is_null(); } */
+ PROTON_CPP_INLINE_EXTERN 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;
+ PROTON_CPP_INLINE_EXTERN ProtonHandle() :impl() {}
+
+ Impl* impl;
+
+ friend class ProtonImplRef<T>;
+};
+
+}} // namespace proton::reactor
+
+#endif /*!PROTON_CPP_PROTONHANDLE_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/ProtonHandler.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/ProtonHandler.h b/proton-c/bindings/cpp/include/proton/cpp/ProtonHandler.h
new file mode 100644
index 0000000..b639cc3
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/ProtonHandler.h
@@ -0,0 +1,83 @@
+#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/cpp/Handler.h"
+
+namespace proton {
+namespace reactor {
+
+class Event;
+class ProtonEvent;
+
+class ProtonHandler : public Handler
+{
+ public:
+ PROTON_CPP_EXTERN ProtonHandler();
+ virtual void onReactorInit(Event &e);
+ virtual void onReactorQuiesced(Event &e);
+ virtual void onReactorFinal(Event &e);
+ virtual void onTimerTask(Event &e);
+ virtual void onConnectionInit(Event &e);
+ virtual void onConnectionBound(Event &e);
+ virtual void onConnectionUnbound(Event &e);
+ virtual void onConnectionLocalOpen(Event &e);
+ virtual void onConnectionLocalClose(Event &e);
+ virtual void onConnectionRemoteOpen(Event &e);
+ virtual void onConnectionRemoteClose(Event &e);
+ virtual void onConnectionFinal(Event &e);
+ virtual void onSessionInit(Event &e);
+ virtual void onSessionLocalOpen(Event &e);
+ virtual void onSessionLocalClose(Event &e);
+ virtual void onSessionRemoteOpen(Event &e);
+ virtual void onSessionRemoteClose(Event &e);
+ virtual void onSessionFinal(Event &e);
+ virtual void onLinkInit(Event &e);
+ virtual void onLinkLocalOpen(Event &e);
+ virtual void onLinkLocalClose(Event &e);
+ virtual void onLinkLocalDetach(Event &e);
+ virtual void onLinkRemoteOpen(Event &e);
+ virtual void onLinkRemoteClose(Event &e);
+ virtual void onLinkRemoteDetach(Event &e);
+ virtual void onLinkFlow(Event &e);
+ virtual void onLinkFinal(Event &e);
+ virtual void onDelivery(Event &e);
+ virtual void onTransport(Event &e);
+ virtual void onTransportError(Event &e);
+ virtual void onTransportHeadClosed(Event &e);
+ virtual void onTransportTailClosed(Event &e);
+ virtual void onTransportClosed(Event &e);
+ virtual void onSelectableInit(Event &e);
+ virtual void onSelectableUpdated(Event &e);
+ virtual void onSelectableReadable(Event &e);
+ virtual void onSelectableWritable(Event &e);
+ virtual void onSelectableExpired(Event &e);
+ virtual void onSelectableError(Event &e);
+ virtual void onSelectableFinal(Event &e);
+
+ virtual void onUnhandled(Event &e);
+};
+
+
+}} // namespace proton::reactor
+
+#endif /*!PROTON_CPP_PROTONHANDLER_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/Receiver.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Receiver.h b/proton-c/bindings/cpp/include/proton/cpp/Receiver.h
new file mode 100644
index 0000000..197cfb1
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/Receiver.h
@@ -0,0 +1,47 @@
+#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/cpp/ImportExport.h"
+#include "proton/cpp/Endpoint.h"
+#include "proton/cpp/Link.h"
+#include "proton/types.h"
+#include <string>
+
+struct pn_connection_t;
+
+namespace proton {
+namespace reactor {
+
+class Receiver : public Link
+{
+ public:
+ PROTON_CPP_EXTERN Receiver(pn_link_t *lnk);
+ PROTON_CPP_EXTERN Receiver();
+ protected:
+ virtual void verifyType(pn_link_t *l);
+};
+
+
+}} // namespace proton::reactor
+
+#endif /*!PROTON_CPP_RECEIVER_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/Sender.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Sender.h b/proton-c/bindings/cpp/include/proton/cpp/Sender.h
new file mode 100644
index 0000000..fa8cce8
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/Sender.h
@@ -0,0 +1,50 @@
+#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/cpp/ImportExport.h"
+#include "proton/cpp/Link.h"
+#include "proton/cpp/Message.h"
+
+#include "proton/types.h"
+#include <string>
+
+struct pn_connection_t;
+
+namespace proton {
+namespace reactor {
+
+
+class Sender : public Link
+{
+ public:
+ PROTON_CPP_EXTERN Sender(pn_link_t *lnk);
+ PROTON_CPP_EXTERN Sender();
+ PROTON_CPP_EXTERN void send(Message &m);
+ protected:
+ virtual void verifyType(pn_link_t *l);
+};
+
+
+}} // namespace proton::reactor
+
+#endif /*!PROTON_CPP_SENDER_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/Session.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Session.h b/proton-c/bindings/cpp/include/proton/cpp/Session.h
new file mode 100644
index 0000000..e556cde
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/Session.h
@@ -0,0 +1,59 @@
+#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/cpp/ImportExport.h"
+#include "proton/cpp/Endpoint.h"
+#include "proton/cpp/Link.h"
+
+#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:
+ PROTON_CPP_EXTERN Session(pn_session_t *s);
+ PROTON_CPP_EXTERN ~Session();
+ PROTON_CPP_EXTERN void open();
+ PROTON_CPP_EXTERN void close();
+ PROTON_CPP_EXTERN pn_session_t *getPnSession();
+ virtual PROTON_CPP_EXTERN Connection &getConnection();
+ Receiver createReceiver(std::string name);
+ Sender createSender(std::string name);
+ private:
+ pn_session_t *pnSession;
+};
+
+
+}} // namespace proton::reactor
+
+#endif /*!PROTON_CPP_SESSION_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/Transport.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Transport.h b/proton-c/bindings/cpp/include/proton/cpp/Transport.h
new file mode 100644
index 0000000..141e0a3
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/Transport.h
@@ -0,0 +1,48 @@
+#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/cpp/ImportExport.h"
+#include "proton/transport.h"
+#include <string>
+
+struct pn_connection_t;
+
+namespace proton {
+namespace reactor {
+
+class Connection;
+
+class Transport
+{
+ public:
+ PROTON_CPP_EXTERN Transport();
+ PROTON_CPP_EXTERN ~Transport();
+ PROTON_CPP_EXTERN void bind(Connection &c);
+ Connection *connection;
+ pn_transport_t *pnTransport;
+};
+
+
+}} // namespace proton::reactor
+
+#endif /*!PROTON_CPP_TRANSPORT_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/exceptions.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/exceptions.h b/proton-c/bindings/cpp/include/proton/cpp/exceptions.h
new file mode 100644
index 0000000..713c5c5
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/exceptions.h
@@ -0,0 +1,56 @@
+#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 "proton/cpp/ImportExport.h"
+#include <string>
+#include <exception>
+
+namespace proton {
+namespace reactor {
+
+class ProtonException : public std::exception
+{
+ public:
+ PROTON_CPP_EXTERN explicit ProtonException(const std::string& message=std::string()) throw();
+ PROTON_CPP_EXTERN virtual ~ProtonException() throw();
+ PROTON_CPP_EXTERN virtual const char* what() const throw();
+
+ private:
+ const std::string message;
+};
+
+class MessageReject : public ProtonException
+{
+ public:
+ PROTON_CPP_EXTERN explicit MessageReject(const std::string& message=std::string()) throw();
+};
+
+class MessageRelease : public ProtonException
+{
+ public:
+ PROTON_CPP_EXTERN explicit MessageRelease(const std::string& message=std::string()) throw();
+};
+
+}} // namespace proton::reactor
+
+#endif /*!PROTON_CPP_EXCEPTIONS_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/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..aa73ebf
--- /dev/null
+++ b/proton-c/bindings/cpp/src/Acceptor.cpp
@@ -0,0 +1,56 @@
+/*
+ *
+ * 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/cpp/Acceptor.h"
+#include "proton/cpp/exceptions.h"
+#include "ProtonImplRef.h"
+#include "Msg.h"
+
+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/ad7c9778/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..e85b323
--- /dev/null
+++ b/proton-c/bindings/cpp/src/Connection.cpp
@@ -0,0 +1,69 @@
+/*
+ *
+ * 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/cpp/Container.h"
+#include "proton/cpp/Connection.h"
+#include "proton/cpp/Handler.h"
+#include "proton/cpp/exceptions.h"
+#include "Msg.h"
+#include "contexts.h"
+#include "ConnectionImpl.h"
+#include "PrivateImplRef.h"
+
+#include "proton/connection.h"
+
+namespace proton {
+namespace reactor {
+
+template class Handle<ConnectionImpl>;
+typedef PrivateImplRef<Connection> PI;
+
+Connection::Connection() {}
+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) {
+ ConnectionImpl *cimpl = new ConnectionImpl(c);
+ 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(); }
+
+}} // namespace proton::reactor
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/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
new file mode 100644
index 0000000..2feecb5
--- /dev/null
+++ b/proton-c/bindings/cpp/src/ConnectionImpl.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/cpp/Container.h"
+#include "proton/cpp/Handler.h"
+#include "proton/cpp/exceptions.h"
+#include "ConnectionImpl.h"
+#include "Msg.h"
+#include "contexts.h"
+
+#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) : container(c), refCount(0), override(0), transport(0), defaultSession(0),
+ pnConnection(pn_reactor_connection(container.getReactor(), NULL)),
+ reactorReference(this)
+{
+ setConnectionContext(pnConnection, this);
+}
+
+ConnectionImpl::~ConnectionImpl() {}
+
+Transport &ConnectionImpl::getTransport() {
+ if (transport)
+ return *transport;
+ throw ProtonException(MSG("Connection has no transport"));
+}
+
+Handler* ConnectionImpl::getOverride() { return override; }
+void ConnectionImpl::setOverride(Handler *h) { 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 ProtonException(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 ProtonException(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 ProtonException(MSG("Invalid Proton connection specifier"));
+ Container container(getContainerContext(reactor));
+ if (!container) // can't be one created by our container
+ throw ProtonException(MSG("Unknown Proton connection specifier"));
+ Connection connection(container);
+ impl = connection.impl;
+ setConnectionContext(conn, impl);
+ impl->reactorReference = connection;
+ }
+ return impl->reactorReference;
+}
+
+}} // namespace proton::reactor
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/ConnectionImpl.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ConnectionImpl.h b/proton-c/bindings/cpp/src/ConnectionImpl.h
new file mode 100644
index 0000000..ad8d71e
--- /dev/null
+++ b/proton-c/bindings/cpp/src/ConnectionImpl.h
@@ -0,0 +1,73 @@
+#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/cpp/ImportExport.h"
+#include "proton/cpp/Endpoint.h"
+#include "proton/cpp/Container.h"
+#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:
+ PROTON_CPP_EXTERN ConnectionImpl(Container &c);
+ PROTON_CPP_EXTERN ~ConnectionImpl();
+ PROTON_CPP_EXTERN Transport &getTransport();
+ PROTON_CPP_EXTERN Handler *getOverride();
+ PROTON_CPP_EXTERN void setOverride(Handler *h);
+ PROTON_CPP_EXTERN void open();
+ PROTON_CPP_EXTERN void close();
+ PROTON_CPP_EXTERN pn_connection_t *getPnConnection();
+ PROTON_CPP_EXTERN Container &getContainer();
+ PROTON_CPP_EXTERN std::string getHostname();
+ virtual PROTON_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/ad7c9778/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..6885575
--- /dev/null
+++ b/proton-c/bindings/cpp/src/Connector.cpp
@@ -0,0 +1,77 @@
+/*
+ *
+ * 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/cpp/Connection.h"
+#include "proton/cpp/Transport.h"
+#include "proton/cpp/Container.h"
+#include "proton/cpp/Event.h"
+#include "proton/connection.h"
+#include "Connector.h"
+#include "ConnectionImpl.h"
+#include "Url.h"
+#include "LogInternal.h"
+
+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());
+ PN_CPP_LOG(info, "connecting to " << hostname << "...");
+ transport = new Transport();
+ transport->bind(connection);
+ connection.impl->transport = transport;
+}
+
+
+void Connector::onConnectionLocalOpen(Event &e) {
+ connect();
+}
+
+void Connector::onConnectionRemoteOpen(Event &e) {
+ PN_CPP_LOG(info, "connected to " << e.getConnection().getHostname());
+}
+
+void Connector::onConnectionInit(Event &e) {
+
+}
+
+void Connector::onTransportClosed(Event &e) {
+ // TODO: prepend with reconnect logic
+ PN_CPP_LOG(info, "Disconnected");
+ connection.setOverride(0); // No more call backs
+ pn_connection_release(connection.impl->pnConnection);
+ delete this;
+}
+
+
+}} // namespace proton::reactor
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/Connector.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Connector.h b/proton-c/bindings/cpp/src/Connector.h
new file mode 100644
index 0000000..d829699
--- /dev/null
+++ b/proton-c/bindings/cpp/src/Connector.h
@@ -0,0 +1,59 @@
+#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/cpp/ProtonHandler.h"
+#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/ad7c9778/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..8e79b15
--- /dev/null
+++ b/proton-c/bindings/cpp/src/Container.cpp
@@ -0,0 +1,86 @@
+/*
+ *
+ * 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/cpp/Container.h"
+#include "proton/cpp/MessagingEvent.h"
+#include "proton/cpp/Connection.h"
+#include "proton/cpp/Session.h"
+#include "proton/cpp/MessagingAdapter.h"
+#include "proton/cpp/Acceptor.h"
+#include "proton/cpp/exceptions.h"
+#include "ContainerImpl.h"
+#include "PrivateImplRef.h"
+#include "LogInternal.h"
+
+#include "Connector.h"
+#include "contexts.h"
+#include "Url.h"
+#include "platform.h"
+
+#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);
+}
+
+Connection Container::connect(std::string &host) { return impl->connect(host); }
+
+pn_reactor_t *Container::getReactor() { return impl->getReactor(); }
+
+pn_handler_t *Container::getGlobalHandler() { return impl->getGlobalHandler(); }
+
+std::string Container::getContainerId() { return impl->getContainerId(); }
+
+
+Sender Container::createSender(Connection &connection, std::string &addr) {
+ return impl->createSender(connection, addr);
+}
+
+Sender Container::createSender(std::string &urlString) {
+ return impl->createSender(urlString);
+}
+
+Receiver Container::createReceiver(Connection &connection, std::string &addr) {
+ return impl->createReceiver(connection, addr);
+}
+
+Acceptor Container::listen(const std::string &urlString) {
+ return impl->listen(urlString);
+}
+
+
+void Container::run() {
+ impl->run();
+}
+
+}} // namespace proton::reactor
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org