/usr/share/cruisecontrol-bin-2.6.1/projects/qpid-trunk/cpp/src/qpid/broker/QueueRegistry.h

00001 /*
00002  *
00003  * Licensed to the Apache Software Foundation (ASF) under one
00004  * or more contributor license agreements.  See the NOTICE file
00005  * distributed with this work for additional information
00006  * regarding copyright ownership.  The ASF licenses this file
00007  * to you under the Apache License, Version 2.0 (the
00008  * "License"); you may not use this file except in compliance
00009  * with the License.  You may obtain a copy of the License at
00010  * 
00011  *   http://www.apache.org/licenses/LICENSE-2.0
00012  * 
00013  * Unless required by applicable law or agreed to in writing,
00014  * software distributed under the License is distributed on an
00015  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
00016  * KIND, either express or implied.  See the License for the
00017  * specific language governing permissions and limitations
00018  * under the License.
00019  *
00020  */
00021 #ifndef _QueueRegistry_
00022 #define _QueueRegistry_
00023 
00024 #include <map>
00025 #include "qpid/sys/Mutex.h"
00026 #include "Queue.h"
00027 #include "qpid/management/Manageable.h"
00028 
00029 namespace qpid {
00030 namespace broker {
00031 
00039 class QueueRegistry{
00040   public:
00041     QueueRegistry();
00042     ~QueueRegistry();
00043 
00050     std::pair<Queue::shared_ptr, bool> declare(const string& name, bool durable = false, bool autodelete = false, 
00051                                                const OwnershipToken* const owner = 0);
00052 
00065     void destroy   (const string& name);
00066     template <class Test> bool destroyIf(const string& name, Test test)
00067     {
00068         qpid::sys::RWlock::ScopedWlock locker(lock);
00069         if (test()) {
00070             destroyLH (name);
00071             return true;
00072         } else {
00073             return false;
00074         }
00075     }
00076 
00080     Queue::shared_ptr find(const string& name);
00081 
00085     string generateName();
00086 
00090     void setStore (MessageStore*);
00091 
00095     MessageStore* getStore() const;
00096 
00100     void setParent (management::Manageable* _parent) { parent = _parent; }
00101     
00102 private:
00103     typedef std::map<string, Queue::shared_ptr> QueueMap;
00104     QueueMap queues;
00105     qpid::sys::RWlock lock;
00106     int counter;
00107     MessageStore* store;
00108     management::Manageable* parent;
00109 
00110     //destroy impl that assumes lock is already held:
00111     void destroyLH (const string& name);
00112 };
00113 
00114     
00115 }
00116 }
00117 
00118 
00119 #endif

Generated on Thu Apr 10 11:08:17 2008 for Qpid by  doxygen 1.4.7