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 2007/08/16 22:12:37 UTC

svn commit: r566822 [2/3] - in /incubator/qpid/trunk/qpid/cpp: gentools/src/org/apache/qpid/gentools/ gentools/templ.cpp/ rubygen/ rubygen/templates/ src/ src/qpid/ src/qpid/broker/ src/qpid/client/ src/qpid/cluster/ src/qpid/framing/ src/qpid/sys/posi...

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionHandler.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionHandler.h?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionHandler.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionHandler.h Thu Aug 16 13:12:33 2007
@@ -25,6 +25,8 @@
 #include "StateManager.h"
 #include "ChainableFrameHandler.h"
 #include "qpid/framing/InputHandler.h"
+#include "qpid/framing/FieldTable.h"
+#include "qpid/framing/AMQMethodBody.h"
 
 namespace qpid {
 namespace client {
@@ -53,10 +55,10 @@
     enum STATES {NOT_STARTED, NEGOTIATING, OPENING, OPEN, CLOSING, CLOSED, FAILED};
     std::set<int> ESTABLISHED;
     
-    void handle(framing::AMQMethodBody::shared_ptr method);
-    void send(framing::AMQBody::shared_ptr body);
+    void handle(framing::AMQMethodBody* method);
+    void send(const framing::AMQBody& body);
     void error(uint16_t code, const std::string& message, uint16_t classId = 0, uint16_t methodId = 0);
-    void error(uint16_t code, const std::string& message, framing::AMQBody::shared_ptr body);
+    void error(uint16_t code, const std::string& message, framing::AMQBody* body);
     void fail(const std::string& message);
 
 public:

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/client/Correlator.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/client/Correlator.cpp?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/client/Correlator.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/client/Correlator.cpp Thu Aug 16 13:12:33 2007
@@ -25,7 +25,7 @@
 using namespace qpid::framing;
 using namespace boost;
 
-void Correlator::receive(AMQMethodBody::shared_ptr response)
+void Correlator::receive(AMQMethodBody* response)
 {
     if (listeners.empty()) {
         throw ConnectionException(503, "Unexpected method!");//TODO: include the method & class name

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/client/Correlator.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/client/Correlator.h?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/client/Correlator.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/client/Correlator.h Thu Aug 16 13:12:33 2007
@@ -36,9 +36,9 @@
 class Correlator
 {
 public:
-    typedef boost::function<void(framing::AMQMethodBody::shared_ptr)> Listener;
+    typedef boost::function<void(framing::AMQMethodBody*)> Listener;
 
-    void receive(framing::AMQMethodBody::shared_ptr);
+    void receive(framing::AMQMethodBody*);
     void listen(Listener l);
 
 private:

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/client/ExecutionHandler.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/client/ExecutionHandler.cpp?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/client/ExecutionHandler.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/client/ExecutionHandler.cpp Thu Aug 16 13:12:33 2007
@@ -23,31 +23,35 @@
 #include "qpid/Exception.h"
 #include "qpid/framing/BasicDeliverBody.h"
 #include "qpid/framing/MessageTransferBody.h"
+#include "qpid/framing/AMQP_HighestVersion.h"
+#include "qpid/framing/all_method_bodies.h"
 
 using namespace qpid::client;
 using namespace qpid::framing;
 using namespace boost;
 
-bool isMessageMethod(AMQMethodBody::shared_ptr method)
+bool isMessageMethod(AMQMethodBody* method)
 {
     return method->isA<BasicDeliverBody>() || method->isA<MessageTransferBody>() || method->isA<BasicGetOkBody>();
 }
 
-bool isMessageMethod(AMQBody::shared_ptr body)
+bool isMessageMethod(AMQBody* body)
 {
-    return body->type() == METHOD_BODY && isMessageMethod(shared_polymorphic_cast<AMQMethodBody>(body));
+    AMQMethodBody* method=body->getMethod();
+    return method && isMessageMethod(method);
 }
 
 bool isContentFrame(AMQFrame& frame)
 {
-    AMQBody::shared_ptr body = frame.getBody();
+    AMQBody* body = frame.getBody();
     uint8_t type = body->type();
     return type == HEADER_BODY || type == CONTENT_BODY || isMessageMethod(body); 
 }
 
-bool invoke(AMQBody::shared_ptr body, Invocable* target)
+bool invoke(AMQBody* body, Invocable* target)
 {
-    return body->type() == METHOD_BODY && shared_polymorphic_cast<AMQMethodBody>(body)->invoke(target);
+    AMQMethodBody* method=body->getMethod();
+    return method && method->invoke(target);
 }
 
 ExecutionHandler::ExecutionHandler(uint64_t _maxFrameSize) : 
@@ -56,7 +60,7 @@
 //incoming:
 void ExecutionHandler::handle(AMQFrame& frame)
 {
-    AMQBody::shared_ptr body = frame.getBody();
+    AMQBody* body = frame.getBody();
     if (!invoke(body, this)) {
         if (isContentFrame(frame)) {
             if (!arriving) {
@@ -69,7 +73,7 @@
             }
         } else {
             ++incoming.hwm;    
-            correlation.receive(shared_polymorphic_cast<AMQMethodBody>(body));
+            correlation.receive(body->getMethod());
         }        
     }
 }
@@ -95,16 +99,15 @@
 {
     //send completion
     incoming.lwm = incoming.hwm;
-    //make_shared_ptr(new ExecutionCompleteBody(getVersion(), incoming.hwm.getValue(), SequenceNumberSet())));
 }
 
 void ExecutionHandler::sendFlush()
 {
-    AMQFrame frame(version, 0, make_shared_ptr(new ExecutionFlushBody(version)));
+    AMQFrame frame(version, 0, ExecutionFlushBody());
     out(frame);        
 }
 
-void ExecutionHandler::send(AMQBody::shared_ptr command, CompletionTracker::Listener f, Correlator::Listener g)
+void ExecutionHandler::send(const AMQBody& command, CompletionTracker::Listener f, Correlator::Listener g)
 {
     //allocate id:
     ++outgoing.hwm;
@@ -116,18 +119,19 @@
         correlation.listen(g);
     }
 
-    AMQFrame frame(version, 0/*id will be filled in be channel handler*/, command);
+    AMQFrame frame(version, 0/*id will be filled in be channel handler*/,
+                   command);
     out(frame);
 }
 
-void ExecutionHandler::sendContent(AMQBody::shared_ptr command, const BasicHeaderProperties& headers, const std::string& data, 
+void ExecutionHandler::sendContent(const AMQBody& command, const BasicHeaderProperties& headers, const std::string& data, 
                                    CompletionTracker::Listener f, Correlator::Listener g)
 {
     send(command, f, g);
 
-    AMQHeaderBody::shared_ptr header(new AMQHeaderBody(BASIC));
-    BasicHeaderProperties::copy(*static_cast<BasicHeaderProperties*>(header->getProperties()), headers);
-    header->setContentSize(data.size());
+    AMQHeaderBody header(BASIC);
+    BasicHeaderProperties::copy(*static_cast<BasicHeaderProperties*>(header.getProperties()), headers);
+    header.setContentSize(data.size());
     AMQFrame h(version, 0, header);
     out(h);
 
@@ -136,7 +140,7 @@
         //frame itself uses 8 bytes
         u_int32_t frag_size = maxFrameSize - 8;
         if(data_length < frag_size){
-            AMQFrame frame(version, 0, make_shared_ptr(new AMQContentBody(data)));
+            AMQFrame frame(version, 0, AMQContentBody(data));
             out(frame);
         }else{
             u_int32_t offset = 0;
@@ -144,7 +148,7 @@
             while (remaining > 0) {
                 u_int32_t length = remaining > frag_size ? frag_size : remaining;
                 string frag(data.substr(offset, length));
-                AMQFrame frame(version, 0, make_shared_ptr(new AMQContentBody(frag)));
+                AMQFrame frame(version, 0, AMQContentBody(frag));
                 out(frame);
                 offset += length;
                 remaining = data_length - offset;

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/client/ExecutionHandler.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/client/ExecutionHandler.h?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/client/ExecutionHandler.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/client/ExecutionHandler.h Thu Aug 16 13:12:33 2007
@@ -56,10 +56,10 @@
     void setMaxFrameSize(uint64_t size) { maxFrameSize = size; }
 
     void handle(framing::AMQFrame& frame);
-    void send(framing::AMQBody::shared_ptr command, 
+    void send(const framing::AMQBody& command, 
               CompletionTracker::Listener f = CompletionTracker::Listener(), 
               Correlator::Listener g = Correlator::Listener());
-    void sendContent(framing::AMQBody::shared_ptr command, 
+    void sendContent(const framing::AMQBody& command, 
                      const framing::BasicHeaderProperties& headers, const std::string& data, 
                      CompletionTracker::Listener f = CompletionTracker::Listener(), 
                      Correlator::Listener g = Correlator::Listener());

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/client/FutureResponse.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/client/FutureResponse.cpp?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/client/FutureResponse.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/client/FutureResponse.cpp Thu Aug 16 13:12:33 2007
@@ -26,16 +26,16 @@
 using namespace qpid::sys;
 
 
-AMQMethodBody::shared_ptr FutureResponse::getResponse()
+AMQMethodBody* FutureResponse::getResponse()
 {
     waitForCompletion();
-    return response;
+    return response.get();
 }
 
-void FutureResponse::received(AMQMethodBody::shared_ptr r)
+void FutureResponse::received(AMQMethodBody* r)
 {
     Monitor::ScopedLock l(lock);
-    response = r;
+    response = *r;
     complete = true;
     lock.notifyAll();
 }

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/client/FutureResponse.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/client/FutureResponse.h?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/client/FutureResponse.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/client/FutureResponse.h Thu Aug 16 13:12:33 2007
@@ -23,6 +23,7 @@
 #define _FutureResponse_
 
 #include "qpid/framing/amqp_framing.h"
+#include "qpid/framing/MethodHolder.h"
 #include "FutureCompletion.h"
 
 namespace qpid {
@@ -30,11 +31,10 @@
 
 class FutureResponse : public FutureCompletion 
 {
-    framing::AMQMethodBody::shared_ptr response;
-
+    framing::MethodHolder response;
 public:
-    framing::AMQMethodBody::shared_ptr getResponse();
-    void received(framing::AMQMethodBody::shared_ptr response);
+    framing::AMQMethodBody* getResponse();
+    void received(framing::AMQMethodBody* response);
 };
 
 }}

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/client/ReceivedContent.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/client/ReceivedContent.cpp?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/client/ReceivedContent.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/client/ReceivedContent.cpp Thu Aug 16 13:12:33 2007
@@ -20,6 +20,7 @@
  */
 
 #include "ReceivedContent.h"
+#include "qpid/framing/all_method_bodies.h"
 
 using qpid::client::ReceivedContent;
 using namespace qpid::framing;
@@ -27,9 +28,9 @@
 
 ReceivedContent::ReceivedContent(const SequenceNumber& _id) : id(_id) {}
 
-void ReceivedContent::append(AMQBody::shared_ptr part)
+void ReceivedContent::append(AMQBody* part)
 {
-    parts.push_back(part);
+    parts.push_back(AMQFrame(ProtocolVersion(), 0, part));
 }
 
 bool ReceivedContent::isComplete() const
@@ -37,7 +38,7 @@
     if (parts.empty()) {
          return false;
     } else if (isA<BasicDeliverBody>() || isA<BasicGetOkBody>()) {
-        AMQHeaderBody::shared_ptr headers(getHeaders());
+        const AMQHeaderBody* headers(getHeaders());
         return headers && headers->getContentSize() == getContentSize();
     } else if (isA<MessageTransferBody>()) {
         //no longer support references, headers and data are still method fields
@@ -48,14 +49,14 @@
 }
 
 
-AMQMethodBody::shared_ptr ReceivedContent::getMethod() const
+const AMQMethodBody* ReceivedContent::getMethod() const
 {
-    return parts.empty() ? AMQMethodBody::shared_ptr() : dynamic_pointer_cast<AMQMethodBody>(parts[0]);
+    return parts.empty() ? 0 : dynamic_cast<const AMQMethodBody*>(parts[0].getBody());
 }
 
-AMQHeaderBody::shared_ptr ReceivedContent::getHeaders() const
+const AMQHeaderBody* ReceivedContent::getHeaders() const
 {
-    return parts.size() < 2 ? AMQHeaderBody::shared_ptr() : dynamic_pointer_cast<AMQHeaderBody>(parts[1]);
+    return parts.size() < 2 ? 0 : dynamic_cast<const AMQHeaderBody*>(parts[1].getBody());
 }
 
 uint64_t ReceivedContent::getContentSize() const
@@ -63,7 +64,7 @@
     if (isA<BasicDeliverBody>() || isA<BasicGetOkBody>()) {
         uint64_t size(0);
         for (uint i = 2; i < parts.size(); i++) {
-            size += parts[i]->size();
+            size += parts[i].getBody()->size();
         }
         return size;
     } else if (isA<MessageTransferBody>()) {
@@ -78,7 +79,7 @@
     if (isA<BasicDeliverBody>() || isA<BasicGetOkBody>()) {
         string data;
         for (uint i = 2; i < parts.size(); i++) {
-            data += dynamic_pointer_cast<AMQContentBody>(parts[i])->getData();
+            data += static_cast<const AMQContentBody*>(parts[i].getBody())->getData();
         }
         return data;
     } else if (isA<MessageTransferBody>()) {
@@ -93,7 +94,7 @@
     if (!isComplete()) throw Exception("Incomplete message");
 
     if (isA<BasicDeliverBody>() || isA<BasicGetOkBody>()) {
-        BasicHeaderProperties* properties = dynamic_cast<BasicHeaderProperties*>(getHeaders()->getProperties());
+        const BasicHeaderProperties* properties = dynamic_cast<const BasicHeaderProperties*>(getHeaders()->getProperties());
         BasicHeaderProperties::copy<Message, BasicHeaderProperties>(msg, *properties);
         msg.setData(getContent());
     } else if (isA<MessageTransferBody>()) {

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/client/ReceivedContent.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/client/ReceivedContent.h?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/client/ReceivedContent.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/client/ReceivedContent.h Thu Aug 16 13:12:33 2007
@@ -20,8 +20,8 @@
  */
 #include <string>
 #include <vector>
-#include <boost/shared_ptr.hpp>
 #include "qpid/framing/amqp_framing.h"
+#include "qpid/framing/AMQFrame.h"
 #include "qpid/framing/SequenceNumber.h"
 #include "ClientMessage.h"
 
@@ -38,37 +38,29 @@
 class ReceivedContent
 {
     const framing::SequenceNumber id;
-    std::vector<framing::AMQBody::shared_ptr> parts;
+    std::vector<framing::AMQFrame> parts;
 
 public:
     typedef boost::shared_ptr<ReceivedContent> shared_ptr;
 
     ReceivedContent(const framing::SequenceNumber& id);
-    void append(framing::AMQBody::shared_ptr part);
+    void append(framing::AMQBody* part);
     bool isComplete() const;
 
     uint64_t getContentSize() const;
     std::string getContent() const;
 
-    framing::AMQMethodBody::shared_ptr getMethod() const;
-    framing::AMQHeaderBody::shared_ptr getHeaders() const;
+    const framing::AMQMethodBody* getMethod() const;
+    const framing::AMQHeaderBody* getHeaders() const;
      
     template <class T> bool isA() const {
-        framing::AMQMethodBody::shared_ptr method = getMethod();
-        if (!method) {
-            return false;
-        } else {
-            return method->isA<T>();
-        }
+        const framing::AMQMethodBody* method=getMethod();
+        return method && method->isA<T>();
     }
 
-    template <class T> boost::shared_ptr<T> as() const {
-        framing::AMQMethodBody::shared_ptr method = getMethod();
-        if (method && method->isA<T>()) {
-            return boost::dynamic_pointer_cast<T>(method);
-        } else {
-            return boost::shared_ptr<T>();
-        }
+    template <class T> const T* as() const {
+        const framing::AMQMethodBody* method=getMethod();
+        return (method && method->isA<T>()) ? dynamic_cast<const T*>(method) : 0;
     }    
 
     const framing::SequenceNumber& getId() const { return id; }

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/client/Response.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/client/Response.h?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/client/Response.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/client/Response.h Thu Aug 16 13:12:33 2007
@@ -38,12 +38,12 @@
 
     template <class T> T& as() 
     {
-        framing::AMQMethodBody::shared_ptr response(future->getResponse());
+        framing::AMQMethodBody* response(future->getResponse());
         return dynamic_cast<T&>(*response);
     }
     template <class T> bool isA() 
     {
-        framing::AMQMethodBody::shared_ptr response(future->getResponse());
+        framing::AMQMethodBody* response(future->getResponse());
         return response && response->isA<T>();
     }
     

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/client/SessionCore.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/client/SessionCore.cpp?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/client/SessionCore.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/client/SessionCore.cpp Thu Aug 16 13:12:33 2007
@@ -44,7 +44,7 @@
     l3.sendFlush();
 }
 
-Response SessionCore::send(AMQMethodBody::shared_ptr method, bool expectResponse)
+Response SessionCore::send(const AMQMethodBody& method, bool expectResponse)
 {
     boost::shared_ptr<FutureResponse> f(futures.createResponse());
     if (expectResponse) {
@@ -59,7 +59,7 @@
     return Response(f);
 }
 
-Response SessionCore::send(AMQMethodBody::shared_ptr method, const MethodContent& content, bool expectResponse)
+Response SessionCore::send(const AMQMethodBody& method, const MethodContent& content, bool expectResponse)
 {
     //TODO: lots of duplication between these two send methods; refactor
     boost::shared_ptr<FutureResponse> f(futures.createResponse());

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/client/SessionCore.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/client/SessionCore.h?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/client/SessionCore.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/client/SessionCore.h Thu Aug 16 13:12:33 2007
@@ -47,8 +47,8 @@
     typedef boost::shared_ptr<SessionCore> shared_ptr;
 
     SessionCore(uint16_t id, boost::shared_ptr<framing::FrameHandler> out, uint64_t maxFrameSize);
-    Response send(framing::AMQMethodBody::shared_ptr method, bool expectResponse = false);
-    Response send(framing::AMQMethodBody::shared_ptr method, const framing::MethodContent& content, bool expectResponse = false);
+    Response send(const framing::AMQMethodBody& method, bool expectResponse = false);
+    Response send(const framing::AMQMethodBody& method, const framing::MethodContent& content, bool expectResponse = false);
     ReceivedContent::shared_ptr get();
     uint16_t getId() const { return id; } 
     void setSync(bool);

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/cluster/ClassifierHandler.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/cluster/ClassifierHandler.cpp?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/cluster/ClassifierHandler.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/cluster/ClassifierHandler.cpp Thu Aug 16 13:12:33 2007
@@ -36,7 +36,7 @@
 
 FullMethodId fullId(ClassId c, MethodId m) { return c<<16+m; }
 
-FullMethodId fullId(const shared_ptr<AMQMethodBody>& body) {
+FullMethodId fullId(const AMQMethodBody*& body) {
     return fullId(body->amqpClassId(), body->amqpMethodId());
 }
 
@@ -59,8 +59,8 @@
     // TODO aconway 2007-07-03: Flatten the frame hierarchy so we
     // can do a single lookup to dispatch a frame.
     Chain chosen;
-    shared_ptr<AMQMethodBody> method =
-        dynamic_pointer_cast<AMQMethodBody>(frame.getBody());
+    AMQMethodBody* method = dynamic_cast<AMQMethodBody*>(frame.getBody());
+
     // FIXME aconway 2007-07-05: Need to stop bypassed frames
     // from overtaking mcast frames.
     //

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/cluster/Cluster.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/cluster/Cluster.cpp?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/cluster/Cluster.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/cluster/Cluster.cpp Thu Aug 16 13:12:33 2007
@@ -95,7 +95,7 @@
 
 void Cluster::notify() {
     AMQFrame frame(ProtocolVersion(), 0,
-                   new ClusterNotifyBody(ProtocolVersion(), url));
+                   ClusterNotifyBody(ProtocolVersion(), url));
     handle(frame);
 }
 

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/cluster/SessionManager.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/cluster/SessionManager.cpp?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/cluster/SessionManager.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/cluster/SessionManager.cpp Thu Aug 16 13:12:33 2007
@@ -36,7 +36,7 @@
 using namespace broker;
 
 /** Handler to send frames direct to local broker (bypass correlation etc.) */
-    struct BrokerHandler : public FrameHandler, private ChannelAdapter, private DeliveryAdapter {
+struct BrokerHandler : public FrameHandler, private ChannelAdapter, private DeliveryAdapter {
     Connection connection;
     Channel channel;
     BrokerAdapter adapter;
@@ -61,13 +61,13 @@
     }
 
     // Dummy methods.
-    virtual void handleHeader(boost::shared_ptr<AMQHeaderBody>){}
-    virtual void handleContent(boost::shared_ptr<AMQContentBody>){}
-    virtual void handleHeartbeat(boost::shared_ptr<AMQHeartbeatBody>){}
+    virtual void handleHeader(AMQHeaderBody*){}
+    virtual void handleContent(AMQContentBody*){}
+    virtual void handleHeartbeat(AMQHeartbeatBody*){}
     virtual bool isOpen() const{ return true; }
-    virtual void handleMethod(shared_ptr<AMQMethodBody>){}
+    virtual void handleMethod(AMQMethodBody*){}
     // No-op send.
-        virtual void send(shared_ptr<AMQBody>) {}
+    virtual void send(const AMQBody&) {}
 
     //delivery adapter methods, also no-ops:
     virtual DeliveryId deliver(Message::shared_ptr&, DeliveryToken::shared_ptr) { return 0; }

Propchange: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Thu Aug 16 13:12:33 2007
@@ -11,3 +11,5 @@
 AMQP_ServerProxy.h
 MethodHolderMaxSize.h
 MethodHolder_construct.cpp
+MethodBodyConstVisitor.h
+all_method_bodies.h

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQBody.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQBody.h?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQBody.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQBody.h Thu Aug 16 13:12:33 2007
@@ -1,3 +1,6 @@
+#ifndef QPID_FRAMING_AMQBODY_H
+#define QPID_FRAMING_AMQBODY_H
+
 /*
  *
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -18,42 +21,58 @@
  * under the License.
  *
  */
-#include <boost/shared_ptr.hpp>
-#include "amqp_types.h"
-#include "Buffer.h"
+#include "qpid/framing/amqp_types.h"
+#include "qpid/shared_ptr.h"
 
-#ifndef _AMQBody_
-#define _AMQBody_
+#include <ostream>
 
 namespace qpid {
-    namespace framing {
+namespace framing {
+
+class Buffer;
+
+class AMQMethodBody;
+class AMQHeaderBody;
+class AMQContentBody;
+class AMQHeartbeatBody;
+
+struct AMQBodyConstVisitor {
+    virtual ~AMQBodyConstVisitor() {}
+    virtual void visit(const AMQHeaderBody&) = 0;
+    virtual void visit(const AMQContentBody&) = 0;
+    virtual void visit(const AMQHeartbeatBody&) = 0;
+    virtual void visit(const AMQMethodBody&) = 0;
+};
+
+class AMQBody
+{
+  public:
+    typedef shared_ptr<AMQBody> shared_ptr;
+
+    virtual ~AMQBody();
+
+    virtual uint8_t type() const = 0;
+
+    virtual void encode(Buffer& buffer) const = 0;
+    virtual void decode(Buffer& buffer, uint32_t=0) = 0;
+    virtual uint32_t size() const = 0;
+
+    virtual void print(std::ostream& out) const = 0;
+    virtual void accept(AMQBodyConstVisitor&) const = 0;
+
+    virtual AMQMethodBody* getMethod() { return 0; }
+    virtual const AMQMethodBody* getMethod() const { return 0; }
+};
+
+std::ostream& operator<<(std::ostream& out, const AMQBody& body) ;
 
-        class AMQBody
-        {
-          public:
-            typedef boost::shared_ptr<AMQBody> shared_ptr;
-
-            virtual ~AMQBody();
-            virtual uint32_t size() const = 0;
-            virtual uint8_t type() const = 0;
-            virtual void encode(Buffer& buffer) const = 0;
-            virtual void decode(Buffer& buffer, uint32_t size) = 0;
-
-            virtual void print(std::ostream& out) const = 0;
-        };
-
-        std::ostream& operator<<(std::ostream& out, const AMQBody& body) ;
-
-        enum BodyTypes {
-            METHOD_BODY = 1,
-            HEADER_BODY = 2,
-            CONTENT_BODY = 3,
-            HEARTBEAT_BODY = 8,
-            REQUEST_BODY = 9,
-            RESPONSE_BODY = 10
-        };
-    }
-}
+enum BodyTypes {
+    METHOD_BODY = 1,
+    HEADER_BODY = 2,
+    CONTENT_BODY = 3,
+    HEARTBEAT_BODY = 8
+};
 
+}} // namespace qpid::framing
 
-#endif
+#endif  /*!QPID_FRAMING_AMQBODY_H*/

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQContentBody.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQContentBody.cpp?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQContentBody.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQContentBody.cpp Thu Aug 16 13:12:33 2007
@@ -12,7 +12,7 @@
  * 
  * 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
+n * "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.

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQContentBody.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQContentBody.h?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQContentBody.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQContentBody.h Thu Aug 16 13:12:33 2007
@@ -28,13 +28,11 @@
 namespace qpid {
 namespace framing {
 
-class AMQContentBody : public AMQBody
+class AMQContentBody :  public AMQBody
 {
     string data;
 
 public:
-    typedef boost::shared_ptr<AMQContentBody> shared_ptr;
-
     AMQContentBody();
     AMQContentBody(const string& data);
     inline virtual ~AMQContentBody(){}
@@ -44,6 +42,7 @@
     void encode(Buffer& buffer) const;
     void decode(Buffer& buffer, uint32_t size);
     void print(std::ostream& out) const;
+    void accept(AMQBodyConstVisitor& v) const { v.visit(*this); }
 };
 
 }

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQFrame.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQFrame.cpp?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQFrame.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQFrame.cpp Thu Aug 16 13:12:33 2007
@@ -1,4 +1,3 @@
-
 /*
  *
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -19,46 +18,70 @@
  * under the License.
  *
  */
-#include <boost/format.hpp>
-
 #include "AMQFrame.h"
+
 #include "qpid/QpidError.h"
-#include "AMQMethodBody.h"
+#include "qpid/framing/variant.h"
+#include "qpid/framing/AMQMethodBody.h"
 
+#include <boost/format.hpp>
+
+#include <iostream>
 
 namespace qpid {
 namespace framing {
 
+namespace {
+struct GetBodyVisitor : public NoBlankVisitor<AMQBody*> {
+    QPID_USING_NOBLANK(AMQBody*);
+    AMQBody* operator()(MethodHolder& t) const { return t.get(); }
+    template <class T> AMQBody* operator()(T& t) const { return &t; }
+};
+
+struct EncodeVisitor : public NoBlankVisitor<void> {
+    Buffer& buffer;
+    EncodeVisitor(Buffer& b) : buffer(b) {}
+    
+    QPID_USING_NOBLANK(void);
+    template <class T> void operator()(const T& t) const { return t.encode(buffer); }
+};
+
+struct SizeVisitor : public NoBlankVisitor<uint32_t> {
+    QPID_USING_NOBLANK(uint32_t);
+    template <class T> uint32_t operator()(const T& t) const { return t.size(); }
+};
+
+struct DecodeVisitor : public NoBlankVisitor<void> {
+    Buffer& buffer;
+    uint32_t size;
+    DecodeVisitor(Buffer& b, uint32_t s) : buffer(b), size(s) {}
+    QPID_USING_NOBLANK(void);
+    void operator()(MethodHolder& t) const { return t.decode(buffer); }
+    template <class T> void operator()(T& t) const { return t.decode(buffer, size); }
+};
 
-AMQP_MethodVersionMap AMQFrame::versionMap;
-
-AMQFrame::AMQFrame(ProtocolVersion _version)
-    : channel(0), type(0), version(_version)
- {
-     assert(version != ProtocolVersion(0,0));
- }
-
-AMQFrame::AMQFrame(ProtocolVersion _version, uint16_t _channel, AMQBody* _body) : channel(_channel), body(_body),version(_version) {}
+}
 
-AMQFrame::AMQFrame(ProtocolVersion _version, uint16_t _channel, const AMQBody::shared_ptr& _body) :
-    channel(_channel), body(_body), version(_version)
-{}
+AMQBody* AMQFrame::getBody() {
+    return boost::apply_visitor(GetBodyVisitor(), body);
+}
 
-AMQFrame::~AMQFrame() {}
+const AMQBody* AMQFrame::getBody() const {
+    return boost::apply_visitor(GetBodyVisitor(), const_cast<Variant&>(body));
+}
 
 void AMQFrame::encode(Buffer& buffer)
 {
-    buffer.putOctet(body->type());
+    buffer.putOctet(getBody()->type());
     buffer.putShort(channel);    
-    buffer.putLong(body->size());
-    body->encode(buffer);
+    buffer.putLong(boost::apply_visitor(SizeVisitor(), body));
+    boost::apply_visitor(EncodeVisitor(buffer), body);
     buffer.putOctet(0xCE);
 }
 
 uint32_t AMQFrame::size() const{
-    assert(body.get());
-    return 1/*type*/ + 2/*channel*/ + 4/*body size*/ + body->size()
-        + 1/*0xCE*/;
+    return 1/*type*/ + 2/*channel*/ + 4/*body size*/ +
+        boost::apply_visitor(SizeVisitor(), body) + 1/*0xCE*/;
 }
 
 bool AMQFrame::decode(Buffer& buffer)
@@ -66,56 +89,42 @@
     if(buffer.available() < 7)
         return false;
     buffer.record();
-    uint32_t frameSize = decodeHead(buffer);
-    if(buffer.available() < frameSize + 1){
+
+    uint8_t type = buffer.getOctet();
+    channel = buffer.getShort();
+    uint32_t size =  buffer.getLong();
+
+    if(buffer.available() < size+1){
         buffer.restore();
         return false;
     }
-    decodeBody(buffer, frameSize);
+    decodeBody(buffer, size, type);
     uint8_t end = buffer.getOctet();
     if(end != 0xCE) THROW_QPID_ERROR(FRAMING_ERROR, "Frame end not found");
     return true;
 }
 
-uint32_t AMQFrame::decodeHead(Buffer& buffer){    
-    type = buffer.getOctet();
-    channel = buffer.getShort();
-    return buffer.getLong();
-}
-
-void AMQFrame::decodeBody(Buffer& buffer, uint32_t size)
+void AMQFrame::decodeBody(Buffer& buffer, uint32_t size, uint8_t type)
 {    
     switch(type)
     {
-      case METHOD_BODY:
-        body = AMQMethodBody::create(versionMap, version, buffer);
-        break;
-      case HEADER_BODY: 
-	body = AMQBody::shared_ptr(new AMQHeaderBody()); 
-	break;
-      case CONTENT_BODY: 
-	body = AMQBody::shared_ptr(new AMQContentBody()); 
-	break;
-      case HEARTBEAT_BODY: 
-	body = AMQBody::shared_ptr(new AMQHeartbeatBody()); 
-	break;
+      case METHOD_BODY: body = MethodHolder(); break;
+      case HEADER_BODY: body = AMQHeaderBody();	break;
+      case CONTENT_BODY: body = AMQContentBody(); break;
+      case HEARTBEAT_BODY: body = AMQHeartbeatBody(); break;
+
       default:
 	THROW_QPID_ERROR(
             FRAMING_ERROR,
             boost::format("Unknown frame type %d") % type);
     }
-    body->decode(buffer, size);
+    boost::apply_visitor(DecodeVisitor(buffer,size), body);
 }
 
-std::ostream& operator<<(std::ostream& out, const AMQFrame& t)
+std::ostream& operator<<(std::ostream& out, const AMQFrame& f)
 {
-    out << "Frame[channel=" << t.channel << "; ";
-    if (t.body.get() == 0)
-        out << "empty";
-    else
-        out << *t.body;
-    out << "]";
-    return out;
+    return out << "Frame[channel=" << f.getChannel() << "; " << *f.getBody()
+               << "]";
 }
 
 

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQFrame.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQFrame.h?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQFrame.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQFrame.h Thu Aug 16 13:12:33 2007
@@ -21,55 +21,76 @@
  * under the License.
  *
  */
-#include <boost/cast.hpp>
-
-#include "amqp_types.h"
-#include "AMQBody.h"
 #include "AMQDataBlock.h"
-#include "AMQMethodBody.h"
 #include "AMQHeaderBody.h"
 #include "AMQContentBody.h"
 #include "AMQHeartbeatBody.h"
-#include "qpid/framing/AMQP_MethodVersionMap.h"
-#include "qpid/framing/AMQP_HighestVersion.h"
-#include "qpid/framing/Buffer.h"
-#include "qpid/shared_ptr.h"
+#include "MethodHolder.h"
+#include "ProtocolVersion.h"
+
+#include <boost/cast.hpp>
+#include <boost/variant.hpp>
 
 namespace qpid {
 namespace framing {
-
 	
 class AMQFrame : public AMQDataBlock
 {
   public:
-    AMQFrame(ProtocolVersion _version = highestProtocolVersion);
-    AMQFrame(ProtocolVersion _version, uint16_t channel, AMQBody* body);
-    AMQFrame(ProtocolVersion _version, uint16_t channel, const AMQBody::shared_ptr& body);    
-    virtual ~AMQFrame();
-    virtual void encode(Buffer& buffer); 
-    virtual bool decode(Buffer& buffer); 
-    virtual uint32_t size() const;
-    uint16_t getChannel() const { return channel; }
-
-    shared_ptr<AMQBody> getBody() { return body; }
-    void setBody(const shared_ptr<AMQBody>& b) { body = b; }
-
-    /** Convenience template to cast the body to an expected type */
-    template <class T> boost::shared_ptr<T> castBody() {
-        assert(dynamic_cast<T*>(getBody().get()));
-        boost::static_pointer_cast<T>(getBody());
+    AMQFrame(ProtocolVersion=ProtocolVersion()) {}
+
+    /** Construct a frame with a copy of b */
+    AMQFrame(ProtocolVersion, ChannelId c, const AMQBody* b) : channel(c) {
+        setBody(*b);
+    }
+    
+    AMQFrame(ProtocolVersion, ChannelId c, const AMQBody& b) : channel(c) {
+        setBody(b);
+    }
+    
+    ChannelId getChannel() const { return channel; }
+    void setChannel(ChannelId c) { channel = c; }
+
+    AMQBody* getBody();
+    const AMQBody* getBody() const;
+
+    /** Copy a body instance to the frame */
+    void setBody(const AMQBody& b) { CopyVisitor cv(*this); b.accept(cv); }
+
+    /** Convenience template to cast the body to an expected type. */
+    template <class T> T* castBody() {
+        boost::polymorphic_downcast<T*>(getBody());
     }
 
-    uint32_t decodeHead(Buffer& buffer); 
-    void decodeBody(Buffer& buffer, uint32_t size); 
+    bool empty() { return boost::get<boost::blank>(&body); }
 
-    uint16_t channel;
-    uint8_t type;
-    AMQBody::shared_ptr body;
-    ProtocolVersion version;
+    void encode(Buffer& buffer); 
+    bool decode(Buffer& buffer); 
+    uint32_t size() const;
 
   private:
-    static AMQP_MethodVersionMap versionMap;
+    struct CopyVisitor : public AMQBodyConstVisitor {
+        AMQFrame& frame;
+        CopyVisitor(AMQFrame& f) : frame(f) {}
+        void visit(const AMQHeaderBody& x) { frame.body=x; }
+        void visit(const AMQContentBody& x) { frame.body=x; }
+        void visit(const AMQHeartbeatBody& x) { frame.body=x; }
+        void visit(const AMQMethodBody& x) { frame.body=MethodHolder(x); }
+    };
+  friend struct CopyVisitor;
+
+    typedef boost::variant<boost::blank,
+                           AMQHeaderBody,
+                           AMQContentBody,
+                           AMQHeartbeatBody,
+                           MethodHolder> Variant;
+
+    void visit(AMQHeaderBody& x) { body=x; }
+
+    void decodeBody(Buffer& buffer, uint32_t size, uint8_t type);
+
+    uint16_t channel;
+    Variant body;
 };
 
 std::ostream& operator<<(std::ostream&, const AMQFrame&);

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQHeaderBody.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQHeaderBody.cpp?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQHeaderBody.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQHeaderBody.cpp Thu Aug 16 13:12:33 2007
@@ -22,54 +22,34 @@
 #include "qpid/QpidError.h"
 #include "BasicHeaderProperties.h"
 
-qpid::framing::AMQHeaderBody::AMQHeaderBody(int classId) : weight(0), contentSize(0){
-    createProperties(classId);
-}
+qpid::framing::AMQHeaderBody::AMQHeaderBody(int) : weight(0), contentSize(0) {}
 
-qpid::framing::AMQHeaderBody::AMQHeaderBody() : properties(0), weight(0), contentSize(0){
-}
+qpid::framing::AMQHeaderBody::AMQHeaderBody() : weight(0), contentSize(0){}
 
-qpid::framing::AMQHeaderBody::~AMQHeaderBody(){ 
-    delete properties;
-}
+qpid::framing::AMQHeaderBody::~AMQHeaderBody(){}
 
 uint32_t qpid::framing::AMQHeaderBody::size() const{
-    return 12 + properties->size();
+    return 12 + properties.size();
 }
 
 void qpid::framing::AMQHeaderBody::encode(Buffer& buffer) const {
-    buffer.putShort(properties->classId());
+    buffer.putShort(properties.classId());
     buffer.putShort(weight);
     buffer.putLongLong(contentSize);
-    properties->encode(buffer);
+    properties.encode(buffer);
 }
 
 void qpid::framing::AMQHeaderBody::decode(Buffer& buffer, uint32_t bufSize){
-    uint16_t classId = buffer.getShort();
+    buffer.getShort();          // Ignore classId
     weight = buffer.getShort();
     contentSize = buffer.getLongLong();
-    createProperties(classId);
-    properties->decode(buffer, bufSize - 12);
-}
-
-void qpid::framing::AMQHeaderBody::createProperties(int classId){
-    switch(classId){
-    case BASIC:
-	properties = new qpid::framing::BasicHeaderProperties();
-	break;
-    default:
-	THROW_QPID_ERROR(FRAMING_ERROR, "Unknown header class");
-    }
+    properties.decode(buffer, bufSize - 12);
 }
 
 void qpid::framing::AMQHeaderBody::print(std::ostream& out) const
 {
     out << "header (" << size() << " bytes)"  << " content_size=" << getContentSize();
-    const BasicHeaderProperties* props =
-        dynamic_cast<const BasicHeaderProperties*>(getProperties());
-    if (props) {
-        out << ", message_id=" << props->getMessageId(); 
-        out << ", delivery_mode=" << (int) props->getDeliveryMode(); 
-        out << ", headers=" << const_cast<BasicHeaderProperties*>(props)->getHeaders();
-    }
+    out << ", message_id=" << properties.getMessageId(); 
+    out << ", delivery_mode=" << (int) properties.getDeliveryMode(); 
+    out << ", headers=" << properties.getHeaders();
 }

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQHeaderBody.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQHeaderBody.h?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQHeaderBody.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQHeaderBody.h Thu Aug 16 13:12:33 2007
@@ -21,7 +21,7 @@
 #include "amqp_types.h"
 #include "AMQBody.h"
 #include "Buffer.h"
-#include "HeaderProperties.h"
+#include "BasicHeaderProperties.h"
 
 #ifndef _AMQHeaderBody_
 #define _AMQHeaderBody_
@@ -31,19 +31,15 @@
 
 class AMQHeaderBody :  public AMQBody
 {
-    HeaderProperties* properties;
+    BasicHeaderProperties properties;
     uint16_t weight;
     uint64_t contentSize;
-
-    void createProperties(int classId);
-public:
-    typedef boost::shared_ptr<AMQHeaderBody> shared_ptr;
-
+  public:
     AMQHeaderBody(int classId);
     AMQHeaderBody();
     inline uint8_t type() const { return HEADER_BODY; }
-    HeaderProperties* getProperties(){ return properties; }
-    const HeaderProperties* getProperties() const { return properties; }
+    BasicHeaderProperties* getProperties(){ return &properties; }
+    const BasicHeaderProperties* getProperties() const { return &properties; }
     inline uint64_t getContentSize() const { return contentSize; }
     inline void setContentSize(uint64_t _size) { contentSize = _size; }
     virtual ~AMQHeaderBody();
@@ -51,6 +47,8 @@
     virtual void encode(Buffer& buffer) const;
     virtual void decode(Buffer& buffer, uint32_t size);
     virtual void print(std::ostream& out) const;
+
+    void accept(AMQBodyConstVisitor& v) const { v.visit(*this); }
 };
 
 }

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQHeartbeatBody.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQHeartbeatBody.h?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQHeartbeatBody.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQHeartbeatBody.h Thu Aug 16 13:12:33 2007
@@ -31,14 +31,13 @@
 class AMQHeartbeatBody :  public AMQBody
 {
 public:
-    typedef boost::shared_ptr<AMQHeartbeatBody> shared_ptr;
-
     virtual ~AMQHeartbeatBody();
     inline uint32_t size() const { return 0; }
     inline uint8_t type() const { return HEARTBEAT_BODY; }
     inline void encode(Buffer& ) const {}
     inline void decode(Buffer& , uint32_t /*size*/) {}
     virtual void print(std::ostream& out) const;
+    void accept(AMQBodyConstVisitor& v) const { v.visit(*this); }
 };
 
 }

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQMethodBody.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQMethodBody.cpp?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQMethodBody.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQMethodBody.cpp Thu Aug 16 13:12:33 2007
@@ -18,51 +18,11 @@
  * under the License.
  *
  */
-#include "AMQFrame.h"
 #include "AMQMethodBody.h"
-#include "qpid/QpidError.h"
-#include "qpid/framing/AMQP_MethodVersionMap.h"
 
 namespace qpid {
 namespace framing {
 
-void AMQMethodBody::encodeId(Buffer& buffer) const{
-    buffer.putShort(amqpClassId());
-    buffer.putShort(amqpMethodId());
-}
-
-void AMQMethodBody::invoke(AMQP_ServerOperations&){
-    assert(0);
-    THROW_QPID_ERROR(PROTOCOL_ERROR, "Method not supported by AMQP Server.");
-}
-
-bool AMQMethodBody::invoke(Invocable*) {
-    return false;
-}
-
-AMQMethodBody::shared_ptr AMQMethodBody::create(
-    AMQP_MethodVersionMap& versionMap, ProtocolVersion version,
-    Buffer& buffer)
-{
-    ClassMethodId id;
-    id.decode(buffer);
-    return AMQMethodBody::shared_ptr(
-        versionMap.createMethodBody(
-            id.classId, id.methodId, version.getMajor(), version.getMinor()));
-}
-
-void AMQMethodBody::ClassMethodId::decode(Buffer& buffer) {
-    classId = buffer.getShort();
-    methodId = buffer.getShort();
-}
-
-void AMQMethodBody::decode(Buffer& buffer, uint32_t /*size*/) {
-    decodeContent(buffer);
-}
-
-void AMQMethodBody::encode(Buffer& buffer) const {
-    encodeId(buffer);
-    encodeContent(buffer);
-}
+AMQMethodBody::~AMQMethodBody() {}
 
 }} // namespace qpid::framing

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQMethodBody.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQMethodBody.h?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQMethodBody.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQMethodBody.h Thu Aug 16 13:12:33 2007
@@ -21,65 +21,48 @@
  * under the License.
  *
  */
-#include <iostream>
 #include "amqp_types.h"
 #include "AMQBody.h"
-#include "Buffer.h"
-#include "qpid/framing/AMQP_ServerOperations.h"
+#include "qpid/framing/ProtocolVersion.h"
+#include "qpid/shared_ptr.h"
+
+#include <ostream>
+
+#include <assert.h>
 
 namespace qpid {
 namespace framing {
 
-class AMQP_MethodVersionMap;
+class Buffer;
+class AMQP_ServerOperations;
+class Invocable;
+class MethodBodyConstVisitor;
 
-class AMQMethodBody : public AMQBody
-{
+class AMQMethodBody : public AMQBody {
   public:
-    typedef boost::shared_ptr<AMQMethodBody> shared_ptr;
-
-    static shared_ptr create(
-        AMQP_MethodVersionMap& map, ProtocolVersion version, Buffer& buf);
-
-    ProtocolVersion version;    
-    uint8_t type() const { return METHOD_BODY; }
-    AMQMethodBody(uint8_t major, uint8_t minor) : version(major, minor) {}
-    AMQMethodBody(ProtocolVersion ver) : version(ver) {}
-    virtual ~AMQMethodBody() {}
-    void decode(Buffer&, uint32_t);
-    virtual void encode(Buffer& buffer) const;
+    AMQMethodBody() {}
+    AMQMethodBody(uint8_t, uint8_t) {}
+    
+    virtual ~AMQMethodBody();
 
+    virtual void accept(MethodBodyConstVisitor&) const = 0;
+    
     virtual MethodId amqpMethodId() const = 0;
     virtual ClassId  amqpClassId() const = 0;
     
-    virtual void invoke(AMQP_ServerOperations&);
-    virtual bool invoke(Invocable* target);
+    virtual void invoke(AMQP_ServerOperations&) { assert(0); }
+    virtual bool invoke(Invocable*) { return false; }
 
-    template <class T> bool isA() {
+    template <class T> bool isA() const {
         return amqpClassId()==T::CLASS_ID && amqpMethodId()==T::METHOD_ID;
     }
 
-    /** Return request ID or response correlationID */
-    virtual RequestId getRequestId() const { return 0; }
-
-    virtual bool isRequest() const { return false; }
-    virtual bool isResponse() const { return false; }
-
-    static uint32_t baseSize() { return 4; }
-  protected:
-
-    struct ClassMethodId {
-        uint16_t classId;
-        uint16_t methodId;
-        void decode(Buffer& b);
-    };
-    
-    void encodeId(Buffer& buffer) const;
-    virtual void encodeContent(Buffer& buffer) const = 0;
-    virtual void decodeContent(Buffer& buffer) = 0;
-
-    virtual void printPrefix(std::ostream&) const {}
+    virtual uint32_t size() const = 0;
+    virtual uint8_t type() const { return METHOD_BODY; }
 
-  friend class MethodHolder;
+    AMQMethodBody* getMethod() { return this; }
+    const AMQMethodBody* getMethod() const { return this; }
+    void accept(AMQBodyConstVisitor& v) const { v.visit(*this); }
 };
 
 

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/BasicHeaderProperties.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/BasicHeaderProperties.h?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/BasicHeaderProperties.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/BasicHeaderProperties.h Thu Aug 16 13:12:33 2007
@@ -57,7 +57,7 @@
     virtual void encode(Buffer& buffer) const;
     virtual void decode(Buffer& buffer, uint32_t size);
 
-    virtual uint8_t classId() { return BASIC; }
+    virtual uint8_t classId() const { return BASIC; }
 
     string getContentType() const { return contentType; }
     string getContentEncoding() const { return contentEncoding; }

Added: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Blob.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Blob.cpp?view=auto&rev=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Blob.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Blob.cpp Thu Aug 16 13:12:33 2007
@@ -0,0 +1,30 @@
+/*
+ * 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 "Blob.h"
+
+
+namespace qpid {
+namespace framing {
+
+void BlobHelper<void>::destroy(void*) {}
+void BlobHelper<void>::copy(void*, const void*) {}
+
+}} // namespace qpid::framing

Propchange: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Blob.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Blob.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Blob.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Blob.h?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Blob.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Blob.h Thu Aug 16 13:12:33 2007
@@ -33,6 +33,8 @@
 namespace boost {
 
 /**
+ * 0-arg typed_in_place_factory constructor and in_place() override.
+ * 
  * Boost doesn't provide the 0 arg version since it assumes
  * in_place_factory will be used when there is no default ctor.
  */
@@ -48,20 +50,29 @@
 
 } // namespace boost
 
+
 namespace qpid {
 namespace framing {
 
 using boost::in_place;
 
-template <class T>
-void destroyT(void* ptr) { static_cast<T*>(ptr)->~T(); }
-inline void nullDestroy(void*) {}
+template <class T> struct BlobHelper {
+    static void destroy(void* ptr) { static_cast<T*>(ptr)->~T(); }
+    static void copy(void* dest, const void* src) {
+        new (dest) T(*static_cast<const T*>(src));
+    }
+};
+
+template <> struct BlobHelper<void> {
+    static void destroy(void*);
+    static void copy(void* to, const void* from);
+};
 
 /**
  * A "blob" is a chunk of memory which can contain a single object at
  * a time arbitrary type, provided sizeof(T)<=blob.size(). Blob
  * ensures proper construction and destruction of its contents,
- * nothing else.
+ * and proper copying between Blobs, but nothing else.
  * 
  * In particular the user must ensure the blob is big enough for its
  * contents and must know the type of object in the blob to cast get().
@@ -75,7 +86,13 @@
 {
     boost::aligned_storage<Size> store;
     void (*destroy)(void*);
+    void (*copy)(void*, const void*);
 
+    template <class T> void setType() {
+        destroy=&BlobHelper<T>::destroy;
+        copy=&BlobHelper<T>::copy;
+    }
+    
     template<class TypedInPlaceFactory>
     void construct (const TypedInPlaceFactory& factory,
                     const boost::typed_in_place_factory_base* )
@@ -84,16 +101,28 @@
         assert(sizeof(T) <= Size);
         clear();                // Destroy old object.
         factory.apply(store.address());
-        destroy=&destroyT<T>;
+        setType<T>();
     }
 
   public:
     /** Construct an empty blob. */
-    Blob() : destroy(&nullDestroy) {}
+    Blob() { setType<void>(); }
+
+    /** Copy a blob. */
+    Blob(const Blob& b) { *this = b; }
+
+    /** Assign a blob */
+    Blob& operator=(const Blob& b) {
+        setType<void>();        // Exception safety.
+        b.copy(this->get(), b.get());
+        copy = b.copy;
+        destroy = b.destroy;
+        return *this;
+    }
 
     /** @see construct() */
     template<class Expr>
-    Blob( const Expr & expr ) : destroy(nullDestroy) { construct(expr,&expr); }
+    Blob( const Expr & expr ) { setType<void>(); construct(expr,&expr); }
 
     ~Blob() { clear(); }
 
@@ -106,7 +135,7 @@
 
     /** Copy construct an instance of T into the Blob. */
     template<class T>
-    Blob& operator=(const T& x) { construct(in_place<T>(x)); }
+    Blob& operator=(const T& x) { construct(in_place<T>(x)); return *this; }
     
     /** Get pointer to blob contents. Caller must know how to cast it. */
     void* get() { return store.address(); }
@@ -116,16 +145,14 @@
     
     /** Destroy the object in the blob making it empty. */
     void clear() {
-        void (*saveDestroy)(void*) = destroy; // Exception safety
-        destroy = &nullDestroy;
-        saveDestroy(store.address());
+        void (*oldDestroy)(void*) = destroy; 
+        setType<void>();
+        oldDestroy(store.address());
     }
 
-    /** True if there is no object allocated in the blob */
-    bool empty() { return destroy==nullDestroy; }
-
     static size_t size() { return Size; }
 };
+
 
 }} // namespace qpid::framing
 

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/BodyHandler.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/BodyHandler.cpp?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/BodyHandler.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/BodyHandler.cpp Thu Aug 16 13:12:33 2007
@@ -25,25 +25,28 @@
 #include "AMQContentBody.h"
 #include "AMQHeartbeatBody.h"
 
+#include <boost/cast.hpp>
+
 using namespace qpid::framing;
 using namespace boost;
 
 BodyHandler::~BodyHandler() {}
 
-void BodyHandler::handleBody(shared_ptr<AMQBody> body) {
+// TODO aconway 2007-08-13: Replace with visitor.
+void BodyHandler::handleBody(AMQBody* body) {
     switch(body->type())
     {
       case METHOD_BODY:
-	handleMethod(shared_polymorphic_cast<AMQMethodBody>(body));
+	handleMethod(polymorphic_downcast<AMQMethodBody*>(body));
 	break;
       case HEADER_BODY:
-	handleHeader(shared_polymorphic_cast<AMQHeaderBody>(body));
+	handleHeader(polymorphic_downcast<AMQHeaderBody*>(body));
 	break;
       case CONTENT_BODY:
-	handleContent(shared_polymorphic_cast<AMQContentBody>(body));
+	handleContent(polymorphic_downcast<AMQContentBody*>(body));
 	break;
       case HEARTBEAT_BODY:
-	handleHeartbeat(shared_polymorphic_cast<AMQHeartbeatBody>(body));
+	handleHeartbeat(polymorphic_downcast<AMQHeartbeatBody*>(body));
 	break;
       default:
         QPID_ERROR(PROTOCOL_ERROR, "Unknown frame type "+body->type());

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/BodyHandler.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/BodyHandler.h?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/BodyHandler.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/BodyHandler.h Thu Aug 16 13:12:33 2007
@@ -32,6 +32,8 @@
 class AMQContentBody;
 class AMQHeartbeatBody;
 
+// TODO aconway 2007-08-10: rework using Visitor pattern?
+
 /**
  * Interface to handle incoming frame bodies.
  * Derived classes provide logic for each frame type.
@@ -39,13 +41,13 @@
 class BodyHandler {
   public:
     virtual ~BodyHandler();
-    virtual void handleBody(boost::shared_ptr<AMQBody> body);
+    virtual void handleBody(AMQBody* body);
 
   protected:
-    virtual void handleMethod(boost::shared_ptr<AMQMethodBody>) = 0;
-    virtual void handleHeader(boost::shared_ptr<AMQHeaderBody>) = 0;
-    virtual void handleContent(boost::shared_ptr<AMQContentBody>) = 0;
-    virtual void handleHeartbeat(boost::shared_ptr<AMQHeartbeatBody>) = 0;
+    virtual void handleMethod(AMQMethodBody*) = 0;
+    virtual void handleHeader(AMQHeaderBody*) = 0;
+    virtual void handleContent(AMQContentBody*) = 0;
+    virtual void handleHeartbeat(AMQHeartbeatBody*) = 0;
 };
 
 }}

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ChannelAdapter.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ChannelAdapter.cpp?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ChannelAdapter.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ChannelAdapter.cpp Thu Aug 16 13:12:33 2007
@@ -23,6 +23,9 @@
 #include "FrameHandler.h"
 #include "qpid/Exception.h"
 
+#include "AMQMethodBody.h"
+#include "qpid/framing/ConnectionOpenBody.h"
+
 using boost::format;
 
 namespace qpid {
@@ -45,7 +48,7 @@
     handlers.out= make_shared_ptr(new OutputHandlerFrameHandler(out));
 }
 
-void ChannelAdapter::send(shared_ptr<AMQBody> body)
+void ChannelAdapter::send(const AMQBody& body)
 {
     assertChannelOpen();
     AMQFrame frame(getVersion(), getId(), body);

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ChannelAdapter.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ChannelAdapter.h?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ChannelAdapter.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ChannelAdapter.h Thu Aug 16 13:12:33 2007
@@ -25,11 +25,11 @@
  *
  */
 
-#include "qpid/shared_ptr.h"
 #include "BodyHandler.h"
 #include "ProtocolVersion.h"
 #include "amqp_types.h"
 #include "FrameHandler.h"
+#include "OutputHandler.h"
 
 namespace qpid {
 namespace framing {
@@ -66,7 +66,7 @@
     ChannelId getId() const { return id; }
     ProtocolVersion getVersion() const { return version; }
 
-    virtual void send(shared_ptr<AMQBody> body);
+    virtual void send(const AMQBody& body);
 
     virtual bool isOpen() const = 0;
     
@@ -75,7 +75,7 @@
     void assertChannelOpen() const;
     void assertChannelNotOpen() const;
 
-    virtual void handleMethod(shared_ptr<AMQMethodBody>) = 0;
+    virtual void handleMethod(AMQMethodBody*) = 0;
 
   private:
     class ChannelAdapterHandler;

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/HeaderProperties.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/HeaderProperties.h?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/HeaderProperties.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/HeaderProperties.h Thu Aug 16 13:12:33 2007
@@ -34,7 +34,7 @@
 	
     public:
 	inline virtual ~HeaderProperties(){}
-	virtual uint8_t classId() = 0;
+	virtual uint8_t classId() const = 0;
 	virtual uint32_t size() const = 0;
 	virtual void encode(Buffer& buffer) const = 0;
 	virtual void decode(Buffer& buffer, uint32_t size) = 0;

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/MethodHolder.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/MethodHolder.cpp?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/MethodHolder.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/MethodHolder.cpp Thu Aug 16 13:12:33 2007
@@ -23,8 +23,8 @@
 #include "qpid/framing/AMQMethodBody.h"
 #include "qpid/framing/Buffer.h"
 
-// Note: MethodHolder::construct is in a separate generated file
-// MethodHolder_construct.cpp
+// Note: MethodHolder::construct is and operator= are code-generated
+// in file MethodHolder_construct.cpp.
 
 using namespace boost;
 
@@ -35,16 +35,18 @@
     const AMQMethodBody* body = get();
     b.putShort(body->amqpClassId());
     b.putShort(body->amqpMethodId());
-    body->encodeContent(b);
+    body->encode(b);
 }
 
 void MethodHolder::decode(Buffer& b) {
-    construct(std::make_pair(b.getShort(), b.getShort()));
-    get()->decodeContent(b);
+    ClassId c=b.getShort();
+    MethodId m=b.getShort();
+    construct(c,m);
+    get()->decode(b);
 }
 
 uint32_t  MethodHolder::size() const {
-    return sizeof(Id)+get()->size();
+    return sizeof(ClassId)+sizeof(MethodId)+get()->size();
 }
 
 std::ostream& operator<<(std::ostream& out, const MethodHolder& h) {

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/MethodHolder.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/MethodHolder.h?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/MethodHolder.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/MethodHolder.h Thu Aug 16 13:12:33 2007
@@ -22,64 +22,74 @@
  *
  */
 
+#include "qpid/framing/AMQBody.h"
+#include "qpid/framing/amqp_types.h"
 #include "qpid/framing/amqp_types.h"
 #include "qpid/framing/Blob.h"
 #include "qpid/framing/MethodHolderMaxSize.h" // Generated file.
 
+#include <boost/type_traits/is_base_and_derived.hpp>
+#include <boost/utility/enable_if.hpp>
+
 #include <utility>
 
 namespace qpid {
 namespace framing {
 
 class AMQMethodBody;
+class AMQBody;
 class Buffer;
 
+class MethodHolder;
+std::ostream& operator<<(std::ostream& out, const MethodHolder& h);
+
 /**
  * Holder for arbitrary method body.
  */
+// TODO aconway 2007-08-14: Fix up naming, this class should really be
+// called AMQMethodBody and use a different name for the root of
+// the concrete method body tree, which should not inherit AMQBody.
+// 
 class MethodHolder
 {
-  public:
-    typedef std::pair<ClassId, MethodId> Id; 
-
-    template <class T>static Id idOf() {
-        return std::make_pair(T::CLASS_ID, T::METHOD_ID); }
+    template <class T> struct EnableIfMethod:
+        public boost::enable_if<boost::is_base_and_derived<AMQMethodBody,T>,T>
+    {};
 
+    template <class T> EnableIfMethod<T>& assertMethod(T& t) { return t; }
+        
+  public:
     MethodHolder() {}
-    MethodHolder(const Id& id) { construct(id); }
-    MethodHolder(ClassId& c, MethodId& m) { construct(std::make_pair(c,m)); }
+    MethodHolder(ClassId& c, MethodId& m) { construct(c,m); }
 
-    template <class M>
-    MethodHolder(const M& m) : blob(m), id(idOf<M>()) {}
+    /** Construct with a copy of a method body. */
+    MethodHolder(const AMQMethodBody& m) { *this = m; }
 
-    template <class M>
-    MethodHolder& operator=(const M& m) { blob=m; id=idOf<M>(); return *this; }
+    /** Copy method body into holder. */
+    MethodHolder& operator=(const AMQMethodBody&);
 
-    /** Construct the method body corresponding to Id */
-    void construct(const Id&);
+    /** Construct the method body corresponding to class/method id */
+    void construct(ClassId c, MethodId m);
 
+    uint8_t type() const { return 1; }
     void encode(Buffer&) const;
     void decode(Buffer&);
     uint32_t size() const;
             
     AMQMethodBody* get() {
-        return static_cast<AMQMethodBody*>(blob.get());
+        return reinterpret_cast<AMQMethodBody*>(blob.get());
     }
     const AMQMethodBody* get() const {
-        return static_cast<const AMQMethodBody*>(blob.get());
+        return reinterpret_cast<const AMQMethodBody*>(blob.get());
     }
 
-    AMQMethodBody* operator* () { return get(); }
-    const AMQMethodBody* operator*() const { return get(); }
-    AMQMethodBody* operator-> () { return get(); }
-    const AMQMethodBody* operator->() const { return get(); }
-
   private:
     Blob<MAX_METHODBODY_SIZE> blob;
-    Id id;
+    class CopyVisitor;
+  friend struct CopyVisitor;
 };
 
-std::ostream& operator<<(std::ostream& out, const MethodHolder& h);
+
 
 }} // namespace qpid::framing
 

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/amqp_framing.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/amqp_framing.h?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/amqp_framing.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/amqp_framing.h Thu Aug 16 13:12:33 2007
@@ -26,7 +26,6 @@
 #include "AMQHeaderBody.h"
 #include "AMQContentBody.h"
 #include "AMQHeartbeatBody.h"
-#include "qpid/framing/AMQP_MethodVersionMap.h"
 #include "InputHandler.h"
 #include "OutputHandler.h"
 #include "InitiationHandler.h"

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/amqp_types.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/amqp_types.h?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/amqp_types.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/amqp_types.h Thu Aug 16 13:12:33 2007
@@ -44,8 +44,6 @@
 using std::string;
 typedef uint8_t FrameType;
 typedef uint16_t ChannelId;
-typedef uint64_t RequestId;
-typedef uint64_t ResponseId;
 typedef uint32_t BatchOffset;
 typedef uint16_t ClassId;
 typedef uint16_t MethodId;

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/shared_ptr.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/shared_ptr.h?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/shared_ptr.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/shared_ptr.h Thu Aug 16 13:12:33 2007
@@ -42,6 +42,8 @@
     return shared_ptr<T>(ptr, deleter);
 }
 
+inline void nullDeleter(void const *) {} 
+
 } // namespace qpid
 
 

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/sys/posix/Socket.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/sys/posix/Socket.cpp?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/sys/posix/Socket.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/sys/posix/Socket.cpp Thu Aug 16 13:12:33 2007
@@ -134,7 +134,9 @@
 
 int Socket::listen(int port, int backlog) const
 {
-	const int& socket = impl->fd;
+    const int& socket = impl->fd;
+    int yes=1;
+    QPID_POSIX_CHECK(setsockopt(socket,SOL_SOCKET,SO_REUSEADDR,&yes,sizeof(yes)));
     struct sockaddr_in name;
     name.sin_family = AF_INET;
     name.sin_port = htons(port);

Modified: incubator/qpid/trunk/qpid/cpp/src/tests/BrokerChannelTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/BrokerChannelTest.cpp?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/BrokerChannelTest.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/BrokerChannelTest.cpp Thu Aug 16 13:12:33 2007
@@ -31,6 +31,7 @@
 #include "MockChannel.h"
 #include "qpid/broker/Connection.h"
 #include "qpid/framing/ProtocolInitiation.h"
+#include "qpid/framing/ConnectionStartBody.h"
 #include <vector>
 
 using namespace boost;
@@ -233,18 +234,18 @@
         Queue::shared_ptr queue(new Queue("my_queue"));
         exchange->bind(queue, "", 0);
 
-        AMQHeaderBody::shared_ptr header(new AMQHeaderBody(BASIC));
+        AMQHeaderBody header(BASIC);
         uint64_t contentSize(0);
         for (int i = 0; i < 3; i++) {
             contentSize += data[i].size();
         }
-        header->setContentSize(contentSize);
+        header.setContentSize(contentSize);
         channel.handlePublish(msg);
-        channel.handleHeader(header);
+        channel.handleHeader(&header);
 
         for (int i = 0; i < 3; i++) {
-            AMQContentBody::shared_ptr body(new AMQContentBody(data[i]));
-            channel.handleContent(body);
+            AMQContentBody body(data[i]);
+            channel.handleContent(&body);
         }
         Message::shared_ptr msg2 = queue->dequeue();
         CPPUNIT_ASSERT_EQUAL(msg, msg2.get());
@@ -312,8 +313,7 @@
         //there will always be a connection-start frame
         CPPUNIT_ASSERT_EQUAL((size_t) 1, handler.frames.size());
         CPPUNIT_ASSERT_EQUAL(ChannelId(0), handler.frames[0].getChannel());
-        CPPUNIT_ASSERT(dynamic_cast<ConnectionStartBody*>(
-                           handler.frames[0].getBody().get()));
+        CPPUNIT_ASSERT(dynamic_cast<ConnectionStartBody*>(handler.frames[0].getBody()));
         
         const string data("abcdefghijklmn");
 
@@ -340,17 +340,17 @@
     {
         BasicMessage* msg = new BasicMessage(
             0, exchange, routingKey, false, false);
-        AMQHeaderBody::shared_ptr header(new AMQHeaderBody(BASIC));
-        header->setContentSize(contentSize);        
-        msg->setHeader(header);
+        AMQHeaderBody header(BASIC);
+        header.setContentSize(contentSize);        
+        msg->setHeader(&header);
         msg->getHeaderProperties()->setMessageId(messageId);
         return msg;
     }
 
     void addContent(Message::shared_ptr msg, const string& data)
     {
-        AMQContentBody::shared_ptr body(new AMQContentBody(data));
-        msg->addContent(body);
+        AMQContentBody body(data);
+        msg->addContent(&body);
     }
 };
 

Modified: incubator/qpid/trunk/qpid/cpp/src/tests/Cluster.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/Cluster.cpp?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/Cluster.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/Cluster.cpp Thu Aug 16 13:12:33 2007
@@ -33,7 +33,7 @@
 /** Verify membership in a cluster with one member. */
 BOOST_AUTO_TEST_CASE(testClusterOne) {
     TestCluster cluster("clusterOne", "amqp:one:1");
-    AMQFrame send(VER, 1, new SessionPingBody(VER));
+    AMQFrame send(VER, 1, SessionPingBody(VER));
     cluster.handle(send);
     AMQFrame received;
     BOOST_REQUIRE(cluster.received.waitPop(received));
@@ -59,7 +59,7 @@
         BOOST_REQUIRE(cluster.waitFor(2)); // Myself and child.
 
         // Exchange frames with child.
-        AMQFrame send(VER, 1, new SessionPingBody(VER));
+        AMQFrame send(VER, 1, SessionPingBody(VER));
         cluster.handle(send);
         AMQFrame received;
         BOOST_REQUIRE(cluster.received.waitPop(received));
@@ -90,8 +90,8 @@
     
 /** Test the ClassifierHandler */
 BOOST_AUTO_TEST_CASE(testClassifierHandlerWiring) {
-    AMQFrame queueDecl(VER, 0, new QueueDeclareBody(VER));
-    AMQFrame messageTrans(VER, 0, new MessageTransferBody(VER));
+    AMQFrame queueDecl(VER, 0, QueueDeclareBody(VER));
+    AMQFrame messageTrans(VER, 0, MessageTransferBody(VER));
     shared_ptr<CountHandler> wiring(new CountHandler());
     shared_ptr<CountHandler> other(new CountHandler());
     

Modified: incubator/qpid/trunk/qpid/cpp/src/tests/Cluster.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/Cluster.h?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/Cluster.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/Cluster.h Thu Aug 16 13:12:33 2007
@@ -55,8 +55,6 @@
 
 typedef TestHandler<AMQFrame> TestFrameHandler;
 
-void nullDeleter(void*) {}
-
 struct TestCluster : public Cluster
 {
     TestCluster(string name, string url)

Modified: incubator/qpid/trunk/qpid/cpp/src/tests/Cluster_child.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/Cluster_child.cpp?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/Cluster_child.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/Cluster_child.cpp Thu Aug 16 13:12:33 2007
@@ -40,7 +40,7 @@
     BOOST_CHECK_TYPEID_EQUAL(SessionPingBody, *frame.getBody());
     BOOST_CHECK_EQUAL(2u, cluster.size()); // Me and parent
 
-    AMQFrame send(VER, 1, new SessionPongBody(VER));
+    AMQFrame send(VER, 1, SessionPongBody(VER));
     cluster.handle(send);
     BOOST_REQUIRE(cluster.received.waitPop(frame));
     BOOST_CHECK_TYPEID_EQUAL(SessionPongBody, *frame.getBody());

Modified: incubator/qpid/trunk/qpid/cpp/src/tests/FramingTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/FramingTest.cpp?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/FramingTest.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/FramingTest.cpp Thu Aug 16 13:12:33 2007
@@ -18,24 +18,27 @@
  * under the License.
  *
  */
+#include "InProcessBroker.h"
+#include "qpid/QpidError.h"
+#include "qpid/client/ClientExchange.h"
+#include "qpid/client/ClientQueue.h"
+#include "qpid/client/Connection.h"
+#include "qpid/client/Connector.h"
+#include "qpid/framing/AMQP_HighestVersion.h"
+#include "qpid/framing/BasicGetOkBody.h"
 #include "qpid/framing/ConnectionRedirectBody.h"
 #include "qpid/framing/ProtocolVersion.h"
+#include "qpid/framing/all_method_bodies.h"
 #include "qpid/framing/amqp_framing.h"
-#include <iostream>
 #include "qpid_test_plugin.h"
+
+#include <boost/bind.hpp>
+#include <boost/lexical_cast.hpp>
+#include <iostream>
+
+#include <memory>
 #include <sstream>
 #include <typeinfo>
-#include "qpid/QpidError.h"
-#include "qpid/framing/AMQP_HighestVersion.h"
-#include "InProcessBroker.h"
-#include "qpid/client/Connection.h"
-#include "qpid/client/Connector.h"
-#include "qpid/client/ClientExchange.h"
-#include "qpid/client/ClientQueue.h"
-#include "qpid/framing/BasicGetOkBody.h"
-#include <memory>
-#include <boost/lexical_cast.hpp>
-#include <boost/bind.hpp>
 
 using namespace qpid;
 using namespace qpid::framing;
@@ -62,13 +65,11 @@
     CPPUNIT_TEST(testInlineContent);
     CPPUNIT_TEST(testContentReference);
     CPPUNIT_TEST(testContentValidation);
-    CPPUNIT_TEST(testRequestResponseRoundtrip);
     CPPUNIT_TEST_SUITE_END();
 
   private:
     Buffer buffer;
     ProtocolVersion version;
-    AMQP_MethodVersionMap versionMap;
     
   public:
 
@@ -77,10 +78,10 @@
     void testBasicQosBody() 
     {
         BasicQosBody in(version, 0xCAFEBABE, 0xABBA, true);
-        in.encodeContent(buffer);
+        in.encode(buffer);
         buffer.flip(); 
         BasicQosBody out(version);
-        out.decodeContent(buffer);
+        out.decode(buffer);
         CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out));
     }
     
@@ -88,10 +89,10 @@
     {
         std::string s = "security credential";
         ConnectionSecureBody in(version, s);
-        in.encodeContent(buffer);
+        in.encode(buffer);
         buffer.flip(); 
         ConnectionSecureBody out(version);
-        out.decodeContent(buffer);
+        out.decode(buffer);
         CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out));
     }
 
@@ -100,10 +101,10 @@
         std::string a = "hostA";
         std::string b = "hostB";
         ConnectionRedirectBody in(version, a, b);
-        in.encodeContent(buffer);
+        in.encode(buffer);
         buffer.flip(); 
         ConnectionRedirectBody out(version);
-        out.decodeContent(buffer);
+        out.decode(buffer);
         CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out));
     }
 
@@ -111,10 +112,10 @@
     {
         std::string s = "text";
         AccessRequestBody in(version, s, true, false, true, false, true);
-        in.encodeContent(buffer);
+        in.encode(buffer);
         buffer.flip(); 
         AccessRequestBody out(version);
-        out.decodeContent(buffer);
+        out.decode(buffer);
         CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out));
     }
 
@@ -124,10 +125,10 @@
         std::string t = "tag";
         BasicConsumeBody in(version, 0, q, t, false, true, false, false,
                             FieldTable());
-        in.encodeContent(buffer);
+        in.encode(buffer);
         buffer.flip(); 
         BasicConsumeBody out(version);
-        out.decodeContent(buffer);
+        out.decode(buffer);
         CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out));
     }
     
@@ -137,7 +138,7 @@
         std::string a = "hostA";
         std::string b = "hostB";
         AMQFrame in(version, 999,
-                    new ConnectionRedirectBody(version, a, b));
+                    ConnectionRedirectBody(version, a, b));
         in.encode(buffer);
         buffer.flip(); 
         AMQFrame out;
@@ -148,7 +149,7 @@
     void testBasicConsumeOkBodyFrame()
     {
         std::string s = "hostA";
-        AMQFrame in(version, 999, new BasicConsumeOkBody(version, s));
+        AMQFrame in(version, 999, BasicConsumeOkBody(version, s));
         in.encode(buffer);
         buffer.flip(); 
         AMQFrame out;
@@ -211,46 +212,6 @@
         
     }
 
-    // expect may contain null chars so use string(ptr,size) constructor
-    // Use sizeof(expect)-1 to strip the trailing null.
-#define ASSERT_FRAME(expect, frame) \
-    CPPUNIT_ASSERT_EQUAL(string(expect, sizeof(expect)-1), boost::lexical_cast<string>(frame))
-
-    void testRequestResponseRoundtrip() {
-        boost::shared_ptr<broker::InProcessBroker> ibroker(new broker::InProcessBroker(version));
-        client::Connection clientConnection(boost::static_pointer_cast<client::Connector>(ibroker));
-        clientConnection.open("");
-        client::Channel c;
-        clientConnection.openChannel(c);
-
-        client::Exchange exchange(
-            "MyExchange", client::Exchange::TOPIC_EXCHANGE);
-        client::Queue queue("MyQueue", true);
-        c.declareExchange(exchange);
-        c.declareQueue(queue);
-        c.bind(exchange, queue, "MyTopic", framing::FieldTable());
-        c.close();
-        clientConnection.close();
-        broker::InProcessBroker::Conversation::const_iterator i = ibroker->conversation.begin();
-        ASSERT_FRAME("BROKER: Frame[channel=0; ConnectionStart: versionMajor=0; versionMinor=10; serverProperties={}; mechanisms=PLAIN; locales=en_US]", *i++);
-        ASSERT_FRAME("CLIENT: Frame[channel=0; ConnectionStartOk: clientProperties={}; mechanism=PLAIN; response=\000guest\000guest; locale=en_US]", *i++);
-        ASSERT_FRAME("BROKER: Frame[channel=0; ConnectionTune: channelMax=32767; frameMax=65536; heartbeat=0]", *i++);
-        ASSERT_FRAME("CLIENT: Frame[channel=0; ConnectionTuneOk: channelMax=32767; frameMax=65536; heartbeat=0]", *i++);
-        ASSERT_FRAME("CLIENT: Frame[channel=0; ConnectionOpen: virtualHost=/; capabilities=; insist=1]", *i++);
-        ASSERT_FRAME("BROKER: Frame[channel=0; ConnectionOpenOk: knownHosts=]", *i++);
-        ASSERT_FRAME("CLIENT: Frame[channel=1; ChannelOpen: outOfBand=]", *i++);
-        ASSERT_FRAME("BROKER: Frame[channel=1; ChannelOpenOk: ]", *i++);
-        ASSERT_FRAME("CLIENT: Frame[channel=1; ExchangeDeclare: ticket=0; exchange=MyExchange; type=topic; alternateExchange=; passive=0; durable=0; autoDelete=0; arguments={}]", *i++);
-        ASSERT_FRAME("CLIENT: Frame[channel=1; ExecutionFlush: ]", *i++);
-        ASSERT_FRAME("BROKER: Frame[channel=1; ExecutionComplete: cumulativeExecutionMark=1; rangedExecutionSet={}]", *i++);
-        ASSERT_FRAME("CLIENT: Frame[channel=1; QueueDeclare: ticket=0; queue=MyQueue; alternateExchange=; passive=0; durable=0; exclusive=1; autoDelete=1; nowait=0; arguments={}]", *i++);
-        ASSERT_FRAME("BROKER: Frame[channel=1; QueueDeclareOk: queue=MyQueue; messageCount=0; consumerCount=0]", *i++);
-        ASSERT_FRAME("CLIENT: Frame[channel=1; ExecutionFlush: ]", *i++);
-        ASSERT_FRAME("BROKER: Frame[channel=1; ExecutionComplete: cumulativeExecutionMark=2; rangedExecutionSet={}]", *i++);
-        ASSERT_FRAME("CLIENT: Frame[channel=1; QueueBind: ticket=0; queue=MyQueue; exchange=MyExchange; routingKey=MyTopic; arguments={}]", *i++);
-        ASSERT_FRAME("CLIENT: Frame[channel=1; ExecutionFlush: ]", *i++);
-        ASSERT_FRAME("BROKER: Frame[channel=1; ExecutionComplete: cumulativeExecutionMark=3; rangedExecutionSet={}]", *i++);
-    }
  };
 
 

Modified: incubator/qpid/trunk/qpid/cpp/src/tests/InMemoryContentTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/InMemoryContentTest.cpp?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/InMemoryContentTest.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/InMemoryContentTest.cpp Thu Aug 16 13:12:33 2007
@@ -65,9 +65,8 @@
         CPPUNIT_ASSERT_EQUAL(outCount, channel.out.frames.size());
 
         for (unsigned int i = 0; i < outCount; i++) {
-            AMQContentBody::shared_ptr chunk(
-                dynamic_pointer_cast<AMQContentBody>(
-                    channel.out.frames[i].getBody()));
+            AMQContentBody* chunk = dynamic_cast<AMQContentBody*>(
+                channel.out.frames[i].getBody());
             CPPUNIT_ASSERT(chunk);
             CPPUNIT_ASSERT_EQUAL(out[i], chunk->getData());
             CPPUNIT_ASSERT_EQUAL(
@@ -78,8 +77,8 @@
     void addframes(InMemoryContent& content, size_t frameCount, string* frameData)
     {
         for (unsigned int i = 0; i < frameCount; i++) {
-            AMQContentBody::shared_ptr frame(new AMQContentBody(frameData[i]));
-            content.add(frame);
+            AMQContentBody frame(frameData[i]);
+            content.add(&frame);
         }
     }
 

Modified: incubator/qpid/trunk/qpid/cpp/src/tests/InProcessBroker.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/InProcessBroker.h?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/InProcessBroker.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/InProcessBroker.h Thu Aug 16 13:12:33 2007
@@ -54,7 +54,7 @@
 
         template <class MethodType>
         MethodType* asMethod() {
-            return dynamic_cast<MethodType*>(frame.getBody().get());
+            return dynamic_cast<MethodType*>(frame.getBody());
         }
         framing::AMQFrame frame;
         Sender sender;

Modified: incubator/qpid/trunk/qpid/cpp/src/tests/LazyLoadedContentTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/LazyLoadedContentTest.cpp?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/LazyLoadedContentTest.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/LazyLoadedContentTest.cpp Thu Aug 16 13:12:33 2007
@@ -97,7 +97,8 @@
         CPPUNIT_ASSERT_EQUAL(outCount, channel.out.frames.size());
 
         for (unsigned int i = 0; i < outCount; i++) {
-            AMQContentBody::shared_ptr chunk(dynamic_pointer_cast<AMQContentBody, AMQBody>(channel.out.frames[i].getBody()));
+            AMQContentBody* chunk(dynamic_cast<AMQContentBody*>(
+                                      channel.out.frames[i].getBody()));
             CPPUNIT_ASSERT(chunk);
             CPPUNIT_ASSERT_EQUAL(out[i], chunk->getData());
             CPPUNIT_ASSERT_EQUAL(

Modified: incubator/qpid/trunk/qpid/cpp/src/tests/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/Makefile.am?view=diff&rev=566822&r1=566821&r2=566822
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/Makefile.am (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/Makefile.am Thu Aug 16 13:12:33 2007
@@ -43,7 +43,6 @@
 Shlib_SOURCES=Shlib.cpp
 Shlib_LDADD=-lboost_unit_test_framework $(lib_common)
 
-
 # TODO aconway 2007-08-07: Why aren't these tests run automatically?
 
 check_PROGRAMS+=ConcurrentQueue
@@ -53,10 +52,6 @@
 check_PROGRAMS+=Serializer
 Serializer_SOURCES=Serializer.cpp
 Serializer_LDADD=-lboost_unit_test_framework $(lib_common)
-
-check_PROGRAMS+=Visitor
-Visitor_SOURCES=Visitor.cpp
-Visitor_LDADD=-lboost_unit_test_framework
 
 include cluster.mk