00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _HeadersExchange_
00022 #define _HeadersExchange_
00023
00024 #include <vector>
00025 #include "Exchange.h"
00026 #include "qpid/framing/FieldTable.h"
00027 #include "qpid/sys/CopyOnWriteArray.h"
00028 #include "qpid/sys/Mutex.h"
00029 #include "Queue.h"
00030
00031 namespace qpid {
00032 namespace broker {
00033
00034
00035 class HeadersExchange : public virtual Exchange {
00036 typedef std::pair<qpid::framing::FieldTable, Binding::shared_ptr> HeaderMap;
00037 typedef qpid::sys::CopyOnWriteArray<Binding::shared_ptr> Bindings;
00038
00039 struct MatchArgs
00040 {
00041 const Queue::shared_ptr queue;
00042 const qpid::framing::FieldTable* args;
00043 MatchArgs(Queue::shared_ptr q, const qpid::framing::FieldTable* a);
00044 bool operator()(Exchange::Binding::shared_ptr b);
00045 };
00046 struct MatchKey
00047 {
00048 const Queue::shared_ptr queue;
00049 const std::string& key;
00050 MatchKey(Queue::shared_ptr q, const std::string& k);
00051 bool operator()(Exchange::Binding::shared_ptr b);
00052 };
00053
00054 Bindings bindings;
00055 qpid::sys::Mutex lock;
00056
00057 static std::string getMatch(const framing::FieldTable* args);
00058
00059 public:
00060 static const std::string typeName;
00061
00062 HeadersExchange(const string& name, management::Manageable* parent = 0);
00063 HeadersExchange(const string& _name, bool _durable,
00064 const qpid::framing::FieldTable& _args,
00065 management::Manageable* parent = 0);
00066
00067 virtual std::string getType() const { return typeName; }
00068
00069 virtual bool bind(Queue::shared_ptr queue, const string& routingKey, const qpid::framing::FieldTable* args);
00070
00071 virtual bool unbind(Queue::shared_ptr queue, const string& routingKey, const qpid::framing::FieldTable* args);
00072
00073 virtual void route(Deliverable& msg, const string& routingKey, const qpid::framing::FieldTable* args);
00074
00075 virtual bool isBound(Queue::shared_ptr queue, const string* const routingKey, const qpid::framing::FieldTable* const args);
00076
00077 virtual ~HeadersExchange();
00078
00079 static bool match(const qpid::framing::FieldTable& bindArgs, const qpid::framing::FieldTable& msgArgs);
00080 static bool equal(const qpid::framing::FieldTable& bindArgs, const qpid::framing::FieldTable& msgArgs);
00081 };
00082
00083
00084
00085 }
00086 }
00087
00088 #endif