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 2006/12/01 06:11:53 UTC

svn commit: r481159 [8/12] - in /incubator/qpid/trunk/qpid/cpp: ./ build-aux/ gen/ lib/ lib/broker/ lib/client/ lib/common/ lib/common/framing/ lib/common/sys/ lib/common/sys/apr/ lib/common/sys/posix/ m4/ src/ src/qpid/ src/qpid/apr/ src/qpid/broker/ ...

Added: incubator/qpid/trunk/qpid/cpp/lib/client/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/lib/client/Makefile.am?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/lib/client/Makefile.am (added)
+++ incubator/qpid/trunk/qpid/cpp/lib/client/Makefile.am Thu Nov 30 21:11:45 2006
@@ -0,0 +1,31 @@
+AM_CXXFLAGS = $(WARNING_CFLAGS)
+INCLUDES = \
+  -I$(top_srcdir)/gen \
+  -I$(top_srcdir)/lib/common \
+  -I$(top_srcdir)/lib/common/sys \
+  -I$(top_srcdir)/lib/common/framing
+
+lib_LTLIBRARIES = libclient.la
+libclient_la_LDFLAGS = -version-info $(LIBTOOL_VERSION_INFO_ARG)
+libclient_la_SOURCES =				\
+  ClientChannel.cpp				\
+  ClientChannel.h				\
+  ClientExchange.cpp				\
+  ClientExchange.h				\
+  ClientMessage.cpp				\
+  ClientMessage.h				\
+  ClientQueue.cpp				\
+  ClientQueue.h					\
+  Connection.cpp				\
+  Connection.h					\
+  Connector.cpp					\
+  Connector.h					\
+  IncomingMessage.cpp				\
+  IncomingMessage.h				\
+  MessageListener.cpp				\
+  MessageListener.h				\
+  MethodBodyInstances.h				\
+  ResponseHandler.cpp				\
+  ResponseHandler.h				\
+  ReturnedMessageHandler.cpp			\
+  ReturnedMessageHandler.h

Added: incubator/qpid/trunk/qpid/cpp/lib/client/MessageListener.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/lib/client/MessageListener.cpp?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/lib/client/MessageListener.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/lib/client/MessageListener.cpp Thu Nov 30 21:11:45 2006
@@ -0,0 +1,24 @@
+/*
+ *
+ * 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 <MessageListener.h>
+
+qpid::client::MessageListener::~MessageListener() {}

Propchange: incubator/qpid/trunk/qpid/cpp/lib/client/MessageListener.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/lib/client/MessageListener.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/lib/client/MessageListener.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/lib/client/MessageListener.h?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/lib/client/MessageListener.h (added)
+++ incubator/qpid/trunk/qpid/cpp/lib/client/MessageListener.h Thu Nov 30 21:11:45 2006
@@ -0,0 +1,41 @@
+/*
+ *
+ * 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 <string>
+
+#ifndef _MessageListener_
+#define _MessageListener_
+
+#include <ClientMessage.h>
+
+namespace qpid {
+namespace client {
+
+    class MessageListener{
+    public:
+        virtual ~MessageListener();
+	virtual void received(Message& msg) = 0;
+    };
+
+}
+}
+
+
+#endif

Propchange: incubator/qpid/trunk/qpid/cpp/lib/client/MessageListener.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/lib/client/MessageListener.h
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/lib/client/MethodBodyInstances.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/lib/client/MethodBodyInstances.h?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/lib/client/MethodBodyInstances.h (added)
+++ incubator/qpid/trunk/qpid/cpp/lib/client/MethodBodyInstances.h Thu Nov 30 21:11:45 2006
@@ -0,0 +1,101 @@
+/*
+ *
+ * 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 <framing/amqp_framing.h>
+
+/**
+ * This file replaces the auto-generated instances in the former
+ * amqp_methods.h file. Add additional instances as needed.
+ */
+
+#ifndef _MethodBodyInstances_h_
+#define _MethodBodyInstances_h_
+
+namespace qpid {
+namespace client {
+
+class MethodBodyInstances
+{
+private:
+	qpid::framing::ProtocolVersion	version;
+public:
+	const qpid::framing::BasicCancelOkBody		basic_cancel_ok;
+	const qpid::framing::BasicConsumeOkBody		basic_consume_ok;
+	const qpid::framing::BasicDeliverBody		basic_deliver;
+	const qpid::framing::BasicGetEmptyBody		basic_get_empty;
+	const qpid::framing::BasicGetOkBody		basic_get_ok;
+	const qpid::framing::BasicQosOkBody		basic_qos_ok;
+	const qpid::framing::BasicReturnBody		basic_return;
+	const qpid::framing::ChannelCloseBody		channel_close;
+        const qpid::framing::ChannelCloseOkBody		channel_close_ok;
+	const qpid::framing::ChannelFlowBody		channel_flow;
+        const qpid::framing::ChannelOpenOkBody		channel_open_ok;
+        const qpid::framing::ConnectionCloseBody	connection_close;
+        const qpid::framing::ConnectionCloseOkBody	connection_close_ok;
+        const qpid::framing::ConnectionOpenOkBody	connection_open_ok;
+        const qpid::framing::ConnectionRedirectBody	connection_redirect;
+        const qpid::framing::ConnectionStartBody	connection_start;
+        const qpid::framing::ConnectionTuneBody		connection_tune;
+	const qpid::framing::ExchangeDeclareOkBody	exchange_declare_ok;      
+	const qpid::framing::ExchangeDeleteOkBody	exchange_delete_ok;
+	const qpid::framing::QueueDeclareOkBody		queue_declare_ok;
+	const qpid::framing::QueueDeleteOkBody		queue_delete_ok;
+	const qpid::framing::QueueBindOkBody		queue_bind_ok;
+	const qpid::framing::TxCommitOkBody		tx_commit_ok;
+	const qpid::framing::TxRollbackOkBody		tx_rollback_ok;
+	const qpid::framing::TxSelectOkBody		tx_select_ok;
+
+    MethodBodyInstances(u_int8_t major, u_int8_t minor) :
+    	version(major, minor),
+        basic_cancel_ok(version),
+        basic_consume_ok(version),
+        basic_deliver(version),
+        basic_get_empty(version),
+        basic_get_ok(version),
+        basic_qos_ok(version),
+        basic_return(version),
+        channel_close(version),
+        channel_close_ok(version),
+        channel_flow(version),
+        channel_open_ok(version),
+        connection_close(version),
+        connection_close_ok(version),
+        connection_open_ok(version),
+        connection_redirect(version),
+        connection_start(version),
+        connection_tune(version),
+        exchange_declare_ok(version),      
+        exchange_delete_ok(version),
+        queue_declare_ok(version),
+        queue_delete_ok(version),
+        queue_bind_ok(version),
+        tx_commit_ok(version),
+        tx_rollback_ok(version),
+        tx_select_ok(version)
+    {}
+
+};
+
+static MethodBodyInstances method_bodies(8, 0);
+
+} // namespace client
+} // namespace qpid
+
+#endif

Propchange: incubator/qpid/trunk/qpid/cpp/lib/client/MethodBodyInstances.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/lib/client/MethodBodyInstances.h
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/lib/client/ResponseHandler.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/lib/client/ResponseHandler.cpp?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/lib/client/ResponseHandler.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/lib/client/ResponseHandler.cpp Thu Nov 30 21:11:45 2006
@@ -0,0 +1,61 @@
+/*
+ *
+ * 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 <ResponseHandler.h>
+#include <sys/Monitor.h>
+#include <QpidError.h>
+
+using namespace qpid::sys;
+
+qpid::client::ResponseHandler::ResponseHandler() : waiting(false){}
+
+qpid::client::ResponseHandler::~ResponseHandler(){}
+
+bool qpid::client::ResponseHandler::validate(const qpid::framing::AMQMethodBody& expected){
+    return expected.match(response.get());
+}
+
+void qpid::client::ResponseHandler::waitForResponse(){
+    Monitor::ScopedLock l(monitor);
+    if(waiting){
+	monitor.wait();
+    }
+}
+
+void qpid::client::ResponseHandler::signalResponse(qpid::framing::AMQMethodBody::shared_ptr _response){
+    response = _response;
+    Monitor::ScopedLock l(monitor);
+    waiting = false;
+    monitor.notify();
+}
+
+void qpid::client::ResponseHandler::receive(const qpid::framing::AMQMethodBody& expected){
+    Monitor::ScopedLock l(monitor);
+    if(waiting){
+	monitor.wait();
+    }
+    if(!validate(expected)){
+	THROW_QPID_ERROR(PROTOCOL_ERROR, "Protocol Error");
+    }
+}
+
+void qpid::client::ResponseHandler::expect(){
+    waiting = true;
+}

Propchange: incubator/qpid/trunk/qpid/cpp/lib/client/ResponseHandler.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/lib/client/ResponseHandler.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/lib/client/ResponseHandler.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/lib/client/ResponseHandler.h?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/lib/client/ResponseHandler.h (added)
+++ incubator/qpid/trunk/qpid/cpp/lib/client/ResponseHandler.h Thu Nov 30 21:11:45 2006
@@ -0,0 +1,52 @@
+/*
+ *
+ * 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 <string>
+#include <framing/amqp_framing.h>
+#include <sys/Monitor.h>
+
+#ifndef _ResponseHandler_
+#define _ResponseHandler_
+
+namespace qpid {
+    namespace client {
+
+        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
+        };
+
+    }
+}
+
+
+#endif

Propchange: incubator/qpid/trunk/qpid/cpp/lib/client/ResponseHandler.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/lib/client/ResponseHandler.h
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/lib/client/ReturnedMessageHandler.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/lib/client/ReturnedMessageHandler.cpp?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/lib/client/ReturnedMessageHandler.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/lib/client/ReturnedMessageHandler.cpp Thu Nov 30 21:11:45 2006
@@ -0,0 +1,24 @@
+/*
+ *
+ * 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 <ReturnedMessageHandler.h>
+
+qpid::client::ReturnedMessageHandler::~ReturnedMessageHandler() {}

Propchange: incubator/qpid/trunk/qpid/cpp/lib/client/ReturnedMessageHandler.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/lib/client/ReturnedMessageHandler.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/lib/client/ReturnedMessageHandler.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/lib/client/ReturnedMessageHandler.h?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/lib/client/ReturnedMessageHandler.h (added)
+++ incubator/qpid/trunk/qpid/cpp/lib/client/ReturnedMessageHandler.h Thu Nov 30 21:11:45 2006
@@ -0,0 +1,41 @@
+/*
+ *
+ * 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 <string>
+
+#ifndef _ReturnedMessageHandler_
+#define _ReturnedMessageHandler_
+
+#include <ClientMessage.h>
+
+namespace qpid {
+namespace client {
+
+    class ReturnedMessageHandler{
+    public:
+        virtual ~ReturnedMessageHandler();
+	virtual void returned(Message& msg) = 0;
+    };
+
+}
+}
+
+
+#endif

Propchange: incubator/qpid/trunk/qpid/cpp/lib/client/ReturnedMessageHandler.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/lib/client/ReturnedMessageHandler.h
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/lib/common/Exception.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/lib/common/Exception.cpp?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/lib/common/Exception.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/lib/common/Exception.cpp Thu Nov 30 21:11:45 2006
@@ -0,0 +1,42 @@
+/*
+ *
+ * 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 <Exception.h>
+
+namespace qpid {
+
+Exception::Exception() throw() {}
+
+Exception::Exception(const std::string& str) throw() : whatStr(str) {}
+
+Exception::Exception(const char* str) throw() : whatStr(str) {}
+
+Exception::~Exception() throw() {}
+
+const char* Exception::what() const throw() { return whatStr.c_str(); }
+
+std::string Exception::toString() const throw() { return whatStr; }
+
+Exception* Exception::clone() const throw() { return new Exception(*this); }
+
+void Exception::throwSelf() const  { throw *this; }
+
+} // namespace qpid

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/Exception.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/Exception.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/lib/common/Exception.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/lib/common/Exception.h?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/lib/common/Exception.h (added)
+++ incubator/qpid/trunk/qpid/cpp/lib/common/Exception.h Thu Nov 30 21:11:45 2006
@@ -0,0 +1,61 @@
+#ifndef _Exception_
+#define _Exception_
+
+/*
+ *
+ * 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 <exception>
+#include <string>
+#include <memory>
+#include <boost/shared_ptr.hpp>
+
+namespace qpid
+{
+/**
+ * Exception base class for all Qpid exceptions.
+ */
+class Exception : public std::exception
+{
+  protected:
+    std::string whatStr;
+
+  public:
+    Exception() throw();
+    Exception(const std::string& str) throw();
+    Exception(const char* str) throw();
+    Exception(const std::exception&) throw();
+
+    virtual ~Exception() throw();
+
+    virtual const char* what() const throw();
+    virtual std::string toString() const throw();
+
+    virtual Exception* clone() const throw();
+    virtual void throwSelf() const;
+
+    typedef boost::shared_ptr<Exception> shared_ptr;
+};
+
+
+
+}
+
+#endif  /*!_Exception_*/

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/Exception.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/Exception.h
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/lib/common/ExceptionHolder.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/lib/common/ExceptionHolder.cpp?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/lib/common/ExceptionHolder.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/lib/common/ExceptionHolder.cpp Thu Nov 30 21:11:45 2006
@@ -0,0 +1,32 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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 "ExceptionHolder.h"
+
+namespace qpid {
+
+ExceptionHolder::ExceptionHolder(const std::exception& e) {
+    const Exception* ex = dynamic_cast<const Exception*>(&e);
+    if (ex) {
+        reset(ex->clone());
+    } else {
+        reset(new Exception(e.what()));
+    }
+}
+
+}

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/ExceptionHolder.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/ExceptionHolder.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/lib/common/ExceptionHolder.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/lib/common/ExceptionHolder.h?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/lib/common/ExceptionHolder.h (added)
+++ incubator/qpid/trunk/qpid/cpp/lib/common/ExceptionHolder.h Thu Nov 30 21:11:45 2006
@@ -0,0 +1,62 @@
+#ifndef _qpid_ExceptionHolder_h
+#define _qpid_ExceptionHolder_h
+
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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 <Exception.h>
+#include <boost/shared_ptr.hpp>
+
+namespace qpid {
+
+/**
+ * Holder for a heap-allocated exc eption that can be stack allocated
+ * and thrown safely.
+ *
+ * Basically this is a shared_ptr with the Exception functions added
+ * so the catcher need not be aware that it is a pointer rather than a
+ * reference.
+ * 
+ * shared_ptr is chosen over auto_ptr because it has normal 
+ * copy semantics. 
+ */
+class ExceptionHolder : public Exception, public boost::shared_ptr<Exception>
+{
+  public:
+    typedef boost::shared_ptr<Exception> shared_ptr;
+
+    ExceptionHolder() throw() {}
+    ExceptionHolder(Exception* p) throw() : shared_ptr(p) {}
+    ExceptionHolder(shared_ptr p) throw() : shared_ptr(p) {}
+
+    ExceptionHolder(const Exception& e) throw() : shared_ptr(e.clone()) {}
+    ExceptionHolder(const std::exception& e);
+
+    ~ExceptionHolder() throw() {}
+
+    const char* what() const throw() { return (*this)->what(); }
+    std::string toString() const throw() { return (*this)->toString(); }
+    virtual Exception* clone() const throw() { return (*this)->clone(); }
+    virtual void throwSelf() const { (*this)->throwSelf(); }
+};
+
+} // namespace qpid
+
+
+
+#endif  /*!_qpid_ExceptionHolder_h*/

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/ExceptionHolder.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/ExceptionHolder.h
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/lib/common/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/lib/common/Makefile.am?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/lib/common/Makefile.am (added)
+++ incubator/qpid/trunk/qpid/cpp/lib/common/Makefile.am Thu Nov 30 21:11:45 2006
@@ -0,0 +1,109 @@
+AM_CXXFLAGS = $(WARNING_CFLAGS)
+INCLUDES = \
+  -I$(top_srcdir)/gen \
+  -I$(top_srcdir)/lib/common/sys \
+  -I$(top_srcdir)/lib/common/framing
+
+# This is a kludge to include the contents of the apr/ directory.
+# For now, we don't use it.
+EXTRA_DIST =			\
+  sys/apr/APRAcceptor.cpp	\
+  sys/apr/APRBase.cpp		\
+  sys/apr/APRBase.h		\
+  sys/apr/APRPool.cpp		\
+  sys/apr/APRPool.h		\
+  sys/apr/APRSocket.cpp		\
+  sys/apr/APRSocket.h		\
+  sys/apr/LFProcessor.cpp	\
+  sys/apr/LFProcessor.h		\
+  sys/apr/LFSessionContext.cpp	\
+  sys/apr/LFSessionContext.h	\
+  sys/apr/Socket.cpp		\
+  sys/apr/Thread.cpp
+
+
+framing = framing
+posix   = sys/posix
+gen     = $(srcdir)/../../gen
+
+lib_LTLIBRARIES = libcommon.la
+libcommon_la_LIBADD =		\
+  $(LIB_DLOPEN)			\
+  $(LIB_CLOCK_GETTIME)
+
+libcommon_la_LDFLAGS =		\
+  -version-info			\
+  $(LIBTOOL_VERSION_INFO_ARG)
+
+libcommon_la_SOURCES =				\
+  $(framing)/AMQBody.cpp			\
+  $(framing)/AMQBody.h				\
+  $(framing)/AMQContentBody.cpp			\
+  $(framing)/AMQContentBody.h			\
+  $(framing)/AMQDataBlock.h			\
+  $(framing)/AMQFrame.cpp			\
+  $(framing)/AMQFrame.h				\
+  $(framing)/AMQHeaderBody.cpp			\
+  $(framing)/AMQHeaderBody.h			\
+  $(framing)/AMQHeartbeatBody.cpp		\
+  $(framing)/AMQHeartbeatBody.h			\
+  $(framing)/AMQMethodBody.cpp			\
+  $(framing)/AMQMethodBody.h			\
+  $(framing)/BasicHeaderProperties.cpp		\
+  $(framing)/BasicHeaderProperties.h		\
+  $(framing)/BodyHandler.cpp			\
+  $(framing)/BodyHandler.h			\
+  $(framing)/Buffer.cpp				\
+  $(framing)/Buffer.h				\
+  $(framing)/FieldTable.cpp			\
+  $(framing)/FieldTable.h			\
+  $(framing)/HeaderProperties.h			\
+  $(framing)/InitiationHandler.cpp		\
+  $(framing)/InitiationHandler.h		\
+  $(framing)/InputHandler.h			\
+  $(framing)/OutputHandler.h			\
+  $(framing)/ProtocolInitiation.cpp		\
+  $(framing)/ProtocolInitiation.h		\
+  $(framing)/ProtocolVersion.cpp		\
+  $(framing)/ProtocolVersion.h			\
+  $(framing)/ProtocolVersionException.cpp	\
+  $(framing)/ProtocolVersionException.h		\
+  $(framing)/Value.cpp				\
+  $(framing)/Value.h				\
+  $(framing)/amqp_framing.h			\
+  $(framing)/amqp_types.h			\
+  $(gen)/AMQP_ClientProxy.cpp			\
+  $(gen)/AMQP_MethodVersionMap.cpp		\
+  $(gen)/AMQP_ServerProxy.cpp			\
+  $(posix)/PosixAcceptor.cpp			\
+  $(posix)/Socket.cpp				\
+  $(posix)/Thread.cpp				\
+  $(posix)/check.cpp				\
+  $(posix)/check.h				\
+  $(posix)/EventChannel.cpp			\
+  $(posix)/EventChannel.h			\
+  $(posix)/EventChannelThreads.cpp		\
+  $(posix)/EventChannelThreads.h		\
+  Exception.cpp					\
+  Exception.h					\
+  ExceptionHolder.cpp				\
+  ExceptionHolder.h				\
+  QpidError.cpp					\
+  QpidError.h					\
+  SharedObject.h				\
+  sys/Acceptor.h				\
+  sys/AtomicCount.h				\
+  sys/Module.h					\
+  sys/Monitor.h					\
+  sys/Mutex.h					\
+  sys/Runnable.cpp				\
+  sys/Runnable.h				\
+  sys/SessionContext.h				\
+  sys/SessionHandler.h				\
+  sys/SessionHandlerFactory.h			\
+  sys/ShutdownHandler.h				\
+  sys/Socket.h					\
+  sys/Thread.h					\
+  sys/Time.cpp					\
+  sys/Time.h					\
+  sys/TimeoutHandler.h

Added: incubator/qpid/trunk/qpid/cpp/lib/common/QpidError.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/lib/common/QpidError.cpp?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/lib/common/QpidError.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/lib/common/QpidError.cpp Thu Nov 30 21:11:45 2006
@@ -0,0 +1,44 @@
+/*
+ *
+ * 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 <QpidError.h>
+#include <sstream>
+
+using namespace qpid;
+
+QpidError::QpidError() : code(0) {}
+
+QpidError::QpidError(int _code, const std::string& _msg,
+                     const SrcLine& _loc) throw()
+    : code(_code), msg(_msg), location(_loc)
+{
+    std::ostringstream os;
+    os << "Error [" << code << "] " << msg << " ("
+       << location.file << ":" << location.line << ")";
+    whatStr = os.str();
+}
+
+QpidError::~QpidError() throw() {}
+
+Exception* QpidError::clone() const throw() { return new QpidError(*this); }
+
+void QpidError::throwSelf() const  { throw *this; }
+

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/QpidError.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/QpidError.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/lib/common/QpidError.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/lib/common/QpidError.h?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/lib/common/QpidError.h (added)
+++ incubator/qpid/trunk/qpid/cpp/lib/common/QpidError.h Thu Nov 30 21:11:45 2006
@@ -0,0 +1,67 @@
+#ifndef __QpidError__
+#define __QpidError__
+/*
+ *
+ * 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 <string>
+#include <memory>
+#include <ostream>
+#include <Exception.h>
+
+namespace qpid {
+
+struct SrcLine {
+  public:
+    SrcLine(const std::string& file_="", int line_=0) :
+        file(file_), line(line_) {}
+
+    std::string file;
+    int line;
+};
+    
+class QpidError : public Exception { 
+  public:
+    const int code;
+    const std::string msg;
+    const SrcLine location;
+
+    QpidError();
+    QpidError(int _code, const std::string& _msg, const SrcLine& _loc) throw();
+    ~QpidError() throw();
+    Exception* clone() const throw();
+    void throwSelf() const;
+};
+
+
+} // namespace qpid
+
+#define SRCLINE ::qpid::SrcLine(__FILE__, __LINE__)
+
+#define QPID_ERROR(CODE, MESSAGE) ::qpid::QpidError((CODE), (MESSAGE), SRCLINE)
+
+#define THROW_QPID_ERROR(CODE, MESSAGE) throw QPID_ERROR(CODE,MESSAGE)
+
+const int PROTOCOL_ERROR = 10000;
+const int APR_ERROR = 20000;
+const int FRAMING_ERROR = 30000;
+const int CLIENT_ERROR = 40000;
+const int INTERNAL_ERROR = 50000;
+
+#endif

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/QpidError.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/QpidError.h
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/lib/common/SharedObject.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/lib/common/SharedObject.h?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/lib/common/SharedObject.h (added)
+++ incubator/qpid/trunk/qpid/cpp/lib/common/SharedObject.h Thu Nov 30 21:11:45 2006
@@ -0,0 +1,55 @@
+#ifndef _SharedObject_
+#define _SharedObject_
+
+/*
+ *
+ * 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 <boost/shared_ptr.hpp>
+#include <boost/noncopyable.hpp>
+
+namespace qpid {
+    /**
+     * Template to enforce shared object conventions.
+     * Shared object classes should inherit : public qpid::SharedObject
+     * That ensures Foo:
+     * - has typedef boost::shared_ptr<T> shared_ptr
+     * - has virtual destructor
+     * - is boost::noncopyable (no default copy or assign)
+     * - has a protected default constructor.
+     *
+     * Shared objects should not have public constructors.
+     * Make constructors protected and provide public statc create()
+     * functions that return a shared_ptr.
+     */
+    template <class T>
+    class SharedObject : private boost::noncopyable
+    {
+      public:
+        typedef boost::shared_ptr<T> shared_ptr;
+
+        virtual ~SharedObject() {};
+
+      protected:
+        SharedObject() {} 
+    };
+}
+
+#endif  /*!_SharedObject_*/

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/SharedObject.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/SharedObject.h
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQBody.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQBody.cpp?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQBody.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQBody.cpp Thu Nov 30 21:11:45 2006
@@ -0,0 +1,36 @@
+/*
+ *
+ * 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 <AMQBody.h>
+#include <iostream>
+
+std::ostream& qpid::framing::operator<<(std::ostream& out, const qpid::framing::AMQBody& body) 
+{
+    body.print(out);
+    return out;
+}
+        
+
+qpid::framing::AMQBody::~AMQBody() {}
+
+void qpid::framing::AMQBody::print(std::ostream& out) const {
+    out << "unknown body";
+}

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQBody.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQBody.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQBody.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQBody.h?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQBody.h (added)
+++ incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQBody.h Thu Nov 30 21:11:45 2006
@@ -0,0 +1,51 @@
+/*
+ *
+ * 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 <boost/shared_ptr.hpp>
+#include <amqp_types.h>
+#include <Buffer.h>
+
+#ifndef _AMQBody_
+#define _AMQBody_
+
+namespace qpid {
+    namespace framing {
+
+        class AMQBody
+        {
+          public:
+            typedef boost::shared_ptr<AMQBody> shared_ptr;
+
+            virtual ~AMQBody();
+            virtual u_int32_t size() const = 0;
+            virtual u_int8_t type() const = 0;
+            virtual void encode(Buffer& buffer) const = 0;
+            virtual void decode(Buffer& buffer, u_int32_t size) = 0;
+            virtual void print(std::ostream& out) const;
+        };
+
+        std::ostream& operator<<(std::ostream& out, const AMQBody& body) ;
+
+        enum body_types {METHOD_BODY = 1, HEADER_BODY = 2, CONTENT_BODY = 3, HEARTBEAT_BODY = 8};
+    }
+}
+
+
+#endif

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQBody.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQBody.h
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQContentBody.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQContentBody.cpp?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQContentBody.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQContentBody.cpp Thu Nov 30 21:11:45 2006
@@ -0,0 +1,43 @@
+/*
+ *
+ * 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 <AMQContentBody.h>
+#include <iostream>
+
+qpid::framing::AMQContentBody::AMQContentBody(){
+}
+
+qpid::framing::AMQContentBody::AMQContentBody(const string& _data) : data(_data){
+}
+
+u_int32_t qpid::framing::AMQContentBody::size() const{
+    return data.size();
+}
+void qpid::framing::AMQContentBody::encode(Buffer& buffer) const{
+    buffer.putRawData(data);
+}
+void qpid::framing::AMQContentBody::decode(Buffer& buffer, u_int32_t _size){
+    buffer.getRawData(data, _size);
+}
+
+void qpid::framing::AMQContentBody::print(std::ostream& out) const
+{
+    out << "content (" << size() << " bytes)";
+}

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQContentBody.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQContentBody.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQContentBody.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQContentBody.h?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQContentBody.h (added)
+++ incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQContentBody.h Thu Nov 30 21:11:45 2006
@@ -0,0 +1,53 @@
+/*
+ *
+ * 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 <amqp_types.h>
+#include <AMQBody.h>
+#include <Buffer.h>
+
+#ifndef _AMQContentBody_
+#define _AMQContentBody_
+
+namespace qpid {
+namespace framing {
+
+class AMQContentBody : virtual public AMQBody
+{
+    string data;
+
+public:
+    typedef boost::shared_ptr<AMQContentBody> shared_ptr;
+
+    AMQContentBody();
+    AMQContentBody(const string& data);
+    inline virtual ~AMQContentBody(){}
+    inline u_int8_t type() const { return CONTENT_BODY; };
+    inline string& getData(){ return data; }
+    u_int32_t size() const;
+    void encode(Buffer& buffer) const;
+    void decode(Buffer& buffer, u_int32_t size);
+    void print(std::ostream& out) const;
+};
+
+}
+}
+
+
+#endif

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQContentBody.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQContentBody.h
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQDataBlock.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQDataBlock.h?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQDataBlock.h (added)
+++ incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQDataBlock.h Thu Nov 30 21:11:45 2006
@@ -0,0 +1,42 @@
+/*
+ *
+ * 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 <Buffer.h>
+
+#ifndef _AMQDataBlock_
+#define _AMQDataBlock_
+
+namespace qpid {
+namespace framing {
+
+class AMQDataBlock
+{
+public:
+    virtual ~AMQDataBlock() {}
+    virtual void encode(Buffer& buffer) = 0; 
+    virtual bool decode(Buffer& buffer) = 0; 
+    virtual u_int32_t size() const = 0;
+};
+
+}
+}
+
+
+#endif

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQDataBlock.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQDataBlock.h
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQFrame.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQFrame.cpp?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQFrame.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQFrame.cpp Thu Nov 30 21:11:45 2006
@@ -0,0 +1,138 @@
+
+/*
+ *
+ * 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 <AMQFrame.h>
+#include <QpidError.h>
+
+using namespace qpid::framing;
+
+// This only works as a static as the version is currently fixed to 8.0
+// TODO: When the class is version-aware this will need to change
+AMQP_MethodVersionMap AMQFrame::versionMap(8,0);
+
+// AMQP version management change - kpvdr 2-11-17
+// TODO: Make this class version-aware
+AMQFrame::AMQFrame() {}
+
+// AMQP version management change - kpvdr 2006-11-17
+// TODO: Make this class version-aware
+AMQFrame::AMQFrame(u_int16_t _channel, AMQBody* _body) :
+channel(_channel), body(_body)
+{}
+
+// AMQP version management change - kpvdr 2006-11-17
+// TODO: Make this class version-aware
+AMQFrame::AMQFrame(u_int16_t _channel, AMQBody::shared_ptr& _body) :
+channel(_channel), body(_body)
+{}
+
+AMQFrame::~AMQFrame() {}
+
+u_int16_t AMQFrame::getChannel(){
+    return channel;
+}
+
+AMQBody::shared_ptr& AMQFrame::getBody(){
+    return body;
+}
+
+void AMQFrame::encode(Buffer& buffer)
+{
+    buffer.putOctet(body->type());
+    buffer.putShort(channel);    
+    buffer.putLong(body->size());
+    body->encode(buffer);
+    buffer.putOctet(0xCE);
+}
+
+AMQBody::shared_ptr AMQFrame::createMethodBody(Buffer& buffer){
+    u_int16_t classId = buffer.getShort();
+    u_int16_t methodId = buffer.getShort();
+    // AMQP version management change - kpvdr 2006-11-16
+    // TODO: Make this class version-aware and link these hard-wired numbers to that version
+    AMQBody::shared_ptr body(versionMap.createMethodBody(classId, methodId, 8, 0));
+    // Origianl stmt:
+	// AMQBody::shared_ptr body(createAMQMethodBody(classId, methodId));
+    return body;
+}
+
+u_int32_t AMQFrame::size() const{
+    if(!body.get()) THROW_QPID_ERROR(INTERNAL_ERROR, "Attempt to get size of frame with no body set!");
+    return 1/*type*/ + 2/*channel*/ + 4/*body size*/ + body->size() + 1/*0xCE*/;
+}
+
+bool AMQFrame::decode(Buffer& buffer)
+{    
+    if(buffer.available() < 7) return false;
+    buffer.record();
+    u_int32_t bufSize = decodeHead(buffer);
+
+    if(buffer.available() < bufSize + 1){
+        buffer.restore();
+        return false;
+    }
+    decodeBody(buffer, bufSize);
+    u_int8_t end = buffer.getOctet();
+    if(end != 0xCE) THROW_QPID_ERROR(FRAMING_ERROR, "Frame end not found");
+    return true;
+}
+
+u_int32_t AMQFrame::decodeHead(Buffer& buffer){    
+    type = buffer.getOctet();
+    channel = buffer.getShort();
+    return buffer.getLong();
+}
+
+void AMQFrame::decodeBody(Buffer& buffer, uint32_t bufSize)
+{    
+    switch(type)
+    {
+    case METHOD_BODY:
+	body = createMethodBody(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;
+    default:
+	string msg("Unknown body type: ");
+	msg += type;
+	THROW_QPID_ERROR(FRAMING_ERROR, msg);
+    }
+    body->decode(buffer, bufSize);
+}
+
+std::ostream& qpid::framing::operator<<(std::ostream& out, const AMQFrame& t)
+{
+    out << "Frame[channel=" << t.channel << "; ";
+    if (t.body.get() == 0)
+        out << "empty";
+    else
+        out << *t.body;
+    out << "]";
+    return out;
+}
+

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQFrame.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQFrame.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQFrame.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQFrame.h?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQFrame.h (added)
+++ incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQFrame.h Thu Nov 30 21:11:45 2006
@@ -0,0 +1,68 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+/*#include <qpid/framing/amqp_methods.h>*/
+#include <amqp_types.h>
+#include <AMQBody.h>
+#include <AMQDataBlock.h>
+#include <AMQMethodBody.h>
+#include <AMQHeaderBody.h>
+#include <AMQContentBody.h>
+#include <AMQHeartbeatBody.h>
+#include <AMQP_MethodVersionMap.h>
+#include <Buffer.h>
+
+#ifndef _AMQFrame_
+#define _AMQFrame_
+
+namespace qpid {
+    namespace framing {
+
+        class AMQFrame : virtual public AMQDataBlock
+        {
+            static AMQP_MethodVersionMap versionMap;
+            
+            u_int16_t channel;
+            u_int8_t type;//used if the body is decoded separately from the 'head'
+            AMQBody::shared_ptr body;
+			AMQBody::shared_ptr createMethodBody(Buffer& buffer);
+            
+        public:
+            AMQFrame();
+            AMQFrame(u_int16_t channel, AMQBody* body);
+            AMQFrame(u_int16_t channel, AMQBody::shared_ptr& body);
+            virtual ~AMQFrame();
+            virtual void encode(Buffer& buffer); 
+            virtual bool decode(Buffer& buffer); 
+            virtual u_int32_t size() const;
+            u_int16_t getChannel();
+            AMQBody::shared_ptr& getBody();
+
+            u_int32_t decodeHead(Buffer& buffer); 
+            void decodeBody(Buffer& buffer, uint32_t size); 
+
+            friend std::ostream& operator<<(std::ostream& out, const AMQFrame& body);
+        };
+
+    }
+}
+
+
+#endif

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQFrame.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQFrame.h
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQHeaderBody.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQHeaderBody.cpp?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQHeaderBody.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQHeaderBody.cpp Thu Nov 30 21:11:45 2006
@@ -0,0 +1,75 @@
+/*
+ *
+ * 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 <AMQHeaderBody.h>
+#include <QpidError.h>
+#include <BasicHeaderProperties.h>
+
+qpid::framing::AMQHeaderBody::AMQHeaderBody(int classId) : weight(0), contentSize(0){
+    createProperties(classId);
+}
+
+qpid::framing::AMQHeaderBody::AMQHeaderBody() : properties(0), weight(0), contentSize(0){
+}
+
+qpid::framing::AMQHeaderBody::~AMQHeaderBody(){ 
+    delete properties;
+}
+
+u_int32_t qpid::framing::AMQHeaderBody::size() const{
+    return 12 + properties->size();
+}
+
+void qpid::framing::AMQHeaderBody::encode(Buffer& buffer) const {
+    buffer.putShort(properties->classId());
+    buffer.putShort(weight);
+    buffer.putLongLong(contentSize);
+    properties->encode(buffer);
+}
+
+void qpid::framing::AMQHeaderBody::decode(Buffer& buffer, u_int32_t bufSize){
+    u_int16_t classId = buffer.getShort();
+    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");
+    }
+}
+
+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();
+    }
+}

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQHeaderBody.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQHeaderBody.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQHeaderBody.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQHeaderBody.h?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQHeaderBody.h (added)
+++ incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQHeaderBody.h Thu Nov 30 21:11:45 2006
@@ -0,0 +1,60 @@
+/*
+ *
+ * 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 <amqp_types.h>
+#include <AMQBody.h>
+#include <Buffer.h>
+#include <HeaderProperties.h>
+
+#ifndef _AMQHeaderBody_
+#define _AMQHeaderBody_
+
+namespace qpid {
+namespace framing {
+
+class AMQHeaderBody : virtual public AMQBody
+{
+    HeaderProperties* properties;
+    u_int16_t weight;
+    u_int64_t contentSize;
+
+    void createProperties(int classId);
+public:
+    typedef boost::shared_ptr<AMQHeaderBody> shared_ptr;
+
+    AMQHeaderBody(int classId);
+    AMQHeaderBody();
+    inline u_int8_t type() const { return HEADER_BODY; }
+    HeaderProperties* getProperties(){ return properties; }
+    const HeaderProperties* getProperties() const { return properties; }
+    inline u_int64_t getContentSize() const { return contentSize; }
+    inline void setContentSize(u_int64_t _size) { contentSize = _size; }
+    virtual ~AMQHeaderBody();
+    virtual u_int32_t size() const;
+    virtual void encode(Buffer& buffer) const;
+    virtual void decode(Buffer& buffer, u_int32_t size);
+    virtual void print(std::ostream& out) const;
+};
+
+}
+}
+
+
+#endif

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQHeaderBody.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQHeaderBody.h
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQHeartbeatBody.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQHeartbeatBody.cpp?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQHeartbeatBody.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQHeartbeatBody.cpp Thu Nov 30 21:11:45 2006
@@ -0,0 +1,29 @@
+/*
+ *
+ * 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 <AMQHeartbeatBody.h>
+#include <iostream>
+
+qpid::framing::AMQHeartbeatBody::~AMQHeartbeatBody() {}
+
+void qpid::framing::AMQHeartbeatBody::print(std::ostream& out) const {
+    out << "heartbeat";
+}

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQHeartbeatBody.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQHeartbeatBody.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQHeartbeatBody.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQHeartbeatBody.h?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQHeartbeatBody.h (added)
+++ incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQHeartbeatBody.h Thu Nov 30 21:11:45 2006
@@ -0,0 +1,47 @@
+/*
+ *
+ * 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 <amqp_types.h>
+#include <AMQBody.h>
+#include <Buffer.h>
+
+#ifndef _AMQHeartbeatBody_
+#define _AMQHeartbeatBody_
+
+namespace qpid {
+namespace framing {
+
+class AMQHeartbeatBody : virtual public AMQBody
+{
+public:
+    typedef boost::shared_ptr<AMQHeartbeatBody> shared_ptr;
+
+    virtual ~AMQHeartbeatBody();
+    inline u_int32_t size() const { return 0; }
+    inline u_int8_t type() const { return HEARTBEAT_BODY; }
+    inline void encode(Buffer& ) const {}
+    inline void decode(Buffer& , u_int32_t /*size*/) {}
+    virtual void print(std::ostream& out) const;
+};
+
+}
+}
+
+#endif

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQHeartbeatBody.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQHeartbeatBody.h
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQMethodBody.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQMethodBody.cpp?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQMethodBody.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQMethodBody.cpp Thu Nov 30 21:11:45 2006
@@ -0,0 +1,46 @@
+/*
+ *
+ * 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 <AMQMethodBody.h>
+#include <QpidError.h>
+
+void qpid::framing::AMQMethodBody::encode(Buffer& buffer) const{
+    buffer.putShort(amqpClassId());
+    buffer.putShort(amqpMethodId());
+    encodeContent(buffer);
+}
+
+void qpid::framing::AMQMethodBody::decode(Buffer& buffer, u_int32_t /*size*/){
+    decodeContent(buffer);
+}
+
+bool qpid::framing::AMQMethodBody::match(AMQMethodBody* other) const{
+    return other != 0 && other->amqpClassId() == amqpClassId() && other->amqpMethodId() == amqpMethodId();
+}
+
+void qpid::framing::AMQMethodBody::invoke(AMQP_ServerOperations& /*target*/, u_int16_t /*channel*/){
+    THROW_QPID_ERROR(PROTOCOL_ERROR, "Method not supported by AMQP Server.");
+}
+
+
+std::ostream& qpid::framing::operator<<(std::ostream& out, const AMQMethodBody& m){
+    m.print(out);
+    return out;
+}

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQMethodBody.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQMethodBody.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQMethodBody.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQMethodBody.h?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQMethodBody.h (added)
+++ incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQMethodBody.h Thu Nov 30 21:11:45 2006
@@ -0,0 +1,62 @@
+/*
+ *
+ * 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 <iostream>
+#include <amqp_types.h>
+#include <AMQBody.h>
+#include <Buffer.h>
+#include <AMQP_ServerOperations.h>
+
+#ifndef _AMQMethodBody_
+#define _AMQMethodBody_
+
+namespace qpid {
+namespace framing {
+
+class AMQMethodBody : virtual public AMQBody
+{
+public:
+    typedef boost::shared_ptr<AMQMethodBody> shared_ptr;
+
+	ProtocolVersion version;
+    inline u_int8_t type() const { return METHOD_BODY; }
+    inline u_int32_t size() const { return 4 + bodySize(); }
+    inline AMQMethodBody(u_int8_t major, u_int8_t minor) : version(major, minor) {}
+    inline AMQMethodBody(ProtocolVersion version) : version(version) {}
+    inline virtual ~AMQMethodBody() {}
+    virtual void print(std::ostream& out) const = 0;
+    virtual u_int16_t amqpMethodId() const = 0;
+    virtual u_int16_t amqpClassId() const = 0;
+    virtual void invoke(AMQP_ServerOperations& target, u_int16_t channel);
+    virtual void encodeContent(Buffer& buffer) const = 0;
+    virtual void decodeContent(Buffer& buffer) = 0;
+    virtual u_int32_t bodySize() const = 0;
+    void encode(Buffer& buffer) const;
+    void decode(Buffer& buffer, u_int32_t size);
+    bool match(AMQMethodBody* other) const;
+};
+
+std::ostream& operator<<(std::ostream& out, const AMQMethodBody& body);
+
+}
+}
+
+
+#endif

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQMethodBody.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/framing/AMQMethodBody.h
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/lib/common/framing/BasicHeaderProperties.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/lib/common/framing/BasicHeaderProperties.cpp?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/lib/common/framing/BasicHeaderProperties.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/lib/common/framing/BasicHeaderProperties.cpp Thu Nov 30 21:11:45 2006
@@ -0,0 +1,103 @@
+/*
+ *
+ * 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 <BasicHeaderProperties.h>
+
+//TODO: This could be easily generated from the spec
+
+qpid::framing::BasicHeaderProperties::BasicHeaderProperties() : deliveryMode(0), priority(0), timestamp(0){}
+qpid::framing::BasicHeaderProperties::~BasicHeaderProperties(){}
+
+u_int32_t qpid::framing::BasicHeaderProperties::size() const{
+    u_int32_t bytes = 2;//flags
+    if(contentType.length() > 0) bytes += contentType.length() + 1;
+    if(contentEncoding.length() > 0) bytes += contentEncoding.length() + 1;
+    if(headers.count() > 0) bytes += headers.size();
+    if(deliveryMode != 0) bytes += 1;
+    if(priority != 0) bytes += 1;
+    if(correlationId.length() > 0) bytes += correlationId.length() + 1;
+    if(replyTo.length() > 0) bytes += replyTo.length() + 1;
+    if(expiration.length() > 0) bytes += expiration.length() + 1;
+    if(messageId.length() > 0) bytes += messageId.length() + 1;
+    if(timestamp != 0) bytes += 8;
+    if(type.length() > 0) bytes += type.length() + 1;
+    if(userId.length() > 0) bytes += userId.length() + 1;
+    if(appId.length() > 0) bytes += appId.length() + 1;
+    if(clusterId.length() > 0) bytes += clusterId.length() + 1;
+
+    return bytes;
+}
+
+void qpid::framing::BasicHeaderProperties::encode(qpid::framing::Buffer& buffer) const{
+    u_int16_t flags = getFlags();
+    buffer.putShort(flags);
+    
+    if(contentType.length() > 0) buffer.putShortString(contentType);
+    if(contentEncoding.length() > 0) buffer.putShortString(contentEncoding);
+    if(headers.count() > 0) buffer.putFieldTable(headers);
+    if(deliveryMode != 0) buffer.putOctet(deliveryMode);
+    if(priority != 0) buffer.putOctet(priority);
+    if(correlationId.length() > 0) buffer.putShortString(correlationId);
+    if(replyTo.length() > 0) buffer.putShortString(replyTo);
+    if(expiration.length() > 0) buffer.putShortString(expiration);
+    if(messageId.length() > 0) buffer.putShortString(messageId);
+    if(timestamp != 0) buffer.putLongLong(timestamp);;
+    if(type.length() > 0) buffer.putShortString(type);
+    if(userId.length() > 0) buffer.putShortString(userId);
+    if(appId.length() > 0) buffer.putShortString(appId);
+    if(clusterId.length() > 0) buffer.putShortString(clusterId);    
+}
+
+void qpid::framing::BasicHeaderProperties::decode(qpid::framing::Buffer& buffer, u_int32_t /*size*/){
+    u_int16_t flags = buffer.getShort();
+    if(flags & (1 << 15)) buffer.getShortString(contentType);
+    if(flags & (1 << 14)) buffer.getShortString(contentEncoding);
+    if(flags & (1 << 13)) buffer.getFieldTable(headers);
+    if(flags & (1 << 12)) deliveryMode = buffer.getOctet();
+    if(flags & (1 << 11)) priority = buffer.getOctet();
+    if(flags & (1 << 10)) buffer.getShortString(correlationId);
+    if(flags & (1 <<  9)) buffer.getShortString(replyTo);
+    if(flags & (1 <<  8)) buffer.getShortString(expiration);
+    if(flags & (1 <<  7)) buffer.getShortString(messageId);
+    if(flags & (1 <<  6)) timestamp = buffer.getLongLong();
+    if(flags & (1 <<  5)) buffer.getShortString(type);
+    if(flags & (1 <<  4)) buffer.getShortString(userId);
+    if(flags & (1 <<  3)) buffer.getShortString(appId);
+    if(flags & (1 <<  2)) buffer.getShortString(clusterId);    
+}
+
+u_int16_t qpid::framing::BasicHeaderProperties::getFlags() const{
+    u_int16_t flags(0);
+    if(contentType.length() > 0)     flags |= (1 << 15);
+    if(contentEncoding.length() > 0) flags |= (1 << 14);
+    if(headers.count() > 0)          flags |= (1 << 13);
+    if(deliveryMode != 0)            flags |= (1 << 12);
+    if(priority != 0)                flags |= (1 << 11);
+    if(correlationId.length() > 0)   flags |= (1 << 10); 
+    if(replyTo.length() > 0)         flags |= (1 <<  9);
+    if(expiration.length() > 0)      flags |= (1 <<  8);
+    if(messageId.length() > 0)       flags |= (1 <<  7);
+    if(timestamp != 0)               flags |= (1 <<  6);
+    if(type.length() > 0)            flags |= (1 <<  5);
+    if(userId.length() > 0)          flags |= (1 <<  4);
+    if(appId.length() > 0)           flags |= (1 <<  3);
+    if(clusterId.length() > 0)       flags |= (1 <<  2);
+    return flags;
+}

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/framing/BasicHeaderProperties.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/framing/BasicHeaderProperties.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/lib/common/framing/BasicHeaderProperties.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/lib/common/framing/BasicHeaderProperties.h?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/lib/common/framing/BasicHeaderProperties.h (added)
+++ incubator/qpid/trunk/qpid/cpp/lib/common/framing/BasicHeaderProperties.h Thu Nov 30 21:11:45 2006
@@ -0,0 +1,97 @@
+/*
+ *
+ * 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 <amqp_types.h>
+#include <Buffer.h>
+#include <FieldTable.h>
+#include <HeaderProperties.h>
+
+#ifndef _BasicHeaderProperties_
+#define _BasicHeaderProperties_
+
+namespace qpid {
+namespace framing {
+    enum delivery_mode {TRANSIENT = 1, PERSISTENT = 2};
+
+    //TODO: This could be easily generated from the spec
+    class BasicHeaderProperties : public HeaderProperties
+    {
+	string contentType;
+	string contentEncoding;
+	FieldTable headers;
+	u_int8_t deliveryMode;
+	u_int8_t priority;
+	string correlationId;
+	string replyTo;
+	string expiration;
+	string messageId;
+	u_int64_t timestamp;
+	string type;
+	string userId;
+	string appId;
+	string clusterId;
+	
+	u_int16_t getFlags() const;
+
+    public:
+	BasicHeaderProperties();
+	virtual ~BasicHeaderProperties();
+	virtual u_int32_t size() const;
+	virtual void encode(Buffer& buffer) const;
+	virtual void decode(Buffer& buffer, u_int32_t size);
+
+	inline virtual u_int8_t classId() { return BASIC; }
+
+	inline const string& getContentType() const { return contentType; }
+	inline const string& getContentEncoding() const { return contentEncoding; }
+	inline FieldTable& getHeaders() { return headers; }
+	inline u_int8_t getDeliveryMode() const { return deliveryMode; }
+	inline u_int8_t getPriority() const { return priority; }
+	inline const string& getCorrelationId() const {return correlationId; }
+	inline const string& getReplyTo() const { return replyTo; }
+	inline const string& getExpiration() const { return expiration; }
+	inline const string& getMessageId() const {return messageId; }
+	inline u_int64_t getTimestamp() const { return timestamp; }
+	inline const string& getType() const { return type; }
+	inline const string& getUserId() const { return userId; }
+	inline const string& getAppId() const { return appId; }
+	inline const string& getClusterId() const { return clusterId; }
+
+	void inline setContentType(const string& _type){ contentType = _type; }
+	void inline setContentEncoding(const string& encoding){ contentEncoding = encoding; }
+	void inline setHeaders(const FieldTable& _headers){ headers = _headers; }
+	void inline setDeliveryMode(u_int8_t mode){ deliveryMode = mode; }
+	void inline setPriority(u_int8_t _priority){ priority = _priority; }
+	void inline setCorrelationId(const string& _correlationId){ correlationId = _correlationId; }
+	void inline setReplyTo(const string& _replyTo){ replyTo = _replyTo;}
+	void inline setExpiration(const string&  _expiration){ expiration = _expiration; }
+	void inline setMessageId(const string& _messageId){ messageId = _messageId; }
+	void inline setTimestamp(u_int64_t _timestamp){ timestamp = _timestamp; }
+	void inline setType(const string& _type){ type = _type; }
+	void inline setUserId(const string& _userId){ userId = _userId; }
+	void inline setAppId(const string& _appId){appId = _appId; }
+	void inline setClusterId(const string& _clusterId){ clusterId = _clusterId; }
+    };
+
+}
+}
+
+
+#endif

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/framing/BasicHeaderProperties.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/framing/BasicHeaderProperties.h
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/lib/common/framing/BodyHandler.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/lib/common/framing/BodyHandler.cpp?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/lib/common/framing/BodyHandler.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/lib/common/framing/BodyHandler.cpp Thu Nov 30 21:11:45 2006
@@ -0,0 +1,54 @@
+/*
+ *
+ * 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 <boost/shared_ptr.hpp>
+#include <BodyHandler.h>
+
+using namespace qpid::framing;
+using namespace boost;
+
+BodyHandler::~BodyHandler() {}
+
+void BodyHandler::handleBody(AMQBody::shared_ptr& body){
+
+    switch(body->type())
+    {
+
+    case METHOD_BODY:
+	handleMethod(dynamic_pointer_cast<AMQMethodBody, AMQBody>(body));
+	break;
+ 
+   case HEADER_BODY:
+	handleHeader(dynamic_pointer_cast<AMQHeaderBody, AMQBody>(body));
+	break;
+
+    case CONTENT_BODY:
+	handleContent(dynamic_pointer_cast<AMQContentBody, AMQBody>(body));
+	break;
+
+    case HEARTBEAT_BODY:
+	handleHeartbeat(dynamic_pointer_cast<AMQHeartbeatBody, AMQBody>(body));
+	break;
+
+    default:
+	throw UnknownBodyType(body->type());
+    }
+
+}

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/framing/BodyHandler.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/framing/BodyHandler.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/qpid/trunk/qpid/cpp/lib/common/framing/BodyHandler.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/lib/common/framing/BodyHandler.h?view=auto&rev=481159
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/lib/common/framing/BodyHandler.h (added)
+++ incubator/qpid/trunk/qpid/cpp/lib/common/framing/BodyHandler.h Thu Nov 30 21:11:45 2006
@@ -0,0 +1,54 @@
+/*
+ *
+ * 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 <string>
+
+#ifndef _BodyHandler_
+#define _BodyHandler_
+
+#include <AMQMethodBody.h>
+#include <AMQHeaderBody.h>
+#include <AMQContentBody.h>
+#include <AMQHeartbeatBody.h>
+
+namespace qpid {
+namespace framing {
+
+    class BodyHandler{
+    public:
+        virtual ~BodyHandler();
+	virtual void handleMethod(AMQMethodBody::shared_ptr body) = 0;
+	virtual void handleHeader(AMQHeaderBody::shared_ptr body) = 0;
+	virtual void handleContent(AMQContentBody::shared_ptr body) = 0;
+	virtual void handleHeartbeat(AMQHeartbeatBody::shared_ptr body) = 0;
+
+        void handleBody(AMQBody::shared_ptr& body);
+    };
+
+    class UnknownBodyType{
+    public:
+	const u_int16_t type;
+	inline UnknownBodyType(u_int16_t _type) : type(_type){}
+    };
+}
+}
+
+
+#endif

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/framing/BodyHandler.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/lib/common/framing/BodyHandler.h
------------------------------------------------------------------------------
    svn:keywords = Rev Date