diff options
author | Andrew Stitcher <astitcher@apache.org> | 2012-03-28 21:00:40 +0000 |
---|---|---|
committer | Andrew Stitcher <astitcher@apache.org> | 2012-03-28 21:00:40 +0000 |
commit | c3d1faded9c8b9038cc2643c902a71a488e2d60d (patch) | |
tree | fd7de366125ea614027c5834e435e0c8237d1083 | |
parent | cb0c0dbd13a27b535623ca0fdd6ef59f6f13622a (diff) | |
download | qpid-python-c3d1faded9c8b9038cc2643c902a71a488e2d60d.tar.gz |
QPID-3921: C++ header files need tidyup
Tidied up header use of FieldValue.h
- Removed all unnecessary includes of FieldValue.h from other header
files especially Array.h. (This avoids the world recompiling when working
on FieldValue!)
- Corrected up header guards in Array.h
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1306595 13f79535-47bb-0310-9956-ffa450edef68
23 files changed, 52 insertions, 26 deletions
diff --git a/qpid/cpp/include/qpid/framing/Array.h b/qpid/cpp/include/qpid/framing/Array.h index 1e97be3bb4..4f82d4dbf0 100644 --- a/qpid/cpp/include/qpid/framing/Array.h +++ b/qpid/cpp/include/qpid/framing/Array.h @@ -1,3 +1,6 @@ +#ifndef QPID_FRAMING_ARRAY_H +#define QPID_FRAMING_ARRAY_H + /* * * Licensed to the Apache Software Foundation (ASF) under one @@ -18,21 +21,22 @@ * under the License. * */ + #include "qpid/framing/amqp_types.h" -#include "qpid/framing/FieldValue.h" #include "qpid/framing/TypeCode.h" + #include <boost/shared_ptr.hpp> + #include <iostream> #include <vector> -#include "qpid/CommonImportExport.h" -#ifndef _Array_ -#define _Array_ +#include "qpid/CommonImportExport.h" namespace qpid { namespace framing { class Buffer; +class FieldValue; class QPID_COMMON_CLASS_EXTERN Array { @@ -75,12 +79,10 @@ class QPID_COMMON_CLASS_EXTERN Array // Non-std interface QPID_COMMON_INLINE_EXTERN void add(ValuePtr value) { push_back(value); } - template <class T> - void collect(std::vector<T>& out) const - { - for (ValueVector::const_iterator i = values.begin(); i != values.end(); ++i) { - out.push_back((*i)->get<T>()); - } + // For use in standard algorithms + template <typename R, typename V> + static R get(const V& v) { + return v->get<R>(); } private: diff --git a/qpid/cpp/rubygen/framing.0-10/structs.rb b/qpid/cpp/rubygen/framing.0-10/structs.rb index 62b33ce773..0a1bb475c9 100755 --- a/qpid/cpp/rubygen/framing.0-10/structs.rb +++ b/qpid/cpp/rubygen/framing.0-10/structs.rb @@ -465,6 +465,7 @@ EOS end gen <<EOS #include "qpid/framing/#{classname}.h" +#include "qpid/framing/Buffer.h" #include "qpid/framing/reply_exceptions.h" using namespace qpid::framing; diff --git a/qpid/cpp/src/qpid/UrlArray.cpp b/qpid/cpp/src/qpid/UrlArray.cpp index 489309c8ad..9ebacbd945 100644 --- a/qpid/cpp/src/qpid/UrlArray.cpp +++ b/qpid/cpp/src/qpid/UrlArray.cpp @@ -20,6 +20,8 @@ */ #include "UrlArray.h" +#include <qpid/framing/FieldValue.h> + namespace qpid { std::vector<Url> urlArrayToVector(const framing::Array& array) { diff --git a/qpid/cpp/src/qpid/UrlArray.h b/qpid/cpp/src/qpid/UrlArray.h index 8b11df5c73..ce9e42f248 100644 --- a/qpid/cpp/src/qpid/UrlArray.h +++ b/qpid/cpp/src/qpid/UrlArray.h @@ -23,7 +23,6 @@ */ #include "qpid/framing/Array.h" -#include "qpid/framing/FieldValue.h" #include "qpid/Url.h" #include <vector> diff --git a/qpid/cpp/src/qpid/broker/ConnectionHandler.cpp b/qpid/cpp/src/qpid/broker/ConnectionHandler.cpp index f1d43c5cdb..6894324117 100644 --- a/qpid/cpp/src/qpid/broker/ConnectionHandler.cpp +++ b/qpid/cpp/src/qpid/broker/ConnectionHandler.cpp @@ -28,6 +28,7 @@ #include "qpid/framing/AllInvoker.h" #include "qpid/framing/ConnectionStartOkBody.h" #include "qpid/framing/enum.h" +#include "qpid/framing/FieldValue.h" #include "qpid/log/Statement.h" #include "qpid/sys/SecurityLayer.h" #include "qpid/broker/AclModule.h" diff --git a/qpid/cpp/src/qpid/broker/Fairshare.cpp b/qpid/cpp/src/qpid/broker/Fairshare.cpp index 313aa746f1..7cdad1a44f 100644 --- a/qpid/cpp/src/qpid/broker/Fairshare.cpp +++ b/qpid/cpp/src/qpid/broker/Fairshare.cpp @@ -21,6 +21,7 @@ #include "qpid/broker/Fairshare.h" #include "qpid/broker/QueuedMessage.h" #include "qpid/framing/FieldTable.h" +#include "qpid/framing/FieldValue.h" #include "qpid/log/Statement.h" #include <boost/format.hpp> #include <boost/lexical_cast.hpp> diff --git a/qpid/cpp/src/qpid/broker/MessageGroupManager.cpp b/qpid/cpp/src/qpid/broker/MessageGroupManager.cpp index 22253532cb..15cd56a676 100644 --- a/qpid/cpp/src/qpid/broker/MessageGroupManager.cpp +++ b/qpid/cpp/src/qpid/broker/MessageGroupManager.cpp @@ -19,11 +19,13 @@ * */ +#include "qpid/broker/MessageGroupManager.h" + +#include "qpid/broker/Queue.h" #include "qpid/framing/FieldTable.h" -#include "qpid/types/Variant.h" +#include "qpid/framing/FieldValue.h" #include "qpid/log/Statement.h" -#include "qpid/broker/Queue.h" -#include "qpid/broker/MessageGroupManager.h" +#include "qpid/types/Variant.h" using namespace qpid::broker; diff --git a/qpid/cpp/src/qpid/broker/MessageGroupManager.h b/qpid/cpp/src/qpid/broker/MessageGroupManager.h index 340ebbc56a..2dd97ea2ff 100644 --- a/qpid/cpp/src/qpid/broker/MessageGroupManager.h +++ b/qpid/cpp/src/qpid/broker/MessageGroupManager.h @@ -28,11 +28,14 @@ #include "qpid/broker/MessageDistributor.h" #include "qpid/sys/unordered_map.h" +#include <deque> + namespace qpid { namespace broker { class QueueObserver; class MessageDistributor; +class Messages; class MessageGroupManager : public StatefulQueueObserver, public MessageDistributor { diff --git a/qpid/cpp/src/qpid/broker/Queue.cpp b/qpid/cpp/src/qpid/broker/Queue.cpp index da5b97ef4e..a223392e2e 100644 --- a/qpid/cpp/src/qpid/broker/Queue.cpp +++ b/qpid/cpp/src/qpid/broker/Queue.cpp @@ -19,8 +19,9 @@ * */ -#include "qpid/broker/Broker.h" #include "qpid/broker/Queue.h" + +#include "qpid/broker/Broker.h" #include "qpid/broker/QueueEvents.h" #include "qpid/broker/Exchange.h" #include "qpid/broker/Fairshare.h" @@ -41,6 +42,7 @@ #include "qpid/management/ManagementAgent.h" #include "qpid/framing/reply_exceptions.h" #include "qpid/framing/FieldTable.h" +#include "qpid/framing/FieldValue.h" #include "qpid/sys/ClusterSafe.h" #include "qpid/sys/Monitor.h" #include "qpid/sys/Time.h" diff --git a/qpid/cpp/src/qpid/broker/SaslAuthenticator.cpp b/qpid/cpp/src/qpid/broker/SaslAuthenticator.cpp index d7adbd68ab..80fa5e1c0e 100644 --- a/qpid/cpp/src/qpid/broker/SaslAuthenticator.cpp +++ b/qpid/cpp/src/qpid/broker/SaslAuthenticator.cpp @@ -26,6 +26,7 @@ #include "qpid/broker/Connection.h" #include "qpid/log/Statement.h" #include "qpid/framing/reply_exceptions.h" +#include "qpid/framing/FieldValue.h" #include "qpid/sys/SecuritySettings.h" #include <boost/format.hpp> diff --git a/qpid/cpp/src/qpid/broker/SessionAdapter.cpp b/qpid/cpp/src/qpid/broker/SessionAdapter.cpp index 4aad46f782..82a5f31872 100644 --- a/qpid/cpp/src/qpid/broker/SessionAdapter.cpp +++ b/qpid/cpp/src/qpid/broker/SessionAdapter.cpp @@ -21,8 +21,9 @@ #include "qpid/Exception.h" #include "qpid/framing/reply_exceptions.h" #include "qpid/framing/enum.h" -#include "qpid/log/Statement.h" +#include "qpid/framing/FieldValue.h" #include "qpid/framing/SequenceSet.h" +#include "qpid/log/Statement.h" #include "qpid/management/ManagementAgent.h" #include "qpid/broker/SessionState.h" #include "qmf/org/apache/qpid/broker/EventExchangeDeclare.h" diff --git a/qpid/cpp/src/qpid/client/ConnectionHandler.cpp b/qpid/cpp/src/qpid/client/ConnectionHandler.cpp index ab0d8e0700..94561f8079 100644 --- a/qpid/cpp/src/qpid/client/ConnectionHandler.cpp +++ b/qpid/cpp/src/qpid/client/ConnectionHandler.cpp @@ -28,10 +28,13 @@ #include "qpid/framing/all_method_bodies.h" #include "qpid/framing/ClientInvoker.h" #include "qpid/framing/reply_exceptions.h" +#include "qpid/framing/FieldValue.h" #include "qpid/log/Helpers.h" #include "qpid/log/Statement.h" #include "qpid/sys/SystemInfo.h" +#include <algorithm> + using namespace qpid::client; using namespace qpid::framing; using namespace qpid::framing::connection; @@ -238,15 +241,16 @@ void ConnectionHandler::start(const FieldTable& /*serverProps*/, const Array& me ); std::vector<std::string> mechlist; + mechlist.reserve(mechanisms.size()); if (mechanism.empty()) { //mechlist is simply what the server offers - mechanisms.collect(mechlist); + std::transform(mechanisms.begin(), mechanisms.end(), std::back_inserter(mechlist), Array::get<std::string, Array::ValuePtr>); } else { //mechlist is the intersection of those indicated by user and //those supported by server, in the order listed by user std::vector<std::string> allowed = split(mechanism, " "); - std::vector<std::string> supported; - mechanisms.collect(supported); + std::vector<std::string> supported(mechanisms.size()); + std::transform(mechanisms.begin(), mechanisms.end(), std::back_inserter(supported), Array::get<std::string, Array::ValuePtr>); intersection(allowed, supported, mechlist); if (mechlist.empty()) { throw Exception(QPID_MSG("Desired mechanism(s) not valid: " << mechanism << " (supported: " << join(supported) << ")")); diff --git a/qpid/cpp/src/qpid/client/amqp0_10/AddressResolution.cpp b/qpid/cpp/src/qpid/client/amqp0_10/AddressResolution.cpp index 5924e30dd8..a8f4fb5237 100644 --- a/qpid/cpp/src/qpid/client/amqp0_10/AddressResolution.cpp +++ b/qpid/cpp/src/qpid/client/amqp0_10/AddressResolution.cpp @@ -32,6 +32,7 @@ #include "qpid/framing/ExchangeBoundResult.h" #include "qpid/framing/ExchangeQueryResult.h" #include "qpid/framing/FieldTable.h" +#include "qpid/framing/FieldValue.h" #include "qpid/framing/QueueQueryResult.h" #include "qpid/framing/ReplyTo.h" #include "qpid/framing/reply_exceptions.h" diff --git a/qpid/cpp/src/qpid/cluster/ClusterMap.cpp b/qpid/cpp/src/qpid/cluster/ClusterMap.cpp index 12730d20ec..d9817db35f 100644 --- a/qpid/cpp/src/qpid/cluster/ClusterMap.cpp +++ b/qpid/cpp/src/qpid/cluster/ClusterMap.cpp @@ -21,6 +21,7 @@ #include "qpid/cluster/ClusterMap.h" #include "qpid/Url.h" #include "qpid/framing/FieldTable.h" +#include "qpid/framing/FieldValue.h" #include "qpid/log/Statement.h" #include <boost/bind.hpp> #include <algorithm> diff --git a/qpid/cpp/src/qpid/cluster/Connection.cpp b/qpid/cpp/src/qpid/cluster/Connection.cpp index fc6ada096f..3d5a7be1c3 100644 --- a/qpid/cpp/src/qpid/cluster/Connection.cpp +++ b/qpid/cpp/src/qpid/cluster/Connection.cpp @@ -47,6 +47,7 @@ #include "qpid/framing/ClusterConnectionAnnounceBody.h" #include "qpid/framing/ConnectionCloseBody.h" #include "qpid/framing/ConnectionCloseOkBody.h" +#include "qpid/framing/FieldValue.h" #include "qpid/log/Statement.h" #include "qpid/sys/ClusterSafe.h" #include "qpid/types/Variant.h" diff --git a/qpid/cpp/src/qpid/cluster/UpdateClient.cpp b/qpid/cpp/src/qpid/cluster/UpdateClient.cpp index 95c64ff060..3a3582d032 100644 --- a/qpid/cpp/src/qpid/cluster/UpdateClient.cpp +++ b/qpid/cpp/src/qpid/cluster/UpdateClient.cpp @@ -57,6 +57,7 @@ #include "qpid/framing/ClusterConnectionShadowReadyBody.h" #include "qpid/framing/ClusterConnectionSessionStateBody.h" #include "qpid/framing/ClusterConnectionConsumerStateBody.h" +#include "qpid/framing/FieldValue.h" #include "qpid/framing/enum.h" #include "qpid/framing/ProtocolVersion.h" #include "qpid/framing/TypeCode.h" diff --git a/qpid/cpp/src/qpid/management/ManagementAgent.cpp b/qpid/cpp/src/qpid/management/ManagementAgent.cpp index 29e409b204..062a530706 100644 --- a/qpid/cpp/src/qpid/management/ManagementAgent.cpp +++ b/qpid/cpp/src/qpid/management/ManagementAgent.cpp @@ -30,6 +30,7 @@ #include "qpid/log/Statement.h" #include <qpid/broker/Message.h> #include "qpid/framing/MessageTransferBody.h" +#include "qpid/framing/FieldValue.h" #include "qpid/sys/Time.h" #include "qpid/sys/Thread.h" #include "qpid/broker/ConnectionState.h" diff --git a/qpid/cpp/src/qpid/management/ManagementAgent.h b/qpid/cpp/src/qpid/management/ManagementAgent.h index f01c66b4af..c7e830dcf5 100644 --- a/qpid/cpp/src/qpid/management/ManagementAgent.h +++ b/qpid/cpp/src/qpid/management/ManagementAgent.h @@ -36,7 +36,6 @@ #include "qpid/sys/MemStat.h" #include "qpid/types/Variant.h" #include <qpid/framing/AMQFrame.h> -#include <qpid/framing/FieldValue.h> #include <qpid/framing/ResizableBuffer.h> #include <memory> #include <string> diff --git a/qpid/cpp/src/tests/Array.cpp b/qpid/cpp/src/tests/Array.cpp index 7622b89d15..8ce7615162 100644 --- a/qpid/cpp/src/tests/Array.cpp +++ b/qpid/cpp/src/tests/Array.cpp @@ -58,7 +58,7 @@ QPID_AUTO_TEST_CASE(testEncodeDecode) BOOST_CHECK_EQUAL(a, b); std::vector<std::string> data2; - b.collect(data2); + std::transform(b.begin(), b.end(), std::back_inserter(data2), Array::get<std::string, Array::ValuePtr>); //BOOST_CHECK_EQUAL(data, data2); BOOST_CHECK(data == data2); } @@ -74,7 +74,7 @@ QPID_AUTO_TEST_CASE(testArrayAssignment) BOOST_CHECK_EQUAL(a, b); } std::vector<std::string> data2; - b.collect(data2); + std::transform(b.begin(), b.end(), std::back_inserter(data2), Array::get<std::string, Array::ValuePtr>); //BOOST_CHECK_EQUAL(data, data2); BOOST_CHECK(data == data2); } diff --git a/qpid/cpp/src/tests/FieldTable.cpp b/qpid/cpp/src/tests/FieldTable.cpp index fe2a14ec03..c79d110ae4 100644 --- a/qpid/cpp/src/tests/FieldTable.cpp +++ b/qpid/cpp/src/tests/FieldTable.cpp @@ -19,11 +19,11 @@ * */ #include <iostream> +#include <algorithm> #include "qpid/framing/Array.h" #include "qpid/framing/FieldTable.h" #include "qpid/framing/FieldValue.h" #include "qpid/framing/List.h" -#include "qpid/sys/alloca.h" #include "unit_test.h" @@ -127,7 +127,7 @@ QPID_AUTO_TEST_CASE(testNestedValues) BOOST_CHECK(string("B") == b.getAsString("id")); a.getArray("C", c); std::vector<std::string> items; - c.collect(items); + std::transform(c.begin(), c.end(), std::back_inserter(items), Array::get<std::string, Array::ValuePtr>); BOOST_CHECK((uint) 2 == items.size()); BOOST_CHECK(string("one") == items[0]); BOOST_CHECK(string("two") == items[1]); diff --git a/qpid/cpp/src/tests/FramingTest.cpp b/qpid/cpp/src/tests/FramingTest.cpp index f8795316cc..2392b6fec4 100644 --- a/qpid/cpp/src/tests/FramingTest.cpp +++ b/qpid/cpp/src/tests/FramingTest.cpp @@ -25,6 +25,7 @@ #include "qpid/framing/all_method_bodies.h" #include "qpid/framing/amqp_framing.h" #include "qpid/framing/reply_exceptions.h" +#include "qpid/framing/FieldValue.h" #include "unit_test.h" #include <boost/bind.hpp> diff --git a/qpid/cpp/src/tests/QueueFlowLimitTest.cpp b/qpid/cpp/src/tests/QueueFlowLimitTest.cpp index 8a6923fb09..bd868398f8 100644 --- a/qpid/cpp/src/tests/QueueFlowLimitTest.cpp +++ b/qpid/cpp/src/tests/QueueFlowLimitTest.cpp @@ -27,6 +27,7 @@ #include "qpid/broker/QueueFlowLimit.h" #include "qpid/sys/Time.h" #include "qpid/framing/reply_exceptions.h" +#include "qpid/framing/FieldValue.h" #include "MessageUtils.h" #include "BrokerFixture.h" diff --git a/qpid/cpp/src/tests/qpid-txtest.cpp b/qpid/cpp/src/tests/qpid-txtest.cpp index d0ba2f1245..6e7d46802c 100644 --- a/qpid/cpp/src/tests/qpid-txtest.cpp +++ b/qpid/cpp/src/tests/qpid-txtest.cpp @@ -33,6 +33,7 @@ #include "qpid/client/SubscriptionManager.h" #include "qpid/framing/Array.h" #include "qpid/framing/Buffer.h" +#include "qpid/framing/FieldValue.h" #include "qpid/framing/Uuid.h" #include "qpid/sys/Thread.h" @@ -245,10 +246,10 @@ struct Controller : public Client // Recover DTX transactions (if any) if (opts.dtx) { - std::vector<std::string> inDoubtXids; framing::DtxRecoverResult dtxRes = session.dtxRecover().get(); const framing::Array& xidArr = dtxRes.getInDoubt(); - xidArr.collect(inDoubtXids); + std::vector<std::string> inDoubtXids(xidArr.size()); + std::transform(xidArr.begin(), xidArr.end(), inDoubtXids.begin(), framing::Array::get<std::string, framing::Array::ValuePtr>); if (inDoubtXids.size()) { if (!opts.quiet) std::cout << "Recovering DTX in-doubt transaction(s):" << std::endl; |