summaryrefslogtreecommitdiff
path: root/cpp/lib
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/lib')
-rw-r--r--cpp/lib/broker/BrokerMessage.cpp4
-rw-r--r--cpp/lib/broker/Content.h28
-rw-r--r--cpp/lib/broker/InMemoryContent.cpp3
-rw-r--r--cpp/lib/broker/InMemoryContent.h2
-rw-r--r--cpp/lib/broker/LazyLoadedContent.cpp9
-rw-r--r--cpp/lib/broker/LazyLoadedContent.h3
6 files changed, 31 insertions, 18 deletions
diff --git a/cpp/lib/broker/BrokerMessage.cpp b/cpp/lib/broker/BrokerMessage.cpp
index d232efff16..76417056cb 100644
--- a/cpp/lib/broker/BrokerMessage.cpp
+++ b/cpp/lib/broker/BrokerMessage.cpp
@@ -58,9 +58,7 @@ BasicMessage::BasicMessage(
BasicMessage::BasicMessage() : size(0)
{}
-BasicMessage::~BasicMessage(){
- if (content.get()) content->destroy();
-}
+BasicMessage::~BasicMessage(){}
void BasicMessage::setHeader(AMQHeaderBody::shared_ptr _header){
this->header = _header;
diff --git a/cpp/lib/broker/Content.h b/cpp/lib/broker/Content.h
index 3058fdfd6a..1b884536f0 100644
--- a/cpp/lib/broker/Content.h
+++ b/cpp/lib/broker/Content.h
@@ -21,6 +21,8 @@
#ifndef _Content_
#define _Content_
+#include <boost/function.hpp>
+
#include <AMQContentBody.h>
#include <Buffer.h>
#include <OutputHandler.h>
@@ -34,13 +36,31 @@ class ChannelAdapter;
namespace broker {
class Content{
public:
+ typedef std::string DataBlock;
+ typedef boost::function1<void, const DataBlock&> SendFn;
+
+ virtual ~Content(){}
+
+ /** Add a block of data to the content */
+ // FIXME aconway 2007-02-07:
+ // virtual void add(const DataBlock& data) = 0;
virtual void add(framing::AMQContentBody::shared_ptr data) = 0;
+
+ /** Total size of content in bytes */
virtual u_int32_t size() = 0;
- virtual void send(framing::ChannelAdapter& channel,
- u_int32_t framesize) = 0;
+
+ /**
+ * Iterate over the content calling SendFn for each block.
+ * Subdivide blocks if necessary to ensure each block is
+ * <= framesize bytes long.
+ */
+ // FIXME aconway 2007-02-07:
+ // virtual void send(SendFn send, u_int32_t framesize) = 0;
+ virtual void send(framing::ChannelAdapter& channel, u_int32_t framesize) = 0;
+
+ //FIXME aconway 2007-02-07: This is inconsistently implemented
+ //find out what is needed.
virtual void encode(qpid::framing::Buffer& buffer) = 0;
- virtual void destroy() = 0;
- virtual ~Content(){}
};
}}
diff --git a/cpp/lib/broker/InMemoryContent.cpp b/cpp/lib/broker/InMemoryContent.cpp
index e27ccd8c4a..a91fe4d66f 100644
--- a/cpp/lib/broker/InMemoryContent.cpp
+++ b/cpp/lib/broker/InMemoryContent.cpp
@@ -71,6 +71,3 @@ void InMemoryContent::encode(Buffer& buffer)
}
}
-void InMemoryContent::destroy()
-{
-}
diff --git a/cpp/lib/broker/InMemoryContent.h b/cpp/lib/broker/InMemoryContent.h
index 7003ea2aab..8308ae4350 100644
--- a/cpp/lib/broker/InMemoryContent.h
+++ b/cpp/lib/broker/InMemoryContent.h
@@ -37,8 +37,6 @@ namespace qpid {
u_int32_t size();
void send(framing::ChannelAdapter&, u_int32_t framesize);
void encode(qpid::framing::Buffer& buffer);
- void destroy();
- ~InMemoryContent(){}
};
}
}
diff --git a/cpp/lib/broker/LazyLoadedContent.cpp b/cpp/lib/broker/LazyLoadedContent.cpp
index d8f18d5c8b..e4ea1333e7 100644
--- a/cpp/lib/broker/LazyLoadedContent.cpp
+++ b/cpp/lib/broker/LazyLoadedContent.cpp
@@ -25,6 +25,11 @@
using namespace qpid::broker;
using namespace qpid::framing;
+LazyLoadedContent::~LazyLoadedContent()
+{
+ store->destroy(msg);
+}
+
LazyLoadedContent::LazyLoadedContent(MessageStore* const _store, Message* const _msg, u_int64_t _expectedSize) :
store(_store), msg(_msg), expectedSize(_expectedSize) {}
@@ -61,7 +66,3 @@ void LazyLoadedContent::encode(Buffer&)
//do nothing as all content is written as soon as it is added
}
-void LazyLoadedContent::destroy()
-{
- store->destroy(msg);
-}
diff --git a/cpp/lib/broker/LazyLoadedContent.h b/cpp/lib/broker/LazyLoadedContent.h
index 56fdd7699b..e5fd7c8957 100644
--- a/cpp/lib/broker/LazyLoadedContent.h
+++ b/cpp/lib/broker/LazyLoadedContent.h
@@ -34,14 +34,13 @@ namespace qpid {
LazyLoadedContent(
MessageStore* const store, Message* const msg,
u_int64_t expectedSize);
+ ~LazyLoadedContent();
void add(qpid::framing::AMQContentBody::shared_ptr data);
u_int32_t size();
void send(
framing::ChannelAdapter&,
u_int32_t framesize);
void encode(qpid::framing::Buffer& buffer);
- void destroy();
- ~LazyLoadedContent(){}
};
}
}