00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _QueueRegistry_
00022 #define _QueueRegistry_
00023
00024 #include "Queue.h"
00025 #include "qpid/sys/Mutex.h"
00026 #include "qpid/management/Manageable.h"
00027 #include <boost/bind.hpp>
00028 #include <algorithm>
00029 #include <map>
00030
00031 namespace qpid {
00032 namespace broker {
00033
00041 class QueueRegistry{
00042 public:
00043 QueueRegistry();
00044 ~QueueRegistry();
00045
00052 std::pair<Queue::shared_ptr, bool> declare(const string& name, bool durable = false, bool autodelete = false,
00053 const OwnershipToken* owner = 0);
00054
00067 void destroy (const string& name);
00068 template <class Test> bool destroyIf(const string& name, Test test)
00069 {
00070 qpid::sys::RWlock::ScopedWlock locker(lock);
00071 if (test()) {
00072 destroyLH (name);
00073 return true;
00074 } else {
00075 return false;
00076 }
00077 }
00078
00082 Queue::shared_ptr find(const string& name);
00083
00087 string generateName();
00088
00092 void setStore (MessageStore*);
00093
00097 MessageStore* getStore() const;
00098
00102 void setParent (management::Manageable* _parent) { parent = _parent; }
00103
00105 template <class F> void eachQueue(F f) const {
00106 qpid::sys::RWlock::ScopedWlock l(lock);
00107 for (QueueMap::const_iterator i = queues.begin(); i != queues.end(); ++i)
00108 f(i->second);
00109 }
00110
00115 void updateQueueClusterState(bool lastNode);
00116
00117 private:
00118 typedef std::map<string, Queue::shared_ptr> QueueMap;
00119 QueueMap queues;
00120 mutable qpid::sys::RWlock lock;
00121 int counter;
00122 MessageStore* store;
00123 management::Manageable* parent;
00124 bool lastNode;
00125
00126
00127 void destroyLH (const string& name);
00128 };
00129
00130
00131 }}
00132
00133
00134 #endif