From 2ad1a5da3732b280d9b780313969bef4da05f113 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Fri, 21 Aug 2009 21:19:22 +0000 Subject: Implemented the new QMF ConnectionSettings and incorporated into the bindings. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@806725 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/bindings/qmf/qmfengine.i | 28 +++++++++++++--------------- cpp/bindings/qmf/ruby/Makefile.am | 2 +- cpp/bindings/qmf/ruby/qmf.rb | 32 +++++++++++++++++++++++++++++--- cpp/bindings/qmf/tests/agent_ruby.rb | 4 ++-- 4 files changed, 45 insertions(+), 21 deletions(-) (limited to 'cpp/bindings') diff --git a/cpp/bindings/qmf/qmfengine.i b/cpp/bindings/qmf/qmfengine.i index e1a4c53bec..8ae28730e5 100644 --- a/cpp/bindings/qmf/qmfengine.i +++ b/cpp/bindings/qmf/qmfengine.i @@ -19,24 +19,22 @@ %{ -#include "AgentEngine.h" -#include +#include "qmf/AgentEngine.h" +#include %} - -%include -%include -%include -%include -%include -%include -%include -%include -%include - -%include -%include +%include +%include +%include +%include +%include +%include +%include +%include +%include +%include +%include %inline { diff --git a/cpp/bindings/qmf/ruby/Makefile.am b/cpp/bindings/qmf/ruby/Makefile.am index 1dc08f646a..0537dd1cd8 100644 --- a/cpp/bindings/qmf/ruby/Makefile.am +++ b/cpp/bindings/qmf/ruby/Makefile.am @@ -19,7 +19,7 @@ if HAVE_RUBY_DEVEL -INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_srcdir)/src/qmf -I$(top_srcdir)/src -I$(top_builddir)/src +INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_srcdir)/src -I$(top_builddir)/src EXTRA_DIST = ruby.i BUILT_SOURCES = qmfengine.cpp diff --git a/cpp/bindings/qmf/ruby/qmf.rb b/cpp/bindings/qmf/ruby/qmf.rb index 35a76c490a..f3915e9c02 100644 --- a/cpp/bindings/qmf/ruby/qmf.rb +++ b/cpp/bindings/qmf/ruby/qmf.rb @@ -30,7 +30,33 @@ module Qmf end end - class ConnectionSettings < Qmfengine::ConnectionSettings + class ConnectionSettings + attr_reader :impl + + def initialize(url = nil) + if url + @impl = Qmfengine::ConnectionSettings.new(url) + else + @impl = Qmfengine::ConnectionSettings.new() + end + end + + def set_attr(key, val) + if val.class == String + v = Qmfengine::Value.new(TYPE_LSTR) + v.setString(val) + elsif val.class == TrueClass or val.class == FalseClass + v = Qmfengine::Value.new(TYPE_BOOL) + v.setBool(val) + elsif val.class == Fixnum + v = Qmfengine::Value.new(TYPE_UINT32) + v.setUint(val) + else + raise ArgumentError, "Value for attribute '#{key}' has unsupported type: #{val.class}" + end + + @impl.setAttr(key, v) + end end class ConnectionHandler @@ -66,8 +92,8 @@ module Qmf class Connection attr_reader :impl - def initialize(settings, delay_min = 1, delay_max = 128, delay_factor = 2) - @impl = Qmfengine::ResilientConnection.new(settings, delay_min, delay_max, delay_factor) + def initialize(settings) + @impl = Qmfengine::ResilientConnection.new(settings.impl) @sockEngine, @sock = Socket::socketpair(Socket::PF_UNIX, Socket::SOCK_STREAM, 0) @impl.setNotifyFd(@sockEngine.fileno) @new_conn_handlers = Array.new diff --git a/cpp/bindings/qmf/tests/agent_ruby.rb b/cpp/bindings/qmf/tests/agent_ruby.rb index d395810cb6..3f04b0ce2e 100755 --- a/cpp/bindings/qmf/tests/agent_ruby.rb +++ b/cpp/bindings/qmf/tests/agent_ruby.rb @@ -71,8 +71,8 @@ class App < Qmf::AgentHandler def main @settings = Qmf::ConnectionSettings.new - @settings.host = ARGV[0] if ARGV.size > 0 - @settings.port = ARGV[1].to_i if ARGV.size > 1 + @settings.set_attr("host", ARGV[0]) if ARGV.size > 0 + @settings.set_attr("port", ARGV[1].to_i) if ARGV.size > 1 @connection = Qmf::Connection.new(@settings) @agent = Qmf::Agent.new(self) -- cgit v1.2.1