summaryrefslogtreecommitdiff
path: root/cpp/bindings/qmf2
diff options
context:
space:
mode:
authorStephen D. Huston <shuston@apache.org>2011-10-20 18:42:46 +0000
committerStephen D. Huston <shuston@apache.org>2011-10-20 18:42:46 +0000
commit5eb354b338bb8d8fcd35b6ac3fb33f8103e757c3 (patch)
treef24776684c025fbed6a0431bf3d6811f0a1aae7a /cpp/bindings/qmf2
parent718ff5b34dd1e87eb79fa4c61fec668d1dc33103 (diff)
downloadqpid-python-5eb354b338bb8d8fcd35b6ac3fb33f8103e757c3.tar.gz
Merge trunk to QPID-2519 branch
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/QPID-2519@1186990 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/bindings/qmf2')
-rw-r--r--cpp/bindings/qmf2/examples/cpp/Makefile.am5
-rw-r--r--cpp/bindings/qmf2/examples/cpp/event_driven_list_agents.cpp107
-rw-r--r--cpp/bindings/qmf2/python/Makefile.am4
-rw-r--r--cpp/bindings/qmf2/qmf2.i1
-rw-r--r--cpp/bindings/qmf2/ruby/Makefile.am4
5 files changed, 116 insertions, 5 deletions
diff --git a/cpp/bindings/qmf2/examples/cpp/Makefile.am b/cpp/bindings/qmf2/examples/cpp/Makefile.am
index 84207d43c4..062fbd0a85 100644
--- a/cpp/bindings/qmf2/examples/cpp/Makefile.am
+++ b/cpp/bindings/qmf2/examples/cpp/Makefile.am
@@ -21,7 +21,7 @@ INCLUDE = -I$(top_srcdir)/include
AM_CPPFLAGS = $(INCLUDE)
-noinst_PROGRAMS=agent list_agents print_events
+noinst_PROGRAMS=agent event_driven_list_agents list_agents print_events
agent_SOURCES=agent.cpp
agent_LDADD=$(top_builddir)/src/libqmf2.la
@@ -29,5 +29,8 @@ agent_LDADD=$(top_builddir)/src/libqmf2.la
list_agents_SOURCES=list_agents.cpp
list_agents_LDADD=$(top_builddir)/src/libqmf2.la
+event_driven_list_agents_SOURCES=event_driven_list_agents.cpp
+event_driven_list_agents_LDADD=$(top_builddir)/src/libqmf2.la
+
print_events_SOURCES=print_events.cpp
print_events_LDADD=$(top_builddir)/src/libqmf2.la
diff --git a/cpp/bindings/qmf2/examples/cpp/event_driven_list_agents.cpp b/cpp/bindings/qmf2/examples/cpp/event_driven_list_agents.cpp
new file mode 100644
index 0000000000..c288aa6bdd
--- /dev/null
+++ b/cpp/bindings/qmf2/examples/cpp/event_driven_list_agents.cpp
@@ -0,0 +1,107 @@
+/*
+ * 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 <sys/select.h>
+#include <time.h>
+
+#include <qpid/messaging/Connection.h>
+#include <qpid/messaging/Duration.h>
+#include <qmf/Agent.h>
+#include <qmf/ConsoleEvent.h>
+#include <qmf/ConsoleSession.h>
+#include <qpid/types/Variant.h>
+#include "qmf/posix/EventNotifier.h"
+
+#include <string>
+#include <iostream>
+
+using namespace std;
+using namespace qmf;
+using qpid::types::Variant;
+using qpid::messaging::Duration;
+
+int main(int argc, char** argv)
+{
+ string url("localhost");
+ string connectionOptions;
+ string sessionOptions;
+
+ if (argc > 1)
+ url = argv[1];
+ if (argc > 2)
+ connectionOptions = argv[2];
+ if (argc > 3)
+ sessionOptions = argv[3];
+
+ qpid::messaging::Connection connection(url, connectionOptions);
+ connection.open();
+
+ ConsoleSession session(connection, sessionOptions);
+ session.open();
+ session.setAgentFilter("");
+
+ posix::EventNotifier notifier(session);
+
+ int fd(notifier.getHandle());
+ time_t lastUpdate;
+ bool ftl = false;
+
+ time(&lastUpdate);
+
+ while (true) {
+ fd_set rfds;
+ struct timeval tv;
+ int nfds, retval;
+
+ FD_ZERO(&rfds);
+ FD_SET(fd, &rfds);
+ nfds = fd + 1;
+ tv.tv_sec = 10;
+ tv.tv_usec = 0;
+
+ retval = select(nfds, &rfds, NULL, NULL, &tv);
+
+ if (retval > 0 && FD_ISSET(fd, &rfds)) {
+ ConsoleEvent event;
+ while (session.nextEvent(event, Duration::IMMEDIATE)) {
+ string eventType = "";
+ switch(event.getType()) {
+ case CONSOLE_AGENT_ADD: eventType = "Added"; break;
+ case CONSOLE_AGENT_DEL: eventType = "Deleted"; break;
+ case CONSOLE_AGENT_RESTART: eventType = "Restarted"; break;
+ case CONSOLE_AGENT_SCHEMA_UPDATE: eventType = "Schema Updated"; break;
+ case CONSOLE_AGENT_SCHEMA_RESPONSE: eventType = "Schema Response"; break;
+ case CONSOLE_EVENT: eventType = "Event"; break;
+ case CONSOLE_QUERY_RESPONSE: eventType = "Query Response"; break;
+ case CONSOLE_METHOD_RESPONSE: eventType = "Method Response"; break;
+ case CONSOLE_EXCEPTION: eventType = "Exception"; break;
+ case CONSOLE_SUBSCRIBE_ADD: eventType = "Subscription Added"; break;
+ case CONSOLE_SUBSCRIBE_UPDATE: eventType = "Subscription Updated"; break;
+ case CONSOLE_SUBSCRIBE_DEL: eventType = "Subscription Deleted" ; break;
+ case CONSOLE_THREAD_FAILED: eventType = "Thread Failure"; break;
+ default: eventType = "[UNDEFINED]";
+ }
+ cout << "Agent " << eventType << ": " << event.getAgent().getName() << endl;
+ }
+ } else {
+ cout << "No message received within waiting period." << endl;
+ }
+ }
+}
+
diff --git a/cpp/bindings/qmf2/python/Makefile.am b/cpp/bindings/qmf2/python/Makefile.am
index 7adc62eddb..3dc04e832f 100644
--- a/cpp/bindings/qmf2/python/Makefile.am
+++ b/cpp/bindings/qmf2/python/Makefile.am
@@ -30,12 +30,12 @@ BUILT_SOURCES = $(generated_file_list)
SWIG_FLAGS = -w362,401
$(generated_file_list): $(srcdir)/python.i $(srcdir)/../qmf2.i $(srcdir)/../../swig_python_typemaps.i
- swig -c++ -python $(SWIG_FLAGS) $(INCLUDES) $(QPID_CXXFLAGS) -I/usr/include -o cqmf2.cpp $(srcdir)/python.i
+ $(SWIG) -c++ -python $(SWIG_FLAGS) $(INCLUDES) $(QPID_CXXFLAGS) -I/usr/include -o cqmf2.cpp $(srcdir)/python.i
pylibdir = $(PYTHON_LIB)
lib_LTLIBRARIES = _cqmf2.la
-cqpiddir = $(pythondir)
+cqpiddir = $(pyexecdir)
cqpid_PYTHON = qmf2.py cqmf2.py
_cqmf2_la_LDFLAGS = -avoid-version -module -shared
diff --git a/cpp/bindings/qmf2/qmf2.i b/cpp/bindings/qmf2/qmf2.i
index a09a95168f..0f573fe3e6 100644
--- a/cpp/bindings/qmf2/qmf2.i
+++ b/cpp/bindings/qmf2/qmf2.i
@@ -37,6 +37,7 @@
%}
+%include <qpid/ImportExport.h>
%include <qpid/messaging/ImportExport.h>
%include <qpid/messaging/Duration.h>
diff --git a/cpp/bindings/qmf2/ruby/Makefile.am b/cpp/bindings/qmf2/ruby/Makefile.am
index ae840f87c6..97bbc6f385 100644
--- a/cpp/bindings/qmf2/ruby/Makefile.am
+++ b/cpp/bindings/qmf2/ruby/Makefile.am
@@ -34,9 +34,9 @@ rubylibarchdir = $(RUBY_LIB_ARCH)
rubylibarch_LTLIBRARIES = cqmf2.la
dist_rubylib_DATA = qmf2.rb
-cqmf2_la_LDFLAGS = -avoid-version -module -shrext ".$(RUBY_DLEXT)"
+cqmf2_la_LDFLAGS = -avoid-version -module -shared -shrext ".$(RUBY_DLEXT)"
cqmf2_la_LIBADD = $(RUBY_LIBS) -L$(top_builddir)/src/.libs -lqmf2 $(top_builddir)/src/libqmf2.la
-cqmf2_la_CXXFLAGS = $(INCLUDES) -I$(RUBY_INC) -I$(RUBY_INC_ARCH)
+cqmf2_la_CXXFLAGS = $(INCLUDES) -I$(RUBY_INC) -I$(RUBY_INC_ARCH) -fno-strict-aliasing
nodist_cqmf2_la_SOURCES = cqmf2.cpp
CLEANFILES = cqmf2.cpp