summaryrefslogtreecommitdiff
path: root/cpp/lib/common
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2008-02-15 08:26:00 +0000
committerGordon Sim <gsim@apache.org>2008-02-15 08:26:00 +0000
commit4351730550bc48c4237de4e616f8e420e084c081 (patch)
treef4d0101055d375a91e3838e0ee31651ff6e72122 /cpp/lib/common
parent4a5dd2bc8257c7a370088a179acc760b143c62a8 (diff)
downloadqpid-python-4351730550bc48c4237de4e616f8e420e084c081.tar.gz
* updated c++ build to work with recent gentools changes
* add null exchange.bound impl to SessionHandlerImpl (to reflect change to spec file) * pass AMQDataBlocks rather than AMQFrames to OutputHandler * allow client to pass messages frames to io layer in one go (via FrameList) if it will fit in a single buffer git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/M2.1@627971 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/lib/common')
-rw-r--r--cpp/lib/common/Makefile.am3
-rw-r--r--cpp/lib/common/framing/AMQDataBlock.cpp33
-rw-r--r--cpp/lib/common/framing/AMQDataBlock.h4
-rw-r--r--cpp/lib/common/framing/AMQFrame.cpp12
-rw-r--r--cpp/lib/common/framing/AMQFrame.h2
-rw-r--r--cpp/lib/common/framing/FrameList.cpp69
-rw-r--r--cpp/lib/common/framing/FrameList.h50
-rw-r--r--cpp/lib/common/framing/OutputHandler.h3
-rw-r--r--cpp/lib/common/framing/ProtocolInitiation.cpp6
-rw-r--r--cpp/lib/common/framing/ProtocolInitiation.h1
-rw-r--r--cpp/lib/common/sys/apr/LFSessionContext.cpp8
-rw-r--r--cpp/lib/common/sys/apr/LFSessionContext.h6
12 files changed, 184 insertions, 13 deletions
diff --git a/cpp/lib/common/Makefile.am b/cpp/lib/common/Makefile.am
index b2e2de2cf1..b584e93ca5 100644
--- a/cpp/lib/common/Makefile.am
+++ b/cpp/lib/common/Makefile.am
@@ -76,6 +76,7 @@ libqpidcommon_la_SOURCES = \
$(platform_src) \
$(framing)/AMQBody.cpp \
$(framing)/AMQContentBody.cpp \
+ $(framing)/AMQDataBlock.cpp \
$(framing)/AMQFrame.cpp \
$(framing)/AMQHeaderBody.cpp \
$(framing)/AMQHeartbeatBody.cpp \
@@ -84,6 +85,7 @@ libqpidcommon_la_SOURCES = \
$(framing)/BodyHandler.cpp \
$(framing)/Buffer.cpp \
$(framing)/FieldTable.cpp \
+ $(framing)/FrameList.cpp \
$(framing)/FramingContent.cpp \
$(framing)/InitiationHandler.cpp \
$(framing)/ProtocolInitiation.cpp \
@@ -114,6 +116,7 @@ nobase_pkginclude_HEADERS = \
$(framing)/BodyHandler.h \
$(framing)/Buffer.h \
$(framing)/FieldTable.h \
+ $(framing)/FrameList.h \
$(framing)/FramingContent.h \
$(framing)/HeaderProperties.h \
$(framing)/InitiationHandler.h \
diff --git a/cpp/lib/common/framing/AMQDataBlock.cpp b/cpp/lib/common/framing/AMQDataBlock.cpp
new file mode 100644
index 0000000000..9c4d6bee63
--- /dev/null
+++ b/cpp/lib/common/framing/AMQDataBlock.cpp
@@ -0,0 +1,33 @@
+/*
+ *
+ * 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 "AMQDataBlock.h"
+
+
+namespace qpid {
+namespace framing {
+
+std::ostream& operator<<(std::ostream& out, const AMQDataBlock& b)
+{
+ b.print(out);
+ return out;
+}
+
+}}
diff --git a/cpp/lib/common/framing/AMQDataBlock.h b/cpp/lib/common/framing/AMQDataBlock.h
index ac91c52164..36de2beea5 100644
--- a/cpp/lib/common/framing/AMQDataBlock.h
+++ b/cpp/lib/common/framing/AMQDataBlock.h
@@ -33,10 +33,12 @@ public:
virtual void encode(Buffer& buffer) = 0;
virtual bool decode(Buffer& buffer) = 0;
virtual u_int32_t size() const = 0;
+ virtual void print(std::ostream& out) const = 0;
+
+ friend std::ostream& operator<<(std::ostream& out, const AMQDataBlock& block);
};
}
}
-
#endif
diff --git a/cpp/lib/common/framing/AMQFrame.cpp b/cpp/lib/common/framing/AMQFrame.cpp
index 6fa5b9ae51..0530dc805c 100644
--- a/cpp/lib/common/framing/AMQFrame.cpp
+++ b/cpp/lib/common/framing/AMQFrame.cpp
@@ -119,14 +119,18 @@ void AMQFrame::decodeBody(Buffer& buffer, uint32_t bufSize)
body->decode(buffer, bufSize);
}
-std::ostream& qpid::framing::operator<<(std::ostream& out, const AMQFrame& t)
+void AMQFrame::print(std::ostream& out) const
{
- out << "Frame[channel=" << t.channel << "; ";
- if (t.body.get() == 0)
+ out << "Frame[channel=" << channel << "; ";
+ if (body.get() == 0)
out << "empty";
else
- out << *t.body;
+ out << *body;
out << "]";
+}
+std::ostream& qpid::framing::operator<<(std::ostream& out, const AMQFrame& t)
+{
+ t.print(out);
return out;
}
diff --git a/cpp/lib/common/framing/AMQFrame.h b/cpp/lib/common/framing/AMQFrame.h
index d3c769087a..21642f112a 100644
--- a/cpp/lib/common/framing/AMQFrame.h
+++ b/cpp/lib/common/framing/AMQFrame.h
@@ -61,6 +61,8 @@ namespace qpid {
u_int32_t decodeHead(Buffer& buffer);
void decodeBody(Buffer& buffer, uint32_t size);
+ void print(std::ostream& out) const;
+
friend std::ostream& operator<<(std::ostream& out, const AMQFrame& body);
};
diff --git a/cpp/lib/common/framing/FrameList.cpp b/cpp/lib/common/framing/FrameList.cpp
new file mode 100644
index 0000000000..f188347101
--- /dev/null
+++ b/cpp/lib/common/framing/FrameList.cpp
@@ -0,0 +1,69 @@
+/*
+ *
+ * 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 "FrameList.h"
+#include "Exception.h"
+
+namespace qpid {
+namespace framing {
+
+FrameList::~FrameList()
+{
+ for (Frames::iterator i = frames.begin(); i != frames.end(); i++) {
+ delete (*i);
+ }
+}
+
+void FrameList::encode(Buffer& buffer)
+{
+ for (Frames::iterator i = frames.begin(); i != frames.end(); i++) {
+ (*i)->encode(buffer);
+ }
+}
+
+bool FrameList::decode(Buffer&)
+{
+ throw Exception("FrameList::decode() not valid!");
+}
+
+u_int32_t FrameList::size() const
+{
+ uint32_t s(0);
+ for (Frames::const_iterator i = frames.begin(); i != frames.end(); i++) {
+ s += (*i)->size();
+ }
+ return s;
+}
+
+void FrameList::print(std::ostream& out) const
+{
+ out << "Frames: ";
+ for (Frames::const_iterator i = frames.begin(); i != frames.end(); i++) {
+ (*i)->print(out);
+ out << "; ";
+ }
+}
+
+void FrameList::add(AMQFrame* f)
+{
+ frames.push_back(f);
+}
+
+}}
diff --git a/cpp/lib/common/framing/FrameList.h b/cpp/lib/common/framing/FrameList.h
new file mode 100644
index 0000000000..59dc385e46
--- /dev/null
+++ b/cpp/lib/common/framing/FrameList.h
@@ -0,0 +1,50 @@
+/*
+ *
+ * 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 "Buffer.h"
+#include "AMQDataBlock.h"
+#include "AMQFrame.h"
+
+#include <list>
+
+#ifndef _FrameList_
+#define _FrameList_
+
+namespace qpid {
+namespace framing {
+
+class FrameList : public AMQDataBlock
+{
+ typedef std::list<AMQFrame*> Frames;
+ Frames frames;
+public:
+ virtual ~FrameList();
+ void encode(Buffer& buffer);
+ bool decode(Buffer& buffer);
+ u_int32_t size() const;
+ void add(AMQFrame* f);
+ void print(std::ostream& out) const;
+};
+
+}
+}
+
+
+#endif
diff --git a/cpp/lib/common/framing/OutputHandler.h b/cpp/lib/common/framing/OutputHandler.h
index 2e01e34df2..16dc519738 100644
--- a/cpp/lib/common/framing/OutputHandler.h
+++ b/cpp/lib/common/framing/OutputHandler.h
@@ -22,6 +22,7 @@
*
*/
#include <boost/noncopyable.hpp>
+#include <AMQDataBlock.h>
#include <AMQFrame.h>
namespace qpid {
@@ -30,7 +31,7 @@ namespace framing {
class OutputHandler : private boost::noncopyable {
public:
virtual ~OutputHandler() {}
- virtual void send(AMQFrame* frame) = 0;
+ virtual void send(AMQDataBlock* frame) = 0;
};
}}
diff --git a/cpp/lib/common/framing/ProtocolInitiation.cpp b/cpp/lib/common/framing/ProtocolInitiation.cpp
index 471f736a7d..360178df5a 100644
--- a/cpp/lib/common/framing/ProtocolInitiation.cpp
+++ b/cpp/lib/common/framing/ProtocolInitiation.cpp
@@ -19,6 +19,7 @@
*
*/
#include <ProtocolInitiation.h>
+#include <iostream>
qpid::framing::ProtocolInitiation::ProtocolInitiation(){}
@@ -55,4 +56,9 @@ bool qpid::framing::ProtocolInitiation::decode(Buffer& buffer){
}
}
+void qpid::framing::ProtocolInitiation::print(std::ostream& out) const
+{
+ out << "AMQP(" << getMajor() << "-" << getMinor() << ")";
+}
+
//TODO: this should prbably be generated from the spec at some point to keep the version numbers up to date
diff --git a/cpp/lib/common/framing/ProtocolInitiation.h b/cpp/lib/common/framing/ProtocolInitiation.h
index 003c3bba81..03e53c75cb 100644
--- a/cpp/lib/common/framing/ProtocolInitiation.h
+++ b/cpp/lib/common/framing/ProtocolInitiation.h
@@ -45,6 +45,7 @@ public:
inline u_int8_t getMajor() const { return version.getMajor(); }
inline u_int8_t getMinor() const { return version.getMinor(); }
inline const ProtocolVersion& getVersion() const { return version; }
+ void print(std::ostream& out) const;
};
}
diff --git a/cpp/lib/common/sys/apr/LFSessionContext.cpp b/cpp/lib/common/sys/apr/LFSessionContext.cpp
index 8a7ce18136..dfe27050c4 100644
--- a/cpp/lib/common/sys/apr/LFSessionContext.cpp
+++ b/cpp/lib/common/sys/apr/LFSessionContext.cpp
@@ -96,7 +96,7 @@ void LFSessionContext::write(){
if(!framesToWrite.empty()){
out.clear();
bool encoded(false);
- AMQFrame* frame = framesToWrite.front();
+ AMQDataBlock* frame = framesToWrite.front();
while(frame && out.available() >= frame->size()){
encoded = true;
frame->encode(out);
@@ -120,7 +120,7 @@ void LFSessionContext::write(){
}
}
-void LFSessionContext::send(AMQFrame* frame){
+void LFSessionContext::send(AMQDataBlock* frame){
Mutex::ScopedLock l(writeLock);
if(!closing){
framesToWrite.push(frame);
@@ -173,9 +173,9 @@ void LFSessionContext::init(SessionHandler* _handler){
processor->add(&fd);
}
-void LFSessionContext::log(const std::string& desc, AMQFrame* const frame){
+void LFSessionContext::log(const std::string& desc, AMQDataBlock* const block){
Mutex::ScopedLock l(logLock);
- std::cout << desc << " [" << &socket << "]: " << *frame << std::endl;
+ std::cout << desc << " [" << &socket << "]: " << *block << std::endl;
}
Mutex LFSessionContext::logLock;
diff --git a/cpp/lib/common/sys/apr/LFSessionContext.h b/cpp/lib/common/sys/apr/LFSessionContext.h
index eeb8279d9a..7862055735 100644
--- a/cpp/lib/common/sys/apr/LFSessionContext.h
+++ b/cpp/lib/common/sys/apr/LFSessionContext.h
@@ -54,7 +54,7 @@ class LFSessionContext : public virtual qpid::sys::SessionContext
apr_pollfd_t fd;
- std::queue<qpid::framing::AMQFrame*> framesToWrite;
+ std::queue<qpid::framing::AMQDataBlock*> framesToWrite;
qpid::sys::Mutex writeLock;
bool processing;
@@ -62,7 +62,7 @@ class LFSessionContext : public virtual qpid::sys::SessionContext
static qpid::sys::Mutex logLock;
void log(const std::string& desc,
- qpid::framing::AMQFrame* const frame);
+ qpid::framing::AMQDataBlock* const block);
public:
@@ -70,7 +70,7 @@ class LFSessionContext : public virtual qpid::sys::SessionContext
LFProcessor* const processor,
bool debug = false);
virtual ~LFSessionContext();
- virtual void send(qpid::framing::AMQFrame* frame);
+ virtual void send(qpid::framing::AMQDataBlock* frame);
virtual void close();
void read();
void write();