Author: aconway
Date: Mon Aug 27 06:50:17 2007
New Revision: 570121
URL: http://svn.apache.org/viewvc?rev=570121&view=rev
Log:
* src/qpid/framing/FrameDefaultVisitor.h:
Visitor for all concrete frame body types.
Override to handle specific bodies (methods or header/content)
and provide default handling for others.
* rubygen/MethodBodyDefaultVisitor.rb:
Visitor for MethodBodies with visit functions that call
virtual defaultVisit(). Override to handle specific methods
and give default behavior for others.
Added:
incubator/qpid/trunk/qpid/cpp/rubygen/MethodBodyDefaultVisitor.rb (with
props)
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/FrameDefaultVisitor.h
(with props)
Added: incubator/qpid/trunk/qpid/cpp/rubygen/MethodBodyDefaultVisitor.rb
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/rubygen/MethodBodyDefaultVisitor.rb?rev=570121&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/rubygen/MethodBodyDefaultVisitor.rb (added)
+++ incubator/qpid/trunk/qpid/cpp/rubygen/MethodBodyDefaultVisitor.rb Mon Aug
27 06:50:17 2007
@@ -0,0 +1,34 @@
+#!/usr/bin/env ruby
+$: << ".." # Include .. in load path
+require 'cppgen'
+
+class MethodBodyDefaultVisitorGen < CppGen
+
+ def initialize(outdir, amqp)
+ super(outdir, amqp)
+ set_classname("qpid::framing::MethodBodyDefaultVisitor")
+ end
+
+ def generate()
+ h_file(@filename) {
+ include "qpid/framing/MethodBodyConstVisitor"
+ namespace(@namespace) {
+ genl
+ cpp_class(@classname, "public MethodBodyConstVisitor") {
+ genl "public:"
+ genl "virtual void defaultVisit() = 0;"
+ @amqp.methods_.each { |m|
+ genl "virtual void visit(const #{m.body_name}&);" }
+ }}}
+
+ cpp_file(@filename) {
+ include(@filename)
+ namespace(@namespace) {
+ @amqp.methods_.each { |m|
+ genl "void [EMAIL PROTECTED]::visit(const #{m.body_name}&) {
defaultVisit(); }"
+ }}}
+ end
+end
+
+MethodBodyDefaultVisitorGen.new(Outdir, Amqp).generate();
+
Propchange: incubator/qpid/trunk/qpid/cpp/rubygen/MethodBodyDefaultVisitor.rb
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/qpid/trunk/qpid/cpp/rubygen/MethodBodyDefaultVisitor.rb
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/FrameDefaultVisitor.h
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/FrameDefaultVisitor.h?rev=570121&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/FrameDefaultVisitor.h (added)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/FrameDefaultVisitor.h Mon
Aug 27 06:50:17 2007
@@ -0,0 +1,56 @@
+#ifndef QPID_FRAMING_FRAMEVISITOR_H
+#define QPID_FRAMING_FRAMEVISITOR_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 "qpid/framing/MethodBodyDefaultVisitor.h"
+#include "qpid/framing/AMQBody.h"
+
+namespace qpid {
+namespace framing {
+
+class AMQMethodBody;
+class AMQHeaderBody;
+class AMQContentBody;
+class AMQHeartbeatBody;
+
+/**
+ * Functor to handle a frame by visiting its content.
+ * Combines AMQBodyConstVisitor and MethodBodyDefaultVisitor.
+ *
+ * Derived classes may override visit methods to specify actions.
+ * Derived classes must override defaultVisit(), which is called
+ * for any non-overridden visit functions.
+ *
+ */
+struct FrameDefaultVisitor : public AMQBodyConstVisitor, public
MethodBodyDefaultVisitor
+{
+ void visit(const AMQHeaderBody& x) { defaultVisit(); }
+ void visit(const AMQContentBody& x) { defaultVisit(); }
+ void visit(const AMQHeartbeatBody& x) { defaultVisit(); }
+ void visit(const AMQMethodBody& method) { method.accept(*this); }
+};
+
+
+
+
+
+#endif /*!QPID_FRAMING_FRAMEVISITOR_H*/
Propchange: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/FrameDefaultVisitor.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/FrameDefaultVisitor.h
------------------------------------------------------------------------------
svn:keywords = Rev Date