summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/framing
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2007-07-05 16:08:29 +0000
committerAlan Conway <aconway@apache.org>2007-07-05 16:08:29 +0000
commit0865408d7fa16f913391ed9391fb13268a74d8a1 (patch)
tree3107946aae1031a960bc68921a33c9708c8bea53 /cpp/src/qpid/framing
parent4e60e87b604f8959907a329a36264f98debc9536 (diff)
downloadqpid-python-0865408d7fa16f913391ed9391fb13268a74d8a1.tar.gz
* src/qpid/cluster/SessionFrame.cpp, .h: Wrap AMQFrame with
session UUID and direction. * src/qpid/cluster/Cluster.cpp, .h: Use SessionFrame. * src/qpid/framing/AMQFrame.h, .cpp: Added setBody(), inline getBody() * src/qpid/framing/Uuid.h, .cpp: Clean up constructors, inline. * src/qpid/framing/Buffer.h: Put/get byte*, size_T. * src/qpid/cluster/SessionManager.cpp, .h: - Maintain the session map. - Handle frames from cluster, dispatch to proper channels. - Implement HandlerUpdater for new channels and maintains git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@553543 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/framing')
-rw-r--r--cpp/src/qpid/framing/AMQFrame.cpp4
-rw-r--r--cpp/src/qpid/framing/AMQFrame.h7
-rw-r--r--cpp/src/qpid/framing/Buffer.h2
-rw-r--r--cpp/src/qpid/framing/Uuid.cpp8
-rw-r--r--cpp/src/qpid/framing/Uuid.h26
5 files changed, 29 insertions, 18 deletions
diff --git a/cpp/src/qpid/framing/AMQFrame.cpp b/cpp/src/qpid/framing/AMQFrame.cpp
index a528913fd9..13f1d3cece 100644
--- a/cpp/src/qpid/framing/AMQFrame.cpp
+++ b/cpp/src/qpid/framing/AMQFrame.cpp
@@ -47,10 +47,6 @@ AMQFrame::AMQFrame(ProtocolVersion _version, uint16_t _channel, const AMQBody::s
AMQFrame::~AMQFrame() {}
-AMQBody::shared_ptr AMQFrame::getBody(){
- return body;
-}
-
void AMQFrame::encode(Buffer& buffer)
{
buffer.putOctet(body->type());
diff --git a/cpp/src/qpid/framing/AMQFrame.h b/cpp/src/qpid/framing/AMQFrame.h
index 1a7b203ad7..16c1427802 100644
--- a/cpp/src/qpid/framing/AMQFrame.h
+++ b/cpp/src/qpid/framing/AMQFrame.h
@@ -32,7 +32,8 @@
#include "AMQHeartbeatBody.h"
#include "qpid/framing/AMQP_MethodVersionMap.h"
#include "qpid/framing/AMQP_HighestVersion.h"
-#include "Buffer.h"
+#include "qpid/framing/Buffer.h"
+#include "qpid/shared_ptr.h"
namespace qpid {
namespace framing {
@@ -49,7 +50,9 @@ class AMQFrame : public AMQDataBlock
virtual bool decode(Buffer& buffer);
virtual uint32_t size() const;
uint16_t getChannel() const { return channel; }
- AMQBody::shared_ptr getBody();
+
+ shared_ptr<AMQBody> getBody() { return body; }
+ void setBody(const shared_ptr<AMQBody>& b) { body = b; }
/** Convenience template to cast the body to an expected type */
template <class T> boost::shared_ptr<T> castBody() {
diff --git a/cpp/src/qpid/framing/Buffer.h b/cpp/src/qpid/framing/Buffer.h
index d35935ad19..04acb65e91 100644
--- a/cpp/src/qpid/framing/Buffer.h
+++ b/cpp/src/qpid/framing/Buffer.h
@@ -81,6 +81,8 @@ public:
void putRawData(const uint8_t* data, size_t size);
void getRawData(uint8_t* data, size_t size);
+ template <class T> void put(const T& data) { data.encode(*this); }
+ template <class T> void get(T& data) { data.decode(*this); }
};
}} // namespace qpid::framing
diff --git a/cpp/src/qpid/framing/Uuid.cpp b/cpp/src/qpid/framing/Uuid.cpp
index b1523f0d61..3a83430d56 100644
--- a/cpp/src/qpid/framing/Uuid.cpp
+++ b/cpp/src/qpid/framing/Uuid.cpp
@@ -21,20 +21,14 @@
#include "qpid/QpidError.h"
#include "qpid/framing/Buffer.h"
-#include <uuid/uuid.h>
-
namespace qpid {
namespace framing {
using namespace std;
-Uuid::Uuid() { uuid_generate(c_array()); }
-
-Uuid::Uuid(uint8_t* uu) { uuid_copy(c_array(),uu); }
-
static const size_t UNPARSED_SIZE=36;
-void Uuid::encode(Buffer& buf) {
+void Uuid::encode(Buffer& buf) const {
buf.putRawData(data(), size());
}
diff --git a/cpp/src/qpid/framing/Uuid.h b/cpp/src/qpid/framing/Uuid.h
index a2f415b118..19ae79db6a 100644
--- a/cpp/src/qpid/framing/Uuid.h
+++ b/cpp/src/qpid/framing/Uuid.h
@@ -20,9 +20,12 @@
*/
#include <boost/array.hpp>
+
#include <ostream>
#include <istream>
+#include <uuid/uuid.h>
+
namespace qpid {
namespace framing {
@@ -35,16 +38,29 @@ class Buffer;
* boost::array so Uuid can be the key type in a map etc.
*/
struct Uuid : public boost::array<uint8_t, 16> {
- /** Geneate universally unique identifier */
- Uuid();
+ /** If unique is true, generate a unique ID else a null ID. */
+ Uuid(bool unique=false) { if (unique) generate(); else clear(); }
+
+ /** Copy from 16 bytes of data */
+ Uuid(const uint8_t* data) { assign(data); }
+
+ /** Copy from 16 bytes of data */
+ void assign(const uint8_t* data) { uuid_copy(c_array(), data); }
+
+ /** Set to a new unique identifier */
+ void generate() { uuid_generate(c_array()); }
- /** Initialize from 16 bytes of data */
- Uuid(uint8_t* data);
+ /** Set to all zeros */
+ void clear() { uuid_clear(c_array()); }
+
+ /** Test for null (all zeros) */
+ bool isNull() const { return uuid_is_null(data()); }
// Default op= and copy ctor are fine.
// boost::array gives us ==, < etc.
- void encode(framing::Buffer& buf);
+ void encode(framing::Buffer& buf) const;
+
void decode(framing::Buffer& buf);
};