diff options
author | Alan Conway <aconway@apache.org> | 2006-10-11 15:50:15 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2006-10-11 15:50:15 +0000 |
commit | 2bcadbb42a6fb2f096c1fc0a4b957d64a5024ef6 (patch) | |
tree | 886eb0659c6f28c2f1d26de7d5fd29fff0072dc5 | |
parent | 9fc2b6c5f0848d65f1bf20e62279c055d12a1d40 (diff) | |
download | qpid-python-2bcadbb42a6fb2f096c1fc0a4b957d64a5024ef6.tar.gz |
Turned up gcc warnings, fixed warnings in code, enabled -Werror.
Note: #include "qpid_test_plugin.h" instead of <cppunit/TestPlugin.h>
Works around warning from a cppunit macro.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@462834 13f79535-47bb-0310-9956-ffa450edef68
86 files changed, 540 insertions, 787 deletions
diff --git a/cpp/broker/inc/Channel.h b/cpp/broker/inc/Channel.h index a5a54aea1f..862d249ce1 100644 --- a/cpp/broker/inc/Channel.h +++ b/cpp/broker/inc/Channel.h @@ -146,8 +146,8 @@ namespace qpid { ~Channel(); inline void setDefaultQueue(Queue::shared_ptr queue){ defaultQueue = queue; } inline Queue::shared_ptr getDefaultQueue(){ return defaultQueue; } - inline u_int32_t setPrefetchSize(u_int32_t size){ prefetchSize = size; } - inline u_int16_t setPrefetchCount(u_int16_t count){ prefetchCount = count; } + inline u_int32_t setPrefetchSize(u_int32_t size){ return prefetchSize = size; } + inline u_int16_t setPrefetchCount(u_int16_t count){ return prefetchCount = count; } bool exists(const string& consumerTag); void consume(string& tag, Queue::shared_ptr queue, bool acks, bool exclusive, ConnectionToken* const connection = 0); void cancel(const string& tag); diff --git a/cpp/broker/inc/Exchange.h b/cpp/broker/inc/Exchange.h index 4066f5ac20..1fdc00fae5 100644 --- a/cpp/broker/inc/Exchange.h +++ b/cpp/broker/inc/Exchange.h @@ -27,7 +27,7 @@ namespace broker { class Exchange{ const std::string name; public: - explicit Exchange(const std::string& name) : name(name) {} + explicit Exchange(const std::string& _name) : name(_name) {} virtual ~Exchange(){} std::string getName() { return name; } virtual void bind(Queue::shared_ptr queue, const string& routingKey, qpid::framing::FieldTable* args) = 0; diff --git a/cpp/broker/inc/TopicExchange.h b/cpp/broker/inc/TopicExchange.h index 68a4026ee7..227280103f 100644 --- a/cpp/broker/inc/TopicExchange.h +++ b/cpp/broker/inc/TopicExchange.h @@ -57,7 +57,7 @@ class TopicPattern : public Tokens TopicPattern(const Tokens& tokens) { operator=(tokens); } TopicPattern(const std::string& str) { operator=(str); } TopicPattern& operator=(const Tokens&); - TopicPattern& operator=(const std::string& str) { operator=(Tokens(str)); } + TopicPattern& operator=(const std::string& str) { return operator=(Tokens(str)); } /** Match a topic */ bool match(const std::string& topic) { return match(Tokens(topic)); } diff --git a/cpp/broker/src/Broker.cpp b/cpp/broker/src/Broker.cpp index 5d59b63622..99cf8d6ce4 100644 --- a/cpp/broker/src/Broker.cpp +++ b/cpp/broker/src/Broker.cpp @@ -87,6 +87,6 @@ Acceptor* createAcceptor(Configuration& config){ throw Configuration::ParseException("Unrecognised acceptor: " + type); } -void handle_signal(int signal){ +void handle_signal(int /*signal*/){ std::cout << "Shutting down..." << std::endl; } diff --git a/cpp/broker/src/Channel.cpp b/cpp/broker/src/Channel.cpp index ed1125ee76..7bc6d599e9 100644 --- a/cpp/broker/src/Channel.cpp +++ b/cpp/broker/src/Channel.cpp @@ -26,16 +26,17 @@ using namespace qpid::framing; using namespace qpid::concurrent; -Channel::Channel(OutputHandler* _out, int _id, u_int32_t _framesize) : out(_out), - id(_id), - prefetchCount(0), - prefetchSize(0), - outstandingSize(0), - outstandingCount(0), - framesize(_framesize), - transactional(false), - deliveryTag(1), - tagGenerator("sgen"){} +Channel::Channel(OutputHandler* _out, int _id, u_int32_t _framesize) : + id(_id), + out(_out), + deliveryTag(1), + transactional(false), + prefetchSize(0), + prefetchCount(0), + outstandingSize(0), + outstandingCount(0), + framesize(_framesize), + tagGenerator("sgen"){} Channel::~Channel(){ } @@ -156,10 +157,10 @@ void Channel::handlePublish(Message* msg){ message = Message::shared_ptr(msg); } -void Channel::ack(u_int64_t deliveryTag, bool multiple){ +void Channel::ack(u_int64_t _deliveryTag, bool multiple){ Locker locker(deliveryLock);//need to synchronize with possible concurrent delivery - ack_iterator i = find_if(unacknowledged.begin(), unacknowledged.end(), MatchAck(deliveryTag)); + ack_iterator i = find_if(unacknowledged.begin(), unacknowledged.end(), MatchAck(_deliveryTag)); if(i == unacknowledged.end()){ throw InvalidAckException(); }else if(multiple){ @@ -178,8 +179,8 @@ void Channel::ack(u_int64_t deliveryTag, bool multiple){ //if the prefetch limit had previously been reached, there may //be messages that can be now be delivered - for(consumer_iterator i = consumers.begin(); i != consumers.end(); i++){ - i->second->requestDispatch(); + for(consumer_iterator j = consumers.begin(); j != consumers.end(); j++){ + j->second->requestDispatch(); } } diff --git a/cpp/broker/src/Configuration.cpp b/cpp/broker/src/Configuration.cpp index aceb35bc87..11c2d374fe 100644 --- a/cpp/broker/src/Configuration.cpp +++ b/cpp/broker/src/Configuration.cpp @@ -16,6 +16,7 @@ * */ #include "Configuration.h" +#include <string.h> using namespace qpid::broker; using namespace std; @@ -191,5 +192,5 @@ bool Configuration::BoolOption::needsValue() const { } void Configuration::BoolOption::setValue(const std::string& _value){ - value = true; + value = strcasecmp(_value.c_str(), "true") == 0; } diff --git a/cpp/broker/src/DirectExchange.cpp b/cpp/broker/src/DirectExchange.cpp index ca29225bee..94cfbc766d 100644 --- a/cpp/broker/src/DirectExchange.cpp +++ b/cpp/broker/src/DirectExchange.cpp @@ -22,7 +22,7 @@ using namespace qpid::broker; using namespace qpid::framing; -DirectExchange::DirectExchange(const string& name) : Exchange(name) { +DirectExchange::DirectExchange(const string& _name) : Exchange(_name) { } @@ -37,7 +37,7 @@ void DirectExchange::bind(Queue::shared_ptr queue, const string& routingKey, Fie lock.release(); } -void DirectExchange::unbind(Queue::shared_ptr queue, const string& routingKey, FieldTable* args){ +void DirectExchange::unbind(Queue::shared_ptr queue, const string& routingKey, FieldTable* /*args*/){ lock.acquire(); std::vector<Queue::shared_ptr>& queues(bindings[routingKey]); @@ -51,7 +51,7 @@ void DirectExchange::unbind(Queue::shared_ptr queue, const string& routingKey, F lock.release(); } -void DirectExchange::route(Message::shared_ptr& msg, const string& routingKey, FieldTable* args){ +void DirectExchange::route(Message::shared_ptr& msg, const string& routingKey, FieldTable* /*args*/){ lock.acquire(); std::vector<Queue::shared_ptr>& queues(bindings[routingKey]); int count(0); diff --git a/cpp/broker/src/FanOutExchange.cpp b/cpp/broker/src/FanOutExchange.cpp index 4eb75cb920..e8cb8f6315 100644 --- a/cpp/broker/src/FanOutExchange.cpp +++ b/cpp/broker/src/FanOutExchange.cpp @@ -23,7 +23,7 @@ using namespace qpid::broker; using namespace qpid::framing; using namespace qpid::concurrent; -FanOutExchange::FanOutExchange(const std::string& name) : Exchange(name) {} +FanOutExchange::FanOutExchange(const std::string& _name) : Exchange(_name) {} void FanOutExchange::bind(Queue::shared_ptr queue, const string& routingKey, FieldTable* args){ Locker locker(lock); @@ -35,7 +35,7 @@ void FanOutExchange::bind(Queue::shared_ptr queue, const string& routingKey, Fie } } -void FanOutExchange::unbind(Queue::shared_ptr queue, const string& routingKey, FieldTable* args){ +void FanOutExchange::unbind(Queue::shared_ptr queue, const string& /*routingKey*/, FieldTable* /*args*/){ Locker locker(lock); Queue::vector::iterator i = std::find(bindings.begin(), bindings.end(), queue); if (i != bindings.end()) { @@ -44,7 +44,7 @@ void FanOutExchange::unbind(Queue::shared_ptr queue, const string& routingKey, F } } -void FanOutExchange::route(Message::shared_ptr& msg, const string& routingKey, FieldTable* args){ +void FanOutExchange::route(Message::shared_ptr& msg, const string& /*routingKey*/, FieldTable* /*args*/){ Locker locker(lock); for(Queue::vector::iterator i = bindings.begin(); i != bindings.end(); ++i){ (*i)->deliver(msg); diff --git a/cpp/broker/src/HeadersExchange.cpp b/cpp/broker/src/HeadersExchange.cpp index 03a029ea4d..65204cdb85 100644 --- a/cpp/broker/src/HeadersExchange.cpp +++ b/cpp/broker/src/HeadersExchange.cpp @@ -18,8 +18,10 @@ #include "HeadersExchange.h" #include "ExchangeBinding.h" #include "Value.h" +#include "QpidError.h" #include <algorithm> + using namespace qpid::broker; using namespace qpid::framing; using namespace qpid::concurrent; @@ -28,38 +30,36 @@ using namespace qpid::concurrent; // The current search algorithm really sucks. // Fieldtables are heavy, maybe use shared_ptr to do handle-body. -namespace qpid { -namespace broker { +using namespace qpid::broker; namespace { -const std::string all("all"); -const std::string any("any"); -const std::string x_match("x-match"); + const std::string all("all"); + const std::string any("any"); + const std::string x_match("x-match"); } -HeadersExchange::HeadersExchange(const string& name) : Exchange(name) { } +HeadersExchange::HeadersExchange(const string& _name) : Exchange(_name) { } void HeadersExchange::bind(Queue::shared_ptr queue, const string& routingKey, FieldTable* args){ std::cout << "HeadersExchange::bind" << std::endl; Locker locker(lock); std::string what = args->getString("x-match"); - // TODO aconway 2006-09-26: throw an exception for invalid bindings. - if (what != all && what != any) return; // Invalid. + if (what != all && what != any) { + THROW_QPID_ERROR(PROTOCOL_ERROR, "Invalid x-match value binding to headers exchange."); + } bindings.push_back(Binding(*args, queue)); queue->bound(new ExchangeBinding(this, queue, routingKey, args)); } -void HeadersExchange::unbind(Queue::shared_ptr queue, const string& routingKey, FieldTable* args){ - Locker locker(lock);; - for (Bindings::iterator i = bindings.begin(); i != bindings.end(); ++i) { - if (i->first == *args) { - bindings.erase(i); - } - } +void HeadersExchange::unbind(Queue::shared_ptr queue, const string& /*routingKey*/, FieldTable* args){ + Locker locker(lock); + Bindings::iterator i = + std::find(bindings.begin(),bindings.end(), Binding(*args, queue)); + if (i != bindings.end()) bindings.erase(i); } -void HeadersExchange::route(Message::shared_ptr& msg, const string& routingKey, FieldTable* args){ +void HeadersExchange::route(Message::shared_ptr& msg, const string& /*routingKey*/, FieldTable* args){ std::cout << "route: " << *args << std::endl; Locker locker(lock);; for (Bindings::iterator i = bindings.begin(); i != bindings.end(); ++i) { @@ -70,12 +70,13 @@ void HeadersExchange::route(Message::shared_ptr& msg, const string& routingKey, HeadersExchange::~HeadersExchange() {} const std::string HeadersExchange::typeName("headers"); + namespace { -bool match_values(const Value& bind, const Value& msg) { - return dynamic_cast<const EmptyValue*>(&bind) || bind == msg; -} + bool match_values(const Value& bind, const Value& msg) { + return dynamic_cast<const EmptyValue*>(&bind) || bind == msg; + } } @@ -115,5 +116,5 @@ bool HeadersExchange::match(const FieldTable& bind, const FieldTable& msg) { } } -}} + diff --git a/cpp/broker/src/Message.cpp b/cpp/broker/src/Message.cpp index b0e5d16b77..0a8a5f7a4d 100644 --- a/cpp/broker/src/Message.cpp +++ b/cpp/broker/src/Message.cpp @@ -41,8 +41,8 @@ Message::Message(const ConnectionToken* const _publisher, Message::~Message(){ } -void Message::setHeader(AMQHeaderBody::shared_ptr header){ - this->header = header; +void Message::setHeader(AMQHeaderBody::shared_ptr _header){ + this->header = _header; } void Message::addContent(AMQContentBody::shared_ptr data){ diff --git a/cpp/broker/src/Queue.cpp b/cpp/broker/src/Queue.cpp index 1db4454235..eaaa3ffa31 100644 --- a/cpp/broker/src/Queue.cpp +++ b/cpp/broker/src/Queue.cpp @@ -22,16 +22,17 @@ using namespace qpid::broker; using namespace qpid::concurrent; -Queue::Queue(const string& _name, bool _durable, u_int32_t _autodelete, const ConnectionToken* const _owner) : name(_name), - durable(_durable), - autodelete(_autodelete), - owner(_owner), - queueing(false), - dispatching(false), - next(0), - lastUsed(0), - exclusive(0){ - +Queue::Queue(const string& _name, bool _durable, u_int32_t _autodelete, const ConnectionToken* const _owner) : + name(_name), + autodelete(_autodelete), + durable(_durable), + owner(_owner), + queueing(false), + dispatching(false), + next(0), + lastUsed(0), + exclusive(0) +{ if(autodelete) lastUsed = apr_time_as_msec(apr_time_now()); } diff --git a/cpp/broker/src/SessionHandlerImpl.cpp b/cpp/broker/src/SessionHandlerImpl.cpp index ad73c1b23b..0d8539332c 100644 --- a/cpp/broker/src/SessionHandlerImpl.cpp +++ b/cpp/broker/src/SessionHandlerImpl.cpp @@ -33,21 +33,20 @@ SessionHandlerImpl::SessionHandlerImpl(SessionContext* _context, QueueRegistry* _queues, ExchangeRegistry* _exchanges, AutoDelete* _cleaner, - const u_int32_t _timeout) : context(_context), - queues(_queues), - exchanges(_exchanges), - cleaner(_cleaner), - timeout(_timeout), - channelHandler(new ChannelHandlerImpl(this)), - connectionHandler(new ConnectionHandlerImpl(this)), - basicHandler(new BasicHandlerImpl(this)), - exchangeHandler(new ExchangeHandlerImpl(this)), - queueHandler(new QueueHandlerImpl(this)), - client(context), - framemax(65536), - heartbeat(0){ - -} + const u_int32_t _timeout) : + context(_context), + client(context), + queues(_queues), + exchanges(_exchanges), + cleaner(_cleaner), + timeout(_timeout), + connectionHandler(new ConnectionHandlerImpl(this)), + channelHandler(new ChannelHandlerImpl(this)), + basicHandler(new BasicHandlerImpl(this)), + exchangeHandler(new ExchangeHandlerImpl(this)), + queueHandler(new QueueHandlerImpl(this)), + framemax(65536), + heartbeat(0) {} SessionHandlerImpl::~SessionHandlerImpl(){ // TODO aconway 2006-09-07: Should be auto_ptr or plain members. @@ -123,7 +122,7 @@ void SessionHandlerImpl::received(qpid::framing::AMQFrame* frame){ } } -void SessionHandlerImpl::initiated(qpid::framing::ProtocolInitiation* header){ +void SessionHandlerImpl::initiated(qpid::framing::ProtocolInitiation* /*header*/){ //send connection start FieldTable properties; string mechanisms("PLAIN"); @@ -161,51 +160,53 @@ void SessionHandlerImpl::handleContent(u_int16_t channel, AMQContentBody::shared getChannel(channel)->handleContent(body, Router(*exchanges)); } -void SessionHandlerImpl::handleHeartbeat(AMQHeartbeatBody::shared_ptr body){ +void SessionHandlerImpl::handleHeartbeat(AMQHeartbeatBody::shared_ptr /*body*/){ std::cout << "SessionHandlerImpl::handleHeartbeat()" << std::endl; } -void SessionHandlerImpl::ConnectionHandlerImpl::startOk(u_int16_t channel, FieldTable& clientProperties, string& mechanism, - string& response, string& locale){ +void SessionHandlerImpl::ConnectionHandlerImpl::startOk( + u_int16_t /*channel*/, FieldTable& /*clientProperties*/, string& /*mechanism*/, + string& /*response*/, string& /*locale*/){ parent->client.getConnection().tune(0, 100, parent->framemax, parent->heartbeat); } -void SessionHandlerImpl::ConnectionHandlerImpl::secureOk(u_int16_t channel, string& response){} +void SessionHandlerImpl::ConnectionHandlerImpl::secureOk(u_int16_t /*channel*/, string& /*response*/){} -void SessionHandlerImpl::ConnectionHandlerImpl::tuneOk(u_int16_t channel, u_int16_t channelmax, u_int32_t framemax, u_int16_t heartbeat){ +void SessionHandlerImpl::ConnectionHandlerImpl::tuneOk(u_int16_t /*channel*/, u_int16_t /*channelmax*/, u_int32_t framemax, u_int16_t heartbeat){ parent->framemax = framemax; parent->heartbeat = heartbeat; } -void SessionHandlerImpl::ConnectionHandlerImpl::open(u_int16_t channel, string& virtualHost, string& capabilities, bool insist){ +void SessionHandlerImpl::ConnectionHandlerImpl::open(u_int16_t /*channel*/, string& /*virtualHost*/, string& /*capabilities*/, bool /*insist*/){ string knownhosts; parent->client.getConnection().openOk(0, knownhosts); } -void SessionHandlerImpl::ConnectionHandlerImpl::close(u_int16_t channel, u_int16_t replyCode, string& replyText, - u_int16_t classId, u_int16_t methodId){ - +void SessionHandlerImpl::ConnectionHandlerImpl::close( + u_int16_t /*channel*/, u_int16_t /*replyCode*/, string& /*replyText*/, + u_int16_t /*classId*/, u_int16_t /*methodId*/) +{ parent->client.getConnection().closeOk(0); parent->context->close(); } -void SessionHandlerImpl::ConnectionHandlerImpl::closeOk(u_int16_t channel){ +void SessionHandlerImpl::ConnectionHandlerImpl::closeOk(u_int16_t /*channel*/){ parent->context->close(); } -void SessionHandlerImpl::ChannelHandlerImpl::open(u_int16_t channel, string& outOfBand){ +void SessionHandlerImpl::ChannelHandlerImpl::open(u_int16_t channel, string& /*outOfBand*/){ parent->channels[channel] = new Channel(parent->context, channel, parent->framemax); parent->client.getChannel().openOk(channel); } -void SessionHandlerImpl::ChannelHandlerImpl::flow(u_int16_t channel, bool active){} -void SessionHandlerImpl::ChannelHandlerImpl::flowOk(u_int16_t channel, bool active){} +void SessionHandlerImpl::ChannelHandlerImpl::flow(u_int16_t /*channel*/, bool /*active*/){} +void SessionHandlerImpl::ChannelHandlerImpl::flowOk(u_int16_t /*channel*/, bool /*active*/){} -void SessionHandlerImpl::ChannelHandlerImpl::close(u_int16_t channel, u_int16_t replyCode, string& replyText, - u_int16_t classId, u_int16_t methodId){ +void SessionHandlerImpl::ChannelHandlerImpl::close(u_int16_t channel, u_int16_t /*replyCode*/, string& /*replyText*/, + u_int16_t /*classId*/, u_int16_t /*methodId*/){ Channel* c = parent->getChannel(channel); if(c){ parent->channels.erase(channel); @@ -215,13 +216,13 @@ void SessionHandlerImpl::ChannelHandlerImpl::close(u_int16_t channel, u_int16_t } } -void SessionHandlerImpl::ChannelHandlerImpl::closeOk(u_int16_t channel){} +void SessionHandlerImpl::ChannelHandlerImpl::closeOk(u_int16_t /*channel*/){} -void SessionHandlerImpl::ExchangeHandlerImpl::declare(u_int16_t channel, u_int16_t ticket, string& exchange, string& type, - bool passive, bool durable, bool autoDelete, bool internal, bool nowait, - FieldTable& arguments){ +void SessionHandlerImpl::ExchangeHandlerImpl::declare(u_int16_t channel, u_int16_t /*ticket*/, string& exchange, string& type, + bool passive, bool /*durable*/, bool /*autoDelete*/, bool /*internal*/, bool nowait, + FieldTable& /*arguments*/){ if(!passive && ( type != TopicExchange::typeName && @@ -252,7 +253,7 @@ void SessionHandlerImpl::ExchangeHandlerImpl::declare(u_int16_t channel, u_int16 } } -void SessionHandlerImpl::ExchangeHandlerImpl::delete_(u_int16_t channel, u_int16_t ticket, string& exchange, bool ifUnused, bool nowait){ +void SessionHandlerImpl::ExchangeHandlerImpl::delete_(u_int16_t channel, u_int16_t /*ticket*/, string& exchange, bool /*ifUnused*/, bool nowait){ //TODO: implement unused parent->exchanges->getLock()->acquire(); parent->exchanges->destroy(exchange); @@ -260,9 +261,9 @@ void SessionHandlerImpl::ExchangeHandlerImpl::delete_(u_int16_t channel, u_int16 if(!nowait) parent->client.getExchange().deleteOk(channel); } -void SessionHandlerImpl::QueueHandlerImpl::declare(u_int16_t channel, u_int16_t ticket, string& name, +void SessionHandlerImpl::QueueHandlerImpl::declare(u_int16_t channel, u_int16_t /*ticket*/, string& name, bool passive, bool durable, bool exclusive, - bool autoDelete, bool nowait, FieldTable& arguments){ + bool autoDelete, bool nowait, FieldTable& /*arguments*/){ Queue::shared_ptr queue; if (passive && !name.empty()) { queue = parent->getQueue(name, channel); @@ -290,7 +291,7 @@ void SessionHandlerImpl::QueueHandlerImpl::declare(u_int16_t channel, u_int16_t } } -void SessionHandlerImpl::QueueHandlerImpl::bind(u_int16_t channel, u_int16_t ticket, string& queueName, +void SessionHandlerImpl::QueueHandlerImpl::bind(u_int16_t channel, u_int16_t /*ticket*/, string& queueName, string& exchangeName, string& routingKey, bool nowait, FieldTable& arguments){ @@ -305,14 +306,14 @@ void SessionHandlerImpl::QueueHandlerImpl::bind(u_int16_t channel, u_int16_t tic } } -void SessionHandlerImpl::QueueHandlerImpl::purge(u_int16_t channel, u_int16_t ticket, string& queueName, bool nowait){ +void SessionHandlerImpl::QueueHandlerImpl::purge(u_int16_t channel, u_int16_t /*ticket*/, string& queueName, bool nowait){ Queue::shared_ptr queue = parent->getQueue(queueName, channel); int count = queue->purge(); if(!nowait) parent->client.getQueue().purgeOk(channel, count); } -void SessionHandlerImpl::QueueHandlerImpl::delete_(u_int16_t channel, u_int16_t ticket, string& queue, +void SessionHandlerImpl::QueueHandlerImpl::delete_(u_int16_t channel, u_int16_t /*ticket*/, string& queue, bool ifUnused, bool ifEmpty, bool nowait){ ChannelException error(0, ""); int count(0); @@ -336,14 +337,14 @@ void SessionHandlerImpl::QueueHandlerImpl::delete_(u_int16_t channel, u_int16_t -void SessionHandlerImpl::BasicHandlerImpl::qos(u_int16_t channel, u_int32_t prefetchSize, u_int16_t prefetchCount, bool global){ +void SessionHandlerImpl::BasicHandlerImpl::qos(u_int16_t channel, u_int32_t prefetchSize, u_int16_t prefetchCount, bool /*global*/){ //TODO: handle global parent->getChannel(channel)->setPrefetchSize(prefetchSize); parent->getChannel(channel)->setPrefetchCount(prefetchCount); parent->client.getBasic().qosOk(channel); } -void SessionHandlerImpl::BasicHandlerImpl::consume(u_int16_t channelId, u_int16_t ticket, +void SessionHandlerImpl::BasicHandlerImpl::consume(u_int16_t channelId, u_int16_t /*ticket*/, string& queueName, string& consumerTag, bool noLocal, bool noAck, bool exclusive, bool nowait){ @@ -372,7 +373,7 @@ void SessionHandlerImpl::BasicHandlerImpl::cancel(u_int16_t channel, string& con if(!nowait) parent->client.getBasic().cancelOk(channel, consumerTag); } -void SessionHandlerImpl::BasicHandlerImpl::publish(u_int16_t channel, u_int16_t ticket, +void SessionHandlerImpl::BasicHandlerImpl::publish(u_int16_t channel, u_int16_t /*ticket*/, string& exchange, string& routingKey, bool mandatory, bool immediate){ @@ -380,7 +381,7 @@ void SessionHandlerImpl::BasicHandlerImpl::publish(u_int16_t channel, u_int16_t parent->getChannel(channel)->handlePublish(msg); } -void SessionHandlerImpl::BasicHandlerImpl::get(u_int16_t channelId, u_int16_t ticket, string& queueName, bool noAck){ +void SessionHandlerImpl::BasicHandlerImpl::get(u_int16_t channelId, u_int16_t /*ticket*/, string& queueName, bool noAck){ Queue::shared_ptr queue = parent->getQueue(queueName, channelId); if(!parent->getChannel(channelId)->get(queue, !noAck)){ string clusterId;//not used, part of an imatix hack @@ -396,7 +397,7 @@ void SessionHandlerImpl::BasicHandlerImpl::ack(u_int16_t channel, u_int64_t deli } } -void SessionHandlerImpl::BasicHandlerImpl::reject(u_int16_t channel, u_int64_t deliveryTag, bool requeue){} +void SessionHandlerImpl::BasicHandlerImpl::reject(u_int16_t /*channel*/, u_int64_t /*deliveryTag*/, bool /*requeue*/){} void SessionHandlerImpl::BasicHandlerImpl::recover(u_int16_t channel, bool requeue){ parent->getChannel(channel)->recover(requeue); diff --git a/cpp/broker/src/TopicExchange.cpp b/cpp/broker/src/TopicExchange.cpp index 287502bc88..53977747c4 100644 --- a/cpp/broker/src/TopicExchange.cpp +++ b/cpp/broker/src/TopicExchange.cpp @@ -47,6 +47,7 @@ size_t Tokens::Hash::operator()(const Tokens& p) const { for (Tokens::const_iterator i = p.begin(); i != p.end(); ++i) { hash += std::tr1::hash<std::string>()(*i); } + return hash; } TopicPattern& TopicPattern::operator=(const Tokens& tokens) { @@ -119,7 +120,7 @@ bool TopicPattern::match(const Tokens& target) const return do_match(begin(), end(), target.begin(), target.end()); } -TopicExchange::TopicExchange(const string& name) : Exchange(name) { } +TopicExchange::TopicExchange(const string& _name) : Exchange(_name) { } void TopicExchange::bind(Queue::shared_ptr queue, const string& routingKey, FieldTable* args){ lock.acquire(); @@ -129,7 +130,7 @@ void TopicExchange::bind(Queue::shared_ptr queue, const string& routingKey, Fiel lock.release(); } -void TopicExchange::unbind(Queue::shared_ptr queue, const string& routingKey, FieldTable* args){ +void TopicExchange::unbind(Queue::shared_ptr queue, const string& routingKey, FieldTable* /*args*/){ lock.acquire(); BindingMap::iterator bi = bindings.find(TopicPattern(routingKey)); Queue::vector& qv(bi->second); @@ -142,7 +143,7 @@ void TopicExchange::unbind(Queue::shared_ptr queue, const string& routingKey, Fi } -void TopicExchange::route(Message::shared_ptr& msg, const string& routingKey, FieldTable* args){ +void TopicExchange::route(Message::shared_ptr& msg, const string& routingKey, FieldTable* /*args*/){ lock.acquire(); for (BindingMap::iterator i = bindings.begin(); i != bindings.end(); ++i) { if (i->first.match(routingKey)) { diff --git a/cpp/broker/test/ChannelTest.cpp b/cpp/broker/test/ChannelTest.cpp index c96d17379e..45498989f2 100644 --- a/cpp/broker/test/ChannelTest.cpp +++ b/cpp/broker/test/ChannelTest.cpp @@ -17,10 +17,7 @@ */ #include "Channel.h" #include "Message.h" -#include <cppunit/TestCase.h> -#include <cppunit/TextTestRunner.h> -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/plugin/TestPlugIn.h> +#include <qpid_test_plugin.h> #include <iostream> #include <memory> diff --git a/cpp/broker/test/HeadersExchangeTest.cpp b/cpp/broker/test/HeadersExchangeTest.cpp index 82d3a292a8..d56e00543d 100644 --- a/cpp/broker/test/HeadersExchangeTest.cpp +++ b/cpp/broker/test/HeadersExchangeTest.cpp @@ -19,10 +19,7 @@ #include "HeadersExchange.h" #include "FieldTable.h" #include "Value.h" -#include <cppunit/TestCase.h> -#include <cppunit/TextTestRunner.h> -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/plugin/TestPlugIn.h> +#include <qpid_test_plugin.h> using namespace qpid::broker; using namespace qpid::framing; diff --git a/cpp/broker/test/QueueRegistryTest.cpp b/cpp/broker/test/QueueRegistryTest.cpp index c4ad40b5cd..bd739aaad5 100644 --- a/cpp/broker/test/QueueRegistryTest.cpp +++ b/cpp/broker/test/QueueRegistryTest.cpp @@ -1,8 +1,5 @@ #include "QueueRegistry.h" -#include <cppunit/TestCase.h> -#include <cppunit/TextTestRunner.h> -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/plugin/TestPlugIn.h> +#include <qpid_test_plugin.h> #include <string> using namespace qpid::broker; diff --git a/cpp/broker/test/QueueTest.cpp b/cpp/broker/test/QueueTest.cpp index 973b1b5cf6..1b4eb814cb 100644 --- a/cpp/broker/test/QueueTest.cpp +++ b/cpp/broker/test/QueueTest.cpp @@ -17,10 +17,7 @@ */ #include "Queue.h" #include "QueueRegistry.h" -#include <cppunit/TestCase.h> -#include <cppunit/TextTestRunner.h> -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/plugin/TestPlugIn.h> +#include <qpid_test_plugin.h> #include <iostream> using namespace qpid::broker; diff --git a/cpp/broker/test/RouterTest.cpp b/cpp/broker/test/RouterTest.cpp index 284a28f583..b1d4b9739f 100644 --- a/cpp/broker/test/RouterTest.cpp +++ b/cpp/broker/test/RouterTest.cpp @@ -20,10 +20,7 @@ #include "ExchangeRegistry.h" #include "Message.h" #include "Router.h" -#include <cppunit/TestCase.h> -#include <cppunit/TextTestRunner.h> -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/plugin/TestPlugIn.h> +#include <qpid_test_plugin.h> #include <iostream> #include <memory> @@ -38,16 +35,14 @@ struct TestExchange : public Exchange{ TestExchange() : Exchange("test"), args(0) {} - void bind(Queue::shared_ptr queue, const string& routingKey, FieldTable* args){ - } + void bind(Queue::shared_ptr /*queue*/, const string& /*routingKey*/, FieldTable* /*args*/){} - void unbind(Queue::shared_ptr queue, const string& routingKey, FieldTable* args){ - } + void unbind(Queue::shared_ptr /*queue*/, const string& /*routingKey*/, FieldTable* /*args*/){ } - void route(Message::shared_ptr& msg, const string& routingKey, FieldTable* args){ - this->msg = msg; - this->routingKey = routingKey; - this->args = args; + void route(Message::shared_ptr& _msg, const string& _routingKey, FieldTable* _args){ + msg = _msg; + routingKey = _routingKey; + args = _args; } }; diff --git a/cpp/broker/test/TopicExchangeTest.cpp b/cpp/broker/test/TopicExchangeTest.cpp index 4653540040..d9b49fc603 100644 --- a/cpp/broker/test/TopicExchangeTest.cpp +++ b/cpp/broker/test/TopicExchangeTest.cpp @@ -1,8 +1,5 @@ #include "TopicExchange.h" -#include <cppunit/TestCase.h> -#include <cppunit/TextTestRunner.h> -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/plugin/TestPlugIn.h> +#include <qpid_test_plugin.h> using namespace qpid::broker; @@ -30,6 +27,7 @@ CppUnit::OStringStream& operator <<(CppUnit::OStringStream& out, const Tokens& v { out << '"' << *i << '"' << (i+1 == v.end() ? "]" : ", "); } + return out; } diff --git a/cpp/broker/test/ValueTest.cpp b/cpp/broker/test/ValueTest.cpp index 181f0ced84..ec9659e603 100644 --- a/cpp/broker/test/ValueTest.cpp +++ b/cpp/broker/test/ValueTest.cpp @@ -1,8 +1,5 @@ #include "Value.h" -#include <cppunit/TestCase.h> -#include <cppunit/TextTestRunner.h> -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/plugin/TestPlugIn.h> +#include <qpid_test_plugin.h> using namespace qpid::framing; diff --git a/cpp/broker/test/exchange_test.cpp b/cpp/broker/test/exchange_test.cpp index 6605f2685b..8c702ff836 100644 --- a/cpp/broker/test/exchange_test.cpp +++ b/cpp/broker/test/exchange_test.cpp @@ -20,10 +20,7 @@ #include "Exchange.h" #include "Queue.h" #include "TopicExchange.h" -#include <cppunit/TestCase.h> -#include <cppunit/TextTestRunner.h> -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/plugin/TestPlugIn.h> +#include <qpid_test_plugin.h> #include <iostream> using namespace qpid::broker; diff --git a/cpp/broker/test/message_test.cpp b/cpp/broker/test/message_test.cpp index 94d25a831e..fc2c6e01bb 100644 --- a/cpp/broker/test/message_test.cpp +++ b/cpp/broker/test/message_test.cpp @@ -17,10 +17,7 @@ */ #include "APRBase.h" #include "Message.h" -#include <cppunit/TestCase.h> -#include <cppunit/TextTestRunner.h> -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/plugin/TestPlugIn.h> +#include <qpid_test_plugin.h> #include <iostream> using namespace qpid::broker; diff --git a/cpp/client/inc/IncomingMessage.h b/cpp/client/inc/IncomingMessage.h index 04b1fb40ba..90fed17ee0 100644 --- a/cpp/client/inc/IncomingMessage.h +++ b/cpp/client/inc/IncomingMessage.h @@ -35,7 +35,7 @@ namespace client { qpid::framing::AMQHeaderBody::shared_ptr header; std::vector<qpid::framing::AMQContentBody::shared_ptr> content; - long contentSize(); + u_int64_t contentSize(); public: IncomingMessage(qpid::framing::BasicDeliverBody::shared_ptr intro); IncomingMessage(qpid::framing::BasicReturnBody::shared_ptr intro); diff --git a/cpp/client/inc/Message.h b/cpp/client/inc/Message.h index f8a5aef565..fc3ec34bcf 100644 --- a/cpp/client/inc/Message.h +++ b/cpp/client/inc/Message.h @@ -38,10 +38,10 @@ namespace client { ~Message(); inline std::string getData(){ return data; } - inline void setData(const std::string& data){ this->data = data; } + inline void setData(const std::string& _data){ data = _data; } inline bool isRedelivered(){ return redelivered; } - inline void setRedelivered(bool redelivered){ this->redelivered = redelivered; } + inline void setRedelivered(bool _redelivered){ redelivered = _redelivered; } inline u_int64_t getDeliveryTag(){ return deliveryTag; } diff --git a/cpp/client/inc/MessageListener.h b/cpp/client/inc/MessageListener.h index 47307a4df5..81b80ff5cb 100644 --- a/cpp/client/inc/MessageListener.h +++ b/cpp/client/inc/MessageListener.h @@ -27,6 +27,7 @@ namespace client { class MessageListener{ public: + virtual ~MessageListener(); virtual void received(Message& msg) = 0; }; diff --git a/cpp/client/inc/ReturnedMessageHandler.h b/cpp/client/inc/ReturnedMessageHandler.h index 0117778fde..0d30d0ab32 100644 --- a/cpp/client/inc/ReturnedMessageHandler.h +++ b/cpp/client/inc/ReturnedMessageHandler.h @@ -27,6 +27,7 @@ namespace client { class ReturnedMessageHandler{ public: + virtual ~ReturnedMessageHandler(); virtual void returned(Message& msg) = 0; }; diff --git a/cpp/client/src/Channel.cpp b/cpp/client/src/Channel.cpp index e965f7e5dd..cf2f5bc081 100644 --- a/cpp/client/src/Channel.cpp +++ b/cpp/client/src/Channel.cpp @@ -26,11 +26,16 @@ using namespace qpid::client; using namespace qpid::framing; using namespace qpid::concurrent; -Channel::Channel(bool _transactional, u_int16_t _prefetch) : id(0), incoming(0), con(0), out(0), - prefetch(_prefetch), - transactional(_transactional), - dispatcher(0), - closed(true){ +Channel::Channel(bool _transactional, u_int16_t _prefetch) : + id(0), + con(0), + dispatcher(0), + out(0), + incoming(0), + closed(true), + prefetch(_prefetch), + transactional(_transactional) +{ threadFactory = new ThreadFactoryImpl(); dispatchMonitor = new MonitorImpl(); retrievalMonitor = new MonitorImpl(); @@ -46,8 +51,8 @@ Channel::~Channel(){ delete threadFactory; } -void Channel::setPrefetch(u_int16_t prefetch){ - this->prefetch = prefetch; +void Channel::setPrefetch(u_int16_t _prefetch){ + prefetch = _prefetch; if(con != 0 && out != 0){ setQos(); } @@ -114,7 +119,9 @@ void Channel::deleteQueue(Queue& queue, bool ifunused, bool ifempty, bool synch) void Channel::bind(const Exchange& exchange, const Queue& queue, const std::string& key, const FieldTable& args, bool synch){ string e = exchange.getName(); string q = queue.getName(); - AMQFrame* frame = new AMQFrame(id, new QueueBindBody(0, q, e, (string&) key,!synch, (FieldTable&) args)); + // TODO aconway 2006-10-10: not const correct, get rid of const_cast. + // + AMQFrame* frame = new AMQFrame(id, new QueueBindBody(0, q, e, key,!synch, const_cast<FieldTable&>(args))); if(synch){ sendAndReceive(frame, queue_bind_ok); }else{ @@ -160,7 +167,6 @@ void Channel::cancel(std::string& tag, bool synch){ } void Channel::cancelAll(){ - int count(consumers.size()); for(consumer_iterator i = consumers.begin(); i != consumers.end(); i = consumers.begin()){ Consumer* c = i->second; if((c->ackMode == LAZY_ACK || c->ackMode == AUTO_ACK) && c->lastDeliveryTag > 0){ @@ -306,7 +312,7 @@ void Channel::handleContent(AMQContentBody::shared_ptr body){ } } -void Channel::handleHeartbeat(AMQHeartbeatBody::shared_ptr body){ +void Channel::handleHeartbeat(AMQHeartbeatBody::shared_ptr /*body*/){ THROW_QPID_ERROR(PROTOCOL_ERROR + 504, "Channel received heartbeat"); } diff --git a/cpp/client/src/Connection.cpp b/cpp/client/src/Connection.cpp index eeb2330561..f332d2242c 100644 --- a/cpp/client/src/Connection.cpp +++ b/cpp/client/src/Connection.cpp @@ -37,9 +37,9 @@ Connection::~Connection(){ delete connector; } -void Connection::open(const std::string& host, int port, const std::string& uid, const std::string& pwd, const std::string& virtualhost){ - this->host = host; - this->port = port; +void Connection::open(const std::string& _host, int _port, const std::string& uid, const std::string& pwd, const std::string& virtualhost){ + host = _host; + port = _port; connector->setInputHandler(this); connector->setTimeoutHandler(this); connector->setShutdownHandler(this); @@ -181,15 +181,15 @@ void Connection::handleMethod(AMQMethodBody::shared_ptr body){ } } -void Connection::handleHeader(AMQHeaderBody::shared_ptr body){ +void Connection::handleHeader(AMQHeaderBody::shared_ptr /*body*/){ error(504, "Channel error: received header body with channel 0."); } -void Connection::handleContent(AMQContentBody::shared_ptr body){ +void Connection::handleContent(AMQContentBody::shared_ptr /*body*/){ error(504, "Channel error: received content body with channel 0."); } -void Connection::handleHeartbeat(AMQHeartbeatBody::shared_ptr body){ +void Connection::handleHeartbeat(AMQHeartbeatBody::shared_ptr /*body*/){ } void Connection::sendAndReceive(AMQFrame* frame, const AMQMethodBody& body){ @@ -204,7 +204,7 @@ void Connection::error(int code, const string& msg, int classid, int methodid){ std::cout << " [" << methodid << ":" << classid << "]"; } std::cout << std::endl; - sendAndReceive(new AMQFrame(0, new ConnectionCloseBody(code, (string&) msg, classid, methodid)), connection_close_ok); + sendAndReceive(new AMQFrame(0, new ConnectionCloseBody(code, msg, classid, methodid)), connection_close_ok); connector->close(); } diff --git a/cpp/client/src/IncomingMessage.cpp b/cpp/client/src/IncomingMessage.cpp index c95a92b651..9576051302 100644 --- a/cpp/client/src/IncomingMessage.cpp +++ b/cpp/client/src/IncomingMessage.cpp @@ -29,12 +29,12 @@ IncomingMessage::IncomingMessage(BasicGetOkBody::shared_ptr intro): response(int IncomingMessage::~IncomingMessage(){ } -void IncomingMessage::setHeader(AMQHeaderBody::shared_ptr header){ - this->header = header; +void IncomingMessage::setHeader(AMQHeaderBody::shared_ptr _header){ + this->header = _header; } -void IncomingMessage::addContent(AMQContentBody::shared_ptr content){ - this->content.push_back(content); +void IncomingMessage::addContent(AMQContentBody::shared_ptr _content){ + this->content.push_back(_content); } bool IncomingMessage::isComplete(){ @@ -75,10 +75,10 @@ void IncomingMessage::getData(string& s){ } } -long IncomingMessage::contentSize(){ - long size(0); - int count(content.size()); - for(int i = 0; i < count; i++){ +u_int64_t IncomingMessage::contentSize(){ + u_int64_t size(0); + u_int64_t count(content.size()); + for(u_int64_t i = 0; i < count; i++){ size += content[i]->size(); } return size; diff --git a/cpp/client/src/MessageListener.cpp b/cpp/client/src/MessageListener.cpp new file mode 100644 index 0000000000..cf55db8edf --- /dev/null +++ b/cpp/client/src/MessageListener.cpp @@ -0,0 +1,21 @@ +/* + * + * 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 "MessageListener.h" + +qpid::client::MessageListener::~MessageListener() {} diff --git a/cpp/client/src/Queue.cpp b/cpp/client/src/Queue.cpp index cb957dd993..5b2881f7ff 100644 --- a/cpp/client/src/Queue.cpp +++ b/cpp/client/src/Queue.cpp @@ -30,8 +30,8 @@ const std::string& qpid::client::Queue::getName() const{ return name; } -void qpid::client::Queue::setName(const std::string& name){ - this->name = name; +void qpid::client::Queue::setName(const std::string& _name){ + name = _name; } bool qpid::client::Queue::isAutoDelete() const{ diff --git a/cpp/client/src/ResponseHandler.cpp b/cpp/client/src/ResponseHandler.cpp index 837bba37fd..6938539469 100644 --- a/cpp/client/src/ResponseHandler.cpp +++ b/cpp/client/src/ResponseHandler.cpp @@ -39,8 +39,8 @@ void qpid::client::ResponseHandler::waitForResponse(){ monitor->release(); } -void qpid::client::ResponseHandler::signalResponse(qpid::framing::AMQMethodBody::shared_ptr response){ - this->response = response; +void qpid::client::ResponseHandler::signalResponse(qpid::framing::AMQMethodBody::shared_ptr _response){ + response = _response; monitor->acquire(); waiting = false; monitor->notify(); diff --git a/cpp/client/src/ReturnedMessageHandler.cpp b/cpp/client/src/ReturnedMessageHandler.cpp new file mode 100644 index 0000000000..cfa91fee97 --- /dev/null +++ b/cpp/client/src/ReturnedMessageHandler.cpp @@ -0,0 +1,21 @@ +/* + * + * 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 "ReturnedMessageHandler.h" + +qpid::client::ReturnedMessageHandler::~ReturnedMessageHandler() {} diff --git a/cpp/client/test/client_test.cpp b/cpp/client/test/client_test.cpp index e33beb3b67..b899d494d7 100644 --- a/cpp/client/test/client_test.cpp +++ b/cpp/client/test/client_test.cpp @@ -36,7 +36,7 @@ class SimpleListener : public virtual MessageListener{ public: inline SimpleListener(Monitor* _monitor) : monitor(_monitor){} - inline virtual void received(Message& msg){ + inline virtual void received(Message& /*msg*/){ std::cout << "Received message " /**<< msg **/<< std::endl; monitor->acquire(); monitor->notify(); @@ -44,7 +44,7 @@ public: } }; -int main(int argc, char** argv) +int main(int argc, char**) { try{ Connection con(argc > 1); diff --git a/cpp/client/test/topic_listener.cpp b/cpp/client/test/topic_listener.cpp index d5b6d77c1a..a1b8e383a0 100644 --- a/cpp/client/test/topic_listener.cpp +++ b/cpp/client/test/topic_listener.cpp @@ -125,11 +125,11 @@ void Listener::shutdown(){ void Listener::report(){ apr_time_t finish = apr_time_as_msec(apr_time_now()); apr_time_t time = finish - start; - std::stringstream report; - report << "Received " << count << " messages in " << time << " ms."; + std::stringstream reportstr; + reportstr << "Received " << count << " messages in " << time << " ms."; Message msg; - msg.setData(report.str()); - channel->publish(msg, string(""), responseQueue); + msg.setData(reportstr.str()); + channel->publish(msg, string(), responseQueue); if(transactional){ channel->commit(); } diff --git a/cpp/common/Makefile b/cpp/common/Makefile index 0533cdd1a9..98e4025390 100644 --- a/cpp/common/Makefile +++ b/cpp/common/Makefile @@ -20,11 +20,7 @@ QPID_HOME=../.. include $(QPID_HOME)/cpp/options.mk - TARGET = $(LIB_DIR)/libqpid_common.so.1.0 - -CXXFLAGS = $(DEBUG) $(OPT) -MMD -fpic $(COMMON_INCLUDES) - SOURCES = $(wildcard */src/*.cpp framing/generated/*.cpp) OBJECTS = $(SOURCES:.cpp=.o) DEPS = $(SOURCES:.cpp=.d) diff --git a/cpp/common/concurrent/inc/Runnable.h b/cpp/common/concurrent/inc/Runnable.h index 523ad813f7..9753a1ad0a 100644 --- a/cpp/common/concurrent/inc/Runnable.h +++ b/cpp/common/concurrent/inc/Runnable.h @@ -24,6 +24,7 @@ namespace concurrent { class Runnable { public: + virtual ~Runnable(); virtual void run() = 0; }; diff --git a/cpp/common/concurrent/src/APRBase.cpp b/cpp/common/concurrent/src/APRBase.cpp index f87ea9e25f..f9b34b9333 100644 --- a/cpp/common/concurrent/src/APRBase.cpp +++ b/cpp/common/concurrent/src/APRBase.cpp @@ -91,7 +91,6 @@ void qpid::concurrent::check(apr_status_t status, const std::string& file, const std::string qpid::concurrent::get_desc(apr_status_t status){ const int size = 50; char tmp[size]; - std::string msg(apr_strerror(status, tmp, size)); - return msg; + return std::string(apr_strerror(status, tmp, size)); } diff --git a/cpp/common/concurrent/src/APRThread.cpp b/cpp/common/concurrent/src/APRThread.cpp index 4202fe81b6..4167fb76ff 100644 --- a/cpp/common/concurrent/src/APRThread.cpp +++ b/cpp/common/concurrent/src/APRThread.cpp @@ -27,7 +27,7 @@ void* APR_THREAD_FUNC ExecRunnable(apr_thread_t* thread, void *data){ return NULL; } -APRThread::APRThread(apr_pool_t* _pool, Runnable* _runnable) : pool(_pool), runnable(_runnable){} +APRThread::APRThread(apr_pool_t* _pool, Runnable* _runnable) : runnable(_runnable), pool(_pool) {} APRThread::~APRThread(){ } diff --git a/cpp/common/concurrent/src/APRThreadPool.cpp b/cpp/common/concurrent/src/APRThreadPool.cpp index e0fcb804e6..8518d98b67 100644 --- a/cpp/common/concurrent/src/APRThreadPool.cpp +++ b/cpp/common/concurrent/src/APRThreadPool.cpp @@ -22,13 +22,11 @@ using namespace qpid::concurrent; -APRThreadPool::APRThreadPool(int _size) : size(_size), factory(new APRThreadFactory()), - deleteFactory(true), running(false){ +APRThreadPool::APRThreadPool(int _size) : deleteFactory(true), size(_size), factory(new APRThreadFactory()), running(false){ worker = new Worker(this); } -APRThreadPool::APRThreadPool(int _size, ThreadFactory* _factory) : size(_size), factory(_factory), - deleteFactory(false), running(false){ +APRThreadPool::APRThreadPool(int _size, ThreadFactory* _factory) : deleteFactory(false), size(_size), factory(_factory), running(false){ worker = new Worker(this); } diff --git a/cpp/common/concurrent/src/Runnable.cpp b/cpp/common/concurrent/src/Runnable.cpp new file mode 100644 index 0000000000..cf9b8d586f --- /dev/null +++ b/cpp/common/concurrent/src/Runnable.cpp @@ -0,0 +1,19 @@ +/* + * 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 "Runnable.h" +qpid::concurrent::Runnable::~Runnable() {} diff --git a/cpp/common/framing/generated/stylesheets/amqp_client_handler_impl.xsl b/cpp/common/framing/generated/stylesheets/amqp_client_handler_impl.xsl index aa095eaf79..0cc34e0ecf 100644 --- a/cpp/common/framing/generated/stylesheets/amqp_client_handler_impl.xsl +++ b/cpp/common/framing/generated/stylesheets/amqp_client_handler_impl.xsl @@ -7,7 +7,7 @@ =============================== Template: client_handler_impl_h =============================== - Template to generate the AMQP_ServerHandlerImpl class header file. + Template to generate the AMQP_ClientHandlerImpl class header file. --> <xsl:template match="amqp" mode="client_handler_impl_h"> <xsl:param name="domain-cpp-table"/> @@ -122,7 +122,7 @@ class AMQP_ClientHandlerImpl : virtual public AMQP_ClientOperations ================================= Template: client_handler_impl_cpp ================================= - Template to generate the AMQP_ServerHandlerImpl class stubs. + Template to generate the AMQP_ClientHandlerImpl class stubs. --> <xsl:template match="amqp" mode="client_handler_impl_cpp"> <xsl:param name="domain-cpp-table"/> @@ -163,12 +163,12 @@ AMQP_ClientHandlerImpl::~AMQP_ClientHandlerImpl() <xsl:for-each select="method"> <xsl:if test="chassis[@name='client']"> <xsl:text>void AMQP_ClientHandlerImpl::</xsl:text><xsl:value-of select="$class"/><xsl:text>HandlerImpl::</xsl:text> - <xsl:value-of select="amqp:cpp-name(@name)"/><xsl:text>( u_int16_t channel</xsl:text> + <xsl:value-of select="amqp:cpp-name(@name)"/><xsl:text>( u_int16_t /*channel*/</xsl:text> <xsl:if test="field"> <xsl:text>,
 </xsl:text> <xsl:for-each select="field"> <xsl:variable name="domain-cpp-type" select="amqp:cpp-lookup(@domain, $domain-cpp-table)"/> - <xsl:value-of select="concat($domain-cpp-type, amqp:cpp-arg-ref($domain-cpp-type), ' ', amqp:cpp-name(@name))"/> + <xsl:value-of select="concat($domain-cpp-type, amqp:cpp-arg-ref($domain-cpp-type), ' /*', amqp:cpp-name(@name), '*/')"/> <xsl:if test="position()!=last()"> <xsl:text>,
 </xsl:text> </xsl:if> diff --git a/cpp/common/framing/generated/stylesheets/amqp_server_handler_impl.xsl b/cpp/common/framing/generated/stylesheets/amqp_server_handler_impl.xsl index de879a5670..6450d3fd0c 100644 --- a/cpp/common/framing/generated/stylesheets/amqp_server_handler_impl.xsl +++ b/cpp/common/framing/generated/stylesheets/amqp_server_handler_impl.xsl @@ -163,12 +163,12 @@ AMQP_ServerHandlerImpl::~AMQP_ServerHandlerImpl() <xsl:for-each select="method"> <xsl:if test="chassis[@name='server']"> <xsl:text>void AMQP_ServerHandlerImpl::</xsl:text><xsl:value-of select="$class"/><xsl:text>HandlerImpl::</xsl:text> - <xsl:value-of select="amqp:cpp-name(@name)"/><xsl:text>( u_int16_t channel</xsl:text> + <xsl:value-of select="amqp:cpp-name(@name)"/><xsl:text>( u_int16_t /*channel*/</xsl:text> <xsl:if test="field"> <xsl:text>,
 </xsl:text> <xsl:for-each select="field"> <xsl:variable name="domain-cpp-type" select="amqp:cpp-lookup(@domain, $domain-cpp-table)"/> - <xsl:value-of select="concat($domain-cpp-type, amqp:cpp-arg-ref($domain-cpp-type), ' ', amqp:cpp-name(@name))"/> + <xsl:value-of select="concat($domain-cpp-type, amqp:cpp-arg-ref($domain-cpp-type), ' /*', amqp:cpp-name(@name), '*/')"/> <xsl:if test="position()!=last()"> <xsl:text>,
 </xsl:text> </xsl:if> diff --git a/cpp/common/framing/generated/stylesheets/amqp_server_operations.xsl b/cpp/common/framing/generated/stylesheets/amqp_server_operations.xsl index b42242e8fe..4b97700f04 100644 --- a/cpp/common/framing/generated/stylesheets/amqp_server_operations.xsl +++ b/cpp/common/framing/generated/stylesheets/amqp_server_operations.xsl @@ -66,7 +66,7 @@ class AMQP_ServerOperations <xsl:value-of select="amqp:process-docs(doc)"/> <xsl:text>*/
</xsl:text> </xsl:if> - <xsl:for-each select="rule">/** + <xsl:for-each select="rule"> <xsl:text>
/**
</xsl:text> <xsl:text>Rule "</xsl:text><xsl:value-of select="@name"/><xsl:text>":
</xsl:text> <xsl:value-of select="amqp:process-docs(doc)"/> diff --git a/cpp/common/framing/generated/stylesheets/cpp.xsl b/cpp/common/framing/generated/stylesheets/cpp.xsl index ae66f65745..f9e5ba4141 100644 --- a/cpp/common/framing/generated/stylesheets/cpp.xsl +++ b/cpp/common/framing/generated/stylesheets/cpp.xsl @@ -122,7 +122,7 @@ public: } </xsl:if> - inline void encodeContent(Buffer& buffer) const + inline void encodeContent(Buffer& <xsl:if test="$f/field">buffer</xsl:if>) const { <xsl:if test="$f/field[@type='bit']"> u_int8_t flags = 0; @@ -140,11 +140,8 @@ public: </xsl:for-each> } - inline void decodeContent(Buffer& buffer) + inline void decodeContent(Buffer& <xsl:if test="$f/field">buffer</xsl:if>) { - <xsl:if test="$f/field[@type='bit']"> - u_int8_t maxbit = <xsl:value-of select="$f/@bit-field-count"/>; - </xsl:if> <xsl:for-each select="$f/field"> <xsl:choose> <xsl:when test="@type = 'bit' and @boolean-index = 1"> diff --git a/cpp/common/framing/inc/AMQHeaderBody.h b/cpp/common/framing/inc/AMQHeaderBody.h index e39fffa8ce..4f9cdb571a 100644 --- a/cpp/common/framing/inc/AMQHeaderBody.h +++ b/cpp/common/framing/inc/AMQHeaderBody.h @@ -42,7 +42,7 @@ public: HeaderProperties* getProperties(){ return properties; } const HeaderProperties* getProperties() const { return properties; } inline u_int64_t getContentSize() const { return contentSize; } - inline void setContentSize(u_int64_t size) { contentSize = size; } + inline void setContentSize(u_int64_t _size) { contentSize = _size; } virtual ~AMQHeaderBody(); virtual u_int32_t size() const; virtual void encode(Buffer& buffer) const; diff --git a/cpp/common/framing/inc/AMQHeartbeatBody.h b/cpp/common/framing/inc/AMQHeartbeatBody.h index cfe057bdcd..da612a2a44 100644 --- a/cpp/common/framing/inc/AMQHeartbeatBody.h +++ b/cpp/common/framing/inc/AMQHeartbeatBody.h @@ -33,8 +33,8 @@ public: virtual ~AMQHeartbeatBody(); inline u_int32_t size() const { return 0; } inline u_int8_t type() const { return HEARTBEAT_BODY; } - inline void encode(Buffer& buffer) const {} - inline void decode(Buffer& buffer, u_int32_t size) {} + inline void encode(Buffer& ) const {} + inline void decode(Buffer& , u_int32_t /*size*/) {} virtual void print(std::ostream& out) const; }; diff --git a/cpp/common/framing/inc/BasicHeaderProperties.h b/cpp/common/framing/inc/BasicHeaderProperties.h index 8688a37bf9..c32612221b 100644 --- a/cpp/common/framing/inc/BasicHeaderProperties.h +++ b/cpp/common/framing/inc/BasicHeaderProperties.h @@ -70,20 +70,20 @@ namespace framing { inline string& getAppId(){ return appId; } inline string& getClusterId(){ return clusterId; } - void inline setContentType(string& type){ contentType = type; } + void inline setContentType(string& _type){ contentType = _type; } void inline setContentEncoding(string& encoding){ contentEncoding = encoding; } - void inline setHeaders(FieldTable& headers){ this->headers = headers; } + void inline setHeaders(FieldTable& _headers){ headers = _headers; } void inline setDeliveryMode(u_int8_t mode){ deliveryMode = mode; } - void inline setPriority(u_int8_t priority){ this->priority = priority; } - void inline setCorrelationId(string& correlationId){ this->correlationId = correlationId; } - void inline setReplyTo(string& replyTo){ this->replyTo = replyTo;} - void inline setExpiration(string& expiration){ this->expiration = expiration; } - void inline setMessageId(string& messageId){ this->messageId = messageId; } - void inline setTimestamp(u_int64_t timestamp){ this->timestamp = timestamp; } - void inline setType(string& type){ this->type = type; } - void inline setUserId(string& userId){ this->userId = userId; } - void inline setAppId(string& appId){this->appId = appId; } - void inline setClusterId(string& clusterId){ this->clusterId = clusterId; } + void inline setPriority(u_int8_t _priority){ priority = _priority; } + void inline setCorrelationId(string& _correlationId){ correlationId = _correlationId; } + void inline setReplyTo(string& _replyTo){ replyTo = _replyTo;} + void inline setExpiration(string& _expiration){ expiration = _expiration; } + void inline setMessageId(string& _messageId){ messageId = _messageId; } + void inline setTimestamp(u_int64_t _timestamp){ timestamp = _timestamp; } + void inline setType(string& _type){ type = _type; } + void inline setUserId(string& _userId){ userId = _userId; } + void inline setAppId(string& _appId){appId = _appId; } + void inline setClusterId(string& _clusterId){ clusterId = _clusterId; } }; } diff --git a/cpp/common/framing/inc/BodyHandler.h b/cpp/common/framing/inc/BodyHandler.h index f92ae66804..a4aee2709e 100644 --- a/cpp/common/framing/inc/BodyHandler.h +++ b/cpp/common/framing/inc/BodyHandler.h @@ -30,6 +30,7 @@ namespace framing { class BodyHandler{ public: + virtual ~BodyHandler(); virtual void handleMethod(AMQMethodBody::shared_ptr body) = 0; virtual void handleHeader(AMQHeaderBody::shared_ptr body) = 0; virtual void handleContent(AMQContentBody::shared_ptr body) = 0; diff --git a/cpp/common/framing/inc/Buffer.h b/cpp/common/framing/inc/Buffer.h index e0532cc9d6..4d3d503b00 100644 --- a/cpp/common/framing/inc/Buffer.h +++ b/cpp/common/framing/inc/Buffer.h @@ -27,16 +27,16 @@ class FieldTable; class Buffer { - const int size; + const u_int32_t size; char* data; - int position; - int limit; - int r_position; - int r_limit; + u_int32_t position; + u_int32_t limit; + u_int32_t r_position; + u_int32_t r_limit; public: - Buffer(int size); + Buffer(u_int32_t size); ~Buffer(); void flip(); @@ -44,9 +44,9 @@ public: void compact(); void record(); void restore(); - int available(); + u_int32_t available(); char* start(); - void move(int bytes); + void move(u_int32_t bytes); void putOctet(u_int8_t i); void putShort(u_int16_t i); diff --git a/cpp/common/framing/inc/InitiationHandler.h b/cpp/common/framing/inc/InitiationHandler.h index 2e8d1e652b..7b1fb36e2d 100644 --- a/cpp/common/framing/inc/InitiationHandler.h +++ b/cpp/common/framing/inc/InitiationHandler.h @@ -27,6 +27,7 @@ namespace framing { class InitiationHandler{ public: + virtual ~InitiationHandler(); virtual void initiated(ProtocolInitiation* header) = 0; }; diff --git a/cpp/common/framing/inc/InputHandler.h b/cpp/common/framing/inc/InputHandler.h index 2722cae0ed..927bd97ab4 100644 --- a/cpp/common/framing/inc/InputHandler.h +++ b/cpp/common/framing/inc/InputHandler.h @@ -27,6 +27,7 @@ namespace framing { class InputHandler{ public: + virtual ~InputHandler(); virtual void received(AMQFrame* frame) = 0; }; diff --git a/cpp/common/framing/inc/OutputHandler.h b/cpp/common/framing/inc/OutputHandler.h index 7fe63660c3..afc8d7f257 100644 --- a/cpp/common/framing/inc/OutputHandler.h +++ b/cpp/common/framing/inc/OutputHandler.h @@ -27,6 +27,7 @@ namespace framing { class OutputHandler{ public: + virtual ~OutputHandler(); virtual void send(AMQFrame* frame) = 0; }; diff --git a/cpp/common/framing/inc/Value.h b/cpp/common/framing/inc/Value.h index 3d525a0bef..fe939e8758 100644 --- a/cpp/common/framing/inc/Value.h +++ b/cpp/common/framing/inc/Value.h @@ -147,8 +147,8 @@ class EmptyValue : public Value { ~EmptyValue(); virtual u_int32_t size() const { return 0; } virtual char getType() const { return 0; } - virtual void encode(Buffer& buffer) {} - virtual void decode(Buffer& buffer) {} + virtual void encode(Buffer& ) {} + virtual void decode(Buffer& ) {} virtual bool operator==(const Value& v) const { return dynamic_cast<const EmptyValue*>(&v); } diff --git a/cpp/common/framing/src/AMQContentBody.cpp b/cpp/common/framing/src/AMQContentBody.cpp index 6bc588c3ab..1be8867d53 100644 --- a/cpp/common/framing/src/AMQContentBody.cpp +++ b/cpp/common/framing/src/AMQContentBody.cpp @@ -30,8 +30,8 @@ u_int32_t qpid::framing::AMQContentBody::size() const{ void qpid::framing::AMQContentBody::encode(Buffer& buffer) const{ buffer.putRawData(data); } -void qpid::framing::AMQContentBody::decode(Buffer& buffer, u_int32_t size){ - buffer.getRawData(data, size); +void qpid::framing::AMQContentBody::decode(Buffer& buffer, u_int32_t _size){ + buffer.getRawData(data, _size); } void qpid::framing::AMQContentBody::print(std::ostream& out) const diff --git a/cpp/common/framing/src/AMQFrame.cpp b/cpp/common/framing/src/AMQFrame.cpp index 5686c9ac81..487ab1a443 100644 --- a/cpp/common/framing/src/AMQFrame.cpp +++ b/cpp/common/framing/src/AMQFrame.cpp @@ -63,33 +63,13 @@ bool AMQFrame::decode(Buffer& buffer) { if(buffer.available() < 7) return false; buffer.record(); - u_int8_t type = buffer.getOctet(); - channel = buffer.getShort(); - u_int32_t size = buffer.getLong(); - if(buffer.available() < size + 1){ + u_int32_t bufSize = decodeHead(buffer); + + if(buffer.available() < bufSize + 1){ buffer.restore(); return false; } - switch(type) - { - case METHOD_BODY: - body = createMethodBody(buffer); - break; - case HEADER_BODY: - body = AMQBody::shared_ptr(new AMQHeaderBody()); - break; - case CONTENT_BODY: - body = AMQBody::shared_ptr(new AMQContentBody()); - break; - case HEARTBEAT_BODY: - body = AMQBody::shared_ptr(new AMQHeartbeatBody()); - break; - default: - string msg("Unknown body type: "); - msg += type; - THROW_QPID_ERROR(FRAMING_ERROR, msg); - } - body->decode(buffer, size); + decodeBody(buffer, bufSize); u_int8_t end = buffer.getOctet(); if(end != 0xCE) THROW_QPID_ERROR(FRAMING_ERROR, "Frame end not found"); return true; @@ -101,7 +81,7 @@ u_int32_t AMQFrame::decodeHead(Buffer& buffer){ return buffer.getLong(); } -void AMQFrame::decodeBody(Buffer& buffer, uint32_t size) +void AMQFrame::decodeBody(Buffer& buffer, uint32_t bufSize) { switch(type) { @@ -122,7 +102,7 @@ void AMQFrame::decodeBody(Buffer& buffer, uint32_t size) msg += type; THROW_QPID_ERROR(FRAMING_ERROR, msg); } - body->decode(buffer, size); + body->decode(buffer, bufSize); } std::ostream& qpid::framing::operator<<(std::ostream& out, const AMQFrame& t){ diff --git a/cpp/common/framing/src/AMQHeaderBody.cpp b/cpp/common/framing/src/AMQHeaderBody.cpp index 1fd387c5d5..dce5f1fd54 100644 --- a/cpp/common/framing/src/AMQHeaderBody.cpp +++ b/cpp/common/framing/src/AMQHeaderBody.cpp @@ -41,12 +41,12 @@ void qpid::framing::AMQHeaderBody::encode(Buffer& buffer) const { properties->encode(buffer); } -void qpid::framing::AMQHeaderBody::decode(Buffer& buffer, u_int32_t size){ +void qpid::framing::AMQHeaderBody::decode(Buffer& buffer, u_int32_t bufSize){ u_int16_t classId = buffer.getShort(); weight = buffer.getShort(); contentSize = buffer.getLongLong(); createProperties(classId); - properties->decode(buffer, size - 12); + properties->decode(buffer, bufSize - 12); } void qpid::framing::AMQHeaderBody::createProperties(int classId){ diff --git a/cpp/common/framing/src/AMQMethodBody.cpp b/cpp/common/framing/src/AMQMethodBody.cpp index 73862bb2bf..7455050377 100644 --- a/cpp/common/framing/src/AMQMethodBody.cpp +++ b/cpp/common/framing/src/AMQMethodBody.cpp @@ -24,7 +24,7 @@ void qpid::framing::AMQMethodBody::encode(Buffer& buffer) const{ encodeContent(buffer); } -void qpid::framing::AMQMethodBody::decode(Buffer& buffer, u_int32_t size){ +void qpid::framing::AMQMethodBody::decode(Buffer& buffer, u_int32_t /*size*/){ decodeContent(buffer); } @@ -32,7 +32,7 @@ bool qpid::framing::AMQMethodBody::match(AMQMethodBody* other) const{ return other != 0 && other->amqpClassId() == amqpClassId() && other->amqpMethodId() == amqpMethodId(); } -void qpid::framing::AMQMethodBody::invoke(AMQP_ServerOperations& target, u_int16_t channel){ +void qpid::framing::AMQMethodBody::invoke(AMQP_ServerOperations& /*target*/, u_int16_t /*channel*/){ THROW_QPID_ERROR(PROTOCOL_ERROR, "Method not supported by AMQP Server."); } diff --git a/cpp/common/framing/src/BasicHeaderProperties.cpp b/cpp/common/framing/src/BasicHeaderProperties.cpp index 4219d33a8f..c9153665d5 100644 --- a/cpp/common/framing/src/BasicHeaderProperties.cpp +++ b/cpp/common/framing/src/BasicHeaderProperties.cpp @@ -23,23 +23,23 @@ qpid::framing::BasicHeaderProperties::BasicHeaderProperties() : deliveryMode(0), qpid::framing::BasicHeaderProperties::~BasicHeaderProperties(){} u_int32_t qpid::framing::BasicHeaderProperties::size() const{ - u_int32_t size = 2;//flags - if(contentType.length() > 0) size += contentType.length() + 1; - if(contentEncoding.length() > 0) size += contentEncoding.length() + 1; - if(headers.count() > 0) size += headers.size(); - if(deliveryMode != 0) size += 1; - if(priority != 0) size += 1; - if(correlationId.length() > 0) size += correlationId.length() + 1; - if(replyTo.length() > 0) size += replyTo.length() + 1; - if(expiration.length() > 0) size += expiration.length() + 1; - if(messageId.length() > 0) size += messageId.length() + 1; - if(timestamp != 0) size += 8; - if(type.length() > 0) size += type.length() + 1; - if(userId.length() > 0) size += userId.length() + 1; - if(appId.length() > 0) size += appId.length() + 1; - if(clusterId.length() > 0) size += clusterId.length() + 1; + u_int32_t bytes = 2;//flags + if(contentType.length() > 0) bytes += contentType.length() + 1; + if(contentEncoding.length() > 0) bytes += contentEncoding.length() + 1; + if(headers.count() > 0) bytes += headers.size(); + if(deliveryMode != 0) bytes += 1; + if(priority != 0) bytes += 1; + if(correlationId.length() > 0) bytes += correlationId.length() + 1; + if(replyTo.length() > 0) bytes += replyTo.length() + 1; + if(expiration.length() > 0) bytes += expiration.length() + 1; + if(messageId.length() > 0) bytes += messageId.length() + 1; + if(timestamp != 0) bytes += 8; + if(type.length() > 0) bytes += type.length() + 1; + if(userId.length() > 0) bytes += userId.length() + 1; + if(appId.length() > 0) bytes += appId.length() + 1; + if(clusterId.length() > 0) bytes += clusterId.length() + 1; - return size; + return bytes; } void qpid::framing::BasicHeaderProperties::encode(qpid::framing::Buffer& buffer) const{ @@ -62,9 +62,8 @@ void qpid::framing::BasicHeaderProperties::encode(qpid::framing::Buffer& buffer) if(clusterId.length() > 0) buffer.putShortString(clusterId); } -void qpid::framing::BasicHeaderProperties::decode(qpid::framing::Buffer& buffer, u_int32_t size){ +void qpid::framing::BasicHeaderProperties::decode(qpid::framing::Buffer& buffer, u_int32_t /*size*/){ u_int16_t flags = buffer.getShort(); - int shift = 15; if(flags & (1 << 15)) buffer.getShortString(contentType); if(flags & (1 << 14)) buffer.getShortString(contentEncoding); if(flags & (1 << 13)) buffer.getFieldTable(headers); @@ -83,7 +82,6 @@ void qpid::framing::BasicHeaderProperties::decode(qpid::framing::Buffer& buffer, u_int16_t qpid::framing::BasicHeaderProperties::getFlags() const{ u_int16_t flags(0); - int shift = 15; if(contentType.length() > 0) flags |= (1 << 15); if(contentEncoding.length() > 0) flags |= (1 << 14); if(headers.count() > 0) flags |= (1 << 13); diff --git a/cpp/common/framing/src/BodyHandler.cpp b/cpp/common/framing/src/BodyHandler.cpp index 4e4e2e02f7..b428c62637 100644 --- a/cpp/common/framing/src/BodyHandler.cpp +++ b/cpp/common/framing/src/BodyHandler.cpp @@ -21,6 +21,8 @@ using namespace qpid::framing; using namespace std::tr1; +BodyHandler::~BodyHandler() {} + void BodyHandler::handleBody(AMQBody::shared_ptr& body){ switch(body->type()) diff --git a/cpp/common/framing/src/Buffer.cpp b/cpp/common/framing/src/Buffer.cpp index 15a4485abd..87aa1df7e9 100644 --- a/cpp/common/framing/src/Buffer.cpp +++ b/cpp/common/framing/src/Buffer.cpp @@ -18,7 +18,7 @@ #include "Buffer.h" #include "FieldTable.h" -qpid::framing::Buffer::Buffer(int _size) : size(_size), position(0), limit(_size){ +qpid::framing::Buffer::Buffer(u_int32_t _size) : size(_size), position(0), limit(_size){ data = new char[size]; } @@ -37,7 +37,7 @@ void qpid::framing::Buffer::clear(){ } void qpid::framing::Buffer::compact(){ - int p = limit - position; + u_int32_t p = limit - position; //copy p chars from position to 0 memmove(data, data + position, p); limit = size; @@ -54,7 +54,7 @@ void qpid::framing::Buffer::restore(){ limit = r_limit; } -int qpid::framing::Buffer::available(){ +u_int32_t qpid::framing::Buffer::available(){ return limit - position; } @@ -62,7 +62,7 @@ char* qpid::framing::Buffer::start(){ return data + position; } -void qpid::framing::Buffer::move(int bytes){ +void qpid::framing::Buffer::move(u_int32_t bytes){ position += bytes; } @@ -123,29 +123,29 @@ u_int64_t qpid::framing::Buffer::getLongLong(){ void qpid::framing::Buffer::putShortString(const string& s){ - u_int8_t size = s.length(); - putOctet(size); - s.copy(data + position, size); - position += size; + u_int8_t len = s.length(); + putOctet(len); + s.copy(data + position, len); + position += len; } void qpid::framing::Buffer::putLongString(const string& s){ - u_int32_t size = s.length(); - putLong(size); - s.copy(data + position, size); - position += size; + u_int32_t len = s.length(); + putLong(len); + s.copy(data + position, len); + position += len; } void qpid::framing::Buffer::getShortString(string& s){ - u_int8_t size = getOctet(); - s.assign(data + position, size); - position += size; + u_int8_t len = getOctet(); + s.assign(data + position, len); + position += len; } void qpid::framing::Buffer::getLongString(string& s){ - u_int32_t size = getLong(); - s.assign(data + position, size); - position += size; + u_int32_t len = getLong(); + s.assign(data + position, len); + position += len; } void qpid::framing::Buffer::putFieldTable(const FieldTable& t){ @@ -157,12 +157,12 @@ void qpid::framing::Buffer::getFieldTable(FieldTable& t){ } void qpid::framing::Buffer::putRawData(const string& s){ - u_int32_t size = s.length(); - s.copy(data + position, size); - position += size; + u_int32_t len = s.length(); + s.copy(data + position, len); + position += len; } -void qpid::framing::Buffer::getRawData(string& s, u_int32_t size){ - s.assign(data + position, size); - position += size; +void qpid::framing::Buffer::getRawData(string& s, u_int32_t len){ + s.assign(data + position, len); + position += len; } diff --git a/cpp/common/framing/src/FieldTable.cpp b/cpp/common/framing/src/FieldTable.cpp index b12b2783df..088c8fb500 100644 --- a/cpp/common/framing/src/FieldTable.cpp +++ b/cpp/common/framing/src/FieldTable.cpp @@ -27,12 +27,12 @@ namespace framing { FieldTable::~FieldTable() {} u_int32_t FieldTable::size() const { - u_int32_t size(4); + u_int32_t len(4); for(ValueMap::const_iterator i = values.begin(); i != values.end(); ++i) { // 2 = shortstr_len_byyte + type_char_byte - size += 2 + (i->first).size() + (i->second)->size(); + len += 2 + (i->first).size() + (i->second)->size(); } - return size; + return len; } int FieldTable::count() const { @@ -74,9 +74,6 @@ void FieldTable::setTable(const std::string& name, const FieldTable& value){ } namespace { -// TODO aconway 2006-09-26: This is messy. Revisit the field table -// and Value classes with a traits-based approach. -// template <class T> T default_value() { return T(); } template <> int default_value<int>() { return 0; } template <> u_int64_t default_value<u_int64_t>() { return 0; } @@ -117,9 +114,11 @@ void FieldTable::encode(Buffer& buffer) const{ } void FieldTable::decode(Buffer& buffer){ - u_int32_t size = buffer.getLong(); - int leftover = buffer.available() - size; - + u_int32_t len = buffer.getLong(); + u_int32_t available = buffer.available(); + if (available < len) + THROW_QPID_ERROR(FRAMING_ERROR, "Not enough data for field table."); + u_int32_t leftover = available - len; while(buffer.available() > leftover){ std::string name; buffer.getShortString(name); diff --git a/cpp/common/framing/src/InitiationHandler.cpp b/cpp/common/framing/src/InitiationHandler.cpp new file mode 100644 index 0000000000..9c18facf44 --- /dev/null +++ b/cpp/common/framing/src/InitiationHandler.cpp @@ -0,0 +1,21 @@ +/* + * + * 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 "InitiationHandler.h" + +qpid::framing::InitiationHandler::~InitiationHandler() {} diff --git a/cpp/common/framing/src/InputHandler.cpp b/cpp/common/framing/src/InputHandler.cpp new file mode 100644 index 0000000000..7116caa24a --- /dev/null +++ b/cpp/common/framing/src/InputHandler.cpp @@ -0,0 +1,21 @@ +/* + * + * 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 "InputHandler.h" + +qpid::framing::InputHandler::~InputHandler() {} diff --git a/cpp/common/framing/src/OutputHandler.cpp b/cpp/common/framing/src/OutputHandler.cpp new file mode 100644 index 0000000000..8d99b4ef92 --- /dev/null +++ b/cpp/common/framing/src/OutputHandler.cpp @@ -0,0 +1,21 @@ +/* + * + * 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 "OutputHandler.h" + +qpid::framing::OutputHandler::~OutputHandler() {} diff --git a/cpp/common/framing/test/BodyHandlerTest.cpp b/cpp/common/framing/test/BodyHandlerTest.cpp index 94038d9a6c..1cad6afe02 100644 --- a/cpp/common/framing/test/BodyHandlerTest.cpp +++ b/cpp/common/framing/test/BodyHandlerTest.cpp @@ -17,11 +17,7 @@ */ #include <iostream> #include "amqp_framing.h" -#include <cppunit/TestCase.h> -#include <cppunit/TextTestRunner.h> -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/plugin/TestPlugIn.h> - +#include "qpid_test_plugin.h" using namespace qpid::framing; class BodyHandlerTest : public CppUnit::TestCase diff --git a/cpp/common/framing/test/field_table_test.cpp b/cpp/common/framing/test/field_table_test.cpp index 48332e05bc..535f7f4a08 100644 --- a/cpp/common/framing/test/field_table_test.cpp +++ b/cpp/common/framing/test/field_table_test.cpp @@ -17,10 +17,7 @@ */ #include <iostream> #include "amqp_framing.h" -#include <cppunit/TestCase.h> -#include <cppunit/TextTestRunner.h> -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/plugin/TestPlugIn.h> +#include <qpid_test_plugin.h> using namespace qpid::framing; diff --git a/cpp/common/framing/test/framing_test.cpp b/cpp/common/framing/test/framing_test.cpp index 1978c2cbed..8c69f8718a 100644 --- a/cpp/common/framing/test/framing_test.cpp +++ b/cpp/common/framing/test/framing_test.cpp @@ -19,10 +19,7 @@ #include "ConnectionRedirectBody.h" #include <iostream> #include <sstream> -#include <cppunit/TestCase.h> -#include <cppunit/TextTestRunner.h> -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/plugin/TestPlugIn.h> +#include <qpid_test_plugin.h> #include <typeinfo> using namespace qpid::framing; diff --git a/cpp/common/framing/test/header_test.cpp b/cpp/common/framing/test/header_test.cpp index 0ff6d47d57..f98dd5d108 100644 --- a/cpp/common/framing/test/header_test.cpp +++ b/cpp/common/framing/test/header_test.cpp @@ -17,10 +17,7 @@ */ #include <iostream> #include "amqp_framing.h" -#include <cppunit/TestCase.h> -#include <cppunit/TextTestRunner.h> -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/plugin/TestPlugIn.h> +#include <qpid_test_plugin.h> using namespace qpid::framing; diff --git a/cpp/common/io/Makefile b/cpp/common/io/Makefile index e94e802afa..617b91448a 100644 --- a/cpp/common/io/Makefile +++ b/cpp/common/io/Makefile @@ -16,10 +16,6 @@ QPID_HOME = ../../.. include ${QPID_HOME}/cpp/options.mk - -# Compiler flags -CXXFLAGS = ${DEBUG} ${OPT} -MMD -I inc -I ../concurrent/inc -I ../error/inc -I ../framing/inc -I ../framing/generated -I ${APR_HOME}/include/apr-1/ - SOURCES := $(wildcard src/*.cpp) OBJECTS := $(subst .cpp,.o,$(SOURCES)) DEPS := $(subst .cpp,.d,$(SOURCES)) diff --git a/cpp/common/io/inc/APRConnector.h b/cpp/common/io/inc/APRConnector.h index c292c4d7e0..c6ed887f78 100644 --- a/cpp/common/io/inc/APRConnector.h +++ b/cpp/common/io/inc/APRConnector.h @@ -68,7 +68,7 @@ namespace io { void checkIdle(apr_status_t status); void writeBlock(qpid::framing::AMQDataBlock* data); - void writeToSocket(char* data, int available); + void writeToSocket(char* data, size_t available); void setSocketTimeout(); void run(); diff --git a/cpp/common/io/inc/ConnectorImpl.h b/cpp/common/io/inc/ConnectorImpl.h index 242f3aed49..1abb72f32a 100644 --- a/cpp/common/io/inc/ConnectorImpl.h +++ b/cpp/common/io/inc/ConnectorImpl.h @@ -32,7 +32,7 @@ namespace io { { public: - ConnectorImpl(bool debug = false, u_int32_t buffer_size = 1024):APRConnector(debug,buffer_size){}; + ConnectorImpl(bool _debug = false, u_int32_t buffer_size = 1024):APRConnector(_debug,buffer_size){}; virtual ~ConnectorImpl(){}; }; #else @@ -40,7 +40,7 @@ namespace io { { public: - ConnectorImpl(bool debug = false, u_int32_t buffer_size = 1024):LConnector(debug, buffer_size){}; + ConnectorImpl(bool _debug = false, u_int32_t buffer_size = 1024):LConnector(_debug, buffer_size){}; virtual ~ConnectorImpl(){}; }; diff --git a/cpp/common/io/inc/LFProcessor.h b/cpp/common/io/inc/LFProcessor.h index 8cfbd237a3..6e67268906 100644 --- a/cpp/common/io/inc/LFProcessor.h +++ b/cpp/common/io/inc/LFProcessor.h @@ -48,12 +48,12 @@ namespace io { const apr_pollfd_t* signalledFDs; int count; const int workerCount; + bool hasLeader; qpid::concurrent::Thread** const workers; qpid::concurrent::APRMonitor leadLock; qpid::concurrent::APRMonitor countLock; qpid::concurrent::APRThreadFactory factory; std::vector<LFSessionContext*> sessions; - bool hasLeader; volatile bool stopped; const apr_pollfd_t* getNextEvent(); diff --git a/cpp/common/io/src/APRConnector.cpp b/cpp/common/io/src/APRConnector.cpp index 0e022a8c73..5f3bfd6957 100644 --- a/cpp/common/io/src/APRConnector.cpp +++ b/cpp/common/io/src/APRConnector.cpp @@ -26,15 +26,18 @@ using namespace qpid::concurrent; using namespace qpid::framing; using qpid::QpidError; -APRConnector::APRConnector(bool _debug, u_int32_t buffer_size) : closed(true), debug(_debug), - idleIn(0), idleOut(0), timeout(0), - timeoutHandler(0), - shutdownHandler(0), - lastIn(0), lastOut(0), - receive_buffer_size(buffer_size), - send_buffer_size(buffer_size), - inbuf(receive_buffer_size), - outbuf(send_buffer_size){ +APRConnector::APRConnector(bool _debug, u_int32_t buffer_size) : + debug(_debug), + receive_buffer_size(buffer_size), + send_buffer_size(buffer_size), + closed(true), + lastIn(0), lastOut(0), + timeout(0), + idleIn(0), idleOut(0), + timeoutHandler(0), + shutdownHandler(0), + inbuf(receive_buffer_size), + outbuf(send_buffer_size){ APRBase::increment(); @@ -104,7 +107,7 @@ void APRConnector::writeBlock(AMQDataBlock* data){ writeLock->release(); } -void APRConnector::writeToSocket(char* data, int available){ +void APRConnector::writeToSocket(char* data, size_t available){ apr_size_t bytes(available); apr_size_t written(0); while(written < available && !closed){ diff --git a/cpp/common/io/src/APRSocket.cpp b/cpp/common/io/src/APRSocket.cpp index 32861ea442..1ef7e270a3 100644 --- a/cpp/common/io/src/APRSocket.cpp +++ b/cpp/common/io/src/APRSocket.cpp @@ -17,7 +17,7 @@ */ #include "APRBase.h" #include "APRSocket.h" - +#include <assert.h> #include <iostream> using namespace qpid::io; @@ -45,6 +45,8 @@ void APRSocket::write(qpid::framing::Buffer& buffer){ do{ bytes = buffer.available(); apr_status_t s = apr_socket_send(socket, buffer.start(), &bytes); + // TODO aconway 2006-10-05: better error handling + assert(s == 0); buffer.move(bytes); }while(bytes > 0); } diff --git a/cpp/common/io/src/BlockingAPRAcceptor.cpp b/cpp/common/io/src/BlockingAPRAcceptor.cpp index 380318bcfa..bf74260a55 100644 --- a/cpp/common/io/src/BlockingAPRAcceptor.cpp +++ b/cpp/common/io/src/BlockingAPRAcceptor.cpp @@ -24,10 +24,11 @@ using namespace qpid::concurrent; using namespace qpid::framing; using namespace qpid::io; -BlockingAPRAcceptor::BlockingAPRAcceptor(bool _debug, int c) : connectionBacklog(c), - threadFactory(new APRThreadFactory()), - debug(_debug){ - +BlockingAPRAcceptor::BlockingAPRAcceptor(bool _debug, int c) : + debug(_debug), + threadFactory(new APRThreadFactory()), + connectionBacklog(c) +{ APRBase::increment(); CHECK_APR_SUCCESS(apr_pool_create(&apr_pool, NULL)); } diff --git a/cpp/common/io/src/BlockingAPRSessionContext.cpp b/cpp/common/io/src/BlockingAPRSessionContext.cpp index 99352c90d5..6d1dc3470c 100644 --- a/cpp/common/io/src/BlockingAPRSessionContext.cpp +++ b/cpp/common/io/src/BlockingAPRSessionContext.cpp @@ -15,6 +15,7 @@ * limitations under the License. * */ +#include <assert.h> #include <iostream> #include "BlockingAPRSessionContext.h" #include "BlockingAPRAcceptor.h" @@ -32,10 +33,10 @@ BlockingAPRSessionContext::BlockingAPRSessionContext(apr_socket_t* _socket, bool _debug) : socket(_socket), debug(_debug), - inbuf(65536), - outbuf(65536), handler(0), acceptor(_acceptor), + inbuf(65536), + outbuf(65536), closed(false){ reader = new Reader(this); @@ -73,9 +74,9 @@ void BlockingAPRSessionContext::read(){ inbuf.flip(); if(!initiated){ - ProtocolInitiation* init = new ProtocolInitiation(); - if(init->decode(inbuf)){ - handler->initiated(init); + ProtocolInitiation* protocolInit = new ProtocolInitiation(); + if(protocolInit->decode(inbuf)){ + handler->initiated(protocolInit); if(debug) std::cout << "RECV: [" << &socket << "]: Initialised " << std::endl; initiated = true; } @@ -122,6 +123,7 @@ void BlockingAPRSessionContext::write(){ apr_size_t bytes = available; while(available > written){ apr_status_t s = apr_socket_send(socket, data + written, &bytes); + assert(s == 0); // TODO aconway 2006-10-05: Error Handling. written += bytes; bytes = available - written; } @@ -146,9 +148,8 @@ void BlockingAPRSessionContext::send(AMQFrame* frame){ } } -void BlockingAPRSessionContext::init(SessionHandler* handler){ - this->handler = handler; - //start the threads +void BlockingAPRSessionContext::init(SessionHandler* _handler){ + handler = _handler; rThread->start(); wThread->start(); } diff --git a/cpp/common/io/src/LFAcceptor.cpp b/cpp/common/io/src/LFAcceptor.cpp index 6653e926db..bb5164f457 100644 --- a/cpp/common/io/src/LFAcceptor.cpp +++ b/cpp/common/io/src/LFAcceptor.cpp @@ -21,12 +21,12 @@ using namespace qpid::concurrent; using namespace qpid::io; -LFAcceptor::LFAcceptor(bool _debug, int c, int worker_threads, int m) : processor(aprPool.pool, worker_threads, 1000, 5000000), - connectionBacklog(c), - max_connections_per_processor(m), - debug(_debug){ - -} +LFAcceptor::LFAcceptor(bool _debug, int c, int worker_threads, int m) : + processor(aprPool.pool, worker_threads, 1000, 5000000), + max_connections_per_processor(m), + debug(_debug), + connectionBacklog(c) +{ } void LFAcceptor::bind(int port, SessionHandlerFactory* factory){ diff --git a/cpp/common/io/src/LFProcessor.cpp b/cpp/common/io/src/LFProcessor.cpp index 8ef3543b8f..3ac66576e3 100644 --- a/cpp/common/io/src/LFProcessor.cpp +++ b/cpp/common/io/src/LFProcessor.cpp @@ -25,15 +25,17 @@ using namespace qpid::io; using namespace qpid::concurrent; using qpid::QpidError; -LFProcessor::LFProcessor(apr_pool_t* pool, int _workers, int _size, int _timeout) : size(_size), - timeout(_timeout), - signalledCount(0), - current(0), - count(0), - hasLeader(false), - workerCount(_workers), - workers(new Thread*[_workers]), - stopped(false){ +LFProcessor::LFProcessor(apr_pool_t* pool, int _workers, int _size, int _timeout) : + size(_size), + timeout(_timeout), + signalledCount(0), + current(0), + count(0), + workerCount(_workers), + hasLeader(false), + workers(new Thread*[_workers]), + stopped(false) +{ CHECK_APR_SUCCESS(apr_pollset_create(&pollset, size, pool, APR_POLLSET_THREADSAFE)); //create & start the required number of threads @@ -87,17 +89,13 @@ void LFProcessor::update(const apr_pollfd_t* const fd){ } bool LFProcessor::full(){ - countLock.acquire(); - bool full = count == size; - countLock.release(); - return full; + Locker locker(countLock); + return count == size; } bool LFProcessor::empty(){ - countLock.acquire(); - bool empty = count == 0; - countLock.release(); - return empty; + Locker locker(countLock); + return count == 0; } void LFProcessor::poll(){ diff --git a/cpp/common/io/src/LFSessionContext.cpp b/cpp/common/io/src/LFSessionContext.cpp index d786cb5e98..7b8208f704 100644 --- a/cpp/common/io/src/LFSessionContext.cpp +++ b/cpp/common/io/src/LFSessionContext.cpp @@ -26,17 +26,19 @@ using namespace qpid::framing; LFSessionContext::LFSessionContext(apr_pool_t* _pool, apr_socket_t* _socket, LFProcessor* const _processor, - bool _debug) : socket(_socket), - processor(_processor), - initiated(false), - processing(false), - closing(false), - in(32768), - out(32768), - reading(0), - writing(0), - debug(_debug){ - + bool _debug) : + debug(_debug), + socket(_socket), + initiated(false), + in(32768), + out(32768), + processor(_processor), + processing(false), + closing(false), + reading(0), + writing(0) +{ + fd.p = _pool; fd.desc_type = APR_POLL_SOCKET; fd.reqevents = APR_POLLIN; @@ -63,9 +65,9 @@ void LFSessionContext::read(){ handler->received(&frame); } }else{ - ProtocolInitiation init; - if(init.decode(in)){ - handler->initiated(&init); + ProtocolInitiation protocolInit; + if(protocolInit.decode(in)){ + handler->initiated(&protocolInit); initiated = true; if(debug) std::cout << "INIT [" << &socket << "]" << std::endl; } @@ -173,8 +175,8 @@ void LFSessionContext::shutdown(){ handleClose(); } -void LFSessionContext::init(SessionHandler* handler){ - this->handler = handler; +void LFSessionContext::init(SessionHandler* _handler){ + handler = _handler; processor->add(&fd); } diff --git a/cpp/common/utils/inc/logger.h b/cpp/common/utils/inc/logger.h deleted file mode 100644 index 8a57854476..0000000000 --- a/cpp/common/utils/inc/logger.h +++ /dev/null @@ -1,82 +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. - * - */ -/********************************************************************* -* -* NOTE: This is a lightweight logging class intended for debugging and -* verification purposes only. -* -* DO NOT USE FOR PRODUCT DEVELOPMENT - Rather, use an agreed upon -* established logging class (such as Apache's log4cxx) for product -* development purposes. -* -*********************************************************************/ - -#ifndef __LOGGER__ -#define __LOGGER__ - -#include <fstream> -#include <iostream> - -namespace qpid { -namespace utils { - -class Logger : public std::ofstream -{ - private: - bool echo_flag; - bool timestamp_flag; - bool eol_flag; - char buff[128]; // Buffer for writing formatted strings - - void write_timestamp(); - - public: - Logger(const char* filename, const bool append); - Logger(std::string& filename, const bool append); - ~Logger(); - - bool getEchoFlag() {return echo_flag;} - bool setEchoFlag(const bool _echo_flag) {echo_flag = _echo_flag;} - bool getTimestampFlag() {return timestamp_flag;} - bool setTimestampFlag(const bool _timestamp_flag) {timestamp_flag = _timestamp_flag;} - - void log(const char* message); - void log(const char* message, const bool echo); - void log(const char* message, const bool echo, const bool timestamp); - - Logger& operator<< (bool b); - Logger& operator<< (const short s); - Logger& operator<< (const unsigned short us); - Logger& operator<< (const int i); - Logger& operator<< (const unsigned int ui); - Logger& operator<< (const long l); - Logger& operator<< (const unsigned long ul); - Logger& operator<< (const long long l); - Logger& operator<< (const unsigned long long ul); - Logger& operator<< (const float f); - Logger& operator<< (const double d); - Logger& operator<< (const long double ld); - Logger& operator<< (const char* cstr); - Logger& operator<< (const std::string& str); -}; - -} -} - - -#endif diff --git a/cpp/common/utils/src/Makefile b/cpp/common/utils/src/Makefile index 0185ab9975..b0ab76973c 100644 --- a/cpp/common/utils/src/Makefile +++ b/cpp/common/utils/src/Makefile @@ -13,13 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # -##### Options ##### -QPID_HOME = ../../../.. - -include ${QPID_HOME}/cpp/options.mk -##### Compiler flags ##### -CXXFLAGS = -I ../inc -I ${APR_HOME}/include/apr-1/ +QPID_HOME = ../../../.. +include $(QPID_HOME)/cpp/options.mk +INCLUDES=$(TEST_INCLUDES) ##### Targets ##### # Add additional source files to SOURCE LIST to include them in the build. diff --git a/cpp/common/utils/src/logger.cpp b/cpp/common/utils/src/logger.cpp deleted file mode 100644 index 603fa6574e..0000000000 --- a/cpp/common/utils/src/logger.cpp +++ /dev/null @@ -1,209 +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. - * - */ -/********************************************************************* -* -* NOTE: This is a lightweight logging class intended for debugging and -* verification purposes only. -* -* DO NOT USE FOR PRODUCT DEVELOPMENT - Rather, use an agreed upon -* established logging class (such as Apache's log4cxx) for product -* development purposes. -* -*********************************************************************/ - -#include <iostream> -#include <ostream> -#include <string.h> -#include "apr_time.h" -#include "logger.h" - -namespace qpid { -namespace utils { - -Logger::Logger(const char* filename, const bool append): - std::ofstream(filename, append ? std::ios::app : std::ios::out) -{ - echo_flag = false; - timestamp_flag = true; - eol_flag = true; -} - -Logger::Logger(std::string& filename, const bool append): - std::ofstream(filename.c_str(), append ? std::ios::app : std::ios::out) -{ - echo_flag = false; - timestamp_flag = true; - eol_flag = true; -} - -Logger::~Logger() -{ - close(); -} - -void Logger::write_timestamp() -{ - int len; - apr_time_exp_t now; - apr_time_exp_lt(&now, apr_time_now()); - sprintf(buff, "%4d/%02d/%02d %02d:%02d:%02d.%06d : ", 1900+now.tm_year, now.tm_mon, - now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec, now.tm_usec); - write(buff, strlen(buff)); -} - - -void Logger::log(const char* message) -{ - if (timestamp_flag && eol_flag) - { - eol_flag = false; - write_timestamp(); - } - write(message, strlen(message)); - if (echo_flag) - std::cout << message; - if (strchr(message, '\n')) - eol_flag = true; -} - -void Logger::log(const char* message, const bool echo) -{ - if (timestamp_flag && eol_flag) - { - eol_flag = false; - write_timestamp(); - } - write(message, strlen(message)); - if (echo) - std::cout << message; - if (strchr(message, '\n')) - eol_flag = true; -} - -void Logger::log(const char* message, const bool echo, const bool timestamp) -{ - if (timestamp && eol_flag) - { - eol_flag = false; - write_timestamp(); - } - write(message, strlen(message)); - if (echo) - std::cout << message; - if (strchr(message, '\n')) - eol_flag = true; -} - -Logger& Logger::operator<< (const bool b) -{ - log(b ? "true" : "false"); - return *this; -} - -Logger& Logger::operator<< (const short s) -{ - sprintf(buff, "%d", s); - log(buff); - return *this; -} - -Logger& Logger::operator<< (const unsigned short us) -{ - sprintf(buff, "%u", us); - log(buff); - return *this; -} - -Logger& Logger::operator<< (const int i) -{ - sprintf(buff, "%d", i); - log(buff); - return *this; -} - -Logger& Logger::operator<< (const unsigned int ui) -{ - sprintf(buff, "%u", ui); - log(buff); - return *this; -} - -Logger& Logger::operator<< (const long l) -{ - sprintf(buff, "%ld", l); - log(buff); - return *this; -} - -Logger& Logger::operator<< (const unsigned long ul) -{ - sprintf(buff, "%lu", ul); - log(buff); - return *this; -} - -Logger& Logger::operator<< (const long long l) -{ - sprintf(buff, "%ld", l); - log(buff); - return *this; -} - -Logger& Logger::operator<< (const unsigned long long ul) -{ - sprintf(buff, "%lu", ul); - log(buff); - return *this; -} - -Logger& Logger::operator<< (const float f) -{ - sprintf(buff, "%f", f); - log(buff); - return *this; -} - -Logger& Logger::operator<< (const double d) -{ - sprintf(buff, "%lf", d); - log(buff); - return *this; -} - -Logger& Logger::operator<< (const long double ld) -{ - sprintf(buff, "%Lf", ld); - log(buff); - return *this; -} - -Logger& Logger::operator<< (const char* cstr) -{ - log(cstr); - return *this; -} - -Logger& Logger::operator<< (const std::string& str) -{ - log(str.c_str()); - return *this; -} - -} -} - diff --git a/cpp/common/utils/src/logger_test.cpp b/cpp/common/utils/src/logger_test.cpp deleted file mode 100644 index 1866af9fbb..0000000000 --- a/cpp/common/utils/src/logger_test.cpp +++ /dev/null @@ -1,78 +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 <iostream> -#include <string> -#include "logger.h" - -using namespace qpid::utils; - -void run_sequence(Logger& log) -{ - bool b = true; - short s = -5; - unsigned short us = 12; - int i = -2345; - unsigned int ui = 34567; - long l = -12345678; - unsigned long ul = 23456789; - long long ll = -1234567890; - unsigned long long ull = 1234567890; - float f = -123.45678; - double d = 123.45678901; - long double ld = 23456.789012345678; - char* cstr = "This is a test C string."; - char* cr = "\n"; - std::string str("This is a test std::string"); - log << "bool = " << b << cr; - log << "short = " << s << cr; - log << "unsigned sort = " << us << cr; - log << "int = " << i << cr; - log << "unsigned int = " << ui << cr; - log << "long = " << l << cr; - log << "unsigned long = " << ul << cr; - log << "long long = " << ll << cr; - log << "unsigned long long = " << ull << cr; - log << "float = " << f << cr; - log << "double = " << d << cr; - log << "long double = " << ld << cr; - log << "char* = " << cstr << cr; - log << "std::string = " << str << cr; - log << "String 1\n"; - log << "String 2\n" << "String 3 " << "String 4\n"; - log << "Literal bool = " << false << cr; - log << "Literal unsigned int = " << 15 << cr; - log << "Literal double = " << (double)15 << cr; -} - -int main(int argc, char** argv) -{ - Logger log("test_log.txt", false); - std::cout << "****** Initial state (echo off, timestamp on)" << std::endl; - run_sequence(log); - std::cout << std::endl << "****** (echo off, timestamp off)" << std::endl; - log.setTimestampFlag(false); - run_sequence(log); - std::cout << std::endl << "****** (echo on, timestamp on)" << std::endl; - log.setEchoFlag(true); - log.setTimestampFlag(true); - run_sequence(log); - std::cout << std::endl << "****** (echo on, timestamp off)" << std::endl; - log.setTimestampFlag(false); - run_sequence(log); - return 0; -} diff --git a/cpp/options.mk b/cpp/options.mk index 904f58c774..f5d7d950f8 100644 --- a/cpp/options.mk +++ b/cpp/options.mk @@ -24,15 +24,26 @@ BIN_DIR = ${QPID_CPP_HOME}/bin APR_HOME = /usr/local/apr # Compile flags -DEBUG = -ggdb3 +DEBUG = -ggdb3 -O0 +OPTIMIZE = # _USE_APR_IO_ set when APR IO build is desired. -OPT = -D _USE_APR_IO_ #-O3 +DEFINES = -D _USE_APR_IO_ APR_INCLUDES=-I ${APR_HOME}/include/apr-1/ COMMON_INCLUDES = -I ${COMMON_HOME}/framing/inc -I ${COMMON_HOME}/framing/generated -I ${COMMON_HOME}/concurrent/inc -I ${COMMON_HOME}/io/inc -I ${COMMON_HOME}/error/inc -I $(COMMON_HOME)/utils/inc ${APR_INCLUDES} SRC_INCLUDES = $(COMMON_INCLUDES) -I inc -TEST_INCLUDES = $(COMMON_INCLUDES) -I ../inc +TEST_INCLUDES = $(COMMON_INCLUDES) -I ../inc -I $(QPID_CPP_HOME)/test/include INCLUDES=$(SRC_INCLUDES) # Default to src -CXXFLAGS = $(DEBUG) $(OPT) -MMD -fpic $(INCLUDES) + +# Warnings: Enable as many as possible, keep the code clean. Please +# do not disable warnings or remove -Werror without discussing on +# qpid-dev list. +# +# The following warnings deliberately omitted, they warn on valid code. +# -Wno-unreachable-code -Wpadded +# +WARN = -Werror -pedantic -Wall -Wextra -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wno-long-long -Wvolatile-register-var -Winvalid-pch -Winline + +CXXFLAGS = $(DEBUG) $(OPTIMIZE) $(DEFINES) $(WARN) -MMD -fpic $(INCLUDES) # General link flags LDFLAGS= -L $(LIB_DIR) -L ${APR_HOME}/lib $(RPATH) diff --git a/cpp/test/include/qpid_test_plugin.h b/cpp/test/include/qpid_test_plugin.h new file mode 100644 index 0000000000..dabd2efe6a --- /dev/null +++ b/cpp/test/include/qpid_test_plugin.h @@ -0,0 +1,40 @@ +#ifndef _qpid_test_plugin_ +#define _qpid_test_plugin_ + +/* + * + * 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. + * + */ + +/** + * Convenience to include cppunit headers needed by qpid test plugins and + * workaround for warning from superfluous main() declaration + * in cppunit/TestPlugIn.h + */ + +#include <cppunit/TestCase.h> +#include <cppunit/TextTestRunner.h> +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/plugin/TestPlugIn.h> + +// Redefine CPPUNIT_PLUGIN_IMPLEMENT_MAIN to a dummy typedef to avoid warnings. +// +#if defined(CPPUNIT_HAVE_UNIX_DLL_LOADER) || defined(CPPUNIT_HAVE_UNIX_SHL_LOADER) +#undef CPPUNIT_PLUGIN_IMPLEMENT_MAIN +#define CPPUNIT_PLUGIN_IMPLEMENT_MAIN() typedef char __CppUnitPlugInImplementMainDummyTypeDef +#endif + +#endif /*!_qpid_test_plugin_*/ |