diff options
| author | Ted Ross <tross@apache.org> | 2009-09-25 20:24:22 +0000 |
|---|---|---|
| committer | Ted Ross <tross@apache.org> | 2009-09-25 20:24:22 +0000 |
| commit | 97abe1cb80434eec7308a2f611cc884dd3a10d1f (patch) | |
| tree | b49a46247e68f00c12c797f5fbc41f024f784a3f /cpp/bindings/qmf/ruby | |
| parent | 6214f62e118a83b4cc593298ceb0658e28662845 (diff) | |
| download | qpid-python-97abe1cb80434eec7308a2f611cc884dd3a10d1f.tar.gz | |
QMF updates:
- Refactored into two namespaces:
1) 'qmf' for the public QMF api (c++)
2) 'qmf::engine' for the public engine API (used for language bindings)
- Added object and first_object calls to Console (in Ruby)
- Made objects call compatible with the kwarg arguments used in the older API
- Added to_s functions to classes that needed them
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@818994 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/bindings/qmf/ruby')
| -rw-r--r-- | cpp/bindings/qmf/ruby/Makefile.am | 7 | ||||
| -rw-r--r-- | cpp/bindings/qmf/ruby/qmf.rb | 42 |
2 files changed, 43 insertions, 6 deletions
diff --git a/cpp/bindings/qmf/ruby/Makefile.am b/cpp/bindings/qmf/ruby/Makefile.am index 0537dd1cd8..34096da9ee 100644 --- a/cpp/bindings/qmf/ruby/Makefile.am +++ b/cpp/bindings/qmf/ruby/Makefile.am @@ -23,23 +23,22 @@ INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_srcdir)/src EXTRA_DIST = ruby.i BUILT_SOURCES = qmfengine.cpp -generated_file_list = qmfengine.cpp rubylibdir = $(RUBY_LIB) dist_rubylib_DATA = qmf.rb -$(generated_file_list): $(srcdir)/ruby.i $(srcdir)/../qmfengine.i +qmfengine.cpp: $(srcdir)/ruby.i $(srcdir)/../qmfengine.i $(SWIG) -ruby -c++ -Wall -I/usr/include $(INCLUDES) $(QPID_CXXFLAGS) -o qmfengine.cpp $(srcdir)/ruby.i rubylibarchdir = $(RUBY_LIB_ARCH) rubylibarch_LTLIBRARIES = qmfengine.la qmfengine_la_LDFLAGS = -avoid-version -module -shrext ".$(RUBY_DLEXT)" -qmfengine_la_LIBADD = $(RUBY_LIBS) -L$(top_builddir)/src/.libs -lqpidclient $(top_builddir)/src/libqmfagent.la +qmfengine_la_LIBADD = $(RUBY_LIBS) -L$(top_builddir)/src/.libs -lqpidclient $(top_builddir)/src/libqmfengine.la qmfengine_la_CXXFLAGS = $(INCLUDES) -I$(RUBY_INC) -I$(RUBY_INC_ARCH) nodist_qmfengine_la_SOURCES = qmfengine.cpp -CLEANFILES = $(generated_file_list) +CLEANFILES = qmfengine.cpp endif # HAVE_RUBY_DEVEL diff --git a/cpp/bindings/qmf/ruby/qmf.rb b/cpp/bindings/qmf/ruby/qmf.rb index 265d2ce192..c469376ff4 100644 --- a/cpp/bindings/qmf/ruby/qmf.rb +++ b/cpp/bindings/qmf/ruby/qmf.rb @@ -570,6 +570,10 @@ module Qmf def args Arguments.new(@impl.getArgs) end + + def method_missing(name, *extra_args) + args.__send__(name, extra_args) + end end ##============================================================================== @@ -643,6 +647,10 @@ module Qmf def typecode @impl.getType end + + def to_s + name + end end class SchemaMethod @@ -669,6 +677,10 @@ module Qmf def name @impl.getName end + + def to_s + name + end end class SchemaProperty @@ -689,6 +701,10 @@ module Qmf def name @impl.getName end + + def to_s + name + end end class SchemaStatistic @@ -706,6 +722,10 @@ module Qmf def name @impl.getName end + + def to_s + name + end end class SchemaClassKey @@ -816,7 +836,7 @@ module Qmf def initialize(handler = nil, kwargs={}) super() @handler = handler - @impl = Qmfengine::ConsoleEngine.new + @impl = Qmfengine::Console.new @event = Qmfengine::ConsoleEvent.new @broker_list = [] @cv = new_cond @@ -902,9 +922,15 @@ module Qmf def objects(query, kwargs = {}) timeout = 30 + kwargs.merge!(query) if query.class == Hash + if kwargs.include?(:timeout) timeout = kwargs[:timeout] + kwargs.delete(:timeout) end + + query = Query.new(kwargs) if query.class == Hash + synchronize do @sync_count = 1 @sync_result = [] @@ -918,6 +944,18 @@ module Qmf end end + # Return one and only one object or nil. + def object(query, kwargs = {}) + objs = objects(query, kwargs) + return objs.length == 1 ? objs[0] : nil + end + + # Return the first of potentially many objects. + def first_object(query, kwargs = {}) + objs = objects(query, kwargs) + return objs.length > 0 ? objs[0] : nil + end + def _get_result(list, context) synchronize do list.each do |item| @@ -1120,7 +1158,7 @@ module Qmf end @conn = nil @handler = handler - @impl = Qmfengine::AgentEngine.new(@agentLabel) + @impl = Qmfengine::Agent.new(@agentLabel) @event = Qmfengine::AgentEvent.new @xmtMessage = Qmfengine::Message.new end |
