diff options
| author | Alan Conway <aconway@apache.org> | 2007-11-22 23:55:39 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2007-11-22 23:55:39 +0000 |
| commit | cb070d9813e4232b4ec8409ca555b529ee5cee4b (patch) | |
| tree | 7f8ed15de2c4f933db59b79b52222c70f2a2a240 /cpp/src/qpid | |
| parent | 4d16c847bd0868ac8ff3039ce22fcdae28606aeb (diff) | |
| download | qpid-python-cb070d9813e4232b4ec8409ca555b529ee5cee4b.tar.gz | |
Added framing::BodyHolder:
- Uniform holder for all body types, replaces MethodHolder.
- Uses in_place constructors to avoid avoid body copy.
framing::AMQFrame:
- Holds body in heap-allocated intrusive_ptr<BodyHolder>
- Uses in_place constructors to avoid avoid body copy.
Removed/downgraded to TODO many redundant FIXME comments.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@597513 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid')
36 files changed, 303 insertions, 464 deletions
diff --git a/cpp/src/qpid/ExceptionHolder.cpp b/cpp/src/qpid/ExceptionHolder.cpp deleted file mode 100644 index de8d7b2487..0000000000 --- a/cpp/src/qpid/ExceptionHolder.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * Copyright (c) 2006 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include "ExceptionHolder.h" - -namespace qpid { - -ExceptionHolder::ExceptionHolder(const std::exception& e) { - const Exception* ex = dynamic_cast<const Exception*>(&e); - if (ex) { - reset(ex->clone()); - } else { - reset(new Exception(e.what())); - } -} - -} diff --git a/cpp/src/qpid/ExceptionHolder.h b/cpp/src/qpid/ExceptionHolder.h deleted file mode 100644 index 723dac4b2d..0000000000 --- a/cpp/src/qpid/ExceptionHolder.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef _qpid_ExceptionHolder_h -#define _qpid_ExceptionHolder_h - -/* - * - * Copyright (c) 2006 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include <assert.h> -#include "Exception.h" -#include <boost/shared_ptr.hpp> - -namespace qpid { - -// FIXME aconway 2007-02-20: Not necessary, a simple -// Exception::shared_ptr will do the job. Remove -// -/** - * Holder for a heap-allocated exc eption that can be stack allocated - * and thrown safely. - * - * Basically this is a shared_ptr with the Exception functions added - * so the catcher need not be aware that it is a pointer rather than a - * reference. - * - * shared_ptr is chosen over auto_ptr because it has normal - * copy semantics. - */ -class ExceptionHolder : public Exception, public boost::shared_ptr<Exception> -{ - public: - typedef boost::shared_ptr<Exception> shared_ptr; - - ExceptionHolder() throw() {} - ExceptionHolder(Exception* p) throw() : shared_ptr(p) {} - ExceptionHolder(shared_ptr p) throw() : shared_ptr(p) {} - - ExceptionHolder(const Exception& e) throw() : shared_ptr(e.clone()) {} - ExceptionHolder(const std::exception& e); - - ~ExceptionHolder() throw() {} - - const char* what() const throw() { return get()->what(); } - std::string toString() const throw() { return get()->toString(); } - Exception* clone() const throw() { return get()->clone(); } - void throwIf() const { if (get()) get()->throwSelf(); } - void throwSelf() const { assert(get()); get()->throwSelf(); } -}; - -} // namespace qpid - - - -#endif /*!_qpid_ExceptionHolder_h*/ diff --git a/cpp/src/qpid/broker/BrokerAdapter.cpp b/cpp/src/qpid/broker/BrokerAdapter.cpp index b00c99c3bb..82378f938b 100644 --- a/cpp/src/qpid/broker/BrokerAdapter.cpp +++ b/cpp/src/qpid/broker/BrokerAdapter.cpp @@ -31,7 +31,7 @@ using namespace qpid::framing; typedef std::vector<Queue::shared_ptr> QueueVector; -// FIXME aconway 2007-08-31: now that functionality is distributed +// TODO aconway 2007-08-31: now that functionality is distributed // between different handlers, BrokerAdapter should be dropped. // Instead the individual class Handler interfaces can be implemented // by the handlers responsible for those classes. diff --git a/cpp/src/qpid/broker/DtxManager.cpp b/cpp/src/qpid/broker/DtxManager.cpp index 0597b41f98..7ac89d3a4e 100644 --- a/cpp/src/qpid/broker/DtxManager.cpp +++ b/cpp/src/qpid/broker/DtxManager.cpp @@ -31,9 +31,7 @@ using namespace qpid::framing; DtxManager::DtxManager(TransactionalStore* const _store) : store(_store) {} -DtxManager::~DtxManager() { - // timer.stop(); // FIXME aconway 2007-10-23: leaking threads. -} +DtxManager::~DtxManager() {} void DtxManager::start(const std::string& xid, DtxBuffer::shared_ptr ops) { diff --git a/cpp/src/qpid/broker/Message.cpp b/cpp/src/qpid/broker/Message.cpp index c307118f20..6aa0f4c30b 100644 --- a/cpp/src/qpid/broker/Message.cpp +++ b/cpp/src/qpid/broker/Message.cpp @@ -165,7 +165,7 @@ void Message::sendContent(Queue& queue, framing::FrameHandler& out, uint16_t max for (uint64_t offset = 0; offset < expectedSize; offset += maxContentSize) { uint64_t remaining = expectedSize - offset; - AMQFrame frame(0, AMQContentBody()); + AMQFrame frame(in_place<AMQContentBody>()); string& data = frame.castBody<AMQContentBody>()->getData(); store->loadContent(queue, *this, data, offset, @@ -196,7 +196,7 @@ void Message::sendHeader(framing::FrameHandler& out, uint16_t /*maxFrameSize*/) frames.map_if(f, TypeFilter<HEADER_BODY>()); } -// FIXME aconway 2007-11-09: Obsolete, remove. Was used to cover over +// TODO aconway 2007-11-09: Obsolete, remove. Was used to cover over // 0-8/0-9 message differences. MessageAdapter& Message::getAdapter() const { diff --git a/cpp/src/qpid/broker/MessageAdapter.h b/cpp/src/qpid/broker/MessageAdapter.h index ef316edacb..3220f304cc 100644 --- a/cpp/src/qpid/broker/MessageAdapter.h +++ b/cpp/src/qpid/broker/MessageAdapter.h @@ -33,7 +33,7 @@ namespace qpid { namespace broker { -// FIXME aconway 2007-11-09: No longer needed, we only have one type of message. +// TODO aconway 2007-11-09: No longer needed, we only have one type of message. struct MessageAdapter { virtual ~MessageAdapter() {} diff --git a/cpp/src/qpid/broker/MessageDelivery.cpp b/cpp/src/qpid/broker/MessageDelivery.cpp index d7f8bceae1..886008c213 100644 --- a/cpp/src/qpid/broker/MessageDelivery.cpp +++ b/cpp/src/qpid/broker/MessageDelivery.cpp @@ -52,8 +52,9 @@ struct BasicGetToken : BaseToken AMQFrame sendMethod(intrusive_ptr<Message> msg, DeliveryId id) { - return AMQFrame(0, BasicGetOkBody( - ProtocolVersion(), id.getValue(), msg->getRedelivered(), msg->getExchangeName(), + return AMQFrame(in_place<BasicGetOkBody>( + ProtocolVersion(), id.getValue(), + msg->getRedelivered(), msg->getExchangeName(), msg->getRoutingKey(), queue->getMessageCount())); } }; @@ -68,9 +69,10 @@ struct BasicConsumeToken : BaseToken AMQFrame sendMethod(intrusive_ptr<Message> msg, DeliveryId id) { - return AMQFrame(0, BasicDeliverBody( + return AMQFrame(in_place<BasicDeliverBody>( ProtocolVersion(), consumer, id.getValue(), - msg->getRedelivered(), msg->getExchangeName(), msg->getRoutingKey())); + msg->getRedelivered(), msg->getExchangeName(), + msg->getRoutingKey())); } }; @@ -90,7 +92,9 @@ struct MessageDeliveryToken : BaseToken if (msg->getRedelivered()){ msg->getProperties<DeliveryProperties>()->setRedelivered(true); } - return AMQFrame(0, MessageTransferBody(ProtocolVersion(), 0, destination, confirmMode, acquireMode)); + return AMQFrame(in_place<MessageTransferBody>( + ProtocolVersion(), 0, destination, + confirmMode, acquireMode)); } }; diff --git a/cpp/src/qpid/broker/SemanticHandler.h b/cpp/src/qpid/broker/SemanticHandler.h index 8b27bc53c3..1afcdaab76 100644 --- a/cpp/src/qpid/broker/SemanticHandler.h +++ b/cpp/src/qpid/broker/SemanticHandler.h @@ -57,7 +57,7 @@ class SemanticHandler : public DeliveryAdapter, SemanticState state; SessionState& session; - // FIXME aconway 2007-09-20: Why are these on the handler rather than the + // TODO aconway 2007-09-20: Why are these on the handler rather than the // state? IncomingExecutionContext incoming; framing::Window outgoing; diff --git a/cpp/src/qpid/broker/SessionHandler.cpp b/cpp/src/qpid/broker/SessionHandler.cpp index b05e22c7bc..a142af2e1a 100644 --- a/cpp/src/qpid/broker/SessionHandler.cpp +++ b/cpp/src/qpid/broker/SessionHandler.cpp @@ -124,13 +124,13 @@ void SessionHandler::resume(const Uuid& id) { void SessionHandler::flow(bool /*active*/) { assertAttached("flow"); - // FIXME aconway 2007-09-19: Removed in 0-10, remove + // TODO aconway 2007-09-19: Removed in 0-10, remove assert(0); throw NotImplementedException("session.flow"); } void SessionHandler::flowOk(bool /*active*/) { assertAttached("flowOk"); - // FIXME aconway 2007-09-19: Removed in 0-10, remove + // TODO aconway 2007-09-19: Removed in 0-10, remove assert(0); throw NotImplementedException("session.flowOk"); } @@ -181,7 +181,7 @@ void SessionHandler::ack(uint32_t cumulativeSeenMark, } void SessionHandler::highWaterMark(uint32_t /*lastSentMark*/) { - // FIXME aconway 2007-10-02: may be removed from spec. + // TODO aconway 2007-10-02: may be removed from spec. assert(0); throw NotImplementedException("session.high-water-mark"); } diff --git a/cpp/src/qpid/broker/SessionState.cpp b/cpp/src/qpid/broker/SessionState.cpp index d5b6f5ba8a..ebf02a8306 100644 --- a/cpp/src/qpid/broker/SessionState.cpp +++ b/cpp/src/qpid/broker/SessionState.cpp @@ -46,7 +46,7 @@ SessionState::SessionState( version(h.getConnection().getVersion()), semanticHandler(new SemanticHandler(*this)) { - // FIXME aconway 2007-09-20: SessionManager may add plugin + // TODO aconway 2007-09-20: SessionManager may add plugin // handlers to the chain. } diff --git a/cpp/src/qpid/client/Channel.cpp b/cpp/src/qpid/client/Channel.cpp index 2d43d300dd..3551946d1e 100644 --- a/cpp/src/qpid/client/Channel.cpp +++ b/cpp/src/qpid/client/Channel.cpp @@ -33,10 +33,6 @@ #include <boost/bind.hpp> #include "qpid/framing/all_method_bodies.h" -// FIXME aconway 2007-01-26: Evaluate all throws, ensure consistent -// handling of errors that should close the connection or the channel. -// Make sure the user thread receives a connection in each case. -// using namespace std; using namespace boost; using namespace qpid::framing; diff --git a/cpp/src/qpid/client/Channel.h b/cpp/src/qpid/client/Channel.h index c1f74e0706..2907da01c6 100644 --- a/cpp/src/qpid/client/Channel.h +++ b/cpp/src/qpid/client/Channel.h @@ -93,7 +93,6 @@ class Channel : private sys::Runnable void dispatch(framing::FrameSet& msg, const std::string& destination); - // FIXME aconway 2007-02-23: Get rid of friendships. friend class Connection; public: diff --git a/cpp/src/qpid/client/ConnectionHandler.cpp b/cpp/src/qpid/client/ConnectionHandler.cpp index a8f10c32a9..cbdeff9cff 100644 --- a/cpp/src/qpid/client/ConnectionHandler.cpp +++ b/cpp/src/qpid/client/ConnectionHandler.cpp @@ -112,7 +112,7 @@ void ConnectionHandler::close() void ConnectionHandler::send(const framing::AMQBody& body) { - AMQFrame f(0, body); + AMQFrame f(body); out(f); } diff --git a/cpp/src/qpid/client/ConnectionImpl.cpp b/cpp/src/qpid/client/ConnectionImpl.cpp index f9273bc165..1ae8a25d6b 100644 --- a/cpp/src/qpid/client/ConnectionImpl.cpp +++ b/cpp/src/qpid/client/ConnectionImpl.cpp @@ -97,7 +97,7 @@ void ConnectionImpl::idleIn() void ConnectionImpl::idleOut() { - AMQFrame frame(0, new AMQHeartbeatBody()); + AMQFrame frame(in_place<AMQHeartbeatBody>()); connector->send(frame); } diff --git a/cpp/src/qpid/client/ExecutionHandler.cpp b/cpp/src/qpid/client/ExecutionHandler.cpp index c70b0fc455..7b8fb8d01f 100644 --- a/cpp/src/qpid/client/ExecutionHandler.cpp +++ b/cpp/src/qpid/client/ExecutionHandler.cpp @@ -118,7 +118,7 @@ void ExecutionHandler::flushTo(const framing::SequenceNumber& point) void ExecutionHandler::sendFlushRequest() { Mutex::ScopedLock l(lock); - AMQFrame frame(0, ExecutionFlushBody()); + AMQFrame frame(in_place<ExecutionFlushBody>()); out(frame); } @@ -134,7 +134,7 @@ void ExecutionHandler::syncTo(const framing::SequenceNumber& point) void ExecutionHandler::sendSyncRequest() { Mutex::ScopedLock l(lock); - AMQFrame frame(0, ExecutionSyncBody()); + AMQFrame frame(in_place<ExecutionSyncBody>()); out(frame); } @@ -161,7 +161,9 @@ void ExecutionHandler::sendCompletion() Mutex::ScopedLock l(lock); SequenceNumberSet range; incomingCompletionStatus.collectRanges(range); - AMQFrame frame(0, ExecutionCompleteBody(version, incomingCompletionStatus.mark.getValue(), range)); + AMQFrame frame( + in_place<ExecutionCompleteBody>( + version, incomingCompletionStatus.mark.getValue(), range)); out(frame); } @@ -177,7 +179,7 @@ SequenceNumber ExecutionHandler::send(const AMQBody& command, CompletionTracker: if(l) { completion.listenForResult(id, l); } - AMQFrame frame(0/*channel will be filled in by channel handler*/, command); + AMQFrame frame(command); if (hasContent) { frame.setEof(false); } @@ -196,7 +198,7 @@ SequenceNumber ExecutionHandler::send(const AMQBody& command, const MethodConten void ExecutionHandler::sendContent(const MethodContent& content) { - AMQFrame header(0, content.getHeader()); + AMQFrame header(content.getHeader()); header.setBof(false); u_int64_t data_length = content.getData().length(); if(data_length > 0){ @@ -205,7 +207,7 @@ void ExecutionHandler::sendContent(const MethodContent& content) //frame itself uses 8 bytes u_int32_t frag_size = maxFrameSize - 8; if(data_length < frag_size){ - AMQFrame frame(0, AMQContentBody(content.getData())); + AMQFrame frame(in_place<AMQContentBody>(content.getData())); frame.setBof(false); out(frame); }else{ @@ -214,7 +216,7 @@ void ExecutionHandler::sendContent(const MethodContent& content) while (remaining > 0) { u_int32_t length = remaining > frag_size ? frag_size : remaining; string frag(content.getData().substr(offset, length)); - AMQFrame frame(0, AMQContentBody(frag)); + AMQFrame frame(in_place<AMQContentBody>(frag)); frame.setBof(false); if (offset > 0) { frame.setBos(false); diff --git a/cpp/src/qpid/client/FutureResponse.cpp b/cpp/src/qpid/client/FutureResponse.cpp index 5d36a1d873..32d99531fa 100644 --- a/cpp/src/qpid/client/FutureResponse.cpp +++ b/cpp/src/qpid/client/FutureResponse.cpp @@ -32,13 +32,13 @@ AMQMethodBody* FutureResponse::getResponse(SessionCore& session) { waitForCompletion(); session.assertOpen(); - return response.get(); + return response.getMethod(); } void FutureResponse::received(const AMQMethodBody* r) { Monitor::ScopedLock l(lock); - response = *r; + response.setBody(*r); complete = true; lock.notifyAll(); } diff --git a/cpp/src/qpid/client/FutureResponse.h b/cpp/src/qpid/client/FutureResponse.h index df3b7c6f30..534ca01bb7 100644 --- a/cpp/src/qpid/client/FutureResponse.h +++ b/cpp/src/qpid/client/FutureResponse.h @@ -23,7 +23,7 @@ #define _FutureResponse_ #include "qpid/framing/amqp_framing.h" -#include "qpid/framing/MethodHolder.h" +#include "qpid/framing/BodyHolder.h" #include "FutureCompletion.h" namespace qpid { @@ -33,7 +33,7 @@ class SessionCore; class FutureResponse : public FutureCompletion { - framing::MethodHolder response; + framing::BodyHolder response; public: framing::AMQMethodBody* getResponse(SessionCore& session); void received(const framing::AMQMethodBody* response); diff --git a/cpp/src/qpid/client/SessionCore.cpp b/cpp/src/qpid/client/SessionCore.cpp index c87eeffc11..8eab54fa62 100644 --- a/cpp/src/qpid/client/SessionCore.cpp +++ b/cpp/src/qpid/client/SessionCore.cpp @@ -403,7 +403,7 @@ void SessionCore::flowOk(bool /*active*/) { } void SessionCore::highWaterMark(uint32_t /*lastSentMark*/) { - // FIXME aconway 2007-10-02: may be removed from spec. + // TODO aconway 2007-10-02: may be removed from spec. assert(0); throw NotImplementedException("session.highWaterMark"); } diff --git a/cpp/src/qpid/cluster/Cluster.cpp b/cpp/src/qpid/cluster/Cluster.cpp index 05ab876e14..3c73719ef9 100644 --- a/cpp/src/qpid/cluster/Cluster.cpp +++ b/cpp/src/qpid/cluster/Cluster.cpp @@ -88,7 +88,7 @@ void Cluster::handle(AMQFrame& frame) { } void Cluster::notify() { - AMQFrame frame(0, ClusterNotifyBody(ProtocolVersion(), url)); + AMQFrame frame(in_place<ClusterNotifyBody>(ProtocolVersion(), url)); handle(frame); } diff --git a/cpp/src/qpid/cluster/SessionManager.h b/cpp/src/qpid/cluster/SessionManager.h index 56cd1d9d28..10fe5f82d1 100644 --- a/cpp/src/qpid/cluster/SessionManager.h +++ b/cpp/src/qpid/cluster/SessionManager.h @@ -57,10 +57,6 @@ class SessionManager : public framing::HandlerUpdater, public framing::FrameHand /** ChannelUpdater: add cluster handlers to session. */ void update(framing::ChannelId, framing::FrameHandler::Chains&); - // FIXME aconway 2007-08-30: Need setUp and tearDown instead of just - // update, so we can tear down closed sesions. - // Or add FrameHandler::destroy(Session) to notify all handlers? - /** FrameHandler: map frames from the cluster to sessions. */ void handle(framing::AMQFrame&); diff --git a/cpp/src/qpid/framing/AMQBody.h b/cpp/src/qpid/framing/AMQBody.h index 0b2718bef3..b05301bd05 100644 --- a/cpp/src/qpid/framing/AMQBody.h +++ b/cpp/src/qpid/framing/AMQBody.h @@ -22,7 +22,6 @@ * */ #include "qpid/framing/amqp_types.h" -#include "qpid/shared_ptr.h" #include <ostream> @@ -47,8 +46,6 @@ struct AMQBodyConstVisitor { class AMQBody { public: - typedef shared_ptr<AMQBody> shared_ptr; - virtual ~AMQBody(); virtual uint8_t type() const = 0; diff --git a/cpp/src/qpid/framing/AMQFrame.cpp b/cpp/src/qpid/framing/AMQFrame.cpp index 423af06173..3750f4a9a8 100644 --- a/cpp/src/qpid/framing/AMQFrame.cpp +++ b/cpp/src/qpid/framing/AMQFrame.cpp @@ -31,49 +31,16 @@ namespace qpid { namespace framing { -namespace { -struct GetBodyVisitor : public NoBlankVisitor<AMQBody*> { - QPID_USING_NOBLANK(AMQBody*); - AMQBody* operator()(MethodHolder& t) const { return t.get(); } - template <class T> AMQBody* operator()(T& t) const { return &t; } -}; - -struct EncodeVisitor : public NoBlankVisitor<void> { - Buffer& buffer; - EncodeVisitor(Buffer& b) : buffer(b) {} - - QPID_USING_NOBLANK(void); - template <class T> void operator()(const T& t) const { return t.encode(buffer); } -}; - -struct SizeVisitor : public NoBlankVisitor<uint32_t> { - QPID_USING_NOBLANK(uint32_t); - template <class T> uint32_t operator()(const T& t) const { return t.size(); } -}; - -struct DecodeVisitor : public NoBlankVisitor<void> { - Buffer& buffer; - uint32_t size; - DecodeVisitor(Buffer& b, uint32_t s) : buffer(b), size(s) {} - QPID_USING_NOBLANK(void); - void operator()(MethodHolder& t) const { return t.decode(buffer); } - template <class T> void operator()(T& t) const { return t.decode(buffer, size); } -}; +AMQFrame::~AMQFrame() {} -} +void AMQFrame::setBody(const AMQBody& b) { body = new BodyHolder(b); } -AMQBody* AMQFrame::getBody() { - return boost::apply_visitor(GetBodyVisitor(), body); -} - -const AMQBody* AMQFrame::getBody() const { - return boost::apply_visitor(GetBodyVisitor(), const_cast<Variant&>(body)); -} +void AMQFrame::setMethod(ClassId c, MethodId m) { body = new BodyHolder(c,m); } -// This is now misleadingly named as it is not the frame size as defined in the spec -// (as it also includes the end marker) -uint32_t AMQFrame::size() const{ - return frameOverhead() + boost::apply_visitor(SizeVisitor(), body); +// This is now misleadingly named as it is not the frame size as +// defined in the spec (as it also includes the end marker) +uint32_t AMQFrame::size() const { + return frameOverhead() + body->size(); } uint32_t AMQFrame::frameOverhead() { @@ -90,7 +57,7 @@ void AMQFrame::encode(Buffer& buffer) const buffer.putOctet(0x0f & subchannel); buffer.putShort(channel); buffer.putLong(0); - boost::apply_visitor(EncodeVisitor(buffer), body); + body->encode(buffer); buffer.putOctet(0xCE); } @@ -119,45 +86,34 @@ bool AMQFrame::decode(Buffer& buffer) (void) buffer.getLong(); // reserved2 // Verify that the protocol header meets current spec - // TODO: should we check reserved2 against zero as well? - the spec isn't clear + // TODO: should we check reserved2 against zero as well? - the + // spec isn't clear if ((flags & 0x30) != 0 || reserved1 != 0 || (field1 & 0xf0) != 0) throw SyntaxErrorException(QPID_MSG("Reserved bits not zero")); - // TODO: should no longer care about body size and only pass up B,E,b,e flags + // TODO: should no longer care about body size and only pass up + // B,E,b,e flags uint16_t body_size = frame_size + 1 - frameOverhead(); if (buffer.available() < body_size+1u){ buffer.restore(); return false; } - decodeBody(buffer, body_size, type); - + body = new BodyHolder(); + body->decode(type,buffer, body_size); uint8_t end = buffer.getOctet(); if (end != 0xCE) throw SyntaxErrorException(QPID_MSG("Frame end not found")); return true; } -void AMQFrame::decodeBody(Buffer& buffer, uint32_t size, uint8_t type) -{ - switch(type) - { - case METHOD_BODY: body = MethodHolder(); break; - case HEADER_BODY: body = AMQHeaderBody(); break; - case CONTENT_BODY: body = AMQContentBody(); break; - case HEARTBEAT_BODY: body = AMQHeartbeatBody(); break; - - default: - throw SyntaxErrorException(QPID_MSG("Invalid frame type " << type)); - } - boost::apply_visitor(DecodeVisitor(buffer,size), body); -} - std::ostream& operator<<(std::ostream& out, const AMQFrame& f) { - return out << "Frame[" - << (f.getBof() ? "B" : "") << (f.getEof() ? "E" : "") << (f.getBos() ? "b" : "") << (f.getEos() ? "e" : "") << "; " - << "channel=" << f.getChannel() << "; " << *f.getBody() - << "]"; + return + out << "Frame[" + << (f.getBof() ? "B" : "") << (f.getEof() ? "E" : "") + << (f.getBos() ? "b" : "") << (f.getEos() ? "e" : "") << "; " + << "channel=" << f.getChannel() << "; " << *f.getBody() + << "]"; } diff --git a/cpp/src/qpid/framing/AMQFrame.h b/cpp/src/qpid/framing/AMQFrame.h index 392b8c0c01..1c65988b3d 100644 --- a/cpp/src/qpid/framing/AMQFrame.h +++ b/cpp/src/qpid/framing/AMQFrame.h @@ -25,46 +25,48 @@ #include "AMQHeaderBody.h" #include "AMQContentBody.h" #include "AMQHeartbeatBody.h" -#include "MethodHolder.h" #include "ProtocolVersion.h" +#include "BodyHolder.h" #include <boost/cast.hpp> -#include <boost/variant.hpp> namespace qpid { namespace framing { - + +class BodyHolder; + class AMQFrame : public AMQDataBlock { public: - AMQFrame() : bof(true), eof(true), bos(true), eos(true), subchannel(0), channel(0) {} + AMQFrame(intrusive_ptr<BodyHolder> b=0) : body(b) { init(); } + AMQFrame(const AMQBody& b) { setBody(b); init(); } + ~AMQFrame(); - /** Construct a frame with a copy of b */ - AMQFrame(ChannelId c, const AMQBody* b) : bof(true), eof(true), bos(true), eos(true), subchannel(0), channel(c) { - setBody(*b); - } - - AMQFrame(ChannelId c, const AMQBody& b) : bof(true), eof(true), bos(true), eos(true), subchannel(0), channel(c) { - setBody(b); + template <class InPlace> + AMQFrame(const InPlace& ip, typename EnableInPlace<InPlace>::type* =0) { + init(); setBody(ip); } - - AMQFrame(const AMQBody& b) : bof(true), eof(true), bos(true), eos(true), subchannel(0), channel(0) { - setBody(b); - } - + ChannelId getChannel() const { return channel; } void setChannel(ChannelId c) { channel = c; } - AMQBody* getBody(); - const AMQBody* getBody() const; + intrusive_ptr<BodyHolder> getHolder() { return body; } + + AMQBody* getBody() { return body ? body->get() : 0; } + const AMQBody* getBody() const { return body ? body->get() : 0; } AMQMethodBody* getMethod() { return getBody()->getMethod(); } const AMQMethodBody* getMethod() const { return getBody()->getMethod(); } - /** Copy a body instance to the frame */ - void setBody(const AMQBody& b) { CopyVisitor cv(*this); b.accept(cv); } + void setBody(const AMQBody& b); + + template <class InPlace> + typename EnableInPlace<InPlace>::type setBody(const InPlace& ip) { + body = new BodyHolder(ip); + } + + void setMethod(ClassId c, MethodId m); - /** Convenience template to cast the body to an expected type. */ template <class T> T* castBody() { return boost::polymorphic_downcast<T*>(getBody()); } @@ -73,8 +75,6 @@ class AMQFrame : public AMQDataBlock return boost::polymorphic_downcast<const T*>(getBody()); } - bool empty() { return boost::get<boost::blank>(&body); } - void encode(Buffer& buffer) const; bool decode(Buffer& buffer); uint32_t size() const; @@ -92,33 +92,15 @@ class AMQFrame : public AMQDataBlock static uint32_t frameOverhead(); private: - struct CopyVisitor : public AMQBodyConstVisitor { - AMQFrame& frame; - CopyVisitor(AMQFrame& f) : frame(f) {} - void visit(const AMQHeaderBody& x) { frame.body=x; } - void visit(const AMQContentBody& x) { frame.body=x; } - void visit(const AMQHeartbeatBody& x) { frame.body=x; } - void visit(const AMQMethodBody& x) { frame.body=MethodHolder(x); } - }; - friend struct CopyVisitor; - - typedef boost::variant<boost::blank, - AMQHeaderBody, - AMQContentBody, - AMQHeartbeatBody, - MethodHolder> Variant; - - void visit(AMQHeaderBody& x) { body=x; } - - void decodeBody(Buffer& buffer, uint32_t size, uint8_t type); - - bool bof; - bool eof; - bool bos; - bool eos; - uint8_t subchannel; - uint16_t channel; - Variant body; + void init() { bof = eof = bos = eos = true; subchannel=0; channel=0; } + + intrusive_ptr<BodyHolder> body; + uint16_t channel : 16; + uint8_t subchannel : 8; + bool bof : 1; + bool eof : 1; + bool bos : 1; + bool eos : 1; }; std::ostream& operator<<(std::ostream&, const AMQFrame&); diff --git a/cpp/src/qpid/framing/AMQMethodBody.h b/cpp/src/qpid/framing/AMQMethodBody.h index 9f64fd1690..da28ee3aa9 100644 --- a/cpp/src/qpid/framing/AMQMethodBody.h +++ b/cpp/src/qpid/framing/AMQMethodBody.h @@ -40,8 +40,6 @@ class MethodBodyConstVisitor; class AMQMethodBody : public AMQBody { public: AMQMethodBody() {} - AMQMethodBody(uint8_t, uint8_t) {} - virtual ~AMQMethodBody(); virtual void accept(MethodBodyConstVisitor&) const = 0; diff --git a/cpp/src/qpid/framing/Blob.h b/cpp/src/qpid/framing/Blob.h index 9d0c33dee6..344e4ac4db 100644 --- a/cpp/src/qpid/framing/Blob.h +++ b/cpp/src/qpid/framing/Blob.h @@ -25,38 +25,45 @@ #include <boost/aligned_storage.hpp> #include <boost/checked_delete.hpp> #include <boost/utility/typed_in_place_factory.hpp> +#include <boost/type_traits/is_base_and_derived.hpp> +#include <boost/utility/enable_if.hpp> #include <new> #include <assert.h> -namespace boost { +namespace qpid { +namespace framing { -/** - * 0-arg typed_in_place_factory constructor and in_place() override. - * - * Boost doesn't provide the 0 arg version since it assumes - * in_place_factory will be used when there is no default ctor. - */ +using boost::in_place; +using boost::typed_in_place_factory_base; + +/** 0-arg typed_in_place_factory, missing in boost. */ template <class T> -class typed_in_place_factory0 : public typed_in_place_factory_base { - public: +struct typed_in_place_factory0 : public typed_in_place_factory_base { typedef T value_type ; void apply ( void* address ) const { new (address) T(); } }; +/** 0-arg in_place<T>() function, missing from boost. */ template<class T> typed_in_place_factory0<T> in_place() { return typed_in_place_factory0<T>(); } -} // namespace boost - - -namespace qpid { -namespace framing { - -using boost::in_place; - +template <class T, class R=void> +struct EnableInPlace + : public boost::enable_if<boost::is_base_and_derived< + typed_in_place_factory_base, T>, + R> +{}; + +template <class T, class R=void> +struct DisableInPlace + : public boost::disable_if<boost::is_base_and_derived< + typed_in_place_factory_base, T>, + R> +{}; + template <class T> struct BlobHelper { static void destroy(void* ptr) { static_cast<T*>(ptr)->~T(); } static void copy(void* dest, const void* src) { @@ -108,11 +115,10 @@ class Blob basePtr=0; } - template<class TypedInPlaceFactory> - void construct (const TypedInPlaceFactory& factory, - const boost::typed_in_place_factory_base* ) + template<class Factory> + typename EnableInPlace<Factory>::type apply(const Factory& factory) { - typedef typename TypedInPlaceFactory::value_type T; + typedef typename Factory::value_type T; assert(empty()); factory.apply(store.address()); setType<T>(); @@ -135,28 +141,31 @@ class Blob Blob(const Blob& b) { initialize(); assign(b); } /** @see construct() */ - template<class Expr> - Blob( const Expr & expr ) { initialize(); construct(expr,&expr); } + template<class InPlace> + Blob(const InPlace & expr, typename EnableInPlace<InPlace>::type* =0) { + initialize(); apply(expr); + } ~Blob() { clear(); } - /** Assign a blob */ + /** Assign from another blob. */ Blob& operator=(const Blob& b) { clear(); assign(b); return *this; } - /** Construcct an object in the blob. Destroyes the previous object. - *@param expr an expresion of the form: in_place<T>(x,y,z) - * will construct an object using the constructor T(x,y,z) - */ - template<class Expr> void - construct(const Expr& expr) { clear(); construct(expr,&expr); } + /** Assign from an in_place constructor expression. */ + template<class InPlace> + typename EnableInPlace<InPlace,Blob&>::type operator=(const InPlace& expr) { + clear(); apply(expr); return *this; + } - /** Copy construct an instance of T into the Blob. */ + /** Assign from an object of type T. */ template <class T> - Blob& operator=(const T& x) { clear(); construct(in_place<T>(x)); return *this; } + typename DisableInPlace<T, Blob&>::type operator=(const T& x) { + clear(); apply(in_place<T>(x)); return *this; + } /** Get pointer to blob contents, returns 0 if empty. */ BaseType* get() { return basePtr; } diff --git a/cpp/src/qpid/framing/BodyHolder.cpp b/cpp/src/qpid/framing/BodyHolder.cpp new file mode 100644 index 0000000000..f66f29d36a --- /dev/null +++ b/cpp/src/qpid/framing/BodyHolder.cpp @@ -0,0 +1,75 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#include "BodyHolder.h" +#include "AMQMethodBody.h" +#include "AMQHeaderBody.h" +#include "AMQContentBody.h" +#include "AMQHeartbeatBody.h" +#include "Buffer.h" +#include "qpid/framing/reply_exceptions.h" + +namespace qpid { +namespace framing { + + +// BodyHolder::operator=(const AMQBody&) is defined +// in generated file BodyHolder_gen.cpp + + +void BodyHolder::encode(Buffer& b) const { + const AMQMethodBody* method=getMethod(); + if (method) { + b.putOctet(method->amqpClassId()); + b.putOctet(method->amqpMethodId()); + method->encode(b); + } + else + get()->encode(b); +} + +void BodyHolder::decode(uint8_t type, Buffer& buffer, uint32_t size) { + switch(type) + { + case METHOD_BODY: { + ClassId c = buffer.getOctet(); + MethodId m = buffer.getOctet(); + setMethod(c, m); + break; + } + case HEADER_BODY: *this=in_place<AMQHeaderBody>(); break; + case CONTENT_BODY: *this=in_place<AMQContentBody>(); break; + case HEARTBEAT_BODY: *this=in_place<AMQHeartbeatBody>(); break; + default: + throw SyntaxErrorException(QPID_MSG("Invalid frame type " << type)); + } + get()->decode(buffer, size); +} + +uint32_t BodyHolder::size() const { + const AMQMethodBody* method=getMethod(); + if (method) + return sizeof(ClassId)+sizeof(MethodId)+method->size(); + else + return get()->size(); +} + +}} // namespace qpid::framing + diff --git a/cpp/src/qpid/framing/BodyHolder.h b/cpp/src/qpid/framing/BodyHolder.h new file mode 100644 index 0000000000..65029e5675 --- /dev/null +++ b/cpp/src/qpid/framing/BodyHolder.h @@ -0,0 +1,88 @@ +#ifndef QPID_FRAMING_BODYHOLDER_H +#define QPID_FRAMING_BODYHOLDER_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/framing/AMQBody.h" +#include "qpid/framing/Blob.h" +#include "qpid/framing/MaxMethodBodySize.h" // Generated file. +#include "qpid/framing/amqp_types.h" +#include "qpid/RefCounted.h" + + +namespace qpid { +namespace framing { + +class AMQMethodBody; +class AMQBody; +class Buffer; + +/** + * Holder for arbitrary frame body. + */ +class BodyHolder : public RefCounted +{ + public: + // default copy, assign dtor ok. + BodyHolder() {} + BodyHolder(const AMQBody& b) { setBody(b); } + BodyHolder(ClassId c, MethodId m) { setMethod(c,m); } + + /** Construct from an in_place constructor expression */ + template <class InPlace> + BodyHolder(const InPlace& ip, typename EnableInPlace<InPlace>::type* =0) + : blob(ip) {} + + void setBody(const AMQBody& b); + + /** Assign from an in_place constructor expression */ + template <class InPlace> + typename EnableInPlace<InPlace,BodyHolder&>::type + operator=(const InPlace& ip) { blob=ip; return *this; } + + /** Assign by copying. */ + template <class T> + typename DisableInPlace<T,BodyHolder&>::type operator=(const T& x) + { blob=in_place<T>(x); return *this; } + + /** Set to method with ClassId c, MethodId m. */ + void setMethod(ClassId c, MethodId m); + + void encode(Buffer&) const; + void decode(uint8_t frameType, Buffer&, uint32_t=0); + uint32_t size() const; + + /** Return body pointer or 0 if empty. */ + AMQBody* get() { return blob.get(); } + const AMQBody* get() const { return blob.get(); } + + /** Return method pointer or 0 if not a method. */ + AMQMethodBody* getMethod() { return get()->getMethod(); } + const AMQMethodBody* getMethod() const { return get()->getMethod(); } + + private: + Blob<MAX_METHOD_BODY_SIZE, AMQBody> blob; +}; + +}} // namespace qpid::framing + +#endif /*!QPID_FRAMING_BODYHOLDER_H*/ diff --git a/cpp/src/qpid/framing/ChannelAdapter.cpp b/cpp/src/qpid/framing/ChannelAdapter.cpp index 8c1a4e1e9e..a1e49a1904 100644 --- a/cpp/src/qpid/framing/ChannelAdapter.cpp +++ b/cpp/src/qpid/framing/ChannelAdapter.cpp @@ -43,7 +43,8 @@ void ChannelAdapter::init(ChannelId i, FrameHandler& out, ProtocolVersion v) void ChannelAdapter::send(const AMQBody& body) { assertChannelOpen(); - AMQFrame frame(getId(), body); + AMQFrame frame(body); + frame.setChannel(getId()); handlers.out(frame); } diff --git a/cpp/src/qpid/framing/FrameDefaultVisitor.h b/cpp/src/qpid/framing/FrameDefaultVisitor.h index 93a5204308..f695414977 100644 --- a/cpp/src/qpid/framing/FrameDefaultVisitor.h +++ b/cpp/src/qpid/framing/FrameDefaultVisitor.h @@ -24,8 +24,6 @@ #include "qpid/framing/MethodBodyDefaultVisitor.h" #include "qpid/framing/AMQBody.h" #include "qpid/framing/AMQMethodBody.h" -#include "qpid/framing/AMQFrame.h" -#include "qpid/framing/FrameHandler.h" namespace qpid { namespace framing { diff --git a/cpp/src/qpid/framing/InputHandler.h b/cpp/src/qpid/framing/InputHandler.h index 99e4e774e1..3a6d786a24 100644 --- a/cpp/src/qpid/framing/InputHandler.h +++ b/cpp/src/qpid/framing/InputHandler.h @@ -27,7 +27,7 @@ namespace qpid { namespace framing { -// FIXME aconway 2007-08-29: Eliminate, replace with FrameHandler. +// TODO aconway 2007-08-29: Eliminate, replace with FrameHandler. class InputHandler : public FrameHandler { public: virtual ~InputHandler() {} diff --git a/cpp/src/qpid/framing/MethodHolder.cpp b/cpp/src/qpid/framing/MethodHolder.cpp deleted file mode 100644 index 78dd2bdcaf..0000000000 --- a/cpp/src/qpid/framing/MethodHolder.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -#include "MethodHolder.h" -#include "qpid/framing/AMQMethodBody.h" -#include "qpid/framing/Buffer.h" - -// Note: MethodHolder::construct is and operator= are code-generated -// in file MethodHolder_construct.cpp. - -using namespace boost; - -namespace qpid { -namespace framing { - -AMQMethodBody* MethodHolder::get() { - return blob.get(); -} - -const AMQMethodBody* MethodHolder::get() const { - return blob.get(); -} - -void MethodHolder::encode(Buffer& b) const { - const AMQMethodBody* body = get(); - b.putOctet(body->amqpClassId()); - b.putOctet(body->amqpMethodId()); - body->encode(b); -} - -void MethodHolder::decode(Buffer& b) { - ClassId c=b.getOctet(); - MethodId m=b.getOctet(); - construct(c,m); - get()->decode(b); -} - -uint32_t MethodHolder::size() const { - return sizeof(ClassId)+sizeof(MethodId)+get()->size(); -} - -std::ostream& operator<<(std::ostream& out, const MethodHolder& h) { - h.get()->print(out); - return out; -} - -}} // namespace qpid::framing diff --git a/cpp/src/qpid/framing/MethodHolder.h b/cpp/src/qpid/framing/MethodHolder.h deleted file mode 100644 index 5324b34ccd..0000000000 --- a/cpp/src/qpid/framing/MethodHolder.h +++ /dev/null @@ -1,96 +0,0 @@ -#ifndef QPID_FRAMING_METHODHOLDER_H -#define QPID_FRAMING_METHODHOLDER_H - -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -#include "qpid/framing/AMQBody.h" -#include "qpid/framing/amqp_types.h" -#include "qpid/framing/amqp_types.h" -#include "qpid/framing/Blob.h" -#include "qpid/framing/MethodHolderMaxSize.h" // Generated file. - -#include <boost/type_traits/is_base_and_derived.hpp> -#include <boost/utility/enable_if.hpp> - -#include <utility> - -namespace qpid { -namespace framing { - -class AMQMethodBody; -class AMQBody; -class Buffer; - -class MethodHolder; -std::ostream& operator<<(std::ostream& out, const MethodHolder& h); - -/** - * Holder for arbitrary method body. - */ -// TODO aconway 2007-08-14: Fix up naming, this class should really be -// called AMQMethodBody and use a different name for the root of -// the concrete method body tree, which should not inherit AMQBody. -// -class MethodHolder -{ - template <class T> struct EnableIfMethod: - public boost::enable_if<boost::is_base_and_derived<AMQMethodBody,T>,T> - {}; - - template <class T> EnableIfMethod<T>& assertMethod(T& t) { return t; } - - public: - MethodHolder() {} - MethodHolder(ClassId& c, MethodId& m) { construct(c,m); } - - /** Construct with a copy of a method body. */ - MethodHolder(const AMQMethodBody& m) { *this = m; } - - /** Copy method body into holder. */ - MethodHolder& operator=(const AMQMethodBody&); - - /** Construct the method body corresponding to class/method id */ - void construct(ClassId c, MethodId m); - - uint8_t type() const { return 1; } - void encode(Buffer&) const; - void decode(Buffer&); - uint32_t size() const; - - /** Return method pointer or 0 if empty. */ - AMQMethodBody* get(); - const AMQMethodBody* get() const; - - /** True if no method has been set */ - bool empty() const { return blob.empty(); } - - private: - Blob<MAX_METHODBODY_SIZE, AMQMethodBody> blob; - class CopyVisitor; - friend struct CopyVisitor; -}; - - - -}} // namespace qpid::framing - -#endif /*!QPID_FRAMING_METHODHOLDER_H*/ diff --git a/cpp/src/qpid/framing/OutputHandler.h b/cpp/src/qpid/framing/OutputHandler.h index 925ff88b12..6f4b27fb72 100644 --- a/cpp/src/qpid/framing/OutputHandler.h +++ b/cpp/src/qpid/framing/OutputHandler.h @@ -27,7 +27,7 @@ namespace qpid { namespace framing { -// FIXME aconway 2007-08-29: Replace with FrameHandler. +// TODO aconway 2007-08-29: Replace with FrameHandler. class OutputHandler : public FrameHandler { public: virtual ~OutputHandler() {} diff --git a/cpp/src/qpid/framing/SendContent.cpp b/cpp/src/qpid/framing/SendContent.cpp index 57ac58038b..85b9b995ad 100644 --- a/cpp/src/qpid/framing/SendContent.cpp +++ b/cpp/src/qpid/framing/SendContent.cpp @@ -51,7 +51,8 @@ void qpid::framing::SendContent::operator()(const AMQFrame& f) void qpid::framing::SendContent::sendFragment(const AMQContentBody& body, uint32_t offset, uint16_t size, bool first, bool last) const { - AMQFrame fragment(0, AMQContentBody(body.getData().substr(offset, size))); + AMQFrame fragment(in_place<AMQContentBody>( + body.getData().substr(offset, size))); setFlags(fragment, first, last); handler.handle(fragment); } diff --git a/cpp/src/qpid/framing/variant.h b/cpp/src/qpid/framing/variant.h index 1fe81f8f67..ceaed2c529 100644 --- a/cpp/src/qpid/framing/variant.h +++ b/cpp/src/qpid/framing/variant.h @@ -32,7 +32,7 @@ class Buffer; /** boost::static_visitor that throws exception if variant contains blank. * Sublclasses need to have a using() declaration, can be generated - * with QPID_USING_BLANK_THROW(R) + * with QPID_USING_NOBLANK(R) */ template <class R=void> struct NoBlankVisitor : public boost::static_visitor<R> { diff --git a/cpp/src/qpid/management/ManagementAgent.cpp b/cpp/src/qpid/management/ManagementAgent.cpp index 6636c59bf5..7aad7e7ce1 100644 --- a/cpp/src/qpid/management/ManagementAgent.cpp +++ b/cpp/src/qpid/management/ManagementAgent.cpp @@ -98,15 +98,14 @@ void ManagementAgent::SendBuffer (Buffer& buf, string routingKey) { intrusive_ptr<Message> msg (new Message ()); - AMQFrame method (0, MessageTransferBody(ProtocolVersion(), - 0, exchange->getName (), 0, 0)); - AMQFrame header (0, AMQHeaderBody()); - AMQFrame content; + AMQFrame method (in_place<MessageTransferBody>( + ProtocolVersion(), 0, exchange->getName (), 0, 0)); + AMQFrame header (in_place<AMQHeaderBody>()); + AMQFrame content(in_place<AMQContentBody>()); QPID_LOG (debug, "ManagementAgent::SendBuffer - key=" << routingKey << " len=" << length); - content.setBody(AMQContentBody()); content.castBody<AMQContentBody>()->decode(buf, length); method.setEof (false); |
