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/01/29 17:13:27 UTC

svn commit: r501087 [2/2] - in /incubator/qpid/branches/qpid.0-9: cpp/ cpp/gen/ cpp/lib/broker/ cpp/lib/client/ cpp/lib/common/framing/ cpp/lib/common/sys/apr/ cpp/tests/ gentools/src/org/apache/qpid/gentools/ gentools/templ.cpp/

Modified: incubator/qpid/branches/qpid.0-9/cpp/lib/client/Connector.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/cpp/lib/client/Connector.cpp?view=diff&rev=501087&r1=501086&r2=501087
==============================================================================
--- incubator/qpid/branches/qpid.0-9/cpp/lib/client/Connector.cpp (original)
+++ incubator/qpid/branches/qpid.0-9/cpp/lib/client/Connector.cpp Mon Jan 29 08:13:24 2007
@@ -22,8 +22,6 @@
 #include <QpidError.h>
 #include <sys/Time.h>
 #include "Connector.h"
-#include "Requester.h"
-#include "Responder.h"
 
 using namespace qpid::sys;
 using namespace qpid::client;
@@ -31,7 +29,6 @@
 using qpid::QpidError;
 
 Connector::Connector(const qpid::framing::ProtocolVersion& pVersion,
-                     Requester& req, Responder& resp,
                      bool _debug, u_int32_t buffer_size) :
     debug(_debug),
     receive_buffer_size(buffer_size),
@@ -44,9 +41,7 @@
     timeoutHandler(0),
     shutdownHandler(0),
     inbuf(receive_buffer_size), 
-    outbuf(send_buffer_size),
-    requester(req),
-    responder(resp)
+    outbuf(send_buffer_size)
 { }
 
 Connector::~Connector(){ }
@@ -58,9 +53,9 @@
     receiver = Thread(this);
 }
 
-void Connector::init(ProtocolInitiation* header){
-    writeBlock(header);
-    delete header;
+void Connector::init(){
+    ProtocolInitiation init(version);
+    writeBlock(&init);
 }
 
 void Connector::close(){
@@ -81,16 +76,11 @@
     return this; 
 }
 
-void Connector::send(AMQFrame* frame){
+void Connector::send(AMQFrame* f){
+    std::auto_ptr<AMQFrame> frame(f);
     AMQBody::shared_ptr body = frame->getBody();
-    u_int8_t type = body->type();
-    if (type == REQUEST_BODY)
-        requester.sending(AMQRequestBody::getData(body));
-    else if (type == RESPONSE_BODY)
-        responder.sending(AMQResponseBody::getData(body));
-    writeBlock(frame);
+    writeBlock(frame.get());
     if(debug) std::cout << "SENT: " << *frame << std::endl; 
-    delete frame;
 }
 
 void Connector::writeBlock(AMQDataBlock* data){
@@ -185,10 +175,8 @@
                 inbuf.compact();
 	    }
 	}
-    }catch(QpidError error){
-	std::cout << "Error [" << error.code << "] " << error.msg
-                  << " (" << error.location.file << ":" << error.location.line
-                  << ")" << std::endl;
+    } catch (const std::exception& e) {
+	std::cout << e.what() << std::endl;
         handleClosed();
     }
 }

Modified: incubator/qpid/branches/qpid.0-9/cpp/lib/client/Connector.h
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/cpp/lib/client/Connector.h?view=diff&rev=501087&r1=501086&r2=501087
==============================================================================
--- incubator/qpid/branches/qpid.0-9/cpp/lib/client/Connector.h (original)
+++ incubator/qpid/branches/qpid.0-9/cpp/lib/client/Connector.h Mon Jan 29 08:13:24 2007
@@ -35,13 +35,6 @@
 
 namespace qpid {
 
-namespace framing {
-
-class Requester;
-class Responder;
-
-} // namespace framing
-
 namespace client {
 
 class Connector : public qpid::framing::OutputHandler, 
@@ -74,9 +67,6 @@
 
     qpid::sys::Socket socket;
 
-    qpid::framing::Requester& requester;
-    qpid::framing::Responder& responder;
-        
     void checkIdle(ssize_t status);
     void writeBlock(qpid::framing::AMQDataBlock* data);
     void writeToSocket(char* data, size_t available);
@@ -85,13 +75,13 @@
     void run();
     void handleClosed();
 
+  friend class Channel;
   public:
     Connector(const qpid::framing::ProtocolVersion& pVersion,
-              qpid::framing::Requester& req, qpid::framing::Responder& resp,
               bool debug = false, u_int32_t buffer_size = 1024);
     virtual ~Connector();
     virtual void connect(const std::string& host, int port);
-    virtual void init(qpid::framing::ProtocolInitiation* header);
+    virtual void init();
     virtual void close();
     virtual void setInputHandler(qpid::framing::InputHandler* handler);
     virtual void setTimeoutHandler(qpid::sys::TimeoutHandler* handler);

Modified: incubator/qpid/branches/qpid.0-9/cpp/lib/client/ResponseHandler.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/cpp/lib/client/ResponseHandler.cpp?view=diff&rev=501087&r1=501086&r2=501087
==============================================================================
--- incubator/qpid/branches/qpid.0-9/cpp/lib/client/ResponseHandler.cpp (original)
+++ incubator/qpid/branches/qpid.0-9/cpp/lib/client/ResponseHandler.cpp Mon Jan 29 08:13:24 2007
@@ -18,27 +18,35 @@
  * under the License.
  *
  */
+#include <boost/format.hpp>
+
 #include <ResponseHandler.h>
 #include <sys/Monitor.h>
 #include <QpidError.h>
+#include "amqp_types.h"
 
 using namespace qpid::sys;
+using namespace qpid::framing;
+
+namespace qpid {
+namespace client {
 
-qpid::client::ResponseHandler::ResponseHandler() : waiting(false){}
+ResponseHandler::ResponseHandler() : waiting(false){}
 
-qpid::client::ResponseHandler::~ResponseHandler(){}
+ResponseHandler::~ResponseHandler(){}
 
-bool qpid::client::ResponseHandler::validate(const qpid::framing::AMQMethodBody& expected){
-    return response != 0 && expected.match(response.get());
+bool ResponseHandler::validate(ClassId c, MethodId  m) {
+    return response != 0 &&
+        response->amqpClassId() ==c && response->amqpMethodId() == m;
 }
 
-void qpid::client::ResponseHandler::waitForResponse(){
+void ResponseHandler::waitForResponse(){
     Monitor::ScopedLock l(monitor);
     while (waiting)
 	monitor.wait();
 }
 
-void qpid::client::ResponseHandler::signalResponse(
+void ResponseHandler::signalResponse(
     qpid::framing::AMQMethodBody::shared_ptr _response)
 {
     Monitor::ScopedLock l(monitor);
@@ -47,15 +55,26 @@
     monitor.notify();
 }
 
-void qpid::client::ResponseHandler::receive(const qpid::framing::AMQMethodBody& expected){
+void ResponseHandler::receive(ClassId c, MethodId  m) {
     Monitor::ScopedLock l(monitor);
     while (waiting)
 	monitor.wait();
-    if(!validate(expected)){
-	THROW_QPID_ERROR(PROTOCOL_ERROR, "Protocol Error");
+    if (!response) {
+        THROW_QPID_ERROR(
+            PROTOCOL_ERROR, "Channel closed unexpectedly.");
+    }
+    if(!validate(response->amqpClassId(), response->amqpMethodId())) {
+	THROW_QPID_ERROR(
+            PROTOCOL_ERROR,
+            (boost::format(
+                 "Expected class:method %d:%d, got %d:%d")
+             % c % m % response->amqpClassId() % response->amqpMethodId()
+            ).str());
     }
 }
 
-void qpid::client::ResponseHandler::expect(){
+void ResponseHandler::expect(){
     waiting = true;
 }
+
+}} // namespace qpid::client

Modified: incubator/qpid/branches/qpid.0-9/cpp/lib/client/ResponseHandler.h
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/cpp/lib/client/ResponseHandler.h?view=diff&rev=501087&r1=501086&r2=501087
==============================================================================
--- incubator/qpid/branches/qpid.0-9/cpp/lib/client/ResponseHandler.h (original)
+++ incubator/qpid/branches/qpid.0-9/cpp/lib/client/ResponseHandler.h Mon Jan 29 08:13:24 2007
@@ -19,6 +19,8 @@
  *
  */
 #include <string>
+
+#include <amqp_types.h>
 #include <framing/amqp_framing.h>
 #include <sys/Monitor.h>
 
@@ -26,26 +28,39 @@
 #define _ResponseHandler_
 
 namespace qpid {
-    namespace client {
+namespace client {
+
+/**
+ * Holds a response from the broker peer for the client.
+ */ 
+class ResponseHandler{
+    bool waiting;
+    qpid::framing::AMQMethodBody::shared_ptr response;
+    qpid::sys::Monitor monitor;
+
+  public:
+    ResponseHandler();
+    ~ResponseHandler();
+    
+    bool isWaiting(){ return waiting; }
+    framing::AMQMethodBody::shared_ptr getResponse(){ return response;}
+    void waitForResponse();
+    
+    void signalResponse(framing::AMQMethodBody::shared_ptr response);
 
-        class ResponseHandler{
-            bool waiting;
-            qpid::framing::AMQMethodBody::shared_ptr response;
-            qpid::sys::Monitor monitor;
-
-        public:
-            ResponseHandler();
-            ~ResponseHandler();
-            inline bool isWaiting(){ return waiting; }
-            inline qpid::framing::AMQMethodBody::shared_ptr getResponse(){ return response; }
-            bool validate(const qpid::framing::AMQMethodBody& expected);
-            void waitForResponse();
-            void signalResponse(qpid::framing::AMQMethodBody::shared_ptr response);
-            void receive(const qpid::framing::AMQMethodBody& expected);
-            void expect();//must be called before calling receive
-        };
+    void expect();//must be called before calling receive
+    bool validate(framing::ClassId, framing::MethodId);
+    void receive(framing::ClassId, framing::MethodId);
 
+    template <class BodyType> bool validate() {
+        return validate(BodyType::CLASS_ID, BodyType::METHOD_ID);
     }
+    template <class BodyType> void receive() {
+        return receive(BodyType::CLASS_ID, BodyType::METHOD_ID);
+    }
+};
+
+}
 }
 
 

Modified: incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/AMQFrame.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/AMQFrame.cpp?view=diff&rev=501087&r1=501086&r2=501087
==============================================================================
--- incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/AMQFrame.cpp (original)
+++ incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/AMQFrame.cpp Mon Jan 29 08:13:24 2007
@@ -19,6 +19,8 @@
  * under the License.
  *
  */
+#include <boost/format.hpp>
+
 #include <AMQFrame.h>
 #include <QpidError.h>
 #include "AMQRequestBody.h"
@@ -67,10 +69,10 @@
 
 bool AMQFrame::decode(Buffer& buffer)
 {    
-    if(buffer.available() < 7) return false;
+    if(buffer.available() < 7)
+        return false;
     buffer.record();
     u_int32_t frameSize = decodeHead(buffer);
-    
     if(buffer.available() < frameSize + 1){
         buffer.restore();
         return false;
@@ -110,10 +112,9 @@
 	body = AMQBody::shared_ptr(new AMQHeartbeatBody()); 
 	break;
       default:
-        assert(0);
-	string msg("Unknown body type: ");
-	msg += type;
-	THROW_QPID_ERROR(FRAMING_ERROR, msg);
+	THROW_QPID_ERROR(
+            FRAMING_ERROR,
+            (boost::format("Unknown frame type %d")%type).str());
     }
     body->decode(buffer, size);
 }

Modified: incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/AMQFrame.h
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/AMQFrame.h?view=diff&rev=501087&r1=501086&r2=501087
==============================================================================
--- incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/AMQFrame.h (original)
+++ incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/AMQFrame.h Mon Jan 29 08:13:24 2007
@@ -38,7 +38,7 @@
 namespace framing {
 
 	
-class AMQFrame : virtual public AMQDataBlock
+class AMQFrame : public AMQDataBlock
 {
   public:
     AMQFrame(const qpid::framing::ProtocolVersion& _version = highestProtocolVersion);

Modified: incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/AMQMethodBody.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/AMQMethodBody.cpp?view=diff&rev=501087&r1=501086&r2=501087
==============================================================================
--- incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/AMQMethodBody.cpp (original)
+++ incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/AMQMethodBody.cpp Mon Jan 29 08:13:24 2007
@@ -31,10 +31,6 @@
     buffer.putShort(amqpMethodId());
 }
 
-bool AMQMethodBody::match(AMQMethodBody* other) const{
-    return other != 0 && other->amqpClassId() == amqpClassId() && other->amqpMethodId() == amqpMethodId();
-}
-
 void AMQMethodBody::invoke(AMQP_ServerOperations&, const MethodContext&){
     assert(0);
     THROW_QPID_ERROR(PROTOCOL_ERROR, "Method not supported by AMQP Server.");
@@ -44,14 +40,14 @@
     AMQP_MethodVersionMap& versionMap, ProtocolVersion version,
     Buffer& buffer)
 {
-    MethodId id;
+    ClassMethodId id;
     id.decode(buffer);
     return AMQMethodBody::shared_ptr(
         versionMap.createMethodBody(
             id.classId, id.methodId, version.getMajor(), version.getMinor()));
 }
 
-void AMQMethodBody::MethodId::decode(Buffer& buffer) {
+void AMQMethodBody::ClassMethodId::decode(Buffer& buffer) {
     classId = buffer.getShort();
     methodId = buffer.getShort();
 }

Modified: incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/AMQMethodBody.h
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/AMQMethodBody.h?view=diff&rev=501087&r1=501086&r2=501087
==============================================================================
--- incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/AMQMethodBody.h (original)
+++ incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/AMQMethodBody.h Mon Jan 29 08:13:24 2007
@@ -48,11 +48,16 @@
     virtual ~AMQMethodBody() {}
     void decode(Buffer&, u_int32_t);
 
-    virtual u_int16_t amqpMethodId() const = 0;
-    virtual u_int16_t amqpClassId() const = 0;
+    virtual MethodId amqpMethodId() const = 0;
+    virtual ClassId  amqpClassId() const = 0;
+    
     virtual void invoke(AMQP_ServerOperations&, const MethodContext&);
-    bool match(AMQMethodBody* other) const;
 
+    // FIXME aconway 2007-01-24: remove match, use isA
+    bool match(AMQMethodBody* other) const;
+    template <class T> bool isA() {
+        return amqpClassId()==T::CLASS_ID && amqpMethodId()==T::METHOD_ID;
+    }
 
     /**
      * Wrap this method in a frame and send using the current context.
@@ -63,7 +68,7 @@
   protected:
     static u_int32_t baseSize() { return 4; }
 
-    struct MethodId {
+    struct ClassMethodId {
         u_int16_t classId;
         u_int16_t methodId;
         void decode(Buffer& b);
@@ -73,6 +78,7 @@
     virtual void encodeContent(Buffer& buffer) const = 0;
     virtual void decodeContent(Buffer& buffer) = 0;
 };
+
 
 }} // namespace qpid::framing
 

Modified: incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/AMQRequestBody.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/AMQRequestBody.cpp?view=diff&rev=501087&r1=501086&r2=501087
==============================================================================
--- incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/AMQRequestBody.cpp (original)
+++ incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/AMQRequestBody.cpp Mon Jan 29 08:13:24 2007
@@ -45,7 +45,7 @@
     AMQP_MethodVersionMap& versionMap, ProtocolVersion version,
     Buffer& buffer)
 {
-    MethodId id;
+    ClassMethodId id;
     Data data;
     data.decode(buffer);
     id.decode(buffer);

Modified: incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/AMQResponseBody.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/AMQResponseBody.cpp?view=diff&rev=501087&r1=501086&r2=501087
==============================================================================
--- incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/AMQResponseBody.cpp (original)
+++ incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/AMQResponseBody.cpp Mon Jan 29 08:13:24 2007
@@ -45,7 +45,7 @@
     AMQP_MethodVersionMap& versionMap, ProtocolVersion version,
     Buffer& buffer)
 {
-    MethodId id;
+    ClassMethodId id;
     Data data;
     data.decode(buffer);
     id.decode(buffer);

Modified: incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/ChannelAdapter.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/ChannelAdapter.cpp?view=diff&rev=501087&r1=501086&r2=501087
==============================================================================
--- incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/ChannelAdapter.cpp (original)
+++ incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/ChannelAdapter.cpp Mon Jan 29 08:13:24 2007
@@ -22,7 +22,17 @@
 namespace qpid {
 namespace framing {
 
+void ChannelAdapter::init(
+    ChannelId i, OutputHandler& o, const ProtocolVersion& v)
+{
+    assertChannelNotOpen();
+    id = i;
+    out = &o;
+    version = v;
+}
+
 void ChannelAdapter::send(AMQFrame* frame) {
+    assertChannelOpen();
     AMQBody::shared_ptr body = frame->getBody();
     switch (body->type()) {
       case REQUEST_BODY: {
@@ -38,33 +48,52 @@
           break;
       }
     }
-    out.send(frame);
+    out->send(frame);
+}
+
+void ChannelAdapter::send(AMQBody::shared_ptr body) {
+    send(new AMQFrame(getVersion(), getId(), body));
 }
 
 void ChannelAdapter::handleRequest(AMQRequestBody::shared_ptr request) {
+    assertMethodOk(*request);
     responder.received(request->getData());
     MethodContext context(id, this, request->getRequestId());
     handleMethodInContext(request, context);
 }
 
 void ChannelAdapter::handleResponse(AMQResponseBody::shared_ptr response) {
+    assertMethodOk(*response);
     handleMethod(response);
     requester.processed(response->getData());
 }
 
 void ChannelAdapter::handleMethod(AMQMethodBody::shared_ptr method) {
+    assertMethodOk(*method);
     MethodContext context(id, this);
     handleMethodInContext(method, context);
 }
 
-void ChannelAdapter::assertChannelZero(u_int16_t id) {
-    if (id != 0)
-        throw ConnectionException(504, "Invalid channel id, not 0");
+void ChannelAdapter::assertMethodOk(AMQMethodBody& /*method*/) const {
+    // No connection methods allowed on a non-zero channel
+    // Subclass ChannelZero overrides for 0 channels.
+    // FIXME aconway 2007-01-25: with ctors
+//     assertChannelOpen();
+//     if (method.amqpClassId() == ConnectionOpenBody::CLASS_ID)
+//         throw ConnectionException(
+//             504, "Connection method on non-0 channel.");
+}
+
+void ChannelAdapter::assertChannelOpen() const {
+    // FIXME aconway 2007-01-25: with ctors
+//     if (!isOpen())
+//         throw ConnectionException(504, "Channel is not open");
 }
 
-void ChannelAdapter::assertChannelNonZero(u_int16_t id) {
-    if (id == 0)
-        throw ConnectionException(504, "Invalid channel id 0");
+void ChannelAdapter::assertChannelNotOpen() const {
+    // FIXME aconway 2007-01-25: with ctors
+//     if (isOpen())
+//         throw ConnectionException(504, "Channel is already open");
 }
 
 }} // namespace qpid::framing

Modified: incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/ChannelAdapter.h
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/ChannelAdapter.h?view=diff&rev=501087&r1=501086&r2=501087
==============================================================================
--- incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/ChannelAdapter.h (original)
+++ incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/ChannelAdapter.h Mon Jan 29 08:13:24 2007
@@ -38,22 +38,29 @@
  * Base class for client and broker channel adapters.
  *
  * As BodyHandler:
- * - Creates MethodContext and dispatches methods+context to derived class.
- * - Updates request/response ID data.
+ * - receives frame bodies from the network.
+ * - Updates request/response data.
+ * - Dispatches requests with a MethodContext for responses.
  *
  * As OutputHandler:
  * - Updates request/resposne ID data.
- * 
+ * - Forwards frame to the peer.
+ *
+ * Thread safety: OBJECT UNSAFE. Instances must not be called
+ * concurrently. AMQP defines channels to be serialized.
  */
 class ChannelAdapter : public BodyHandler, public OutputHandler {
   public:
     /**
      *@param output Processed frames are forwarded to this handler.
      */
-    ChannelAdapter(OutputHandler& output, ChannelId channelId) 
-        : id(channelId), out(output) {}
+    ChannelAdapter() : id(0), out(0) {}
+
+    /** Initialize the channel adapter. */
+    void init(ChannelId, OutputHandler&, const ProtocolVersion&);
 
-    ChannelId getId() { return id; }
+    ChannelId getId() const { return id; }
+    const ProtocolVersion& getVersion() const { return version; }
     
     /**
      * Do request/response-id processing and then forward to
@@ -61,27 +68,37 @@
      * have their request-id set before calling send.
      */
     void send(AMQFrame* frame);
+    /**
+     * Wrap body in a frame and send the frame.
+     * Takes ownership of body.
+     */
+    void send(AMQBody::shared_ptr body);
+    void send(AMQBody* body) { send(AMQBody::shared_ptr(body)); }
 
     void handleMethod(boost::shared_ptr<qpid::framing::AMQMethodBody>);
     void handleRequest(boost::shared_ptr<qpid::framing::AMQRequestBody>);
     void handleResponse(boost::shared_ptr<qpid::framing::AMQResponseBody>);
 
+    virtual bool isOpen() const = 0;
+    
   protected:
-    /** Throw protocol exception if this is not channel 0. */
-    static void assertChannelZero(u_int16_t id);
-    /** Throw protocol exception if this is channel 0. */
-    static void assertChannelNonZero(u_int16_t id);
+    void assertMethodOk(AMQMethodBody& method) const;
+    void assertChannelOpen() const;
+    void assertChannelNotOpen() const;
 
     virtual void handleMethodInContext(
         boost::shared_ptr<qpid::framing::AMQMethodBody> method,
         const MethodContext& context) = 0;
 
-    ChannelId id;
+    RequestId getRequestInProgress() { return requestInProgress; }
 
   private:
+    ChannelId id;
+    OutputHandler* out;
+    ProtocolVersion version;
     Requester requester;
     Responder responder;
-    OutputHandler& out;
+    RequestId requestInProgress; // TODO aconway 2007-01-24: use it.
 };
 
 }}

Modified: incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/ProtocolInitiation.h
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/ProtocolInitiation.h?view=diff&rev=501087&r1=501086&r2=501087
==============================================================================
--- incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/ProtocolInitiation.h (original)
+++ incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/ProtocolInitiation.h Mon Jan 29 08:13:24 2007
@@ -29,7 +29,7 @@
 namespace qpid {
 namespace framing {
 
-class ProtocolInitiation : virtual public AMQDataBlock
+class ProtocolInitiation : public AMQDataBlock
 {
 private:
     ProtocolVersion version;

Modified: incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/amqp_types.h
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/amqp_types.h?view=diff&rev=501087&r1=501086&r2=501087
==============================================================================
--- incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/amqp_types.h (original)
+++ incubator/qpid/branches/qpid.0-9/cpp/lib/common/framing/amqp_types.h Mon Jan 29 08:13:24 2007
@@ -40,6 +40,9 @@
 typedef u_int64_t RequestId;
 typedef u_int64_t ResponseId;
 typedef u_int32_t BatchOffset;
+typedef u_int16_t ClassId;
+typedef u_int16_t MethodId;
+typedef u_int16_t ReplyCode;
 
 }} // namespace qpid::framing
 #endif

Modified: incubator/qpid/branches/qpid.0-9/cpp/lib/common/sys/apr/APRSocket.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/cpp/lib/common/sys/apr/APRSocket.cpp?view=diff&rev=501087&r1=501086&r2=501087
==============================================================================
--- incubator/qpid/branches/qpid.0-9/cpp/lib/common/sys/apr/APRSocket.cpp (original)
+++ incubator/qpid/branches/qpid.0-9/cpp/lib/common/sys/apr/APRSocket.cpp Mon Jan 29 08:13:24 2007
@@ -59,7 +59,7 @@
     }
 }
 
-bool APRSocket::isOpen(){
+bool APRSocket::isOpen() const {
     return !closed;
 }
 

Modified: incubator/qpid/branches/qpid.0-9/cpp/lib/common/sys/apr/APRSocket.h
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/cpp/lib/common/sys/apr/APRSocket.h?view=diff&rev=501087&r1=501086&r2=501087
==============================================================================
--- incubator/qpid/branches/qpid.0-9/cpp/lib/common/sys/apr/APRSocket.h (original)
+++ incubator/qpid/branches/qpid.0-9/cpp/lib/common/sys/apr/APRSocket.h Mon Jan 29 08:13:24 2007
@@ -36,7 +36,7 @@
         void read(qpid::framing::Buffer& b);
         void write(qpid::framing::Buffer& b);
         void close();
-        bool isOpen();
+        bool isOpen() const;
         u_int8_t read();
 	~APRSocket();
     };

Modified: incubator/qpid/branches/qpid.0-9/cpp/tests/TxBufferTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/cpp/tests/TxBufferTest.cpp?view=diff&rev=501087&r1=501086&r2=501087
==============================================================================
--- incubator/qpid/branches/qpid.0-9/cpp/tests/TxBufferTest.cpp (original)
+++ incubator/qpid/branches/qpid.0-9/cpp/tests/TxBufferTest.cpp Mon Jan 29 08:13:24 2007
@@ -143,7 +143,7 @@
             return state == ABORTED;
         }
         
-        bool isOpen(){
+        bool isOpen() const{
             return state == OPEN;
         }
         ~MockTransactionalStore(){}

Modified: incubator/qpid/branches/qpid.0-9/cpp/tests/client_test.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/cpp/tests/client_test.cpp?view=diff&rev=501087&r1=501086&r2=501087
==============================================================================
--- incubator/qpid/branches/qpid.0-9/cpp/tests/client_test.cpp (original)
+++ incubator/qpid/branches/qpid.0-9/cpp/tests/client_test.cpp Mon Jan 29 08:13:24 2007
@@ -63,7 +63,7 @@
 int main(int argc, char**)
 {
     verbose = argc > 1;
-    try{               
+    try {
         //Use a custom exchange
 	Exchange exchange("MyExchange", Exchange::TOPIC_EXCHANGE);
         //Use a named, temporary queue
@@ -78,7 +78,7 @@
         //Create and open a channel on the connection through which
         //most functionality is exposed
 	Channel channel;      
-	con.openChannel(&channel);
+	con.openChannel(channel);
 	if (verbose) std::cout << "Opened channel." << std::endl;	
 
         //'declare' the exchange and the queue, which will create them
@@ -125,17 +125,13 @@
         }
         
         //close the channel & connection
-	con.closeChannel(&channel);
+	channel.close();
 	if (verbose) std::cout << "Closed channel." << std::endl;
 	con.close();	
 	if (verbose) std::cout << "Closed connection." << std::endl;
-    }catch(qpid::QpidError error){
-	if (verbose) std::cout
-            << "Error [" << error.code << "] "
-            << error.msg << " ("
-            << error.location.file << ":" << error.location.line
-            << ")" << std::endl;
-	return 1;
-    }
     return 0;
+    } catch(const std::exception& e) {
+	std::cout << e.what() << std::endl;
+    }
+    return 1;
 }

Modified: incubator/qpid/branches/qpid.0-9/cpp/tests/echo_service.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/cpp/tests/echo_service.cpp?view=diff&rev=501087&r1=501086&r2=501087
==============================================================================
--- incubator/qpid/branches/qpid.0-9/cpp/tests/echo_service.cpp (original)
+++ incubator/qpid/branches/qpid.0-9/cpp/tests/echo_service.cpp Mon Jan 29 08:13:24 2007
@@ -103,7 +103,7 @@
             Connection connection(args.getTrace());
             connection.open(args.getHost(), args.getPort());
             Channel channel;
-            connection.openChannel(&channel);
+            connection.openChannel(channel);
         
             //Setup: declare the private 'response' queue and bind it
             //to the direct exchange by its name which will be
@@ -147,7 +147,7 @@
             Connection connection(args.getTrace());
             connection.open(args.getHost(), args.getPort());
             Channel channel;
-            connection.openChannel(&channel);
+            connection.openChannel(channel);
         
             //Setup: declare the 'request' queue and bind it to the direct exchange with a 'well known' name
             Queue request("request");

Modified: incubator/qpid/branches/qpid.0-9/cpp/tests/topic_listener.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/cpp/tests/topic_listener.cpp?view=diff&rev=501087&r1=501086&r2=501087
==============================================================================
--- incubator/qpid/branches/qpid.0-9/cpp/tests/topic_listener.cpp (original)
+++ incubator/qpid/branches/qpid.0-9/cpp/tests/topic_listener.cpp Mon Jan 29 08:13:24 2007
@@ -105,7 +105,7 @@
             Connection connection(args.getTrace());
             connection.open(args.getHost(), args.getPort());
             Channel channel(args.getTransactional(), args.getPrefetch());
-            connection.openChannel(&channel);
+            connection.openChannel(channel);
         
             //declare exchange, queue and bind them:
             Queue response("response");

Modified: incubator/qpid/branches/qpid.0-9/cpp/tests/topic_publisher.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/cpp/tests/topic_publisher.cpp?view=diff&rev=501087&r1=501086&r2=501087
==============================================================================
--- incubator/qpid/branches/qpid.0-9/cpp/tests/topic_publisher.cpp (original)
+++ incubator/qpid/branches/qpid.0-9/cpp/tests/topic_publisher.cpp Mon Jan 29 08:13:24 2007
@@ -120,7 +120,7 @@
             Connection connection(args.getTrace());
             connection.open(args.getHost(), args.getPort());
             Channel channel(args.getTransactional(), args.getPrefetch());
-            connection.openChannel(&channel);
+            connection.openChannel(channel);
 
             //declare queue (relying on default binding):
             Queue response("response");

Modified: incubator/qpid/branches/qpid.0-9/gentools/src/org/apache/qpid/gentools/CppGenerator.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/gentools/src/org/apache/qpid/gentools/CppGenerator.java?view=diff&rev=501087&r1=501086&r2=501087
==============================================================================
--- incubator/qpid/branches/qpid.0-9/gentools/src/org/apache/qpid/gentools/CppGenerator.java (original)
+++ incubator/qpid/branches/qpid.0-9/gentools/src/org/apache/qpid/gentools/CppGenerator.java Mon Jan 29 08:13:24 2007
@@ -1425,7 +1425,7 @@
         StringBuffer sb = new StringBuffer();
         if (method.fieldMap.size() > 0)
             {
-                sb.append(indent + thisClass.name + Utils.firstUpper(method.name) + "Body(ProtocolVersion& version," + cr);
+                sb.append(indent + thisClass.name + Utils.firstUpper(method.name) + "Body(const ProtocolVersion& version," + cr);
                 sb.append(generateFieldList(method.fieldMap, version, true, false, 8));
                 sb.append(indent + tab + ") :" + cr);
                 sb.append(indent + tab + baseClass(method) + "(version)," + cr);

Modified: incubator/qpid/branches/qpid.0-9/gentools/templ.cpp/AMQP_ClientOperations.h.tmpl
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/gentools/templ.cpp/AMQP_ClientOperations.h.tmpl?view=diff&rev=501087&r1=501086&r2=501087
==============================================================================
--- incubator/qpid/branches/qpid.0-9/gentools/templ.cpp/AMQP_ClientOperations.h.tmpl (original)
+++ incubator/qpid/branches/qpid.0-9/gentools/templ.cpp/AMQP_ClientOperations.h.tmpl Mon Jan 29 08:13:24 2007
@@ -50,7 +50,7 @@
 
 public:
     AMQP_ClientOperations(u_int8_t major, u_int8_t minor) : version(major, minor) {}
-    AMQP_ClientOperations(ProtocolVersion& version) : version(version) {}
+    AMQP_ClientOperations(const ProtocolVersion& version) : version(version) {}
     virtual ~AMQP_ClientOperations() {}
 
     inline u_int8_t getMajor() const { return version.getMajor(); }
@@ -60,7 +60,7 @@
     {
         return version.equals(_major, _minor);
     }
-    inline bool isVersion(ProtocolVersion& _version) const
+    inline bool isVersion(const ProtocolVersion& _version) const
     {
         return version.equals(_version);
     }

Modified: incubator/qpid/branches/qpid.0-9/gentools/templ.cpp/AMQP_ClientProxy.h.tmpl
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/gentools/templ.cpp/AMQP_ClientProxy.h.tmpl?view=diff&rev=501087&r1=501086&r2=501087
==============================================================================
--- incubator/qpid/branches/qpid.0-9/gentools/templ.cpp/AMQP_ClientProxy.h.tmpl (original)
+++ incubator/qpid/branches/qpid.0-9/gentools/templ.cpp/AMQP_ClientProxy.h.tmpl Mon Jan 29 08:13:24 2007
@@ -47,7 +47,7 @@
 
 public:
     AMQP_ClientProxy(OutputHandler* out, u_int8_t major, u_int8_t minor);
-    ProtocolVersion& getProtocolVersion() {return version;}
+    const ProtocolVersion& getProtocolVersion() {return version;}
     virtual ~AMQP_ClientProxy() {}
 
 	// Get methods for handlers

Modified: incubator/qpid/branches/qpid.0-9/gentools/templ.cpp/AMQP_ServerOperations.h.tmpl
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/gentools/templ.cpp/AMQP_ServerOperations.h.tmpl?view=diff&rev=501087&r1=501086&r2=501087
==============================================================================
--- incubator/qpid/branches/qpid.0-9/gentools/templ.cpp/AMQP_ServerOperations.h.tmpl (original)
+++ incubator/qpid/branches/qpid.0-9/gentools/templ.cpp/AMQP_ServerOperations.h.tmpl Mon Jan 29 08:13:24 2007
@@ -49,7 +49,7 @@
 
 public:
     AMQP_ServerOperations(u_int8_t major, u_int8_t minor) : version(major, minor) {}
-    AMQP_ServerOperations(ProtocolVersion& version) : version(version) {}
+    AMQP_ServerOperations(const ProtocolVersion& version) : version(version) {}
     virtual ~AMQP_ServerOperations() {}
 
     inline u_int8_t getMajor() const { return version.getMajor(); }
@@ -59,7 +59,7 @@
     {
         return version.equals(_major, _minor);
     }
-    inline bool isVersion(ProtocolVersion& _version) const
+    inline bool isVersion(const ProtocolVersion& _version) const
     {
         return version.equals(_version);
     }

Modified: incubator/qpid/branches/qpid.0-9/gentools/templ.cpp/AMQP_ServerProxy.h.tmpl
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/gentools/templ.cpp/AMQP_ServerProxy.h.tmpl?view=diff&rev=501087&r1=501086&r2=501087
==============================================================================
--- incubator/qpid/branches/qpid.0-9/gentools/templ.cpp/AMQP_ServerProxy.h.tmpl (original)
+++ incubator/qpid/branches/qpid.0-9/gentools/templ.cpp/AMQP_ServerProxy.h.tmpl Mon Jan 29 08:13:24 2007
@@ -46,7 +46,7 @@
 
 public:
     AMQP_ServerProxy(OutputHandler* out, u_int8_t major, u_int8_t minor);
-    ProtocolVersion& getProtocolVersion() {return version;}
+    const ProtocolVersion& getProtocolVersion() {return version;}
     virtual ~AMQP_ServerProxy() {}
 
 	// Get methods for handlers

Modified: incubator/qpid/branches/qpid.0-9/gentools/templ.cpp/MethodBodyClass.h.tmpl
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/gentools/templ.cpp/MethodBodyClass.h.tmpl?view=diff&rev=501087&r1=501086&r2=501087
==============================================================================
--- incubator/qpid/branches/qpid.0-9/gentools/templ.cpp/MethodBodyClass.h.tmpl (original)
+++ incubator/qpid/branches/qpid.0-9/gentools/templ.cpp/MethodBodyClass.h.tmpl Mon Jan 29 08:13:24 2007
@@ -46,12 +46,16 @@
  
 class ${CLASS}${METHOD}Body : public ${mb_base_class}
 {
-	// Method field declarations
+
+        // Method field declarations
 
 %{FLIST} ${mb_field_declaration}
      
 
 public:
+    static const ClassId CLASS_ID= ${CLASS_ID_INIT};
+    static const MethodId METHOD_ID = ${METHOD_ID_INIT};
+
     typedef boost::shared_ptr<${CLASS}${METHOD}Body> shared_ptr;
 
 	// Constructors and destructors
@@ -74,15 +78,8 @@
 %{FLIST} ${mb_field_print}
     }
 
-    inline u_int16_t amqpClassId() const
-    {
-    	return ${CLASS_ID_INIT};
-    }
-    
-    inline u_int16_t amqpMethodId() const
-    {
-    	return ${METHOD_ID_INIT};
-    }
+    inline ClassId amqpClassId() const { return CLASS_ID; }
+    inline MethodId amqpMethodId() const { return METHOD_ID; }
 
     u_int32_t size() const
     {