You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rh...@apache.org on 2006/09/20 00:07:25 UTC

svn commit: r447994 [5/46] - in /incubator/qpid/trunk/qpid: ./ cpp/ cpp/bin/ cpp/broker/ cpp/broker/inc/ cpp/broker/src/ cpp/broker/test/ cpp/client/ cpp/client/inc/ cpp/client/src/ cpp/client/test/ cpp/common/ cpp/common/concurrent/ cpp/common/concurr...

Added: incubator/qpid/trunk/qpid/cpp/common/concurrent/inc/TaskQueue.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/concurrent/inc/TaskQueue.h?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/concurrent/inc/TaskQueue.h (added)
+++ incubator/qpid/trunk/qpid/cpp/common/concurrent/inc/TaskQueue.h Tue Sep 19 15:06:50 2006
@@ -0,0 +1,200 @@
+/*
+ *
+ * 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.
+ *
+ */
+#ifndef _TaskQueue_
+#define _TaskQueue_
+
+#include <iostream>
+#include <memory>
+#include <queue>
+#include "LockedQueue.h"
+#include "Runnable.h"
+#include "ThreadPool.h"
+
+namespace qpid {
+namespace concurrent {
+    template<class T, class L> class TaskQueue : public virtual Runnable
+    {
+        const int max_iterations_per_run;
+        L lock;
+        //LockedQueue<T, L> queue;
+        std::queue<T*> queue;
+        ThreadPool* const pool;
+        T* work;
+        bool running;        
+        volatile bool stopped;        
+        TaskQueue<T, L>* next;
+
+        volatile bool inrun;
+
+        bool hasWork();
+        void completed();
+
+        T* take();
+
+    protected:
+        /**
+         * Callback though which the task is executed 
+         */
+        virtual void execute(T* t) = 0;
+        /**
+         * Allows a task to be completed asynchronously to the
+         * execute() call if required.
+         */
+        virtual bool isComplete(T* t);
+        /**
+         * Should be called to signal completion of a task that was
+         * signalled as not complete through the isComplete() methods
+         * return value. This will allow normal processing to resume.
+         */
+        virtual void complete();
+
+    public:
+        TaskQueue(ThreadPool* const pool, int max_iterations_per_run = 100);
+        virtual void run();
+        void trigger();
+        bool append(T* t);
+        void stop(bool drain);
+        inline void setNext(TaskQueue<T, L>* next){ this->next = next; }
+    };
+
+    template<class T, class L> TaskQueue<T, L>::TaskQueue(ThreadPool* const _pool, int _max_iterations_per_run) : 
+        pool(_pool), 
+        max_iterations_per_run(_max_iterations_per_run),
+        work(0), 
+        running(false),
+        stopped(false),
+        next(0), inrun(false){
+    }
+
+    template<class T, class L> void TaskQueue<T, L>::run(){
+        if(inrun) std::cout << "Already running" << std::endl;
+        inrun = true;
+
+        bool blocked = false;
+        int count = max_iterations_per_run;
+        while(!blocked && hasWork() && count){
+            execute(work);
+            if(isComplete(work)){
+                completed();
+            }else{
+                blocked = true;
+            }
+            count--;
+        }
+        inrun = false;
+
+        if(!blocked && count == 0){//performed max_iterations_per_run, requeue task to ensure fairness 
+            //running will still be true at this point
+            lock.acquire();
+            running = false;
+            if(stopped) lock.notify();
+            lock.release();
+
+            trigger();
+        }else if(hasWork()){//task was added to queue after we exited the loop above; should not need this?
+            trigger();
+        }
+    }
+
+    template<class T, class L> void TaskQueue<T, L>::trigger(){
+        lock.acquire();
+        if(!running){
+            running = true;
+            pool->addTask(this);
+        }
+        lock.release();
+    }
+
+    template<class T, class L> bool TaskQueue<T, L>::hasWork(){
+        lock.acquire();
+        if(!work) work = take();//queue.take();
+        if(!work){
+            running = false;
+            if(stopped) lock.notify();
+        }
+        lock.release();
+        return work;
+    }
+
+    template<class T, class L> bool TaskQueue<T, L>::append(T* item){
+        if(!stopped){
+            lock.acquire();
+
+            //queue.put(item);
+            queue.push(item);
+
+            if(!running){
+                running = true;
+                pool->addTask(this);
+            }
+            lock.release();
+                //}
+            return true;
+        }else{
+            return false;
+        }
+    }
+
+    template<class T, class L> bool TaskQueue<T, L>::isComplete(T* item){
+        return true;//by default assume all tasks are synchronous w.r.t. execute()
+    }
+
+
+    template<class T, class L> void TaskQueue<T, L>::completed(){
+        if(next){
+            if(!next->append(work)){
+                std::cout << "Warning: dropping task as next queue appears to have stopped." << std::endl;
+            }
+        }else{
+            delete work;
+        }
+        work = 0;        
+    }
+        
+    template<class T, class L> void TaskQueue<T, L>::complete(){
+        completed();
+        lock.acquire();
+        running = false;
+        if(stopped) lock.notify();
+        lock.release();
+    }
+
+    template<class T, class L> void TaskQueue<T, L>::stop(bool drain){
+        //prevent new tasks from being added
+        stopped = true;
+        //wait until no longer running
+        lock.acquire();
+        while(running && (drain && hasWork())){
+            lock.wait();
+        }
+        lock.release();
+    }
+
+    template<class T, class L> T* TaskQueue<T, L>::take(){
+        T* item = 0;
+        if(!queue.empty()){
+            item = queue.front();
+            queue.pop();
+        }
+        return item;
+    }
+}
+}
+
+
+#endif

Propchange: incubator/qpid/trunk/qpid/cpp/common/concurrent/inc/TaskQueue.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/cpp/common/concurrent/inc/Thread.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/concurrent/inc/Thread.h?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/concurrent/inc/Thread.h (added)
+++ incubator/qpid/trunk/qpid/cpp/common/concurrent/inc/Thread.h Tue Sep 19 15:06:50 2006
@@ -0,0 +1,37 @@
+/*
+ *
+ * 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.
+ *
+ */
+#ifndef _Thread_
+#define _Thread_
+
+namespace qpid {
+namespace concurrent {
+
+    class Thread
+    {
+    public:
+        virtual ~Thread(){}
+	virtual void start() = 0;
+	virtual void join() = 0;
+	virtual void interrupt() = 0;
+    };
+
+}
+}
+
+
+#endif

Propchange: incubator/qpid/trunk/qpid/cpp/common/concurrent/inc/Thread.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/cpp/common/concurrent/inc/ThreadFactory.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/concurrent/inc/ThreadFactory.h?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/concurrent/inc/ThreadFactory.h (added)
+++ incubator/qpid/trunk/qpid/cpp/common/concurrent/inc/ThreadFactory.h Tue Sep 19 15:06:50 2006
@@ -0,0 +1,38 @@
+/*
+ *
+ * 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.
+ *
+ */
+#ifndef _ThreadFactory_
+#define _ThreadFactory_
+
+#include "Thread.h"
+#include "Runnable.h"
+
+namespace qpid {
+namespace concurrent {
+
+    class ThreadFactory
+    {
+    public:
+        virtual ~ThreadFactory(){}
+	virtual Thread* create(Runnable* runnable) = 0;
+    };
+
+}
+}
+
+
+#endif

Propchange: incubator/qpid/trunk/qpid/cpp/common/concurrent/inc/ThreadFactory.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/cpp/common/concurrent/inc/ThreadFactoryImpl.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/concurrent/inc/ThreadFactoryImpl.h?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/concurrent/inc/ThreadFactoryImpl.h (added)
+++ incubator/qpid/trunk/qpid/cpp/common/concurrent/inc/ThreadFactoryImpl.h Tue Sep 19 15:06:50 2006
@@ -0,0 +1,52 @@
+/*
+ *
+ * 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.
+ *
+ */
+#ifndef _ThreadFactoryImpl_
+#define _ThreadFactoryImpl_
+
+
+#ifdef _USE_APR_IO_
+#include "APRThreadFactory.h"
+#else
+#include "LThreadFactory.h"
+#endif
+
+
+namespace qpid {
+namespace concurrent {
+
+
+#ifdef _USE_APR_IO_
+    class ThreadFactoryImpl : public virtual APRThreadFactory
+    {
+    public:
+	ThreadFactoryImpl(): APRThreadFactory() {};
+	virtual ~ThreadFactoryImpl() {};
+    };
+#else
+    class ThreadFactoryImpl : public virtual LThreadFactory
+    {
+    public:
+	ThreadFactoryImpl(): LThreadFactory() {};
+	virtual ~ThreadFactoryImpl() {};
+    };
+#endif
+}
+}
+
+
+#endif

Propchange: incubator/qpid/trunk/qpid/cpp/common/concurrent/inc/ThreadFactoryImpl.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/cpp/common/concurrent/inc/ThreadPool.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/concurrent/inc/ThreadPool.h?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/concurrent/inc/ThreadPool.h (added)
+++ incubator/qpid/trunk/qpid/cpp/common/concurrent/inc/ThreadPool.h Tue Sep 19 15:06:50 2006
@@ -0,0 +1,40 @@
+/*
+ *
+ * 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.
+ *
+ */
+#ifndef _ThreadPool_
+#define _ThreadPool_
+
+#include "Thread.h"
+#include "Runnable.h"
+
+namespace qpid {
+namespace concurrent {
+
+    class ThreadPool
+    {
+    public:
+        virtual void start() = 0;
+        virtual void stop() = 0;
+	virtual void addTask(Runnable* runnable) = 0;
+        virtual ~ThreadPool(){}
+    };
+
+}
+}
+
+
+#endif

Propchange: incubator/qpid/trunk/qpid/cpp/common/concurrent/inc/ThreadPool.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/cpp/common/concurrent/src/APRBase.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/concurrent/src/APRBase.cpp?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/concurrent/src/APRBase.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/common/concurrent/src/APRBase.cpp Tue Sep 19 15:06:50 2006
@@ -0,0 +1,97 @@
+/*
+ *
+ * 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 <iostream>
+#include "APRBase.h"
+#include "QpidError.h"
+
+using namespace qpid::concurrent;
+
+APRBase* APRBase::instance = 0;
+
+APRBase* APRBase::getInstance(){
+    if(instance == 0){
+	instance = new APRBase();
+    }
+    return instance;
+}
+
+
+APRBase::APRBase() : count(0){
+    apr_initialize();
+    CHECK_APR_SUCCESS(apr_pool_create(&pool, 0));
+    CHECK_APR_SUCCESS(apr_thread_mutex_create(&mutex, APR_THREAD_MUTEX_NESTED, pool));
+}
+
+APRBase::~APRBase(){
+    CHECK_APR_SUCCESS(apr_thread_mutex_destroy(mutex));
+    apr_pool_destroy(pool);
+    apr_terminate();  
+}
+
+bool APRBase::_increment(){
+    bool deleted(false);
+    CHECK_APR_SUCCESS(apr_thread_mutex_lock(mutex));
+    if(this == instance){
+	count++;
+    }else{
+	deleted = true;
+    }
+    CHECK_APR_SUCCESS(apr_thread_mutex_unlock(mutex));
+    return !deleted;
+}
+
+void APRBase::_decrement(){
+    APRBase* copy = 0;
+    CHECK_APR_SUCCESS(apr_thread_mutex_lock(mutex));
+    if(--count == 0){
+	copy = instance;
+	instance = 0;
+    }
+    CHECK_APR_SUCCESS(apr_thread_mutex_unlock(mutex));
+    if(copy != 0){
+	delete copy;
+    }
+}
+
+void APRBase::increment(){
+    int count = 0;
+    while(count++ < 2 && !getInstance()->_increment()){
+        std::cout << "WARNING: APR initialization triggered concurrently with termination." << std::endl;
+    }
+}
+
+void APRBase::decrement(){
+    getInstance()->_decrement();
+}
+
+void qpid::concurrent::check(apr_status_t status, const std::string& file, const int line){
+    if (status != APR_SUCCESS){
+        const int size = 50;
+        char tmp[size];
+        std::string msg(apr_strerror(status, tmp, size));
+        throw QpidError(APR_ERROR + ((int) status), msg, file, line);
+    }
+}
+
+std::string qpid::concurrent::get_desc(apr_status_t status){
+    const int size = 50;
+    char tmp[size];
+    std::string msg(apr_strerror(status, tmp, size));
+    return msg;
+}
+

Propchange: incubator/qpid/trunk/qpid/cpp/common/concurrent/src/APRBase.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/cpp/common/concurrent/src/APRMonitor.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/concurrent/src/APRMonitor.cpp?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/concurrent/src/APRMonitor.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/common/concurrent/src/APRMonitor.cpp Tue Sep 19 15:06:50 2006
@@ -0,0 +1,60 @@
+/*
+ *
+ * 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 "APRBase.h"
+#include "APRMonitor.h"
+#include <iostream>
+
+qpid::concurrent::APRMonitor::APRMonitor(){
+    APRBase::increment();
+    CHECK_APR_SUCCESS(apr_pool_create(&pool, NULL));
+    CHECK_APR_SUCCESS(apr_thread_mutex_create(&mutex, APR_THREAD_MUTEX_NESTED, pool));
+    CHECK_APR_SUCCESS(apr_thread_cond_create(&condition, pool));
+}
+
+qpid::concurrent::APRMonitor::~APRMonitor(){
+    CHECK_APR_SUCCESS(apr_thread_cond_destroy(condition));
+    CHECK_APR_SUCCESS(apr_thread_mutex_destroy(mutex));
+    apr_pool_destroy(pool);
+    APRBase::decrement();
+}
+
+void qpid::concurrent::APRMonitor::wait(){
+    CHECK_APR_SUCCESS(apr_thread_cond_wait(condition, mutex));
+}
+
+
+void qpid::concurrent::APRMonitor::wait(u_int64_t time){
+    apr_status_t status = apr_thread_cond_timedwait(condition, mutex, time * 1000);
+    if(!status == APR_TIMEUP) CHECK_APR_SUCCESS(status);
+}
+
+void qpid::concurrent::APRMonitor::notify(){
+    CHECK_APR_SUCCESS(apr_thread_cond_signal(condition));
+}
+
+void qpid::concurrent::APRMonitor::notifyAll(){
+    CHECK_APR_SUCCESS(apr_thread_cond_broadcast(condition));
+}
+
+void qpid::concurrent::APRMonitor::acquire(){
+    CHECK_APR_SUCCESS(apr_thread_mutex_lock(mutex));
+}
+
+void qpid::concurrent::APRMonitor::release(){
+    CHECK_APR_SUCCESS(apr_thread_mutex_unlock(mutex));
+}

Propchange: incubator/qpid/trunk/qpid/cpp/common/concurrent/src/APRMonitor.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/cpp/common/concurrent/src/APRThread.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/concurrent/src/APRThread.cpp?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/concurrent/src/APRThread.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/common/concurrent/src/APRThread.cpp Tue Sep 19 15:06:50 2006
@@ -0,0 +1,50 @@
+/*
+ *
+ * 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 "APRBase.h"
+#include "APRThread.h"
+#include "apr_portable.h"
+
+using namespace qpid::concurrent;
+
+void* APR_THREAD_FUNC ExecRunnable(apr_thread_t* thread, void *data){
+    ((Runnable*) data)->run();
+    CHECK_APR_SUCCESS(apr_thread_exit(thread, APR_SUCCESS));
+    return NULL;
+} 
+
+APRThread::APRThread(apr_pool_t* _pool, Runnable* _runnable) : pool(_pool), runnable(_runnable){}
+
+APRThread::~APRThread(){
+}
+
+void APRThread::start(){
+    CHECK_APR_SUCCESS(apr_thread_create(&runner, NULL, ExecRunnable,(void*) runnable, pool));
+}
+
+void APRThread::join(){
+    apr_status_t status;
+    CHECK_APR_SUCCESS(apr_thread_join(&status, runner));
+}
+
+void APRThread::interrupt(){
+    CHECK_APR_SUCCESS(apr_thread_exit(runner, APR_SUCCESS));
+}
+
+unsigned int qpid::concurrent::APRThread::currentThread(){
+    return apr_os_thread_current();
+}

Propchange: incubator/qpid/trunk/qpid/cpp/common/concurrent/src/APRThread.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/cpp/common/concurrent/src/APRThreadFactory.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/concurrent/src/APRThreadFactory.cpp?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/concurrent/src/APRThreadFactory.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/common/concurrent/src/APRThreadFactory.cpp Tue Sep 19 15:06:50 2006
@@ -0,0 +1,35 @@
+/*
+ *
+ * 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 "APRBase.h"
+#include "APRThreadFactory.h"
+
+using namespace qpid::concurrent;
+
+APRThreadFactory::APRThreadFactory(){
+    APRBase::increment();
+    CHECK_APR_SUCCESS(apr_pool_create(&pool, NULL));
+}
+
+APRThreadFactory::~APRThreadFactory(){
+    apr_pool_destroy(pool);
+    APRBase::decrement();
+}
+
+Thread* APRThreadFactory::create(Runnable* runnable){
+    return new APRThread(pool, runnable);
+}

Propchange: incubator/qpid/trunk/qpid/cpp/common/concurrent/src/APRThreadFactory.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/cpp/common/concurrent/src/APRThreadPool.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/concurrent/src/APRThreadPool.cpp?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/concurrent/src/APRThreadPool.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/common/concurrent/src/APRThreadPool.cpp Tue Sep 19 15:06:50 2006
@@ -0,0 +1,85 @@
+/*
+ *
+ * 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 "APRThreadFactory.h"
+#include "APRThreadPool.h"
+#include "QpidError.h"
+#include <iostream>
+
+using namespace qpid::concurrent;
+
+APRThreadPool::APRThreadPool(int _size) : size(_size), factory(new APRThreadFactory()), 
+                                          deleteFactory(true), running(false){
+    worker = new Worker(this);
+}
+
+APRThreadPool::APRThreadPool(int _size, ThreadFactory* _factory) : size(_size), factory(_factory), 
+                                                                   deleteFactory(false), running(false){
+    worker = new Worker(this);
+}
+
+APRThreadPool::~APRThreadPool(){
+    if(deleteFactory) delete factory;
+}
+
+void APRThreadPool::addTask(Runnable* task){
+    lock.acquire();
+    tasks.push(task);
+    lock.notifyAll();
+    lock.release();
+}
+
+void APRThreadPool::runTask(){
+    lock.acquire();
+    while(tasks.empty()){
+        lock.wait();
+    }
+    Runnable* task = tasks.front();
+    tasks.pop();
+    lock.release();
+    try{
+        task->run();
+    }catch(qpid::QpidError error){
+	std::cout << "Error [" << error.code << "] " << error.msg << " (" << error.file << ":" << error.line << ")" << std::endl;
+    }
+}
+
+void APRThreadPool::start(){
+    if(!running){
+        running = true;
+        for(int i = 0; i < size; i++){
+            Thread* t = factory->create(worker);
+            t->start();
+            threads.push_back(t);
+        }
+    }
+}
+
+void APRThreadPool::stop(){
+    if(!running){
+        running = false;
+        lock.acquire();
+        lock.notifyAll();
+        lock.release();
+        for(int i = 0; i < size; i++){
+            threads[i]->join();
+            delete threads[i];
+        }
+    }
+}
+
+

Propchange: incubator/qpid/trunk/qpid/cpp/common/concurrent/src/APRThreadPool.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/cpp/common/error/inc/QpidError.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/error/inc/QpidError.h?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/error/inc/QpidError.h (added)
+++ incubator/qpid/trunk/qpid/cpp/common/error/inc/QpidError.h Tue Sep 19 15:06:50 2006
@@ -0,0 +1,47 @@
+/*
+ *
+ * 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 <string>
+
+#ifndef __QpidError__
+#define __QpidError__
+
+namespace qpid {
+
+class QpidError{
+public:
+    const int code;
+    const std::string msg;
+    const std::string file;
+    const int line;
+
+    inline QpidError(int _code, const std::string& _msg, const std::string& _file, int _line) : code(_code), msg(_msg), file(_file), line(_line) {}
+    ~QpidError(){}
+	
+};
+
+#define THROW_QPID_ERROR(A, B) throw QpidError(A, B, __FILE__, __LINE__)
+
+}
+
+#define PROTOCOL_ERROR 10000
+#define APR_ERROR 20000
+#define FRAMING_ERROR 30000
+#define CLIENT_ERROR 40000
+#define INTERNAL_ERROR 50000
+
+#endif

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

Added: incubator/qpid/trunk/qpid/cpp/common/error/inc/QpidErrorIO.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/error/inc/QpidErrorIO.h?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/error/inc/QpidErrorIO.h (added)
+++ incubator/qpid/trunk/qpid/cpp/common/error/inc/QpidErrorIO.h Tue Sep 19 15:06:50 2006
@@ -0,0 +1,29 @@
+/*
+ *
+ * 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 "QpidError.h"
+#include <ostream>
+
+std::ostream& operator <<(std::ostream& out, const QpidError& error) 
+{
+    out << "Qpid Error [" << error.code << "] " << error.msg
+        << " (" << error.file << ":" << error.line << ")";
+    return out;
+}
+
+

Propchange: incubator/qpid/trunk/qpid/cpp/common/error/inc/QpidErrorIO.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/cpp/common/framing/Makefile
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/Makefile?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/framing/Makefile (added)
+++ incubator/qpid/trunk/qpid/cpp/common/framing/Makefile Tue Sep 19 15:06:50 2006
@@ -0,0 +1,28 @@
+#
+# 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.
+#
+
+.PHONY: all clean test
+
+all:
+	@$(MAKE) -C generated all
+
+test:
+	@$(MAKE) -C test all
+
+clean :
+	@$(MAKE) -C generated clean
+	@$(MAKE) -C test clean
+

Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/Makefile
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/cpp/common/framing/generated/Makefile
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/generated/Makefile?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/framing/generated/Makefile (added)
+++ incubator/qpid/trunk/qpid/cpp/common/framing/generated/Makefile Tue Sep 19 15:06:50 2006
@@ -0,0 +1,41 @@
+#
+# 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.
+#
+
+QPID_HOME = ../../../..
+include ${QPID_HOME}/cpp/options.mk
+
+STYLESHEET_DIR = stylesheets
+JAVA = java
+XSLTP = ${TOOLS_DIR}/saxon8.jar
+
+SPEC = ${SPEC_DIR}/amqp-8.0.xml
+STYLESHEETS = $(wildcard stylesheets/*.xsl)
+
+GENERATED_SOURCES=amqp_methods.cpp # Seed generation
+
+.PHONY: all clean 
+
+all: ${GENERATED_SOURCES}
+
+clean :
+	-@rm -f  *.cpp *.h
+
+${GENERATED_SOURCES}: ${STYLESHEETS} ${SPEC}
+	${JAVA} -jar ${XSLTP} -o results.out ${SPEC} ${STYLESHEET_DIR}/code_gen.xsl
+	${JAVA} -jar ${XSLTP} -o results.out ${SPEC} ${STYLESHEET_DIR}/framing.xsl
+
+-include $(GENERATED_SOURCES:.cpp=.d)
+

Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/generated/Makefile
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/amqp_client.xsl
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/amqp_client.xsl?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/amqp_client.xsl (added)
+++ incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/amqp_client.xsl Tue Sep 19 15:06:50 2006
@@ -0,0 +1,155 @@
+<?xml version='1.0'?> 
+<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:amqp="http://amqp.org"> 
+
+  <xsl:import href="code_utils.xsl"/>
+
+  <!--
+  ==================
+  Template: client_h
+  ==================
+  Client header file.
+  -->
+  <xsl:template match="amqp" mode="client_h">
+    <xsl:param name="domain-cpp-table"/>
+    <xsl:result-document href="AMQP_Client.h" format="textFormat">
+      <xsl:value-of select="amqp:copyright()"/>
+      <xsl:text>
+#ifndef _AMQP_Client_
+#define _AMQP_Client_
+
+#include "AMQP_ServerOperations.h"
+#include "FieldTable.h"
+#include "OutputHandler.h"
+
+namespace qpid {
+namespace framing {
+
+class AMQP_Client : virtual public AMQP_ServerOperations
+{
+        OutputHandler* out;
+
+    public:
+        AMQP_Client(OutputHandler* _out);
+        virtual ~AMQP_Client() {}&#xA;&#xA;</xsl:text>
+      <xsl:for-each select="class">
+        <xsl:variable name="class" select="amqp:cpp-class-name(@name)"/>
+        <xsl:if test="doc">
+          <xsl:text>&#xA;/**&#xA;===== Class: </xsl:text><xsl:value-of select="$class"/><xsl:text> =====&#xA;</xsl:text>
+          <xsl:value-of select="amqp:process-docs(doc)"/>
+          <xsl:text>&#xA;*/&#xA;</xsl:text>
+        </xsl:if>
+        <xsl:text>        class </xsl:text><xsl:value-of select="$class"/><xsl:text> :  virtual public AMQP_ServerOperations::</xsl:text><xsl:value-of select="$class"/><xsl:text>Handler
+        {
+                OutputHandler* out;
+
+            public:
+                /* Constructors and destructors */
+                </xsl:text><xsl:value-of select="$class"/><xsl:text>(OutputHandler* _out);
+                virtual ~</xsl:text><xsl:value-of select="$class"/><xsl:text>();
+                
+                /* Protocol methods */&#xA;</xsl:text>
+        <xsl:for-each select="method">
+          <xsl:if test="chassis[@name='server']">
+            <xsl:variable name="method" select="amqp:cpp-name(@name)"/>
+            <xsl:if test="doc">
+              <xsl:text>&#xA;/**&#xA;----- Method: </xsl:text><xsl:value-of select="$class"/><xsl:text>.</xsl:text><xsl:value-of select="$method"/><xsl:text> -----&#xA;</xsl:text>
+              <xsl:value-of select="amqp:process-docs(doc)"/>
+              <xsl:text>&#xA;*/&#xA;</xsl:text>
+            </xsl:if>
+            <xsl:for-each select="rule">
+              <xsl:text>&#xA;/**&#xA;</xsl:text>
+              <xsl:text>Rule "</xsl:text><xsl:value-of select="@name"/><xsl:text>":&#xA;</xsl:text><xsl:value-of select="amqp:process-docs(doc)"/>
+              <xsl:text>&#xA;*/&#xA;</xsl:text>
+            </xsl:for-each>
+            <xsl:text>                virtual void </xsl:text><xsl:value-of select="$method"/>
+            <xsl:text>( u_int16_t channel</xsl:text><xsl:if test="field"><xsl:text>,&#xA;                        </xsl:text>
+            <xsl:for-each select="field">
+              <xsl:variable name="domain-cpp-type" select="amqp:cpp-lookup(@domain, $domain-cpp-table)"/>
+              <xsl:value-of select="concat($domain-cpp-type, amqp:cpp-arg-ref($domain-cpp-type), ' ', amqp:cpp-name(@name))"/>
+              <xsl:if test="position()!=last()">
+                <xsl:text>,&#xA;                        </xsl:text>
+              </xsl:if>
+            </xsl:for-each>
+          </xsl:if>
+            <xsl:text> );&#xA;</xsl:text>
+          </xsl:if>
+        </xsl:for-each>
+        <xsl:text>        }; /* class </xsl:text><xsl:value-of select="$class"/><xsl:text> */&#xA;</xsl:text>
+      </xsl:for-each>
+      <xsl:text>}; /* class AMQP_Client */
+
+} /* namespace framing */
+} /* namespace qpid */
+
+#endif&#xA;</xsl:text>
+    </xsl:result-document>
+  </xsl:template>
+
+
+  <!--
+  ====================
+  Template: client_cpp
+  ====================
+  Client body.
+  -->
+  <xsl:template match="amqp" mode="client_cpp">
+    <xsl:param name="domain-cpp-table"/>
+    <xsl:result-document href="AMQP_Client.cpp" format="textFormat">
+      <xsl:value-of select="amqp:copyright()"/>
+      <xsl:text>
+
+#include "AMQP_Client.h"
+
+namespace qpid {
+namespace framing {
+
+AMQP_Client::AMQP_Client(OutputHandler* _out) :
+    out(_out)
+{
+}&#xA;&#xA;</xsl:text>
+      <xsl:for-each select="class">
+        <xsl:variable name="class" select="amqp:cpp-class-name(@name)"/>
+        <xsl:text>&#xA;/* ++++++++++ Class: </xsl:text><xsl:value-of select="$class"/><xsl:text> ++++++++++ */
+
+AMQP_Client::</xsl:text><xsl:value-of select="$class"/><xsl:text>::</xsl:text><xsl:value-of select="$class"/><xsl:text>(OutputHandler* _out) :
+    out(_out)
+{
+}
+
+AMQP_Client::</xsl:text><xsl:value-of select="$class"/><xsl:text>::~</xsl:text><xsl:value-of select="$class"/><xsl:text>() {}&#xA;&#xA;</xsl:text>
+        <xsl:for-each select="method">
+          <xsl:if test="chassis[@name='server']">
+            <xsl:text>void AMQP_Client::</xsl:text><xsl:value-of select="$class"/><xsl:text>::</xsl:text>
+            <xsl:value-of select="amqp:cpp-name(@name)"/><xsl:text>( u_int16_t channel</xsl:text><xsl:if test="field">
+            <xsl:text>,&#xA;                        </xsl:text>
+            <xsl:for-each select="field">
+              <xsl:variable name="domain-cpp-type" select="amqp:cpp-lookup(@domain, $domain-cpp-table)"/>
+              <xsl:value-of select="concat($domain-cpp-type, amqp:cpp-arg-ref($domain-cpp-type), ' ', amqp:cpp-name(@name))"/>
+              <xsl:if test="position()!=last()">
+                <xsl:text>,&#xA;                        </xsl:text>
+              </xsl:if>
+            </xsl:for-each>
+          </xsl:if>
+          <xsl:text> )
+{
+    out->send( new AMQFrame( channel,
+        new </xsl:text><xsl:value-of select="concat($class, amqp:field-name(@name), 'Body')"/><xsl:text>( </xsl:text>
+          <xsl:for-each select="field">
+            <xsl:value-of select="amqp:cpp-name(@name)"/>
+            <xsl:if test="position()!=last()">
+              <xsl:text>,&#xA;            </xsl:text>
+            </xsl:if>
+            </xsl:for-each>
+            <xsl:text> ) ) );
+}&#xA;&#xA;</xsl:text>
+          </xsl:if>
+        </xsl:for-each>
+      </xsl:for-each>
+      <xsl:text>
+
+} /* namespace framing */
+} /* namespace qpid */&#xA;</xsl:text>
+    </xsl:result-document>
+  </xsl:template>
+  
+</xsl:stylesheet> 

Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/amqp_client.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/amqp_client_handler_impl.xsl
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/amqp_client_handler_impl.xsl?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/amqp_client_handler_impl.xsl (added)
+++ incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/amqp_client_handler_impl.xsl Tue Sep 19 15:06:50 2006
@@ -0,0 +1,187 @@
+<?xml version='1.0'?> 
+<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:amqp="http://amqp.org"> 
+
+  <xsl:import href="code_utils.xsl"/>
+
+  <!--
+  ===============================
+  Template: client_handler_impl_h
+  ===============================
+  Template to generate the AMQP_ServerHandlerImpl class header file.
+  -->
+  <xsl:template match="amqp" mode="client_handler_impl_h">
+    <xsl:param name="domain-cpp-table"/>
+    <xsl:result-document href="AMQP_ClientHandlerImpl.h" format="textFormat">
+      <xsl:value-of select="amqp:copyright()"/>
+      <xsl:text>
+#ifndef _AMQP_ClientHandlerImpl_
+#define _AMQP_ClientHandlerImpl_
+
+#include "AMQP_ClientOperations.h"
+#include "FieldTable.h"
+
+namespace qpid {
+namespace framing {
+
+class AMQP_ClientHandlerImpl : virtual public AMQP_ClientOperations
+{&#xA;</xsl:text>
+
+      <!-- List of pointers to each inner class instance -->
+      <xsl:for-each select="class">
+        <xsl:variable name="class" select="concat(amqp:cpp-class-name(@name), 'Handler')"/>
+        <xsl:text>        AMQP_ClientOperations::</xsl:text><xsl:value-of select="$class"/><xsl:text>* </xsl:text>
+        <xsl:value-of select="$class"/><xsl:text>Ptr;&#xA;</xsl:text>
+      </xsl:for-each>
+      <xsl:text>
+    public:
+        AMQP_ClientHandlerImpl();
+        virtual ~AMQP_ClientHandlerImpl();&#xA;&#xA;</xsl:text>        
+
+      <!-- List of functions to return pointer to each inner class instance -->
+      <xsl:for-each select="class">
+        <xsl:variable name="class" select="concat(amqp:cpp-class-name(@name), 'Handler')"/>
+        <xsl:text>        inline AMQP_ClientOperations::</xsl:text>
+        <xsl:value-of select="$class"/><xsl:text>* get</xsl:text><xsl:value-of select="$class"/>
+        <xsl:text>() { return </xsl:text><xsl:value-of select="$class"/><xsl:text>Ptr; }&#xA;</xsl:text>
+      </xsl:for-each>
+      <xsl:text>&#xA;</xsl:text>
+
+      <!-- Inner classes -->
+      <xsl:for-each select="class">
+        <xsl:variable name="class" select="concat(amqp:cpp-class-name(@name), 'Handler')"/>
+
+        <!-- Inner class documentation & rules -->
+        <xsl:if test="doc">
+          <xsl:text>&#xA;/**&#xA;</xsl:text>
+          <xsl:text>===== Class: </xsl:text><xsl:value-of select="$class"/><xsl:text>Impl =====&#xA;</xsl:text>
+          <xsl:value-of select="amqp:process-docs(doc)"/>
+          <xsl:text>*/&#xA;</xsl:text>
+        </xsl:if>
+
+        <!-- Inner class definition -->
+        <xsl:text>        class </xsl:text><xsl:value-of select="$class"/>
+        <xsl:text>Impl : virtual public AMQP_ClientOperations::</xsl:text><xsl:value-of select="$class"/>
+        <xsl:text>&#xA;        {
+            public:
+                /* Constructors and destructors */
+                </xsl:text><xsl:value-of select="$class"/><xsl:text>Impl();
+                virtual ~</xsl:text><xsl:value-of select="$class"/><xsl:text>Impl();
+                
+                /* Protocol methods */&#xA;</xsl:text>
+
+        <!-- Inner class methods (only if the chassis is set to "client") -->
+        <xsl:for-each select="method">
+          <xsl:if test="chassis[@name='client']">
+            <xsl:variable name="method" select="amqp:cpp-name(@name)"/>
+
+            <!-- Inner class method documentation & rules -->
+            <xsl:if test="doc">
+              <xsl:text>&#xA;/**&#xA;</xsl:text>
+              <xsl:text>----- Method: </xsl:text><xsl:value-of select="$class"/>
+              <xsl:text>Impl.</xsl:text><xsl:value-of select="@name"/><xsl:text> -----&#xA;</xsl:text>
+              <xsl:value-of select="amqp:process-docs(doc)"/>
+              <xsl:text>*/&#xA;</xsl:text>
+            </xsl:if>
+            <xsl:for-each select="rule">
+              <xsl:text>&#xA;/**&#xA;</xsl:text>
+              <xsl:text>Rule "</xsl:text><xsl:value-of select="@name"/><xsl:text>":&#xA;</xsl:text>
+              <xsl:value-of select="amqp:process-docs(doc)"/>
+              <xsl:text>*/&#xA;</xsl:text>
+            </xsl:for-each>
+
+            <!-- Inner class method definition -->
+            <xsl:text>&#xA;                virtual void </xsl:text><xsl:value-of select="$method"/>
+            <xsl:text>( u_int16_t channel</xsl:text>
+
+            <!-- Inner class method parameter definition -->
+            <xsl:if test="field">
+              <xsl:text>,&#xA;                        </xsl:text>
+              <xsl:for-each select="field">
+                <xsl:variable name="domain-cpp-type" select="amqp:cpp-lookup(@domain, $domain-cpp-table)"/>
+                <xsl:value-of select="concat($domain-cpp-type, amqp:cpp-arg-ref($domain-cpp-type), ' ', amqp:cpp-name(@name))"/>
+                <xsl:if test="position()!=last()">
+                  <xsl:text>,&#xA;                        </xsl:text>
+                </xsl:if>
+              </xsl:for-each>
+            </xsl:if>
+            <xsl:text> );&#xA;</xsl:text>
+          </xsl:if>
+        </xsl:for-each>
+        <xsl:text>&#xA;        }; /* class </xsl:text><xsl:value-of select="$class"/><xsl:text>Impl */&#xA;</xsl:text>
+      </xsl:for-each>
+      <xsl:text>&#xA;}; /* AMQP_ClientHandlerImpl */
+
+} /* namespace framing */
+} /* namespace qpid */
+
+#endif&#xA;</xsl:text>
+    </xsl:result-document>
+  </xsl:template>
+
+  <!--
+  =================================
+  Template: client_handler_impl_cpp
+  =================================
+  Template to generate the AMQP_ServerHandlerImpl class stubs.
+  -->
+  <xsl:template match="amqp" mode="client_handler_impl_cpp">
+    <xsl:param name="domain-cpp-table"/>
+    <xsl:result-document href="AMQP_ClientHandlerImpl.cpp" format="textFormat">
+      <xsl:value-of select="amqp:copyright()"/>
+      <xsl:text>
+#include "AMQP_ClientHandlerImpl.h"
+
+namespace qpid {
+namespace framing {
+
+AMQP_ClientHandlerImpl::AMQP_ClientHandlerImpl() :&#xA;        </xsl:text>
+      <xsl:for-each select="class">
+        <xsl:variable name="class" select="amqp:cpp-class-name(@name)"/>
+        <xsl:value-of select="$class"/>
+        <xsl:text>HandlerPtr( new </xsl:text><xsl:value-of select="$class"/><xsl:text>HandlerImpl() )</xsl:text>
+        <xsl:if test="position()!=last()">
+          <xsl:text>,&#xA;        </xsl:text>
+        </xsl:if>
+      </xsl:for-each>
+      <xsl:text>
+{
+}
+
+AMQP_ClientHandlerImpl::~AMQP_ClientHandlerImpl()
+{&#xA;</xsl:text>
+      <xsl:for-each select="class">
+        <xsl:text>        delete </xsl:text><xsl:value-of select="amqp:cpp-class-name(@name)"/><xsl:text>HandlerPtr;&#xA;</xsl:text>
+      </xsl:for-each>}
+
+      <xsl:for-each select="class">
+        <xsl:variable name="class" select="amqp:cpp-class-name(@name)"/>
+        <xsl:text>&#xA;/* ===== Class: </xsl:text><xsl:value-of select="$class"/><xsl:text>HandlerImpl ===== */&#xA;&#xA;</xsl:text>
+        <xsl:text>AMQP_ClientHandlerImpl::</xsl:text><xsl:value-of select="$class"/><xsl:text>HandlerImpl::</xsl:text>
+        <xsl:value-of select="$class"/><xsl:text>HandlerImpl()&#xA;{&#xA;}&#xA;&#xA;</xsl:text>
+        <xsl:text>AMQP_ClientHandlerImpl::</xsl:text><xsl:value-of select="$class"/><xsl:text>HandlerImpl::~</xsl:text>
+        <xsl:value-of select="$class"/><xsl:text>HandlerImpl()&#xA;{&#xA;}&#xA;&#xA;</xsl:text>
+        <xsl:for-each select="method">
+          <xsl:if test="chassis[@name='client']">
+            <xsl:text>void AMQP_ClientHandlerImpl::</xsl:text><xsl:value-of select="$class"/><xsl:text>HandlerImpl::</xsl:text>
+            <xsl:value-of select="amqp:cpp-name(@name)"/><xsl:text>( u_int16_t channel</xsl:text>
+            <xsl:if test="field">
+              <xsl:text>,&#xA;                        </xsl:text>
+              <xsl:for-each select="field">
+                <xsl:variable name="domain-cpp-type" select="amqp:cpp-lookup(@domain, $domain-cpp-table)"/>
+                <xsl:value-of select="concat($domain-cpp-type, amqp:cpp-arg-ref($domain-cpp-type), ' ', amqp:cpp-name(@name))"/>
+                <xsl:if test="position()!=last()">
+                  <xsl:text>,&#xA;                        </xsl:text>
+                </xsl:if>
+              </xsl:for-each>
+            </xsl:if><xsl:text> )&#xA;{&#xA;}&#xA;&#xA;</xsl:text>
+          </xsl:if>
+        </xsl:for-each>
+      </xsl:for-each>
+      <xsl:text>
+
+} /* namespace framing */
+} /* namespace qpid */&#xA;&#xA;</xsl:text>
+    </xsl:result-document>
+  </xsl:template>
+
+</xsl:stylesheet> 

Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/amqp_client_handler_impl.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/amqp_client_operations.xsl
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/amqp_client_operations.xsl?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/amqp_client_operations.xsl (added)
+++ incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/amqp_client_operations.xsl Tue Sep 19 15:06:50 2006
@@ -0,0 +1,105 @@
+<?xml version='1.0'?> 
+<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:amqp="http://amqp.org"> 
+
+  <xsl:import href="code_utils.xsl"/>
+
+  <!--
+  =============================
+  Template: client-operations-h
+  =============================
+  Template to generate the AMQP_ClientHandler virtual class. This is the pure
+  virtual class from which the AMQP_Server and AMQP_ClientHandlerImpl classes
+  are derived.
+  -->
+  <xsl:template match="amqp" mode="client-operations-h">
+    <xsl:param name="domain-cpp-table"/>
+    <xsl:result-document href="AMQP_ClientOperations.h" format="textFormat">
+      <xsl:value-of select="amqp:copyright()"/>
+      <xsl:text>
+#ifndef _AMQP_ClientOperations_
+#define _AMQP_ClientOperations_
+
+#include "AMQP_Constants.h"
+#include "FieldTable.h"
+
+namespace qpid {
+namespace framing {
+
+class AMQP_ClientOperations
+{
+    public:
+        AMQP_ClientOperations() {}
+        virtual ~AMQP_ClientOperations() {}
+        inline u_int16_t getAmqpMajor() { return (u_int16_t)</xsl:text><xsl:value-of select="@major"/><xsl:text>; }
+        inline u_int16_t getAmqpMinor() { return (u_int16_t)</xsl:text><xsl:value-of select="@minor"/><xsl:text>; }&#xA;&#xA;</xsl:text>
+
+      <!-- Inner classes -->
+      <xsl:for-each select="class">
+        <xsl:variable name="class" select="concat(amqp:cpp-class-name(@name), 'Handler')"/>
+
+        <!-- Inner class documentation & rules -->
+        <xsl:if test="doc">
+          <xsl:text>&#xA;/**&#xA;===== Class: </xsl:text><xsl:value-of select="$class"/><xsl:text> =====&#xA;</xsl:text>
+          <xsl:value-of select="amqp:process-docs(doc)"/>
+          <xsl:text>*/&#xA;</xsl:text>
+        </xsl:if>
+
+        <!-- Inner class definition -->
+        <xsl:text>        class </xsl:text><xsl:value-of select="$class"/><xsl:text>
+        {
+            public:
+                /* Constructors and destructors */
+                </xsl:text><xsl:value-of select="$class"/><xsl:text>() {}
+                virtual ~</xsl:text><xsl:value-of select="$class"/><xsl:text>() {}
+                
+                /* Protocol methods */&#xA;</xsl:text>
+
+        <!-- Inner class methods (only if the chassis is set to "client") -->
+        <xsl:for-each select="method">
+          <xsl:if test="chassis[@name='client']">
+            <xsl:variable name="method" select="amqp:cpp-name(@name)"/>
+
+            <!-- Inner class method documentation & rules -->
+            <xsl:if test="doc">
+              <xsl:text>&#xA;/**&#xA;----- Method: </xsl:text><xsl:value-of select="$class"/><xsl:text>.</xsl:text>
+              <xsl:value-of select="@name"/><xsl:text> -----&#xA;</xsl:text>
+              <xsl:value-of select="amqp:process-docs(doc)"/>
+              <xsl:text>*/&#xA;</xsl:text>
+            </xsl:if>
+            <xsl:for-each select="rule">
+              <xsl:text>&#xA;/**&#xA;</xsl:text>
+              <xsl:text>Rule "</xsl:text><xsl:value-of select="@name"/><xsl:text>":&#xA;</xsl:text>
+              <xsl:value-of select="amqp:process-docs(doc)"/>
+              <xsl:text>*/&#xA;</xsl:text>
+            </xsl:for-each>
+
+            <!-- Inner class method definition -->
+            <xsl:text>                virtual void </xsl:text><xsl:value-of select="$method"/>
+            <xsl:text>( u_int16_t channel</xsl:text>
+
+            <!-- Inner class method parameter definition -->
+            <xsl:if test="field">
+              <xsl:text>,&#xA;                        </xsl:text>
+              <xsl:for-each select="field">
+                <xsl:variable name="domain-cpp-type" select="amqp:cpp-lookup(@domain, $domain-cpp-table)"/>
+                <xsl:value-of select="concat($domain-cpp-type, amqp:cpp-arg-ref($domain-cpp-type), ' ', amqp:cpp-name(@name))"/>
+                <xsl:if test="position()!=last()">
+                  <xsl:text>,&#xA;                        </xsl:text>
+                </xsl:if>
+              </xsl:for-each>
+            </xsl:if>
+            <xsl:text> ) = 0;&#xA;</xsl:text>
+          </xsl:if>
+        </xsl:for-each>
+        <xsl:text>&#xA;        }; /* class </xsl:text><xsl:value-of select="$class"/><xsl:text> */&#xA;</xsl:text>
+      </xsl:for-each>
+      <xsl:text>&#xA;}; /* class AMQP_ClientOperations */
+
+} /* namespace framing */
+} /* namespace qpid */
+
+#endif&#xA;</xsl:text>
+    </xsl:result-document>
+  </xsl:template>
+
+</xsl:stylesheet> 

Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/amqp_client_operations.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/amqp_consts.xsl
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/amqp_consts.xsl?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/amqp_consts.xsl (added)
+++ incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/amqp_consts.xsl Tue Sep 19 15:06:50 2006
@@ -0,0 +1,77 @@
+<?xml version='1.0'?> 
+<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:amqp="http://amqp.org"> 
+
+  <xsl:import href="code_utils.xsl"/>
+  <xsl:output method="text" indent="yes" name="textFormat"/> 
+
+  <xsl:template match="/">
+    <xsl:apply-templates select="amqp" mode="domain-table"/> 
+    <xsl:apply-templates select="amqp" mode="domain-consts"/> 
+  </xsl:template> 
+
+  <!--
+  ======================
+  Template: domain-table
+  ======================
+  Generates the domain name to C++ type lookup table
+  which is required for later generation.
+  Format:
+  <domains>
+    <domain doamin-name="dname1" cpp-type="type1"/>
+    <domain doamin-name="dname2" cpp-type="type2"/>
+    ...
+  </domains>
+  -->
+  <xsl:template match="amqp" mode="domain-table">
+    <domains><xsl:text>&#xA;</xsl:text>
+      <xsl:for-each select="domain">
+        <xsl:text>  </xsl:text><domain>
+          <xsl:attribute name="domain-name">
+            <xsl:value-of select="@name"/>
+          </xsl:attribute>
+          <xsl:attribute name="cpp-type">
+            <xsl:value-of select="amqp:cpp-type(@type)"/>
+          </xsl:attribute>
+        </domain><xsl:text>&#xA;</xsl:text>
+      </xsl:for-each>
+    </domains>
+  </xsl:template>
+
+  <!--
+  =======================
+  Template: domain-consts
+  =======================
+  Generates a header file (AMQP_Constants.h) containing definitions of
+  all the <constant> declarations in the AMQP XML specification.
+  -->
+  <xsl:template match="amqp" mode="domain-consts">
+    <xsl:result-document href="AMQP_Constants.h" format="textFormat">
+      <xsl:value-of select="amqp:copyright()"/>
+      <xsl:text>
+#ifndef _AMQP_Constants_
+#define _AMQP_Constants_
+
+#include "amqp_types.h"
+
+namespace qpid {
+namespace framing {
+
+/**** Constants ****/&#xA;&#xA;</xsl:text>
+      <xsl:for-each select="constant">
+        <xsl:if test="doc">
+          <xsl:text>&#xA;/*&#xA;</xsl:text>
+          <xsl:value-of select="normalize-space(doc)"/>
+          <xsl:text>&#xA;*/&#xA;</xsl:text>
+        </xsl:if>
+        <xsl:text>const u_int16_t </xsl:text><xsl:value-of select="concat('AMQP_', upper-case(amqp:cpp-name(@name)), ' = ', @value)"/><xsl:text>;&#xA;</xsl:text>
+      </xsl:for-each>
+      <xsl:text>
+
+} /* namespace framing */
+} /* namespace qpid */
+
+#endif&#xA;</xsl:text>
+    </xsl:result-document>
+  </xsl:template>
+
+</xsl:stylesheet> 

Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/amqp_consts.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/amqp_server.xsl
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/amqp_server.xsl?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/amqp_server.xsl (added)
+++ incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/amqp_server.xsl Tue Sep 19 15:06:50 2006
@@ -0,0 +1,155 @@
+<?xml version='1.0'?> 
+<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:amqp="http://amqp.org"> 
+
+  <xsl:import href="code_utils.xsl"/>
+
+  <!--
+  ==================
+  Template: server_h
+  ==================
+  Server header file.
+  -->
+  <xsl:template match="amqp" mode="server_h">
+    <xsl:param name="domain-cpp-table"/>
+    <xsl:result-document href="AMQP_Server.h" format="textFormat">
+      <xsl:value-of select="amqp:copyright()"/>
+      <xsl:text>
+#ifndef _AMQP_Server_
+#define _AMQP_Server_
+
+#include "AMQP_ClientOperations.h"
+#include "FieldTable.h"
+#include "OutputHandler.h"
+
+namespace qpid {
+namespace framing {
+
+class AMQP_Server : virtual public AMQP_ClientOperations
+{
+        OutputHandler* out;
+
+    public:
+        AMQP_Server(OutputHandler* _out);
+        virtual ~AMQP_Server() {}&#xA;&#xA;</xsl:text>
+      <xsl:for-each select="class">
+        <xsl:variable name="class" select="amqp:cpp-class-name(@name)"/>
+        <xsl:if test="doc">
+          <xsl:text>&#xA;/**&#xA;===== Class: </xsl:text><xsl:value-of select="$class"/><xsl:text> =====&#xA;</xsl:text>
+          <xsl:value-of select="amqp:process-docs(doc)"/>
+          <xsl:text>&#xA;*/&#xA;</xsl:text>
+        </xsl:if>
+        <xsl:text>        class </xsl:text><xsl:value-of select="$class"/><xsl:text> :  virtual public AMQP_ClientOperations::</xsl:text><xsl:value-of select="$class"/><xsl:text>Handler
+        {
+                OutputHandler* out;
+
+            public:
+                /* Constructors and destructors */
+                </xsl:text><xsl:value-of select="$class"/><xsl:text>(OutputHandler* _out);
+                virtual ~</xsl:text><xsl:value-of select="$class"/><xsl:text>();
+                
+                /* Protocol methods */&#xA;</xsl:text>
+        <xsl:for-each select="method">
+          <xsl:if test="chassis[@name='client']">
+            <xsl:variable name="method" select="amqp:cpp-name(@name)"/>
+            <xsl:if test="doc">
+              <xsl:text>&#xA;/**&#xA;----- Method: </xsl:text><xsl:value-of select="$class"/><xsl:text>.</xsl:text><xsl:value-of select="$method"/><xsl:text> -----&#xA;</xsl:text>
+              <xsl:value-of select="amqp:process-docs(doc)"/>
+              <xsl:text>&#xA;*/&#xA;</xsl:text>
+            </xsl:if>
+            <xsl:for-each select="rule">
+              <xsl:text>&#xA;/**&#xA;</xsl:text>
+              <xsl:text>Rule "</xsl:text><xsl:value-of select="@name"/><xsl:text>":&#xA;</xsl:text><xsl:value-of select="amqp:process-docs(doc)"/>
+              <xsl:text>&#xA;*/&#xA;</xsl:text>
+            </xsl:for-each>
+            <xsl:text>                virtual void </xsl:text><xsl:value-of select="$method"/>
+            <xsl:text>( u_int16_t channel</xsl:text><xsl:if test="field"><xsl:text>,&#xA;                        </xsl:text>
+            <xsl:for-each select="field">
+              <xsl:variable name="domain-cpp-type" select="amqp:cpp-lookup(@domain, $domain-cpp-table)"/>
+              <xsl:value-of select="concat($domain-cpp-type, amqp:cpp-arg-ref($domain-cpp-type), ' ', amqp:cpp-name(@name))"/>
+              <xsl:if test="position()!=last()">
+                <xsl:text>,&#xA;                        </xsl:text>
+              </xsl:if>
+            </xsl:for-each>
+          </xsl:if>
+            <xsl:text> );&#xA;</xsl:text>
+          </xsl:if>
+        </xsl:for-each>
+        <xsl:text>        }; /* class </xsl:text><xsl:value-of select="$class"/><xsl:text> */&#xA;</xsl:text>
+      </xsl:for-each>
+      <xsl:text>}; /* class AMQP_Server */
+
+} /* namespace framing */
+} /* namespace qpid */
+
+#endif&#xA;</xsl:text>
+    </xsl:result-document>
+  </xsl:template>
+
+
+  <!--
+  ====================
+  Template: server_cpp
+  ====================
+  Server body.
+  -->
+  <xsl:template match="amqp" mode="server_cpp">
+    <xsl:param name="domain-cpp-table"/>
+    <xsl:result-document href="AMQP_Server.cpp" format="textFormat">
+      <xsl:value-of select="amqp:copyright()"/>
+      <xsl:text>
+
+#include "AMQP_Server.h"
+
+namespace qpid {
+namespace framing {
+
+AMQP_Server::AMQP_Server(OutputHandler* _out) :
+    out(_out)
+{
+}&#xA;&#xA;</xsl:text>
+      <xsl:for-each select="class">
+        <xsl:variable name="class" select="amqp:cpp-class-name(@name)"/>
+        <xsl:text>&#xA;/* ++++++++++ Class: </xsl:text><xsl:value-of select="$class"/><xsl:text> ++++++++++ */
+
+AMQP_Server::</xsl:text><xsl:value-of select="$class"/><xsl:text>::</xsl:text><xsl:value-of select="$class"/><xsl:text>(OutputHandler* _out) :
+    out(_out)
+{
+}
+
+AMQP_Server::</xsl:text><xsl:value-of select="$class"/><xsl:text>::~</xsl:text><xsl:value-of select="$class"/><xsl:text>() {}&#xA;&#xA;</xsl:text>
+        <xsl:for-each select="method">
+          <xsl:if test="chassis[@name='client']">
+            <xsl:text>void AMQP_Server::</xsl:text><xsl:value-of select="$class"/><xsl:text>::</xsl:text>
+            <xsl:value-of select="amqp:cpp-name(@name)"/><xsl:text>( u_int16_t channel</xsl:text><xsl:if test="field">
+            <xsl:text>,&#xA;                        </xsl:text>
+            <xsl:for-each select="field">
+              <xsl:variable name="domain-cpp-type" select="amqp:cpp-lookup(@domain, $domain-cpp-table)"/>
+              <xsl:value-of select="concat($domain-cpp-type, amqp:cpp-arg-ref($domain-cpp-type), ' ', amqp:cpp-name(@name))"/>
+              <xsl:if test="position()!=last()">
+                <xsl:text>,&#xA;                        </xsl:text>
+              </xsl:if>
+            </xsl:for-each>
+          </xsl:if>
+          <xsl:text> )
+{
+    out->send( new AMQFrame( channel,
+        new </xsl:text><xsl:value-of select="concat($class, amqp:field-name(@name), 'Body')"/><xsl:text>( </xsl:text>
+          <xsl:for-each select="field">
+            <xsl:value-of select="amqp:cpp-name(@name)"/>
+            <xsl:if test="position()!=last()">
+              <xsl:text>,&#xA;            </xsl:text>
+            </xsl:if>
+            </xsl:for-each>
+            <xsl:text> ) ) );
+}&#xA;&#xA;</xsl:text>
+          </xsl:if>
+        </xsl:for-each>
+      </xsl:for-each>
+      <xsl:text>
+
+} /* namespace framing */
+} /* namespace qpid */&#xA;</xsl:text>
+    </xsl:result-document>
+  </xsl:template>
+
+</xsl:stylesheet> 

Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/amqp_server.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/amqp_server_handler_impl.xsl
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/amqp_server_handler_impl.xsl?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/amqp_server_handler_impl.xsl (added)
+++ incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/amqp_server_handler_impl.xsl Tue Sep 19 15:06:50 2006
@@ -0,0 +1,187 @@
+<?xml version='1.0'?> 
+<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:amqp="http://amqp.org"> 
+
+  <xsl:import href="code_utils.xsl"/>
+
+  <!--
+  ===============================
+  Template: server_handler_impl_h
+  ===============================
+  Template to generate the AMQP_ServerHandlerImpl class header file.
+  -->
+  <xsl:template match="amqp" mode="server_handler_impl_h">
+    <xsl:param name="domain-cpp-table"/>
+    <xsl:result-document href="AMQP_ServerHandlerImpl.h" format="textFormat">
+      <xsl:value-of select="amqp:copyright()"/>
+      <xsl:text>
+#ifndef _AMQP_ServerHandlerImpl_
+#define _AMQP_ServerHandlerImpl_
+
+#include "AMQP_ServerOperations.h"
+#include "FieldTable.h"
+
+namespace qpid {
+namespace framing {
+
+class AMQP_ServerHandlerImpl : virtual public AMQP_ServerOperations
+{&#xA;</xsl:text>
+
+      <!-- List of pointers to each inner class instance -->
+      <xsl:for-each select="class">
+        <xsl:variable name="class" select="concat(amqp:cpp-class-name(@name), 'Handler')"/>
+        <xsl:text>        AMQP_ServerOperations::</xsl:text><xsl:value-of select="$class"/><xsl:text>* </xsl:text>
+        <xsl:value-of select="$class"/><xsl:text>Ptr;&#xA;</xsl:text>
+      </xsl:for-each>
+      <xsl:text>
+    public:
+        AMQP_ServerHandlerImpl();
+        virtual ~AMQP_ServerHandlerImpl();&#xA;&#xA;</xsl:text>
+
+      <!-- List of functions to return pointer to each inner class instance -->
+      <xsl:for-each select="class">
+        <xsl:variable name="class" select="concat(amqp:cpp-class-name(@name), 'Handler')"/>
+        <xsl:text>        virtual inline AMQP_ServerOperations::</xsl:text>
+        <xsl:value-of select="$class"/><xsl:text>* get</xsl:text><xsl:value-of select="$class"/>
+        <xsl:text>() { return </xsl:text><xsl:value-of select="$class"/><xsl:text>Ptr; }&#xA;</xsl:text>
+      </xsl:for-each>
+      <xsl:text>&#xA;</xsl:text>
+
+      <!-- Inner classes -->
+      <xsl:for-each select="class">
+        <xsl:variable name="class" select="concat(amqp:cpp-class-name(@name), 'Handler')"/>
+
+        <!-- Inner class documentation & rules -->
+        <xsl:if test="doc">
+          <xsl:text>&#xA;/**&#xA;</xsl:text>
+          <xsl:text>===== Class: </xsl:text><xsl:value-of select="$class"/><xsl:text>Impl =====&#xA;</xsl:text>
+          <xsl:value-of select="amqp:process-docs(doc)"/>
+          <xsl:text>*/&#xA;</xsl:text>
+        </xsl:if>
+
+        <!-- Inner class definition -->
+        <xsl:text>        class </xsl:text><xsl:value-of select="$class"/>
+        <xsl:text>Impl : virtual public AMQP_ServerOperations::</xsl:text><xsl:value-of select="$class"/>
+        <xsl:text>&#xA;        {
+            public:
+                /* Constructors and destructors */
+                </xsl:text><xsl:value-of select="$class"/><xsl:text>Impl();
+                virtual ~</xsl:text><xsl:value-of select="$class"/><xsl:text>Impl();
+                
+                /* Protocol methods */&#xA;</xsl:text>
+
+        <!-- Inner class methods (only if the chassis is set to "server") -->
+        <xsl:for-each select="method">
+          <xsl:if test="chassis[@name='server']">
+            <xsl:variable name="method" select="amqp:cpp-name(@name)"/>
+
+            <!-- Inner class method documentation & rules -->
+            <xsl:if test="doc">
+              <xsl:text>&#xA;/**&#xA;</xsl:text>
+              <xsl:text>----- Method: </xsl:text><xsl:value-of select="$class"/>
+              <xsl:text>Impl.</xsl:text><xsl:value-of select="@name"/><xsl:text> -----&#xA;</xsl:text>
+              <xsl:value-of select="amqp:process-docs(doc)"/>
+              <xsl:text>*/&#xA;</xsl:text>
+            </xsl:if>
+            <xsl:for-each select="rule">
+              <xsl:text>&#xA;/**&#xA;</xsl:text>
+              <xsl:text>Rule "</xsl:text><xsl:value-of select="@name"/><xsl:text>":&#xA;</xsl:text>
+              <xsl:value-of select="amqp:process-docs(doc)"/>
+              <xsl:text>*/&#xA;</xsl:text>
+            </xsl:for-each>
+
+            <!-- Inner class method definition -->
+            <xsl:text>&#xA;                virtual void </xsl:text><xsl:value-of select="$method"/>
+            <xsl:text>( u_int16_t channel</xsl:text>
+
+            <!-- Inner class method parameter definition -->
+            <xsl:if test="field">
+              <xsl:text>,&#xA;                        </xsl:text>
+              <xsl:for-each select="field">
+                <xsl:variable name="domain-cpp-type" select="amqp:cpp-lookup(@domain, $domain-cpp-table)"/>
+                <xsl:value-of select="concat($domain-cpp-type, amqp:cpp-arg-ref($domain-cpp-type), ' ', amqp:cpp-name(@name))"/>
+                <xsl:if test="position()!=last()">
+                  <xsl:text>,&#xA;                        </xsl:text>
+                </xsl:if>
+              </xsl:for-each>
+            </xsl:if>
+            <xsl:text> );&#xA;</xsl:text>
+          </xsl:if>
+        </xsl:for-each>
+        <xsl:text>&#xA;        }; /* class </xsl:text><xsl:value-of select="$class"/><xsl:text>Impl */&#xA;</xsl:text>
+      </xsl:for-each>
+      <xsl:text>&#xA;}; /* AMQP_ServerHandlerImpl */
+
+} /* namespace framing */
+} /* namespace qpid */
+
+#endif&#xA;</xsl:text>
+    </xsl:result-document>
+  </xsl:template>
+
+  <!--
+  =================================
+  Template: server_handler_impl_cpp
+  =================================
+  Template to generate the AMQP_ServerHandlerImpl class stubs.
+  -->
+  <xsl:template match="amqp" mode="server_handler_impl_cpp">
+    <xsl:param name="domain-cpp-table"/>
+    <xsl:result-document href="AMQP_ServerHandlerImpl.cpp" format="textFormat">
+      <xsl:value-of select="amqp:copyright()"/>
+      <xsl:text>
+#include "AMQP_ServerHandlerImpl.h"
+
+namespace qpid {
+namespace framing {
+
+AMQP_ServerHandlerImpl::AMQP_ServerHandlerImpl() :&#xA;        </xsl:text>
+      <xsl:for-each select="class">
+        <xsl:variable name="class" select="amqp:cpp-class-name(@name)"/>
+        <xsl:value-of select="$class"/>
+        <xsl:text>HandlerPtr( new </xsl:text><xsl:value-of select="$class"/><xsl:text>HandlerImpl() )</xsl:text>
+        <xsl:if test="position()!=last()">
+          <xsl:text>,&#xA;        </xsl:text>
+        </xsl:if>
+      </xsl:for-each>
+      <xsl:text>
+{
+}
+
+AMQP_ServerHandlerImpl::~AMQP_ServerHandlerImpl()
+{&#xA;</xsl:text>
+      <xsl:for-each select="class">
+        <xsl:text>        delete </xsl:text><xsl:value-of select="amqp:cpp-class-name(@name)"/><xsl:text>HandlerPtr;&#xA;</xsl:text>
+      </xsl:for-each>}
+
+      <xsl:for-each select="class">
+        <xsl:variable name="class" select="amqp:cpp-class-name(@name)"/>
+        <xsl:text>&#xA;/* ===== Class: </xsl:text><xsl:value-of select="$class"/><xsl:text>HandlerImpl ===== */&#xA;&#xA;</xsl:text>
+        <xsl:text>AMQP_ServerHandlerImpl::</xsl:text><xsl:value-of select="$class"/><xsl:text>HandlerImpl::</xsl:text>
+        <xsl:value-of select="$class"/><xsl:text>HandlerImpl()&#xA;{&#xA;}&#xA;&#xA;</xsl:text>
+        <xsl:text>AMQP_ServerHandlerImpl::</xsl:text><xsl:value-of select="$class"/><xsl:text>HandlerImpl::~</xsl:text>
+        <xsl:value-of select="$class"/><xsl:text>HandlerImpl()&#xA;{&#xA;}&#xA;&#xA;</xsl:text>
+        <xsl:for-each select="method">
+          <xsl:if test="chassis[@name='server']">
+            <xsl:text>void AMQP_ServerHandlerImpl::</xsl:text><xsl:value-of select="$class"/><xsl:text>HandlerImpl::</xsl:text>
+            <xsl:value-of select="amqp:cpp-name(@name)"/><xsl:text>( u_int16_t channel</xsl:text>
+            <xsl:if test="field">
+              <xsl:text>,&#xA;                        </xsl:text>
+              <xsl:for-each select="field">
+                <xsl:variable name="domain-cpp-type" select="amqp:cpp-lookup(@domain, $domain-cpp-table)"/>
+                <xsl:value-of select="concat($domain-cpp-type, amqp:cpp-arg-ref($domain-cpp-type), ' ', amqp:cpp-name(@name))"/>
+                <xsl:if test="position()!=last()">
+                  <xsl:text>,&#xA;                        </xsl:text>
+                </xsl:if>
+              </xsl:for-each>
+            </xsl:if><xsl:text> )&#xA;{&#xA;}&#xA;&#xA;</xsl:text>
+          </xsl:if>
+        </xsl:for-each>
+      </xsl:for-each>
+      <xsl:text>
+
+} /* namespace framing */
+} /* namespace qpid */&#xA;&#xA;</xsl:text>
+    </xsl:result-document>
+  </xsl:template>
+
+</xsl:stylesheet> 

Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/amqp_server_handler_impl.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/amqp_server_operations.xsl
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/amqp_server_operations.xsl?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/amqp_server_operations.xsl (added)
+++ incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/amqp_server_operations.xsl Tue Sep 19 15:06:50 2006
@@ -0,0 +1,113 @@
+<?xml version='1.0'?> 
+<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:amqp="http://amqp.org"> 
+
+  <xsl:import href="code_utils.xsl"/>
+
+  <!--
+  =============================
+  Template: server-operations-h
+  =============================
+  Template to generate the AMQP_ServerHandler virtual class. This is the pure
+  virtual class from which the AMQP_Client and AMQP_ServerHandlerImpl classes
+  are derived.
+  -->
+  <xsl:template match="amqp" mode="server-operations-h">
+    <xsl:param name="domain-cpp-table"/>
+    <xsl:result-document href="AMQP_ServerOperations.h" format="textFormat">
+      <xsl:value-of select="amqp:copyright()"/>
+      <xsl:text>
+#ifndef _AMQP_ServerOperations_
+#define _AMQP_ServerOperations_
+
+#include "AMQP_Constants.h"
+#include "FieldTable.h"
+
+namespace qpid {
+namespace framing {
+
+class AMQP_ServerOperations
+{
+    public:
+        AMQP_ServerOperations() {}
+        virtual ~AMQP_ServerOperations() {}
+        inline u_int16_t getAmqpMajor() { return (u_int16_t)</xsl:text><xsl:value-of select="@major"/><xsl:text>; }
+        inline u_int16_t getAmqpMinor() { return (u_int16_t)</xsl:text><xsl:value-of select="@minor"/><xsl:text>; }&#xA;&#xA;</xsl:text>
+
+      <!-- Inner classes -->
+      <xsl:for-each select="class">
+        <xsl:variable name="class" select="concat(amqp:cpp-class-name(@name), 'Handler')"/>
+
+        <!-- Inner class documentation & rules -->
+        <xsl:if test="doc">
+          <xsl:text>&#xA;/**&#xA;===== Class: </xsl:text><xsl:value-of select="$class"/><xsl:text> =====&#xA;</xsl:text>
+          <xsl:value-of select="amqp:process-docs(doc)"/>
+          <xsl:text>*/&#xA;</xsl:text>
+        </xsl:if>
+
+        <!-- Inner class definition -->
+        <xsl:text>        class </xsl:text><xsl:value-of select="$class"/><xsl:text>
+        {
+            public:
+                /* Constructors and destructors */
+                </xsl:text><xsl:value-of select="$class"/><xsl:text>() {}
+                virtual ~</xsl:text><xsl:value-of select="$class"/><xsl:text>() {}
+                
+                /* Protocol methods */&#xA;</xsl:text>
+
+        <!-- Inner class methods (only if the chassis is set to "server") -->
+        <xsl:for-each select="method">
+          <xsl:if test="chassis[@name='server']">
+            <xsl:variable name="method" select="amqp:cpp-name(@name)"/>
+
+            <!-- Inner class method documentation & rules -->
+            <xsl:if test="doc">
+              <xsl:text>&#xA;/**&#xA;----- Method: </xsl:text><xsl:value-of select="$class"/><xsl:text>.</xsl:text>
+              <xsl:value-of select="@name"/><xsl:text> -----&#xA;</xsl:text>
+              <xsl:value-of select="amqp:process-docs(doc)"/>
+              <xsl:text>*/&#xA;</xsl:text>
+            </xsl:if>
+            <xsl:for-each select="rule">/**
+              <xsl:text>&#xA;/**&#xA;</xsl:text>
+              <xsl:text>Rule "</xsl:text><xsl:value-of select="@name"/><xsl:text>":&#xA;</xsl:text>
+              <xsl:value-of select="amqp:process-docs(doc)"/>
+              <xsl:text>*/&#xA;</xsl:text>
+            </xsl:for-each>
+
+            <!-- Inner class method definition -->
+            <xsl:text>                virtual void </xsl:text><xsl:value-of select="$method"/>
+            <xsl:text>( u_int16_t channel</xsl:text>
+
+            <!-- Inner class method parameter definition -->
+            <xsl:if test="field">
+              <xsl:text>,&#xA;                        </xsl:text>
+              <xsl:for-each select="field">
+                <xsl:variable name="domain-cpp-type" select="amqp:cpp-lookup(@domain, $domain-cpp-table)"/>
+                <xsl:value-of select="concat($domain-cpp-type, amqp:cpp-arg-ref($domain-cpp-type), ' ', amqp:cpp-name(@name))"/>
+                <xsl:if test="position()!=last()">
+                  <xsl:text>,&#xA;                        </xsl:text>
+                </xsl:if>
+              </xsl:for-each>
+            </xsl:if>
+            <xsl:text> ) = 0;&#xA;</xsl:text>
+          </xsl:if>
+        </xsl:for-each>
+        <xsl:text>        }; /* class </xsl:text><xsl:value-of select="$class"/><xsl:text> */&#xA;</xsl:text>
+      </xsl:for-each>
+
+      <xsl:for-each select="class">
+        <xsl:variable name="class" select="concat(amqp:cpp-class-name(@name), 'Handler')"/>
+        <xsl:text>        virtual AMQP_ServerOperations::</xsl:text>
+        <xsl:value-of select="$class"/><xsl:text>* get</xsl:text><xsl:value-of select="$class"/>
+        <xsl:text>() = 0;</xsl:text>
+      </xsl:for-each>
+
+      <xsl:text>}; /* class AMQP_ServerOperations */
+
+} /* namespace framing */
+} /* namespace qpid */
+
+#endif&#xA;</xsl:text>
+    </xsl:result-document>
+  </xsl:template>
+
+</xsl:stylesheet> 

Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/amqp_server_operations.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/code_gen.xsl
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/code_gen.xsl?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/code_gen.xsl (added)
+++ incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/code_gen.xsl Tue Sep 19 15:06:50 2006
@@ -0,0 +1,91 @@
+<?xml version='1.0'?> 
+<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:amqp="http://amqp.org"> 
+
+  <xsl:import href="convert_0.81.xsl"/>
+  <xsl:import href="amqp_consts.xsl"/>
+  <xsl:import href="amqp_server_operations.xsl"/>
+  <xsl:import href="amqp_client_operations.xsl"/>
+  <xsl:import href="amqp_server.xsl"/>
+  <xsl:import href="amqp_client.xsl"/>
+  <xsl:import href="amqp_server_handler_impl.xsl"/>
+  <xsl:import href="amqp_client_handler_impl.xsl"/>
+
+  <xsl:output method="text" indent="yes" name="textFormat"/> 
+  <xsl:key name="domain-lookup" match="domains/domain" use="@domain-name"/>
+
+  <xsl:template match="/">
+
+    <!-- 0. Convert to 0.81 format -->
+    <!--
+    NOTE: The XML specification change from 0.8 to 0.81 is primarily a change to
+    the XML itself, not the protocol it represents. However, at the time of this
+    commit, the 0.81 specification has not been approved by the AMQP working group,
+    so this converter from the 0.8 format to the 0.81 format has been included as
+    a temporary measure. When the 0.81 format becomes official, then this conversion
+    should be removed, and all of the templates below will revert to select=".".
+
+    TODO: Remove this conversion when the new 0.81 spec is checked in.
+    -->
+    <xsl:variable name="format-v081">
+      <xsl:apply-templates mode="do-amqp" select="amqp"/>
+    </xsl:variable>
+    <!-- == Uncomment this to view output for debugging ==
+    <xsl:result-document href="convert_081.out">
+        <xsl:copy-of select="$format-v081"/> 
+    </xsl:result-document>
+    -->
+
+    <!-- 1. Domain to C++ type lookup table -->
+    <xsl:variable name="domain-cpp-table">
+      <xsl:apply-templates mode="domain-table" select="$format-v081"/>
+    </xsl:variable>
+    <!-- == Uncomment this to view output for debugging ==
+    <xsl:result-document href="domain_cpp_table.out">
+        <xsl:copy-of select="$domain-cpp-table"/> 
+    </xsl:result-document>
+    -->
+
+    <!-- 2. Constant declarations (AMQP_Constants.h) -->
+    <xsl:apply-templates mode="domain-consts" select="$format-v081"/>
+
+    <!-- 3. Client and server handler pure virtual classes -->
+    <xsl:apply-templates mode="server-operations-h" select="$format-v081">
+      <xsl:with-param name="domain-cpp-table" select="$domain-cpp-table"/>
+    </xsl:apply-templates>
+    <xsl:apply-templates mode="client-operations-h" select="$format-v081">
+      <xsl:with-param name="domain-cpp-table" select="$domain-cpp-table"/>
+    </xsl:apply-templates>
+
+    <!-- 4. Client and server output classes -->
+    <xsl:apply-templates mode="server_h" select="$format-v081">
+      <xsl:with-param name="domain-cpp-table" select="$domain-cpp-table"/>
+    </xsl:apply-templates>
+    <xsl:apply-templates mode="client_h" select="$format-v081">
+      <xsl:with-param name="domain-cpp-table" select="$domain-cpp-table"/>
+    </xsl:apply-templates>
+    <xsl:apply-templates mode="server_cpp" select="$format-v081">
+      <xsl:with-param name="domain-cpp-table" select="$domain-cpp-table"/>
+    </xsl:apply-templates>
+    <xsl:apply-templates mode="client_cpp" select="$format-v081">
+      <xsl:with-param name="domain-cpp-table" select="$domain-cpp-table"/>
+    </xsl:apply-templates>
+
+    <!-- 5. Client and server handler stub classes -->
+    <xsl:apply-templates mode="server_handler_impl_h" select="$format-v081">
+      <xsl:with-param name="domain-cpp-table" select="$domain-cpp-table"/>
+    </xsl:apply-templates>
+    <xsl:apply-templates mode="client_handler_impl_h" select="$format-v081">
+      <xsl:with-param name="domain-cpp-table" select="$domain-cpp-table"/>
+    </xsl:apply-templates>
+    <!-- TODO: Find a way to only run the .cpp stub generator when required, as
+    running this will overwrite any stub code in existance! -->
+    <xsl:apply-templates mode="server_handler_impl_cpp" select="$format-v081">
+      <xsl:with-param name="domain-cpp-table" select="$domain-cpp-table"/>
+    </xsl:apply-templates>
+    <xsl:apply-templates mode="client_handler_impl_cpp" select="$format-v081">
+      <xsl:with-param name="domain-cpp-table" select="$domain-cpp-table"/>
+    </xsl:apply-templates>
+
+ </xsl:template>
+
+</xsl:stylesheet> 

Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/generated/stylesheets/code_gen.xsl
------------------------------------------------------------------------------
    svn:eol-style = native