From e7881513358cf21203fdb0987807c18b599a5310 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Wed, 15 Jul 2009 16:45:21 +0000 Subject: Merge branch 'move_public_h_to_include' into trunk git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@794325 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/Address.h | 85 ++++++ qpid/cpp/include/qpid/CommonImportExport.h | 33 +++ qpid/cpp/include/qpid/Exception.h | 93 ++++++ qpid/cpp/include/qpid/InlineAllocator.h | 101 +++++++ qpid/cpp/include/qpid/InlineVector.h | 68 +++++ qpid/cpp/include/qpid/Msg.h | 61 ++++ qpid/cpp/include/qpid/Options.h | 265 +++++++++++++++++ qpid/cpp/include/qpid/RangeSet.h | 330 +++++++++++++++++++++ qpid/cpp/include/qpid/SessionId.h | 60 ++++ qpid/cpp/include/qpid/Url.h | 93 ++++++ qpid/cpp/include/qpid/agent/ManagementAgent.h | 163 ++++++++++ qpid/cpp/include/qpid/agent/QmfAgentImportExport.h | 33 +++ qpid/cpp/include/qpid/client/AsyncSession.h | 38 +++ qpid/cpp/include/qpid/client/ClientImportExport.h | 33 +++ qpid/cpp/include/qpid/client/Completion.h | 71 +++++ qpid/cpp/include/qpid/client/Connection.h | 204 +++++++++++++ qpid/cpp/include/qpid/client/ConnectionSettings.h | 133 +++++++++ qpid/cpp/include/qpid/client/FailoverManager.h | 135 +++++++++ qpid/cpp/include/qpid/client/FlowControl.h | 75 +++++ qpid/cpp/include/qpid/client/Future.h | 59 ++++ qpid/cpp/include/qpid/client/FutureCompletion.h | 49 +++ qpid/cpp/include/qpid/client/FutureResult.h | 49 +++ qpid/cpp/include/qpid/client/Handle.h | 71 +++++ qpid/cpp/include/qpid/client/LocalQueue.h | 120 ++++++++ qpid/cpp/include/qpid/client/Message.h | 175 +++++++++++ qpid/cpp/include/qpid/client/MessageListener.h | 101 +++++++ .../cpp/include/qpid/client/MessageReplayTracker.h | 73 +++++ qpid/cpp/include/qpid/client/QueueOptions.h | 114 +++++++ qpid/cpp/include/qpid/client/Session.h | 39 +++ qpid/cpp/include/qpid/client/SessionBase_0_10.h | 109 +++++++ qpid/cpp/include/qpid/client/Subscription.h | 123 ++++++++ qpid/cpp/include/qpid/client/SubscriptionManager.h | 286 ++++++++++++++++++ .../cpp/include/qpid/client/SubscriptionSettings.h | 92 ++++++ qpid/cpp/include/qpid/client/TypedResult.h | 65 ++++ qpid/cpp/include/qpid/console/Agent.h | 58 ++++ qpid/cpp/include/qpid/console/Broker.h | 133 +++++++++ qpid/cpp/include/qpid/console/ClassKey.h | 66 +++++ .../cpp/include/qpid/console/ConsoleImportExport.h | 33 +++ qpid/cpp/include/qpid/console/ConsoleListener.h | 97 ++++++ qpid/cpp/include/qpid/console/Event.h | 86 ++++++ qpid/cpp/include/qpid/console/Object.h | 123 ++++++++ qpid/cpp/include/qpid/console/ObjectId.h | 69 +++++ qpid/cpp/include/qpid/console/Package.h | 78 +++++ qpid/cpp/include/qpid/console/Schema.h | 105 +++++++ qpid/cpp/include/qpid/console/SequenceManager.h | 54 ++++ qpid/cpp/include/qpid/console/SessionManager.h | 205 +++++++++++++ qpid/cpp/include/qpid/console/Value.h | 213 +++++++++++++ qpid/cpp/include/qpid/framing/Array.h | 97 ++++++ qpid/cpp/include/qpid/framing/Buffer.h | 136 +++++++++ qpid/cpp/include/qpid/framing/FieldTable.h | 125 ++++++++ qpid/cpp/include/qpid/framing/FieldValue.h | 321 ++++++++++++++++++++ qpid/cpp/include/qpid/framing/ProtocolVersion.h | 58 ++++ qpid/cpp/include/qpid/framing/SequenceNumber.h | 79 +++++ qpid/cpp/include/qpid/framing/SequenceSet.h | 69 +++++ qpid/cpp/include/qpid/framing/StructHelper.h | 57 ++++ qpid/cpp/include/qpid/framing/Uuid.h | 91 ++++++ qpid/cpp/include/qpid/framing/amqp_types.h | 66 +++++ qpid/cpp/include/qpid/framing/amqp_types_full.h | 38 +++ qpid/cpp/include/qpid/log/Logger.h | 114 +++++++ qpid/cpp/include/qpid/log/Options.h | 50 ++++ qpid/cpp/include/qpid/log/Selector.h | 71 +++++ qpid/cpp/include/qpid/log/SinkOptions.h | 64 ++++ qpid/cpp/include/qpid/log/Statement.h | 121 ++++++++ qpid/cpp/include/qpid/management/Args.h | 44 +++ qpid/cpp/include/qpid/management/Manageable.h | 72 +++++ qpid/cpp/include/qpid/management/ManagementEvent.h | 49 +++ .../cpp/include/qpid/management/ManagementObject.h | 187 ++++++++++++ qpid/cpp/include/qpid/sys/Condition.h | 33 +++ qpid/cpp/include/qpid/sys/IOHandle.h | 61 ++++ qpid/cpp/include/qpid/sys/IntegerTypes.h | 31 ++ qpid/cpp/include/qpid/sys/Monitor.h | 49 +++ qpid/cpp/include/qpid/sys/Mutex.h | 91 ++++++ qpid/cpp/include/qpid/sys/Runnable.h | 51 ++++ qpid/cpp/include/qpid/sys/StrError.h | 36 +++ qpid/cpp/include/qpid/sys/SystemInfo.h | 85 ++++++ qpid/cpp/include/qpid/sys/Thread.h | 65 ++++ qpid/cpp/include/qpid/sys/Time.h | 173 +++++++++++ qpid/cpp/include/qpid/sys/posix/Condition.h | 86 ++++++ qpid/cpp/include/qpid/sys/posix/IntegerTypes.h | 26 ++ qpid/cpp/include/qpid/sys/posix/Mutex.h | 158 ++++++++++ qpid/cpp/include/qpid/sys/posix/PrivatePosix.h | 72 +++++ qpid/cpp/include/qpid/sys/posix/Time.h | 34 +++ qpid/cpp/include/qpid/sys/posix/check.h | 52 ++++ qpid/cpp/include/qpid/sys/uuid.h | 28 ++ 84 files changed, 7959 insertions(+) create mode 100755 qpid/cpp/include/qpid/Address.h create mode 100644 qpid/cpp/include/qpid/CommonImportExport.h create mode 100644 qpid/cpp/include/qpid/Exception.h create mode 100644 qpid/cpp/include/qpid/InlineAllocator.h create mode 100644 qpid/cpp/include/qpid/InlineVector.h create mode 100644 qpid/cpp/include/qpid/Msg.h create mode 100644 qpid/cpp/include/qpid/Options.h create mode 100644 qpid/cpp/include/qpid/RangeSet.h create mode 100644 qpid/cpp/include/qpid/SessionId.h create mode 100644 qpid/cpp/include/qpid/Url.h create mode 100644 qpid/cpp/include/qpid/agent/ManagementAgent.h create mode 100644 qpid/cpp/include/qpid/agent/QmfAgentImportExport.h create mode 100644 qpid/cpp/include/qpid/client/AsyncSession.h create mode 100644 qpid/cpp/include/qpid/client/ClientImportExport.h create mode 100644 qpid/cpp/include/qpid/client/Completion.h create mode 100644 qpid/cpp/include/qpid/client/Connection.h create mode 100644 qpid/cpp/include/qpid/client/ConnectionSettings.h create mode 100644 qpid/cpp/include/qpid/client/FailoverManager.h create mode 100644 qpid/cpp/include/qpid/client/FlowControl.h create mode 100644 qpid/cpp/include/qpid/client/Future.h create mode 100644 qpid/cpp/include/qpid/client/FutureCompletion.h create mode 100644 qpid/cpp/include/qpid/client/FutureResult.h create mode 100644 qpid/cpp/include/qpid/client/Handle.h create mode 100644 qpid/cpp/include/qpid/client/LocalQueue.h create mode 100644 qpid/cpp/include/qpid/client/Message.h create mode 100644 qpid/cpp/include/qpid/client/MessageListener.h create mode 100644 qpid/cpp/include/qpid/client/MessageReplayTracker.h create mode 100644 qpid/cpp/include/qpid/client/QueueOptions.h create mode 100644 qpid/cpp/include/qpid/client/Session.h create mode 100644 qpid/cpp/include/qpid/client/SessionBase_0_10.h create mode 100644 qpid/cpp/include/qpid/client/Subscription.h create mode 100644 qpid/cpp/include/qpid/client/SubscriptionManager.h create mode 100644 qpid/cpp/include/qpid/client/SubscriptionSettings.h create mode 100644 qpid/cpp/include/qpid/client/TypedResult.h create mode 100644 qpid/cpp/include/qpid/console/Agent.h create mode 100644 qpid/cpp/include/qpid/console/Broker.h create mode 100644 qpid/cpp/include/qpid/console/ClassKey.h create mode 100644 qpid/cpp/include/qpid/console/ConsoleImportExport.h create mode 100644 qpid/cpp/include/qpid/console/ConsoleListener.h create mode 100644 qpid/cpp/include/qpid/console/Event.h create mode 100644 qpid/cpp/include/qpid/console/Object.h create mode 100644 qpid/cpp/include/qpid/console/ObjectId.h create mode 100644 qpid/cpp/include/qpid/console/Package.h create mode 100644 qpid/cpp/include/qpid/console/Schema.h create mode 100644 qpid/cpp/include/qpid/console/SequenceManager.h create mode 100644 qpid/cpp/include/qpid/console/SessionManager.h create mode 100644 qpid/cpp/include/qpid/console/Value.h create mode 100644 qpid/cpp/include/qpid/framing/Array.h create mode 100644 qpid/cpp/include/qpid/framing/Buffer.h create mode 100644 qpid/cpp/include/qpid/framing/FieldTable.h create mode 100644 qpid/cpp/include/qpid/framing/FieldValue.h create mode 100644 qpid/cpp/include/qpid/framing/ProtocolVersion.h create mode 100644 qpid/cpp/include/qpid/framing/SequenceNumber.h create mode 100644 qpid/cpp/include/qpid/framing/SequenceSet.h create mode 100644 qpid/cpp/include/qpid/framing/StructHelper.h create mode 100644 qpid/cpp/include/qpid/framing/Uuid.h create mode 100644 qpid/cpp/include/qpid/framing/amqp_types.h create mode 100644 qpid/cpp/include/qpid/framing/amqp_types_full.h create mode 100644 qpid/cpp/include/qpid/log/Logger.h create mode 100644 qpid/cpp/include/qpid/log/Options.h create mode 100644 qpid/cpp/include/qpid/log/Selector.h create mode 100644 qpid/cpp/include/qpid/log/SinkOptions.h create mode 100644 qpid/cpp/include/qpid/log/Statement.h create mode 100644 qpid/cpp/include/qpid/management/Args.h create mode 100644 qpid/cpp/include/qpid/management/Manageable.h create mode 100644 qpid/cpp/include/qpid/management/ManagementEvent.h create mode 100644 qpid/cpp/include/qpid/management/ManagementObject.h create mode 100644 qpid/cpp/include/qpid/sys/Condition.h create mode 100644 qpid/cpp/include/qpid/sys/IOHandle.h create mode 100755 qpid/cpp/include/qpid/sys/IntegerTypes.h create mode 100644 qpid/cpp/include/qpid/sys/Monitor.h create mode 100644 qpid/cpp/include/qpid/sys/Mutex.h create mode 100644 qpid/cpp/include/qpid/sys/Runnable.h create mode 100644 qpid/cpp/include/qpid/sys/StrError.h create mode 100644 qpid/cpp/include/qpid/sys/SystemInfo.h create mode 100644 qpid/cpp/include/qpid/sys/Thread.h create mode 100644 qpid/cpp/include/qpid/sys/Time.h create mode 100644 qpid/cpp/include/qpid/sys/posix/Condition.h create mode 100755 qpid/cpp/include/qpid/sys/posix/IntegerTypes.h create mode 100644 qpid/cpp/include/qpid/sys/posix/Mutex.h create mode 100644 qpid/cpp/include/qpid/sys/posix/PrivatePosix.h create mode 100755 qpid/cpp/include/qpid/sys/posix/Time.h create mode 100644 qpid/cpp/include/qpid/sys/posix/check.h create mode 100644 qpid/cpp/include/qpid/sys/uuid.h (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/Address.h b/qpid/cpp/include/qpid/Address.h new file mode 100755 index 0000000000..fe82b21b9e --- /dev/null +++ b/qpid/cpp/include/qpid/Address.h @@ -0,0 +1,85 @@ +#ifndef QPID_ADDRESS_H +#define QPID_ADDRESS_H + +/* + * + * Copyright (c) 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "qpid/sys/IntegerTypes.h" +#include "qpid/CommonImportExport.h" +#include +#include +#include +#include + +namespace qpid { + +/** TCP address of a broker - host:port */ +struct TcpAddress { + static const uint16_t DEFAULT_PORT=5672; + QPID_COMMON_EXTERN explicit TcpAddress(const std::string& host_=std::string(),uint16_t port_=DEFAULT_PORT); + std::string host; + uint16_t port; +}; +bool operator==(const TcpAddress& x, const TcpAddress& y); +QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& os, const TcpAddress& a); + +/**@internal Not a real address type, this is a placeholder to + * demonstrate and validate multi-protocol Urls for unit tests and + * developer education only. An example address holds just a char. + */ +struct ExampleAddress { + explicit ExampleAddress(char data); + char data; +}; +bool operator==(const ExampleAddress& x, const ExampleAddress& y); +std::ostream& operator<<(std::ostream& os, const ExampleAddress& a); + +/** + * Contains the address of an AMQP broker. Can any supported type of + * broker address. Currently only TcpAddress is supported. + */ +struct Address { +public: + Address(const Address& a) : value(a.value) {} + Address(const TcpAddress& tcp) : value(tcp) {} + Address(const ExampleAddress& eg) : value(eg) {} ///<@internal + + template Address& operator=(const AddressType& t) { value=t; return *this; } + + /** Get the address of type AddressType. + *@return AddressType* pointing to the contained address or 0 if + *contained address is not of type AddressType. + */ + template AddressType* get() { return boost::get(&value); } + + /** Get the address of type AddressType. + *@return AddressType* pointing to the contained address or 0 if + *contained address is not of type AddressType. + */ + template const AddressType* get() const { return boost::get(&value); } + +private: + boost::variant value; + friend std::ostream& operator<<(std::ostream& os, const Address& addr); +}; + + + +} // namespace qpid + +#endif /*!QPID_ADDRESS_H*/ diff --git a/qpid/cpp/include/qpid/CommonImportExport.h b/qpid/cpp/include/qpid/CommonImportExport.h new file mode 100644 index 0000000000..02c06ed7af --- /dev/null +++ b/qpid/cpp/include/qpid/CommonImportExport.h @@ -0,0 +1,33 @@ +#ifndef QPID_COMMON_IMPORT_EXPORT_H +#define QPID_COMMON_IMPORT_EXPORT_H + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#if defined(WIN32) && !defined(QPID_DECLARE_STATIC) +#if defined(COMMON_EXPORT) || defined (qpidcommon_EXPORTS) +#define QPID_COMMON_EXTERN __declspec(dllexport) +#else +#define QPID_COMMON_EXTERN __declspec(dllimport) +#endif +#else +#define QPID_COMMON_EXTERN +#endif + +#endif diff --git a/qpid/cpp/include/qpid/Exception.h b/qpid/cpp/include/qpid/Exception.h new file mode 100644 index 0000000000..7b937c242a --- /dev/null +++ b/qpid/cpp/include/qpid/Exception.h @@ -0,0 +1,93 @@ +#ifndef _Exception_ +#define _Exception_ + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/framing/amqp_types.h" +#include "qpid/framing/constants.h" +#include "qpid/framing/enum.h" +#include "qpid/sys/StrError.h" +#include "qpid/Msg.h" +#include "qpid/CommonImportExport.h" +#include +#include +#include + +namespace qpid +{ + +/** + * Base class for Qpid runtime exceptions. + */ +class Exception : public std::exception +{ + public: + QPID_COMMON_EXTERN explicit Exception(const std::string& message=std::string()) throw(); + QPID_COMMON_EXTERN virtual ~Exception() throw(); + QPID_COMMON_EXTERN virtual const char* what() const throw(); // prefix: message + QPID_COMMON_EXTERN virtual std::string getMessage() const; // Unprefixed message + QPID_COMMON_EXTERN virtual std::string getPrefix() const; // Prefix + + private: + std::string message; + mutable std::string whatStr; +}; + +/** Exception that includes an errno message. */ +struct ErrnoException : public Exception { + ErrnoException(const std::string& msg, int err) : Exception(msg+": "+qpid::sys::strError(err)) {} + ErrnoException(const std::string& msg) : Exception(msg+": "+qpid::sys::strError(errno)) {} +}; + +struct SessionException : public Exception { + const framing::execution::ErrorCode code; + SessionException(framing::execution::ErrorCode code_, const std::string& message) + : Exception(message), code(code_) {} +}; + +struct ChannelException : public Exception { + const framing::session::DetachCode code; + ChannelException(framing::session::DetachCode _code, const std::string& message) + : Exception(message), code(_code) {} +}; + +struct ConnectionException : public Exception { + const framing::connection::CloseCode code; + ConnectionException(framing::connection::CloseCode _code, const std::string& message) + : Exception(message), code(_code) {} +}; + +struct ClosedException : public Exception { + QPID_COMMON_EXTERN ClosedException(const std::string& msg=std::string()); + QPID_COMMON_EXTERN std::string getPrefix() const; +}; + +/** + * Exception representing transport failure + */ +struct TransportFailure : public Exception { + TransportFailure(const std::string& msg=std::string()) : Exception(msg) {} +}; + +} // namespace qpid + +#endif /*!_Exception_*/ diff --git a/qpid/cpp/include/qpid/InlineAllocator.h b/qpid/cpp/include/qpid/InlineAllocator.h new file mode 100644 index 0000000000..2502545dcb --- /dev/null +++ b/qpid/cpp/include/qpid/InlineAllocator.h @@ -0,0 +1,101 @@ +#ifndef QPID_INLINEALLOCATOR_H +#define QPID_INLINEALLOCATOR_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include +#include +#include +#include + +namespace qpid { + +template +struct InlineRebind; + + +/** + * An allocator that has inline storage for up to Max objects + * of type BaseAllocator::value_type. + */ +template +class InlineAllocator : public BaseAllocator { + public: + typedef typename BaseAllocator::pointer pointer; + typedef typename BaseAllocator::size_type size_type; + typedef typename BaseAllocator::value_type value_type; + + InlineAllocator() : allocated(false) {} + InlineAllocator(const InlineAllocator& x) : BaseAllocator(x), allocated(false) {} + + pointer allocate(size_type n) { + if (n <= Max && !allocated) { + allocated=true; + return reinterpret_cast(address()); + } + else + return BaseAllocator::allocate(n, 0); + } + + void deallocate(pointer p, size_type n) { + if (p == address()) { + assert(allocated); + allocated=false; + } + else + BaseAllocator::deallocate(p, n); + } + + template + struct rebind { + typedef typename InlineRebind::other other; + }; + + private: + // POD object with alignment and size to hold Max value_types. + static const size_t ALIGNMENT=boost::alignment_of::value; + typedef typename boost::type_with_alignment::type Aligner; + union Store { + Aligner aligner_; + char sizer_[sizeof(value_type)*Max]; + } store; + value_type* address() { return reinterpret_cast(&store); } + bool allocated; +}; + + +// Rebind: if RequestedType == InlineType, use the InlineAllocator, +// otherwise, use the BaseAllocator without any inlining. + +template +struct InlineRebind { + typedef typename BaseAllocator::template rebind::other other; +}; + +template +struct InlineRebind { + typedef typename qpid::InlineAllocator other; +}; + +} // namespace qpid + +#endif /*!QPID_INLINEALLOCATOR_H*/ diff --git a/qpid/cpp/include/qpid/InlineVector.h b/qpid/cpp/include/qpid/InlineVector.h new file mode 100644 index 0000000000..c55db295f3 --- /dev/null +++ b/qpid/cpp/include/qpid/InlineVector.h @@ -0,0 +1,68 @@ +#ifndef QPID_INLINEVECTOR_H +#define QPID_INLINEVECTOR_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/InlineAllocator.h" +#include + +namespace qpid { + +/** + * A vector that stores up to Max elements in inline storage, + * otherwise uses normal vector allocation. + * + * NOTE: depends on some non-standard but highly probably assumptions + * about how std::vector uses its allocator, they are true for g++. + * - default constructor does not allocate. + * - reserve(N) does not allocate more than N elements. + * - vector never re-allocates when size() < capacity() + */ +template > +class InlineVector : public std::vector > +{ + typedef std::vector > Base; + public: + typedef typename Base::allocator_type allocator_type; + typedef typename Base::value_type value_type; + typedef typename Base::size_type size_type; + + explicit InlineVector(const allocator_type& a=allocator_type()) : Base(a) { + this->reserve(Max); + } + + explicit InlineVector(size_type n, const value_type& x = value_type(), + const allocator_type& a=allocator_type()) : Base(a) + { + this->reserve(std::max(n, Max)); + this->insert(this->end(), n, x); + } + + InlineVector(const InlineVector& x) : Base() { + this->reserve(std::max(x.size(), Max)); + *this = x; + } +}; + +} // namespace qpid + +#endif /*!QPID_INLINEVECTOR_H*/ diff --git a/qpid/cpp/include/qpid/Msg.h b/qpid/cpp/include/qpid/Msg.h new file mode 100644 index 0000000000..5149a94d7f --- /dev/null +++ b/qpid/cpp/include/qpid/Msg.h @@ -0,0 +1,61 @@ +#ifndef QPID_MSG_H +#define QPID_MSG_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include +#include + +namespace qpid { + +/** A simple wrapper for std::ostringstream that allows + * in place construction of a message and automatic conversion + * to string. + * E.g. + *@code + * void foo(const std::string&); + * foo(Msg() << "hello " << 32); + *@endcode + * Will construct the string "hello 32" and pass it to foo() + */ +struct Msg { + std::ostringstream os; + Msg() {} + Msg(const Msg& m) : os(m.str()) {} + std::string str() const { return os.str(); } + operator std::string() const { return str(); } +}; + +template const Msg& operator<<(const Msg& m, const T& t) { + const_cast(m.os)< +#include + +#ifdef _MSC_VER +# pragma warning(pop) +#endif + +#include +#include +#include +#include +#include "qpid/CommonImportExport.h" + +namespace qpid { +namespace po=boost::program_options; + + + +///@internal +QPID_COMMON_EXTERN std::string prettyArg(const std::string&, const std::string&); + +/** @internal Normally only constructed by optValue() */ +template +class OptionValue : public po::typed_value { + public: + OptionValue(T& value, const std::string& arg) + : po::typed_value(&value), argName(arg) {} + std::string name() const { return argName; } + + private: + std::string argName; +}; + + +/** Create an option value. + * name, value appear after the option name in help like this: + * (=) + * T must support operator <<. + *@see Options for example of use. + */ +template +po::value_semantic* optValue(T& value, const char* name) { + std::string valstr(boost::lexical_cast(value)); + return new OptionValue(value, prettyArg(name, valstr)); +} + +/** Create a vector value. Multiple occurences of the option are + * accumulated into the vector + */ +template +po::value_semantic* optValue(std::vector& value, const char* name) { + using namespace std; + ostringstream os; + copy(value.begin(), value.end(), ostream_iterator(os, " ")); + string val=os.str(); + if (!val.empty()) + val.erase(val.end()-1); // Remove trailing " " + return (new OptionValue >(value, prettyArg(name, val))); +} + +/** Create a boolean switch value. Presence of the option sets the value. */ +inline po::value_semantic* optValue(bool& value) { return po::bool_switch(&value); } + +/** + * Base class for options. + * Example of use: + @code + struct MySubOptions : public Options { + int x; + string y; + MySubOptions() : Options("Sub options") { + addOptions() + ("x", optValue(x,"XUNIT"), "Option X") + ("y", optValue(y, "YUNIT"), "Option Y"); + } + }; + + struct MyOptions : public Options { + bool z; + vector foo; + MySubOptions subOptions; + MyOptions() : Options("My Options") { + addOptions() + ("z", boolSwitch(z), "Option Z") + ("foo", optValue(foo), "Multiple option foo"); + add(subOptions); + } + + main(int argc, char** argv) { + Options opts; + opts.parse(argc, char** argv); + // Use values + dosomething(opts.subOptions.x); + if (error) + cout << opts << end; // Help message. + } + + @endcode + */ + + + + +/* + * --------------------------------------------- + * Explanation for Boost 103200 conditional code + * --------------------------------------------- + * + * This boost version has an implementation of the program_options library + * that has no provision for allowing unregistered options to pass by. + * + * But that means that, if you have a program that loads optional modules + * after start-up, and those modules each have their own set of options, + * then if you parse the command line too soon, you will get spurious + * reports of unrecognized options -- and the program will exit! + * + * And we must process the command-line before module-loading, because we + * need to look at the "bootstrap" options. + * + * This conditional code: + * + * 1. implements it's own functor class, derived from the Boost + * "options_description_easy_init" class. This functor is used + * to process added options and do the functor chaining, so that + * I can snoop on the arguments before doing an explicit call + * to its parent. + * + * 2. It implements two static vectors, one to hold long names, and + * one for short names, so that options declared by modules are + * not forgotten when their options_description goes out of scope. + * + * I will be thrilled to personally delete this code if we ever decide + * that qpid doesn't really need to support this antique version of Boost. + * + */ + +#if ( BOOST_VERSION == 103200 ) +struct Options; + + +struct +options_description_less_easy_init + : public po::options_description_easy_init +{ + options_description_less_easy_init ( Options * my_owner, + po::options_description * my_parents_owner + ) + : po::options_description_easy_init(my_parents_owner) + { + owner = my_owner; + } + + + options_description_less_easy_init& + operator()(char const * name, + char const * description); + + + options_description_less_easy_init& + operator()(char const * name, + const po::value_semantic* s); + + + options_description_less_easy_init& + operator()(const char* name, + const po::value_semantic* s, + const char* description); + + + Options * owner; +}; +#endif + + +struct Options : public po::options_description { + + struct Exception : public qpid::Exception { + Exception(const std::string& msg) : qpid::Exception(msg) {} + }; + + QPID_COMMON_EXTERN Options(const std::string& name=std::string()); + + /** + * Parses options from argc/argv, environment variables and config file. + * Note the filename argument can reference an options variable that + * is updated by argc/argv or environment variable parsing. + */ + QPID_COMMON_EXTERN void parse(int argc, char const* const* argv, + const std::string& configfile=std::string(), + bool allowUnknown = false); + + + #if ( BOOST_VERSION == 103200 ) + options_description_less_easy_init m_less_easy; + + options_description_less_easy_init addOptions() { + return m_less_easy; + } + + bool + is_registered_option ( std::string s ); + + void + register_names ( std::string s ); + + static std::vector long_names; + static std::vector short_names; + #else + boost::program_options::options_description_easy_init addOptions() { + return add_options(); + } + #endif +}; + + + +/** + * Standard options for configuration + */ +struct CommonOptions : public Options { + QPID_COMMON_EXTERN CommonOptions(const std::string& name=std::string(), + const std::string& configfile=std::string()); + bool help; + bool version; + std::string config; +}; + + + + +} // namespace qpid + +#endif /*!QPID_COMMONOPTIONS_H*/ diff --git a/qpid/cpp/include/qpid/RangeSet.h b/qpid/cpp/include/qpid/RangeSet.h new file mode 100644 index 0000000000..1b2e4201a6 --- /dev/null +++ b/qpid/cpp/include/qpid/RangeSet.h @@ -0,0 +1,330 @@ +#ifndef QPID_RANGESET_H +#define QPID_RANGESET_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/InlineVector.h" +#include +#include +#include +#include +#include + +namespace qpid { + +/** A range of values, used in RangeSet. + * Range(begin, end) includes begin but excludes end. + * Range::makeClosed(first,last) includes both first and last. + */ +template +class Range { + public: + static Range makeClosed(const T& first, T last) { return Range(first, ++last); } + + Range() : begin_(), end_() {} + explicit Range(const T& t) : begin_(t), end_(t) { ++end_; } + Range(const T& b, const T& e) : begin_(b), end_(e) { assert(b <= e); } + + T begin() const { return begin_; } + /** End of _open_ range, i.e. !contains(end()) */ + T end() const { return end_; } + + T first() const { assert(!empty()); return begin_; } + /** Last in closed range, i.e. contains(end()) */ + T last() const { assert(!empty()); T ret=end_; return --ret; } + + void begin(const T& t) { begin_ = t; } + void end(const T& t) { end_ = t; } + size_t size() const { return end_ - begin_; } + bool empty() const { return begin_ == end_; } + + bool contains(const T& x) const { return begin_ <= x && x < end_; } + bool contains(const Range& r) const { return begin_ <= r.begin_ && r.end_ <= end_; } + bool strictContains(const Range& r) const { return begin_ < r.begin_ && r.end_ < end_; } + + bool operator==(const Range& x) { return begin_ == x.begin_ && end_== x.end_; } + + bool operator<(const T& t) const { return end_ < t; } + bool operator<(const Range& r) const { return end_ < r.begin_; } + + /** touching ranges can be merged into a single range. */ + bool touching(const Range& r) const { + return std::max(begin_, r.begin_) <= std::min(end_, r.end_); + } + + /** @pre touching */ + void merge(const Range& r) { + assert(touching(r)); + begin_ = std::min(begin_, r.begin_); + end_ = std::max(end_, r.end_); + } + + operator bool() const { return !empty(); } + + template void serialize(S& s) { s(begin_)(end_); } + + private: + T begin_, end_; +}; + + +/** + * A set implemented as a list of [begin, end) ranges. + * T must be LessThanComparable and Incrementable. + * RangeSet only provides const iterators. + */ +template +class RangeSet + : boost::additive1, + boost::additive2, Range, + boost::additive2, T> > > +{ + typedef InlineVector, 3> Ranges; // TODO aconway 2008-04-21: what's the optimial inlined value? + + public: + + class iterator : public boost::iterator_facade< + iterator, + const T, + boost::forward_traversal_tag> + { + public: + iterator() : ranges(), iter(), value() {} + + private: + typedef typename Ranges::const_iterator RangesIter; + iterator(const Ranges& r, const RangesIter& i, const T& t) + : ranges(&r), iter(i), value(t) {} + + void increment(); + bool equal(const iterator& i) const; + const T& dereference() const { return value; } + + const Ranges* ranges; + RangesIter iter; + T value; + + friend class RangeSet; + friend class boost::iterator_core_access; + }; + + typedef iterator const_iterator; + + RangeSet() {} + explicit RangeSet(const Range& r) { *this += r; } + RangeSet(const T& a, const T& b) { *this += Range(a,b); } + + bool contiguous() const { return ranges.size() <= 1; } + + bool contains(const T& t) const; + bool contains(const Range&) const; + + /**@pre contiguous() */ + Range toRange() const; + + bool operator==(const RangeSet&) const; + + void addRange (const Range&); + void addSet (const RangeSet&); + + RangeSet& operator+=(const T& t) { return *this += Range(t); } + RangeSet& operator+=(const Range& r) { addRange(r); return *this; } + RangeSet& operator+=(const RangeSet& s) { addSet(s); return *this; } + + void removeRange (const Range&); + void removeSet (const RangeSet&); + + RangeSet& operator-=(const T& t) { return *this -= Range(t); } + RangeSet& operator-=(const Range& r) { removeRange(r); return *this; } + RangeSet& operator-=(const RangeSet& s) { removeSet(s); return *this; } + + T front() const { return ranges.front().begin(); } + T back() const { return ranges.back().end(); } + + // Iterate over elements in the set. + iterator begin() const; + iterator end() const; + + // Iterate over ranges in the set. + typedef typename Ranges::const_iterator RangeIterator; + RangeIterator rangesBegin() const { return ranges.begin(); } + RangeIterator rangesEnd() const { return ranges.end(); } + size_t rangesSize() const { return ranges.size(); } + + // The difference between the start and end of this range set + uint32_t span() const; + + size_t size() const; + bool empty() const { return ranges.empty(); } + void clear() { ranges.clear(); } + + /** Return the largest contiguous range containing x. + * Returns the empty range [x,x) if x is not in the set. + */ + Range rangeContaining(const T&) const; + + template void serialize(S& s) { s.split(*this); s(ranges.begin(), ranges.end()); } + template void encode(S& s) const { s(uint16_t(ranges.size()*sizeof(Range))); } + template void decode(S& s) { uint16_t sz; s(sz); ranges.resize(sz/sizeof(Range)); } + + private: + static size_t accumulateSize(size_t s, const Range& r) { return s+r.size(); } + Ranges ranges; + + template friend std::ostream& operator<<(std::ostream& o, const RangeSet& r); + + friend class iterator; +}; + +template +std::ostream& operator<<(std::ostream& o, const Range& r) { + return o << "[" << r.begin() << "," << r.end() << ")"; +} + +template +std::ostream& operator<<(std::ostream& o, const RangeSet& rs) { + std::ostream_iterator > i(o, " "); + o << "{ "; + std::copy(rs.ranges.begin(), rs.ranges.end(), i); + return o << "}"; +} + +template +bool RangeSet::contains(const T& t) const { + typename Ranges::const_iterator i = + std::lower_bound(ranges.begin(), ranges.end(), Range(t)); + return i != ranges.end() && i->contains(t); +} + +template +bool RangeSet::contains(const Range& r) const { + typename Ranges::const_iterator i = + std::lower_bound(ranges.begin(), ranges.end(), r); + return i != ranges.end() && i->contains(r); +} + +template void RangeSet::addRange(const Range& r) { + if (r.empty()) return; + typename Ranges::iterator i = + std::lower_bound(ranges.begin(), ranges.end(), r); + if (i == ranges.end() || !i->touching(r)) + ranges.insert(i, r); + else { + i->merge(r); + typename Ranges::iterator j = i; + if (++j != ranges.end() && i->touching(*j)) { + i->merge(*j); + ranges.erase(j); + } + } +} + + +template void RangeSet::addSet(const RangeSet& s) { + typedef RangeSet& (RangeSet::*RangeSetRangeOp)(const Range&); + std::for_each(s.ranges.begin(), s.ranges.end(), + boost::bind((RangeSetRangeOp)&RangeSet::operator+=, this, _1)); +} + +template void RangeSet::removeRange(const Range& r) { + if (r.empty()) return; + typename Ranges::iterator i,j; + i = std::lower_bound(ranges.begin(), ranges.end(), r); + if (i == ranges.end() || i->begin() >= r.end()) + return; // Outside of set + if (*i == r) // Erase i + ranges.erase(i); + else if (i->strictContains(r)) { // Split i + Range i1(i->begin(), r.begin()); + Range i2(r.end(), i->end()); + *i = i2; + ranges.insert(i, i1); + } else { + if (i->begin() < r.begin()) { // Truncate i + i->end(r.begin()); + ++i; + } + for (j = i; j != ranges.end() && r.contains(*j); ++j) + ; // Ranges to erase. + if (j != ranges.end() && j->end() > r.end()) + j->begin(r.end()); // Truncate j + ranges.erase(i,j); + } +} + +template void RangeSet::removeSet(const RangeSet& r) { + std::for_each( + r.ranges.begin(), r.ranges.end(), + boost::bind(&RangeSet::removeRange, this, _1)); +} + +template Range RangeSet::toRange() const { + assert(contiguous()); + return empty() ? Range() : ranges.front(); +} + +template void RangeSet::iterator::increment() { + assert(ranges && iter != ranges->end()); + if (!iter->contains(++value)) { + ++iter; + if (iter == ranges->end()) + *this=iterator(); // end() iterator + else + value=iter->begin(); + } +} + +template bool RangeSet::operator==(const RangeSet& r) const { + return ranges.size() == r.ranges.size() && std::equal(ranges.begin(), ranges.end(), r.ranges.begin()); +} + +template typename RangeSet::iterator RangeSet::begin() const { + return empty() ? end() : iterator(ranges, ranges.begin(), front()); +} + +template typename RangeSet::iterator RangeSet::end() const { + return iterator(); +} + +template bool RangeSet::iterator::equal(const iterator& i) const { + return ranges==i.ranges && (ranges==0 || value==i.value); +} + +template Range RangeSet::rangeContaining(const T& t) const { + typename Ranges::const_iterator i = + std::lower_bound(ranges.begin(), ranges.end(), Range(t)); + return (i != ranges.end() && i->contains(t)) ? *i : Range(t,t); +} + +template uint32_t RangeSet::span() const { + if (ranges.empty()) return 0; + return ranges.back().last() - ranges.front().first(); +} + +template size_t RangeSet::size() const { + return std::accumulate(rangesBegin(), rangesEnd(), 0, &RangeSet::accumulateSize); +} + +} // namespace qpid + + +#endif /*!QPID_RANGESET_H*/ diff --git a/qpid/cpp/include/qpid/SessionId.h b/qpid/cpp/include/qpid/SessionId.h new file mode 100644 index 0000000000..e18b360999 --- /dev/null +++ b/qpid/cpp/include/qpid/SessionId.h @@ -0,0 +1,60 @@ +#ifndef QPID_SESSIONID_H +#define QPID_SESSIONID_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include +#include +#include + +namespace qpid { + +/** Identifier for a session. + * There are two parts to a session identifier: + * + * getUserId() returns the authentication principal associated with + * the session's connection. + * + * getName() returns the session name. + * + * The name must be unique among sessions with the same authentication + * principal. + */ +class SessionId : boost::totally_ordered1 { + std::string userId; + std::string name; + public: + QPID_COMMON_EXTERN SessionId(const std::string& userId=std::string(), const std::string& name=std::string()); + std::string getUserId() const { return userId; } + std::string getName() const { return name; } + QPID_COMMON_EXTERN bool operator<(const SessionId&) const ; + QPID_COMMON_EXTERN bool operator==(const SessionId& id) const; + // Convert to a string + QPID_COMMON_EXTERN std::string str() const; +}; + +QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream&, const SessionId&); + + +} // namespace qpid + +#endif /*!QPID_SESSIONID_H*/ diff --git a/qpid/cpp/include/qpid/Url.h b/qpid/cpp/include/qpid/Url.h new file mode 100644 index 0000000000..d0f4bb0c22 --- /dev/null +++ b/qpid/cpp/include/qpid/Url.h @@ -0,0 +1,93 @@ +#ifndef QPID_URL_H +#define QPID_URL_H + +/* + * + * Copyright (c) 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "qpid/Address.h" +#include "qpid/Exception.h" +#include +#include +#include +#include +#include "qpid/CommonImportExport.h" + +namespace qpid { + +QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& os, const TcpAddress& a); + +/** An AMQP URL contains a list of addresses */ +struct Url : public std::vector
{ + + /** Url with the hostname as returned by gethostname(2) */ + static Url getHostNameUrl(uint16_t port); + + /** Url with local IP address(es), may be more than one address + * on a multi-homed host. */ + QPID_COMMON_EXTERN static Url getIpAddressesUrl(uint16_t port); + + struct Invalid : public Exception { Invalid(const std::string& s); }; + + /** Convert to string form. */ + QPID_COMMON_EXTERN std::string str() const; + + /** Empty URL. */ + Url() {} + + /** URL containing a single address */ + explicit Url(const Address& addr) { push_back(addr); } + + /** Parse url, throw Invalid if invalid. */ + explicit Url(const std::string& url) { parse(url.c_str()); } + + /** Parse url, throw Invalid if invalid. */ + explicit Url(const char* url) { parse(url); } + + Url& operator=(const Url& u) { this->std::vector
::operator=(u); cache=u.cache; return *this; } + Url& operator=(const char* s) { parse(s); return *this; } + Url& operator=(const std::string& s) { parse(s); return *this; } + + /** Throw Invalid if the URL does not contain any addresses. */ + QPID_COMMON_EXTERN void throwIfEmpty() const; + + /** Replace contents with parsed URL as defined in + * https://wiki.108.redhat.com/jira/browse/AMQP-95 + *@exception Invalid if the url is invalid. + */ + QPID_COMMON_EXTERN void parse(const char* url); + QPID_COMMON_EXTERN void parse(const std::string& url) { parse(url.c_str()); } + + /** Replace contesnts with parsed URL as defined in + * https://wiki.108.redhat.com/jira/browse/AMQP-95 + * url.empty() will be true if url is invalid. + */ + void parseNoThrow(const char* url); + + private: + mutable std::string cache; // cache string form for efficiency. +}; + +inline bool operator==(const Url& a, const Url& b) { return a.str()==b.str(); } +inline bool operator!=(const Url& a, const Url& b) { return a.str()!=b.str(); } + +QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& os, const Url& url); +QPID_COMMON_EXTERN std::istream& operator>>(std::istream& is, Url& url); + +} // namespace qpid + +#endif /*!QPID_URL_H*/ diff --git a/qpid/cpp/include/qpid/agent/ManagementAgent.h b/qpid/cpp/include/qpid/agent/ManagementAgent.h new file mode 100644 index 0000000000..1a8d0c4025 --- /dev/null +++ b/qpid/cpp/include/qpid/agent/ManagementAgent.h @@ -0,0 +1,163 @@ +#ifndef _qpid_agent_ManagementAgent_ +#define _qpid_agent_ManagementAgent_ + +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +#include "qpid/agent/QmfAgentImportExport.h" +#include "qpid/management/ManagementObject.h" +#include "qpid/management/ManagementEvent.h" +#include "qpid/management/Manageable.h" +#include "qpid/sys/Mutex.h" +#include "qpid/client/ConnectionSettings.h" + +namespace qpid { +namespace management { + +class ManagementAgent +{ + public: + + class Singleton { + public: + QMF_AGENT_EXTERN Singleton(bool disableManagement = false); + QMF_AGENT_EXTERN ~Singleton(); + QMF_AGENT_EXTERN static ManagementAgent* getInstance(); + private: + static sys::Mutex lock; + static bool disabled; + static int refCount; + static ManagementAgent* agent; + }; + + typedef enum { + SEV_EMERG = 0, + SEV_ALERT = 1, + SEV_CRIT = 2, + SEV_ERROR = 3, + SEV_WARN = 4, + SEV_NOTE = 5, + SEV_INFO = 6, + SEV_DEBUG = 7, + SEV_DEFAULT = 8 + } severity_t; + + ManagementAgent() {} + virtual ~ManagementAgent() {} + + virtual int getMaxThreads() = 0; + + // Connect to a management broker + // + // brokerHost - Hostname or IP address (dotted-quad) of broker. + // + // brokerPort - TCP port of broker. + // + // intervalSeconds - The interval (in seconds) that this agent shall use + // between broadcast updates to the broker. + // + // useExternalThread - If true, the thread of control used for callbacks + // must be supplied by the user of the object (via the + // pollCallbacks method). + // + // If false, callbacks shall be invoked on the management + // agent's thread. In this case, the callback implementations + // MUST be thread safe. + // + // storeFile - File where this process has read and write access. This + // file shall be used to store persistent state. + // + virtual void init(const std::string& brokerHost = "localhost", + uint16_t brokerPort = 5672, + uint16_t intervalSeconds = 10, + bool useExternalThread = false, + const std::string& storeFile = "", + const std::string& uid = "guest", + const std::string& pwd = "guest", + const std::string& mech = "PLAIN", + const std::string& proto = "tcp") = 0; + + virtual void init(const client::ConnectionSettings& settings, + uint16_t intervalSeconds = 10, + bool useExternalThread = false, + const std::string& storeFile = "") = 0; + + // Register a schema with the management agent. This is normally called by the + // package initializer generated by the management code generator. + // + virtual void + registerClass(const std::string& packageName, + const std::string& className, + uint8_t* md5Sum, + management::ManagementObject::writeSchemaCall_t schemaCall) = 0; + + virtual void + registerEvent(const std::string& packageName, + const std::string& eventName, + uint8_t* md5Sum, + management::ManagementEvent::writeSchemaCall_t schemaCall) = 0; + + // Add a management object to the agent. Once added, this object shall be visible + // in the greater management context. + // + // Please note that ManagementObject instances are not explicitly deleted from + // the management agent. When the core object represented by a management object + // is deleted, the "resourceDestroy" method on the management object must be called. + // It will then be reclaimed in due course by the management agent. + // + // Once a ManagementObject instance is added to the agent, the agent then owns the + // instance. The caller MUST NOT free the resources of the instance at any time. + // When it is no longer needed, invoke its "resourceDestroy" method and discard the + // pointer. This allows the management agent to report the deletion of the object + // in an orderly way. + // + virtual ObjectId addObject(ManagementObject* objectPtr, uint64_t persistId = 0) = 0; + + // + // + virtual void raiseEvent(const ManagementEvent& event, + severity_t severity = SEV_DEFAULT) = 0; + + // If "useExternalThread" was set to true in init, this method must + // be called to provide a thread for any pending method calls that have arrived. + // The method calls for ManagementObject instances shall be invoked synchronously + // during the execution of this method. + // + // callLimit may optionally be used to limit the number of callbacks invoked. + // if 0, no limit is imposed. + // + // The return value is the number of callbacks that remain queued after this + // call is complete. It can be used to determine whether or not further calls + // to pollCallbacks are necessary to clear the backlog. If callLimit is zero, + // the return value will also be zero. + // + virtual uint32_t pollCallbacks(uint32_t callLimit = 0) = 0; + + // If "useExternalThread" was set to true in the constructor, this method provides + // a standard file descriptor that can be used in a select statement to signal that + // there are method callbacks ready (i.e. that "pollCallbacks" will result in at + // least one method call). When this fd is ready-for-read, pollCallbacks may be + // invoked. Calling pollCallbacks shall reset the ready-to-read state of the fd. + // + virtual int getSignalFd() = 0; +}; + +}} + +#endif /*!_qpid_agent_ManagementAgent_*/ diff --git a/qpid/cpp/include/qpid/agent/QmfAgentImportExport.h b/qpid/cpp/include/qpid/agent/QmfAgentImportExport.h new file mode 100644 index 0000000000..9eee4a18fd --- /dev/null +++ b/qpid/cpp/include/qpid/agent/QmfAgentImportExport.h @@ -0,0 +1,33 @@ +#ifndef QMF_AGENT_IMPORT_EXPORT_H +#define QMF_AGENT_IMPORT_EXPORT_H + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#if defined(WIN32) && !defined(QPID_DECLARE_STATIC) +#if defined(QMF_AGENT_EXPORT) || defined (qmfagent_EXPORTS) +#define QMF_AGENT_EXTERN __declspec(dllexport) +#else +#define QMF_AGENT_EXTERN __declspec(dllimport) +#endif +#else +#define QMF_AGENT_EXTERN +#endif + +#endif diff --git a/qpid/cpp/include/qpid/client/AsyncSession.h b/qpid/cpp/include/qpid/client/AsyncSession.h new file mode 100644 index 0000000000..d91efeb4f1 --- /dev/null +++ b/qpid/cpp/include/qpid/client/AsyncSession.h @@ -0,0 +1,38 @@ +#ifndef QPID_CLIENT_ASYNCSESSION_H +#define QPID_CLIENT_ASYNCSESSION_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#include "qpid/client/AsyncSession_0_10.h" + +namespace qpid { +namespace client { + +/** + * AsyncSession is an alias for Session_0_10 + * + * \ingroup clientapi + */ +typedef AsyncSession_0_10 AsyncSession; + +}} // namespace qpid::client + +#endif /*!QPID_CLIENT_ASYNCSESSION_H*/ diff --git a/qpid/cpp/include/qpid/client/ClientImportExport.h b/qpid/cpp/include/qpid/client/ClientImportExport.h new file mode 100644 index 0000000000..42b02e33c3 --- /dev/null +++ b/qpid/cpp/include/qpid/client/ClientImportExport.h @@ -0,0 +1,33 @@ +#ifndef QPID_CLIENT_IMPORT_EXPORT_H +#define QPID_CLIENT_IMPORT_EXPORT_H + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#if defined(WIN32) && !defined(QPID_DECLARE_STATIC) +#if defined(CLIENT_EXPORT) || defined (qpidclient_EXPORTS) +#define QPID_CLIENT_EXTERN __declspec(dllexport) +#else +#define QPID_CLIENT_EXTERN __declspec(dllimport) +#endif +#else +#define QPID_CLIENT_EXTERN +#endif + +#endif diff --git a/qpid/cpp/include/qpid/client/Completion.h b/qpid/cpp/include/qpid/client/Completion.h new file mode 100644 index 0000000000..99d940f031 --- /dev/null +++ b/qpid/cpp/include/qpid/client/Completion.h @@ -0,0 +1,71 @@ +#ifndef QPID_CLIENT_COMPLETION_H +#define QPID_CLIENT_COMPLETION_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/client/Handle.h" +#include "qpid/client/ClientImportExport.h" +#include + +namespace qpid { +namespace client { + +class CompletionImpl; +template class PrivateImplRef; + +/** + * Asynchronous commands that do not return a result will return a + * Completion. You can use the completion to wait for that specific + * command to complete. + * + *@see TypedResult + * + *\ingroup clientapi + */ +class Completion : public Handle +{ +public: + QPID_CLIENT_EXTERN Completion(CompletionImpl* = 0); + QPID_CLIENT_EXTERN Completion(const Completion&); + QPID_CLIENT_EXTERN ~Completion(); + QPID_CLIENT_EXTERN Completion& operator=(const Completion&); + + /** Wait for the asynchronous command that returned this + *Completion to complete. + * + *@exception If the command returns an error. + */ + QPID_CLIENT_EXTERN void wait(); + QPID_CLIENT_EXTERN bool isComplete(); + + protected: + QPID_CLIENT_EXTERN std::string getResult(); + + private: + typedef CompletionImpl Impl; + friend class PrivateImplRef; +}; + +}} + + +#endif /*!QPID_CLIENT_COMPLETION_H*/ diff --git a/qpid/cpp/include/qpid/client/Connection.h b/qpid/cpp/include/qpid/client/Connection.h new file mode 100644 index 0000000000..b7b967d232 --- /dev/null +++ b/qpid/cpp/include/qpid/client/Connection.h @@ -0,0 +1,204 @@ +#ifndef QPID_CLIENT_CONNECTION_H +#define QPID_CLIENT_CONNECTION_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#include +#include +#include "qpid/client/Session.h" +#include "qpid/client/ClientImportExport.h" +#include "qpid/client/ConnectionSettings.h" +#include "qpid/framing/ProtocolVersion.h" + +namespace qpid { + +struct Url; + +namespace client { + +class ConnectionImpl; + +/** + * Represents a connection to an AMQP broker. All communication is + * initiated by establishing a connection, then creating one or more + * Session objects using the connection. @see newSession() + * + * \ingroup clientapi + * + */ +class Connection +{ + framing::ProtocolVersion version; + + boost::function failureCallback; + + + protected: + boost::shared_ptr impl; + + + public: + /** + * Creates a connection object, but does not open the connection. + * @see open() + */ + QPID_CLIENT_EXTERN Connection(); + + QPID_CLIENT_EXTERN ~Connection(); + + /** + * Opens a connection to a broker. + * + * @param host the host on which the broker is running. + * + * @param port the port on the which the broker is listening. + * + * @param uid the userid to connect with. + * + * @param pwd the password to connect with (currently SASL + * PLAIN is the only authentication method supported so this + * is sent in clear text). + * + * @param virtualhost the AMQP virtual host to use (virtual + * hosts, where implemented(!), provide namespace partitioning + * within a single broker). + */ + QPID_CLIENT_EXTERN void open(const std::string& host, int port = 5672, + const std::string& uid = "guest", + const std::string& pwd = "guest", + const std::string& virtualhost = "/", uint16_t maxFrameSize=65535); + + /** + * Opens a connection to a broker using a URL. + * If the URL contains multiple addresses, try each in turn + * till connection is successful. + * + * @url address of the broker to connect to. + * + * @param uid the userid to connect with. + * + * @param pwd the password to connect with (currently SASL + * PLAIN is the only authentication method supported so this + * is sent in clear text). + * + * @param virtualhost the AMQP virtual host to use (virtual + * hosts, where implemented(!), provide namespace partitioning + * within a single broker). + */ + QPID_CLIENT_EXTERN void open(const Url& url, + const std::string& uid = "guest", + const std::string& pwd = "guest", + const std::string& virtualhost = "/", uint16_t maxFrameSize=65535); + + /** + * Opens a connection to a broker using a URL. + * If the URL contains multiple addresses, try each in turn + * till connection is successful. + * + * @url address of the broker to connect to. + * + * @param settings used for any settings not provided by the URL. + * Settings provided by the url (e.g. host, port) are ignored. + */ + QPID_CLIENT_EXTERN void open(const Url& url, const ConnectionSettings& settings); + + /** + * Opens a connection to a broker. + * + * @param the settings to use (host, port etc). @see ConnectionSettings. + */ + QPID_CLIENT_EXTERN void open(const ConnectionSettings& settings); + + /** + * Close the connection. + * + * Any further use of this connection (without reopening it) will + * not succeed. + */ + QPID_CLIENT_EXTERN void close(); + + /** + * Create a new session on this connection. Sessions allow + * multiple streams of work to be multiplexed over the same + * connection. The returned Session provides functions to send + * commands to the broker. + * + * Session functions are synchronous. In other words, a Session + * function will send a command to the broker and does not return + * until it receives the broker's response confirming the command + * was executed. + * + * AsyncSession provides asynchronous versions of the same + * functions. These functions send a command to the broker but do + * not wait for a response. + * + * You can convert a Session s into an AsyncSession as follows: + * @code + * #include + * AsyncSession as = async(s); + * @endcode + * + * You can execute a single command asynchronously will a Session s + * like ths: + * @code + * async(s).messageTransfer(...); + * @endcode + * + * Using an AsyncSession is faster for sending large numbers of + * commands, since each command is sent as soon as possible + * without waiting for the previous command to be confirmed. + * + * However with AsyncSession you cannot assume that a command has + * completed until you explicitly synchronize. The simplest way to + * do this is to call Session::sync() or AsyncSession::sync(). + * Both of these functions wait for the broker to confirm all + * commands issued so far on the session. + * + *@param name: A name to identify the session. @see qpid::SessionId + * If the name is empty (the default) then a unique name will be + * chosen using a Universally-unique identifier (UUID) algorithm. + */ + QPID_CLIENT_EXTERN Session newSession(const std::string& name=std::string(), uint32_t timeoutSeconds = 0); + + /** + * Resume a suspended session. A session may be resumed + * on a different connection to the one that created it. + */ + QPID_CLIENT_EXTERN void resume(Session& session); + + QPID_CLIENT_EXTERN bool isOpen() const; + + QPID_CLIENT_EXTERN std::vector getKnownBrokers(); + QPID_CLIENT_EXTERN void registerFailureCallback ( boost::function fn ); + + /** + * Return the set of client negotiated settings + */ + QPID_CLIENT_EXTERN const ConnectionSettings& getNegotiatedSettings(); + + friend class ConnectionAccess; ///<@internal + friend class SessionBase_0_10; ///<@internal +}; + +}} // namespace qpid::client + + +#endif /*!QPID_CLIENT_CONNECTION_H*/ diff --git a/qpid/cpp/include/qpid/client/ConnectionSettings.h b/qpid/cpp/include/qpid/client/ConnectionSettings.h new file mode 100644 index 0000000000..46053e1fa8 --- /dev/null +++ b/qpid/cpp/include/qpid/client/ConnectionSettings.h @@ -0,0 +1,133 @@ +#ifndef QPID_CLIENT_CONNECTIONSETTINGS_H +#define QPID_CLIENT_CONNECTIONSETTINGS_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/Options.h" +#include "qpid/log/Options.h" +#include "qpid/Url.h" +#include "qpid/client/ClientImportExport.h" + +#include +#include + +namespace qpid { + +namespace sys { +class Socket; +} + +namespace client { + +/** + * Settings for a Connection. + */ +struct ConnectionSettings { + + QPID_CLIENT_EXTERN ConnectionSettings(); + QPID_CLIENT_EXTERN virtual ~ConnectionSettings(); + + /** + * Allows socket to be configured; default only sets tcp-nodelay + * based on the flag set. Can be overridden. + */ + QPID_CLIENT_EXTERN virtual void configureSocket(qpid::sys::Socket&) const; + + /** + * The protocol used for the connection (defaults to 'tcp') + */ + std::string protocol; + + /** + * The host (or ip address) to connect to (defaults to 'localhost'). + */ + std::string host; + /** + * The port to connect to (defaults to 5672). + */ + uint16_t port; + /** + * Allows an AMQP 'virtual host' to be specified for the + * connection. + */ + std::string virtualhost; + + /** + * The username to use when authenticating the connection. If not + * specified the current users login is used if available. + */ + std::string username; + /** + * The password to use when authenticating the connection. + */ + std::string password; + /** + * The SASL mechanism to use when authenticating the connection; + * the options are currently PLAIN or ANONYMOUS. + */ + std::string mechanism; + /** + * Allows a locale to be specified for the connection. + */ + std::string locale; + /** + * Allows a heartbeat frequency to be specified + */ + uint16_t heartbeat; + /** + * The maximum number of channels that the client will request for + * use on this connection. + */ + uint16_t maxChannels; + /** + * The maximum frame size that the client will request for this + * connection. + */ + uint16_t maxFrameSize; + /** + * Limit the size of the connections send buffer . The buffer + * is limited to bounds * maxFrameSize. + */ + uint bounds; + /** + * If true, TCP_NODELAY will be set for the connection. + */ + bool tcpNoDelay; + /** + * SASL service name + */ + std::string service; + /** + * Minimum acceptable strength of any SASL negotiated security + * layer. 0 means no security layer required. + */ + uint minSsf; + /** + * Maximum acceptable strength of any SASL negotiated security + * layer. 0 means no security layer allowed. + */ + uint maxSsf; +}; + +}} // namespace qpid::client + +#endif /*!QPID_CLIENT_CONNECTIONSETTINGS_H*/ diff --git a/qpid/cpp/include/qpid/client/FailoverManager.h b/qpid/cpp/include/qpid/client/FailoverManager.h new file mode 100644 index 0000000000..d50fcff8bb --- /dev/null +++ b/qpid/cpp/include/qpid/client/FailoverManager.h @@ -0,0 +1,135 @@ +#ifndef QPID_CLIENT_FAILOVERMANAGER_H +#define QPID_CLIENT_FAILOVERMANAGER_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/client/Connection.h" +#include "qpid/client/ConnectionSettings.h" +#include "qpid/Exception.h" +#include "qpid/client/AsyncSession.h" +#include "qpid/sys/Monitor.h" +#include "qpid/client/ClientImportExport.h" +#include + +namespace qpid { +namespace client { + +struct CannotConnectException : qpid::Exception +{ + CannotConnectException(const std::string& m) : qpid::Exception(m) {} +}; + +/** + * Utility to manage failover. + */ +class FailoverManager +{ + public: + /** + * Interface to implement for doing work that can be resumed on + * failover + */ + struct Command + { + /** + * This method will be called with isRetry=false when the + * command is first executed. The session to use for the work + * will be passed to the implementing class. If the connection + * fails while the execute call is in progress, the + * FailoverManager controlling the execution will re-establish + * a connection, open a new session and call back to the + * Command implementations execute method with the new session + * and isRetry=true. + */ + virtual void execute(AsyncSession& session, bool isRetry) = 0; + virtual ~Command() {} + }; + + struct ReconnectionStrategy + { + /** + * This method is called by the FailoverManager prior to + * establishing a connection (or re-connection) and can be + * used if the application wishes to edit or re-order the list + * which will default to the list of known brokers for the + * last connection. + */ + virtual void editUrlList(std::vector& urls) = 0; + virtual ~ReconnectionStrategy() {} + }; + + /** + * Create a manager to control failover for a logical connection. + * + * @param settings the initial connection settings + * @param strategy optional stratgey callback allowing application + * to edit or reorder the list of urls to which reconnection is + * attempted + */ + QPID_CLIENT_EXTERN FailoverManager(const ConnectionSettings& settings, ReconnectionStrategy* strategy = 0); + /** + * Return the current connection if open or attept to reconnect to + * the specified list of urls. If no list is specified the list of + * known brokers from the last connection will be used. If no list + * is specified and this is the first connect attempt, the host + * and port from the initial settings will be used. + * + * If the full list is tried and all attempts fail, + * CannotConnectException is thrown. + */ + QPID_CLIENT_EXTERN Connection& connect(std::vector brokers = std::vector()); + /** + * Return the current connection whether open or not + */ + QPID_CLIENT_EXTERN Connection& getConnection(); + /** + * Close the current connection + */ + QPID_CLIENT_EXTERN void close(); + /** + * Reliably execute the specified command. This involves creating + * a session on which to carry out the work of the command, + * handling failover occuring while exeuting that command and + * re-starting the work. + * + * Multiple concurrent threads can call execute with different + * commands; each thread will be allocated its own + * session. FailoverManager will coordinate the different threads + * on failover to ensure they continue to use the same logical + * connection. + */ + QPID_CLIENT_EXTERN void execute(Command&); + private: + enum State {IDLE, CONNECTING, CANT_CONNECT}; + + qpid::sys::Monitor lock; + Connection connection; + ConnectionSettings settings; + ReconnectionStrategy* strategy; + State state; + + void attempt(Connection&, ConnectionSettings settings, std::vector urls); + void attempt(Connection&, ConnectionSettings settings); +}; +}} // namespace qpid::client + +#endif /*!QPID_CLIENT_FAILOVERMANAGER_H*/ diff --git a/qpid/cpp/include/qpid/client/FlowControl.h b/qpid/cpp/include/qpid/client/FlowControl.h new file mode 100644 index 0000000000..bff7071b3b --- /dev/null +++ b/qpid/cpp/include/qpid/client/FlowControl.h @@ -0,0 +1,75 @@ +#ifndef QPID_CLIENT_FLOWCONTROL_H +#define QPID_CLIENT_FLOWCONTROL_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include + +namespace qpid { +namespace client { + +/** + * Flow control works by associating a finite amount of "credit" + * with a subscription. + * + * Credit includes a message count and a byte count. Each message + * received decreases the message count by one, and the byte count by + * the size of the message. Either count can have the special value + * UNLIMITED which is never decreased. + * + * A subscription's credit is exhausted when the message count is 0 or + * the byte count is too small for the next available message. The + * subscription will not receive any further messages until is credit + * is renewed. + * + * In "window mode" credit is automatically renewed when a message is + * completed (which by default happens when it is accepted). In + * non-window mode credit is not automatically renewed, it must be + * explicitly re-set (@see Subscription) + */ +struct FlowControl { + static const uint32_t UNLIMITED=0xFFFFFFFF; + FlowControl(uint32_t messages_=0, uint32_t bytes_=0, bool window_=false) + : messages(messages_), bytes(bytes_), window(window_) {} + + static FlowControl messageCredit(uint32_t messages_) { return FlowControl(messages_,UNLIMITED,false); } + static FlowControl messageWindow(uint32_t messages_) { return FlowControl(messages_,UNLIMITED,true); } + static FlowControl byteCredit(uint32_t bytes_) { return FlowControl(UNLIMITED,bytes_,false); } + static FlowControl byteWindow(uint32_t bytes_) { return FlowControl(UNLIMITED,bytes_,true); } + static FlowControl unlimited() { return FlowControl(UNLIMITED, UNLIMITED, false); } + static FlowControl zero() { return FlowControl(0, 0, false); } + + /** Message credit: subscription can accept up to this many messages. */ + uint32_t messages; + /** Byte credit: subscription can accept up to this many bytes of message content. */ + uint32_t bytes; + /** Window mode. If true credit is automatically renewed as messages are acknowledged. */ + bool window; + + bool operator==(const FlowControl& x) { + return messages == x.messages && bytes == x.bytes && window == x.window; + }; +}; + +}} // namespace qpid::client + +#endif /*!QPID_CLIENT_FLOWCONTROL_H*/ diff --git a/qpid/cpp/include/qpid/client/Future.h b/qpid/cpp/include/qpid/client/Future.h new file mode 100644 index 0000000000..09088e68f6 --- /dev/null +++ b/qpid/cpp/include/qpid/client/Future.h @@ -0,0 +1,59 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#ifndef _Future_ +#define _Future_ + +#include +#include +#include "qpid/Exception.h" +#include "qpid/framing/SequenceNumber.h" +#include "qpid/client/FutureCompletion.h" +#include "qpid/client/FutureResult.h" +#include "qpid/client/ClientImportExport.h" + +namespace qpid { +namespace client { + +/**@internal */ +class Future +{ + framing::SequenceNumber command; + boost::shared_ptr result; + bool complete; + +public: + Future() : complete(false) {} + Future(const framing::SequenceNumber& id) : command(id), complete(false) {} + + std::string getResult(SessionImpl& session) { + if (result) return result->getResult(session); + else throw Exception("Result not expected"); + } + + QPID_CLIENT_EXTERN void wait(SessionImpl& session); + QPID_CLIENT_EXTERN bool isComplete(SessionImpl& session); + QPID_CLIENT_EXTERN void setFutureResult(boost::shared_ptr r); +}; + +}} + +#endif diff --git a/qpid/cpp/include/qpid/client/FutureCompletion.h b/qpid/cpp/include/qpid/client/FutureCompletion.h new file mode 100644 index 0000000000..0970f494b7 --- /dev/null +++ b/qpid/cpp/include/qpid/client/FutureCompletion.h @@ -0,0 +1,49 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#ifndef _FutureCompletion_ +#define _FutureCompletion_ + +#include "qpid/framing/amqp_framing.h" +#include "qpid/sys/Monitor.h" + +namespace qpid { +namespace client { + +///@internal +class FutureCompletion +{ +protected: + mutable sys::Monitor lock; + bool complete; + +public: + FutureCompletion(); + virtual ~FutureCompletion(){} + bool isComplete() const; + void waitForCompletion() const; + void completed(); +}; + +}} + + +#endif diff --git a/qpid/cpp/include/qpid/client/FutureResult.h b/qpid/cpp/include/qpid/client/FutureResult.h new file mode 100644 index 0000000000..b2b663daa1 --- /dev/null +++ b/qpid/cpp/include/qpid/client/FutureResult.h @@ -0,0 +1,49 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#ifndef _FutureResult_ +#define _FutureResult_ + +#include + +#include "qpid/client/ClientImportExport.h" +#include "qpid/framing/amqp_framing.h" +#include "qpid/client/FutureCompletion.h" + +namespace qpid { +namespace client { + +class SessionImpl; + +///@internal +class FutureResult : public FutureCompletion +{ + std::string result; +public: + QPID_CLIENT_EXTERN const std::string& getResult(SessionImpl& session) const; + void received(const std::string& result); +}; + +}} + + + +#endif diff --git a/qpid/cpp/include/qpid/client/Handle.h b/qpid/cpp/include/qpid/client/Handle.h new file mode 100644 index 0000000000..088e836fcf --- /dev/null +++ b/qpid/cpp/include/qpid/client/Handle.h @@ -0,0 +1,71 @@ +#ifndef QPID_CLIENT_HANDLE_H +#define QPID_CLIENT_HANDLE_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/client/ClientImportExport.h" + +namespace qpid { +namespace client { + +template class PrivateImplRef; + +/** + * A handle is like a pointer: refers to an underlying implementation object. + * Copying the handle does not copy the object. + * + * Handles can be null, like a 0 pointer. Use isValid(), isNull() or the + * conversion to bool to test for a null handle. + */ +template class Handle { + public: + + /**@return true if handle is valid, i.e. not null. */ + QPID_CLIENT_EXTERN bool isValid() const { return impl; } + + /**@return true if handle is null. It is an error to call any function on a null handle. */ + QPID_CLIENT_EXTERN bool isNull() const { return !impl; } + + /** Conversion to bool supports idiom if (handle) { handle->... } */ + QPID_CLIENT_EXTERN operator bool() const { return impl; } + + /** Operator ! supports idiom if (!handle) { do_if_handle_is_null(); } */ + QPID_CLIENT_EXTERN bool operator !() const { return !impl; } + + void swap(Handle& h) { T* t = h.impl; h.impl = impl; impl = t; } + + protected: + typedef T Impl; + QPID_CLIENT_EXTERN Handle() :impl() {} + + // Not implemented,subclasses must implement. + QPID_CLIENT_EXTERN Handle(const Handle&); + QPID_CLIENT_EXTERN Handle& operator=(const Handle&); + + Impl* impl; + + friend class PrivateImplRef; // FIXME aconway 2009-04-30: Specify +}; + +}} // namespace qpid::client + +#endif /*!QPID_CLIENT_HANDLE_H*/ diff --git a/qpid/cpp/include/qpid/client/LocalQueue.h b/qpid/cpp/include/qpid/client/LocalQueue.h new file mode 100644 index 0000000000..70e4cebcf1 --- /dev/null +++ b/qpid/cpp/include/qpid/client/LocalQueue.h @@ -0,0 +1,120 @@ +#ifndef QPID_CLIENT_LOCALQUEUE_H +#define QPID_CLIENT_LOCALQUEUE_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/client/ClientImportExport.h" +#include "qpid/client/Handle.h" +#include "qpid/client/Message.h" +#include "qpid/sys/Time.h" + +namespace qpid { +namespace client { + +class LocalQueueImpl; +template class PrivateImplRef; + +/** + * A local queue to collect messages retrieved from a remote broker + * queue. Create a queue and subscribe it using the SubscriptionManager. + * Messages from the remote queue on the broker will be stored in the + * local queue until you retrieve them. + * + * \ingroup clientapi + * + * \details Using a Local Queue + * + *
+ * LocalQueue local_queue;
+ * subscriptions.subscribe(local_queue, string("message_queue"));
+ * for (int i=0; i<10; i++) {
+ *   Message message = local_queue.get();
+ *   std::cout << message.getData() << std::endl;
+ * }
+ * 
+ * + *

Getting Messages

+ * + *
  • + *

    get()

    + *
    Message message = local_queue.get();
    + *
    // Specifying timeouts (TIME_SEC, TIME_MSEC, TIME_USEC, TIME_NSEC)
    + *#include 
    + *Message message;
    + *local_queue.get(message, 5*sys::TIME_SEC);
+ * + *

Checking size

+ *
  • + *

    empty()

    + *
    if (local_queue.empty()) { ... }
  • + *
  • size()

    + *
    std::cout << local_queue.size();
  • + *
+ */ + +class LocalQueue : public Handle { + public: + /** Create a local queue. Subscribe the local queue to a remote broker + * queue with a SubscriptionManager. + * + * LocalQueue is an alternative to implementing a MessageListener. + */ + QPID_CLIENT_EXTERN LocalQueue(); + QPID_CLIENT_EXTERN LocalQueue(const LocalQueue&); + QPID_CLIENT_EXTERN ~LocalQueue(); + QPID_CLIENT_EXTERN LocalQueue& operator=(const LocalQueue&); + + /** Wait up to timeout for the next message from the local queue. + *@param result Set to the message from the queue. + *@param timeout wait up this timeout for a message to appear. + *@return true if result was set, false if queue was empty after timeout. + */ + QPID_CLIENT_EXTERN bool get(Message& result, sys::Duration timeout=0); + + /** Get the next message off the local queue, or wait up to the timeout + * for message from the broker queue. + *@param timeout wait up this timeout for a message to appear. + *@return message from the queue. + *@throw ClosedException if subscription is closed or timeout exceeded. + */ + QPID_CLIENT_EXTERN Message get(sys::Duration timeout=sys::TIME_INFINITE); + + /** Synonym for get() */ + QPID_CLIENT_EXTERN Message pop(sys::Duration timeout=sys::TIME_INFINITE); + + /** Return true if local queue is empty. */ + QPID_CLIENT_EXTERN bool empty() const; + + /** Number of messages on the local queue */ + QPID_CLIENT_EXTERN size_t size() const; + + LocalQueue(LocalQueueImpl*); ///<@internal + + + private: + typedef LocalQueueImpl Impl; + friend class PrivateImplRef; +}; + +}} // namespace qpid::client + +#endif /*!QPID_CLIENT_LOCALQUEUE_H*/ diff --git a/qpid/cpp/include/qpid/client/Message.h b/qpid/cpp/include/qpid/client/Message.h new file mode 100644 index 0000000000..2401cbdc92 --- /dev/null +++ b/qpid/cpp/include/qpid/client/Message.h @@ -0,0 +1,175 @@ +#ifndef QPID_CLIENT_MESSAGE_H +#define QPID_CLIENT_MESSAGE_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/client/ClientImportExport.h" +#include "qpid/framing/MessageProperties.h" +#include "qpid/framing/DeliveryProperties.h" +#include + +namespace qpid { + +namespace framing { +class FieldTable; +class SequenceNumber; // FIXME aconway 2009-04-17: remove with getID? +} + +namespace client { + +class MessageImpl; + +/** + * A message sent to or received from the broker. + * + * \ingroup clientapi + * \details + * + *

Getting and setting message contents

+ * + *
    + *
  • + *

    getData()

    + *
    std::cout << "Response: " << message.getData() << std::endl;
    + *
  • + *
  • + *

    setData()

    + *
    message.setData("That's all, folks!");
  • + *
  • + *

    appendData()

    + *
    message.appendData(" ... let's add a bit more ...");
  • + *
+ * + *

Getting and Setting Delivery Properties

+ * + *
    + *
  • + *

    getDeliveryProperties()

    + *
    message.getDeliveryProperties().setRoutingKey("control");
    + *
    message.getDeliveryProperties().setDeliveryMode(PERSISTENT);
    + *
    message.getDeliveryProperties().setPriority(9);
    + *
    message.getDeliveryProperties().setTtl(100);
  • + * + *
  • + *

    hasDeliveryProperties()

    + *
    if (! message.hasDeliveryProperties()) {
    + *  ...
    + *}
  • + *
+ * + *

Getting and Setting Message Properties

+ * + *
    + *
  • + *

    getMessageProperties()

    + *
    + *request.getMessageProperties().setReplyTo(ReplyTo("amq.direct", response_queue.str()));
    + * 
    + *
    + *routingKey = request.getMessageProperties().getReplyTo().getRoutingKey();
    + *exchange = request.getMessageProperties().getReplyTo().getExchange();
    + * 
    + *
    message.getMessageProperties().setContentType("text/plain");
    + *
    message.getMessageProperties().setContentEncoding("text/plain");
    + *
  • + *
  • + *

    hasMessageProperties()

    + *
    request.getMessageProperties().hasReplyTo();
    + *
  • + *
+ * + *

Getting and Setting Application Headers

+ * + *
    + *
  • + *

    getHeaders()

    + *
    + *message.getHeaders().getString("control");
    + * 
    + *
    + *message.getHeaders().setString("control","continue");
    + * 
  • + *
+ * + * + */ +class Message +{ +public: + /** Create a Message. + *@param data Data for the message body. + *@param routingKey Passed to the exchange that routes the message. + */ + QPID_CLIENT_EXTERN Message( + const std::string& data=std::string(), + const std::string& routingKey=std::string()); + Message(MessageImpl*); ///< @internal + QPID_CLIENT_EXTERN Message(const Message&); + QPID_CLIENT_EXTERN ~Message(); + QPID_CLIENT_EXTERN Message& operator=(const Message&); + QPID_CLIENT_EXTERN void swap(Message&); + + QPID_CLIENT_EXTERN void setData(const std::string&); + QPID_CLIENT_EXTERN const std::string& getData() const; + QPID_CLIENT_EXTERN std::string& getData(); + + QPID_CLIENT_EXTERN void appendData(const std::string&); + + QPID_CLIENT_EXTERN bool hasMessageProperties() const; + QPID_CLIENT_EXTERN framing::MessageProperties& getMessageProperties(); + QPID_CLIENT_EXTERN const framing::MessageProperties& getMessageProperties() const; + + QPID_CLIENT_EXTERN bool hasDeliveryProperties() const; + QPID_CLIENT_EXTERN framing::DeliveryProperties& getDeliveryProperties(); + QPID_CLIENT_EXTERN const framing::DeliveryProperties& getDeliveryProperties() const; + + + /** The destination of messages sent to the broker is the exchange + * name. The destination of messages received from the broker is + * the delivery tag identifyig the local subscription (often this + * is the name of the subscribed queue.) + */ + QPID_CLIENT_EXTERN std::string getDestination() const; + + /** Check the redelivered flag. */ + QPID_CLIENT_EXTERN bool isRedelivered() const; + /** Set the redelivered flag. */ + QPID_CLIENT_EXTERN void setRedelivered(bool redelivered); + + /** Get a modifyable reference to the message headers. */ + QPID_CLIENT_EXTERN framing::FieldTable& getHeaders(); + + /** Get a non-modifyable reference to the message headers. */ + QPID_CLIENT_EXTERN const framing::FieldTable& getHeaders() const; + + // FIXME aconway 2009-04-17: does this need to be in public API? + ///@internal + QPID_CLIENT_EXTERN const framing::SequenceNumber& getId() const; + + private: + MessageImpl* impl; + friend class MessageImpl; // Helper template for implementation +}; + +}} + +#endif /*!QPID_CLIENT_MESSAGE_H*/ diff --git a/qpid/cpp/include/qpid/client/MessageListener.h b/qpid/cpp/include/qpid/client/MessageListener.h new file mode 100644 index 0000000000..d200f8cf21 --- /dev/null +++ b/qpid/cpp/include/qpid/client/MessageListener.h @@ -0,0 +1,101 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#include +#include "qpid/client/ClientImportExport.h" + +#ifndef _MessageListener_ +#define _MessageListener_ + +#include "qpid/client/Message.h" + +namespace qpid { +namespace client { + + /** + * Implement a subclass of MessageListener and subscribe it using + * the SubscriptionManager to receive messages. + * + * Another way to receive messages is by using a LocalQueue. + * + * \ingroup clientapi + * \details + * + *

Using a MessageListener

+ * + *
    + *
  • + *

    The received() function is called when a message arrives:

    + *
    virtual void received(Message& message)=0;
    + *
  • + *
  • + *

    Derive your own listener, implement the received() function:

    + *
    +     * class Listener : public MessageListener {
    +     *  private:
    +     *    SubscriptionManager& subscriptions;
    +     *  public:
    +     *    Listener(SubscriptionManager& subscriptions);
    +     *    virtual void received(Message& message);
    +     * };
    +     *
    +     * Listener::Listener(SubscriptionManager& subs) : subscriptions(subs)
    +     * {}
    +     *
    +     * void Listener::received(Message& message) {
    +     *   std::cout << "Message: " << message.getData() << std::endl;
    +     *   if (message.getData() == "That's all, folks!") {
    +     *       std::cout << "Shutting down listener for " << message.getDestination()
    +     *                << std::endl;
    +     *       subscriptions.cancel(message.getDestination());
    +     *   }
    +     * }
    +     *
    + *
    +     * SubscriptionManager subscriptions(session);
    +     *
    +     * // Create a listener and subscribe it to the queue named "message_queue"
    +     * Listener listener(subscriptions);
    +     * subscriptions.subscribe(listener, "message_queue");
    +     *
    +     * // Receive messages until the subscription is cancelled
    +     * // by Listener::received()
    +     * subscriptions.run();
    +     * 
    + *
  • + *
+ * + */ + + class MessageListener{ + public: + QPID_CLIENT_EXTERN virtual ~MessageListener(); + + /** Called for each message arriving from the broker. Override + * in your own subclass to process messages. + */ + virtual void received(Message& msg) = 0; + }; + +} +} + + +#endif diff --git a/qpid/cpp/include/qpid/client/MessageReplayTracker.h b/qpid/cpp/include/qpid/client/MessageReplayTracker.h new file mode 100644 index 0000000000..6f5a0f4ac3 --- /dev/null +++ b/qpid/cpp/include/qpid/client/MessageReplayTracker.h @@ -0,0 +1,73 @@ +#ifndef QPID_CLIENT_MESSAGEREPLAYTRACKER_H +#define QPID_CLIENT_MESSAGEREPLAYTRACKER_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#include "qpid/client/AsyncSession.h" +#include "qpid/client/Message.h" +#include "qpid/client/ClientImportExport.h" +#include +#include + +namespace qpid { +namespace client { + +/** + * Utility to track messages sent asynchronously, allowing those that + * are indoubt to be replayed over a new session. + */ +class MessageReplayTracker +{ + public: + QPID_CLIENT_EXTERN MessageReplayTracker(uint flushInterval); + QPID_CLIENT_EXTERN void send(const Message& message, const std::string& destination = ""); + QPID_CLIENT_EXTERN void init(AsyncSession session); + QPID_CLIENT_EXTERN void replay(AsyncSession session); + QPID_CLIENT_EXTERN void setFlushInterval(uint interval); + QPID_CLIENT_EXTERN uint getFlushInterval(); + QPID_CLIENT_EXTERN void checkCompletion(); + + template void foreach(F& f) { + for (std::list::const_iterator i = buffer.begin(); i != buffer.end(); i++) { + f(i->message); + } + } + + private: + struct ReplayRecord + { + Completion status; + Message message; + std::string destination; + + ReplayRecord(const Message& message, const std::string& destination); + void send(MessageReplayTracker&); + bool isComplete(); + }; + + AsyncSession session; + uint flushInterval; + uint count; + std::list buffer; +}; +}} // namespace qpid::client + +#endif /*!QPID_CLIENT_MESSAGEREPLAYTRACKER_H*/ diff --git a/qpid/cpp/include/qpid/client/QueueOptions.h b/qpid/cpp/include/qpid/client/QueueOptions.h new file mode 100644 index 0000000000..9418cb092d --- /dev/null +++ b/qpid/cpp/include/qpid/client/QueueOptions.h @@ -0,0 +1,114 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/client/ClientImportExport.h" +#include "qpid/framing/FieldTable.h" + +#ifndef _QueueOptions_ +#define _QueueOptions_ + +namespace qpid { +namespace client { + +enum QueueSizePolicy {NONE, REJECT, FLOW_TO_DISK, RING, RING_STRICT}; +enum QueueOrderingPolicy {FIFO, LVQ, LVQ_NO_BROWSE}; + +/** + * A help class to set options on the Queue. Create a configured args while + * still allowing any custom configuration via the FieldTable base class + */ +class QueueOptions: public framing::FieldTable +{ + public: + QPID_CLIENT_EXTERN QueueOptions(); + QPID_CLIENT_EXTERN virtual ~QueueOptions(); + + /** + * Sets the queue sizing policy + * + * @param sp SizePolicy + * REJECT - reject if queue greater than size/count + * FLOW_TO_DISK - page messages to disk from this point is greater than size/count + * RING - limit the queue to size/count and over-write old messages round a ring + * RING_STRICT - limit the queue to size/count and reject is head == tail + * NONE - Use default broker sizing policy + * @param maxSize Set the max number of bytes for the sizing policies + * @param setMaxCount Set the max number of messages for the sizing policies + */ + QPID_CLIENT_EXTERN void setSizePolicy(QueueSizePolicy sp, uint64_t maxSize, uint32_t maxCount ); + + /** + * Enables the persisting of a queue to the store module when a cluster fails down to it's last + * node. Does so optimistically. Will start persisting when cluster count >1 again. + */ + QPID_CLIENT_EXTERN void setPersistLastNode(); + + /** + * Sets the odering policy on the Queue, default ordering is FIFO. + */ + QPID_CLIENT_EXTERN void setOrdering(QueueOrderingPolicy op); + + /** + * Use broker defualt sizing ploicy + */ + QPID_CLIENT_EXTERN void clearSizePolicy(); + + /** + * Clear Persist Last Node Policy + */ + QPID_CLIENT_EXTERN void clearPersistLastNode(); + + /** + * get the key used match LVQ in args for message transfer + */ + QPID_CLIENT_EXTERN void getLVQKey(std::string& key); + + /** + * Use default odering policy + */ + QPID_CLIENT_EXTERN void clearOrdering(); + + /** + * Turns on event generation for this queue (either enqueue only + * or for enqueue and dequeue events); the events can then be + * processed by a regsitered broker plugin. + */ + QPID_CLIENT_EXTERN void enableQueueEvents(bool enqueueOnly); + + static QPID_CLIENT_EXTERN const std::string strMaxCountKey; + static QPID_CLIENT_EXTERN const std::string strMaxSizeKey; + static QPID_CLIENT_EXTERN const std::string strTypeKey; + static QPID_CLIENT_EXTERN const std::string strREJECT; + static QPID_CLIENT_EXTERN const std::string strFLOW_TO_DISK; + static QPID_CLIENT_EXTERN const std::string strRING; + static QPID_CLIENT_EXTERN const std::string strRING_STRICT; + static QPID_CLIENT_EXTERN const std::string strLastValueQueue; + static QPID_CLIENT_EXTERN const std::string strPersistLastNode; + static QPID_CLIENT_EXTERN const std::string strLVQMatchProperty; + static QPID_CLIENT_EXTERN const std::string strLastValueQueueNoBrowse; + static QPID_CLIENT_EXTERN const std::string strQueueEventMode; +}; + +} +} + + +#endif diff --git a/qpid/cpp/include/qpid/client/Session.h b/qpid/cpp/include/qpid/client/Session.h new file mode 100644 index 0000000000..c40549bbc5 --- /dev/null +++ b/qpid/cpp/include/qpid/client/Session.h @@ -0,0 +1,39 @@ +#ifndef QPID_CLIENT_SESSION_H +#define QPID_CLIENT_SESSION_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#include "qpid/client/Session_0_10.h" + +namespace qpid { +namespace client { + +/** + * Session is an alias for Session_0_10 + * + * \ingroup clientapi + */ +typedef Session_0_10 Session; + + +}} // namespace qpid::client + +#endif /*!QPID_CLIENT_SESSION_H*/ diff --git a/qpid/cpp/include/qpid/client/SessionBase_0_10.h b/qpid/cpp/include/qpid/client/SessionBase_0_10.h new file mode 100644 index 0000000000..afa458bcee --- /dev/null +++ b/qpid/cpp/include/qpid/client/SessionBase_0_10.h @@ -0,0 +1,109 @@ +#ifndef QPID_CLIENT_SESSIONBASE_H +#define QPID_CLIENT_SESSIONBASE_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/SessionId.h" +#include "qpid/framing/amqp_structs.h" +#include "qpid/client/Message.h" +#include "qpid/client/Completion.h" +#include "qpid/client/TypedResult.h" +#include "qpid/client/ClientImportExport.h" +#include + +namespace qpid { +namespace client { + +class Connection; +class SessionImpl; + +using std::string; +using framing::Content; +using framing::FieldTable; +using framing::SequenceNumber; +using framing::SequenceSet; +using framing::SequenceNumberSet; +using qpid::SessionId; +using framing::Xid; + +/** Unit of message credit: messages or bytes */ +enum CreditUnit { MESSAGE_CREDIT=0, BYTE_CREDIT=1, UNLIMITED_CREDIT=0xFFFFFFFF }; + +/** + * Base class for handles to an AMQP session. + * + * Subclasses provide the AMQP commands for a given + * version of the protocol. + */ +class SessionBase_0_10 { + public: + + ///@internal + QPID_CLIENT_EXTERN SessionBase_0_10(); + QPID_CLIENT_EXTERN ~SessionBase_0_10(); + + /** Get the session ID */ + QPID_CLIENT_EXTERN SessionId getId() const; + + /** Close the session. + * A session is automatically closed when all handles to it are destroyed. + */ + QPID_CLIENT_EXTERN void close(); + + /** + * Synchronize the session: sync() waits until all commands issued + * on this session so far have been completed by the broker. + * + * Note sync() is always synchronous, even on an AsyncSession object + * because that's almost always what you want. You can call + * AsyncSession::executionSync() directly in the unusual event + * that you want to do an asynchronous sync. + */ + QPID_CLIENT_EXTERN void sync(); + + /** Set the timeout for this session. */ + QPID_CLIENT_EXTERN uint32_t timeout(uint32_t seconds); + + /** Suspend the session - detach it from its connection */ + QPID_CLIENT_EXTERN void suspend(); + + /** Resume a suspended session with a new connection */ + QPID_CLIENT_EXTERN void resume(Connection); + + /** Get the channel associated with this session */ + QPID_CLIENT_EXTERN uint16_t getChannel() const; + + QPID_CLIENT_EXTERN void flush(); + QPID_CLIENT_EXTERN void markCompleted(const framing::SequenceSet& ids, bool notifyPeer); + QPID_CLIENT_EXTERN void markCompleted(const framing::SequenceNumber& id, bool cumulative, bool notifyPeer); + QPID_CLIENT_EXTERN void sendCompletion(); + + QPID_CLIENT_EXTERN bool isValid() const; + + protected: + boost::shared_ptr impl; + friend class SessionBase_0_10Access; +}; + +}} // namespace qpid::client + +#endif /*!QPID_CLIENT_SESSIONBASE_H*/ diff --git a/qpid/cpp/include/qpid/client/Subscription.h b/qpid/cpp/include/qpid/client/Subscription.h new file mode 100644 index 0000000000..425b6b92e2 --- /dev/null +++ b/qpid/cpp/include/qpid/client/Subscription.h @@ -0,0 +1,123 @@ +#ifndef QPID_CLIENT_SUBSCRIPTION_H +#define QPID_CLIENT_SUBSCRIPTION_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/client/Handle.h" +#include "qpid/client/Session.h" +#include "qpid/client/SubscriptionSettings.h" +#include "qpid/client/Message.h" +#include "qpid/client/ClientImportExport.h" + +namespace qpid { +namespace client { + +template class PrivateImplRef; +class SubscriptionImpl; +class SubscriptionManager; + +/** + * A handle to an active subscription. Provides methods to query the subscription status + * and control acknowledgement (acquire and accept) of messages. + */ +class Subscription : public Handle { + public: + QPID_CLIENT_EXTERN Subscription(SubscriptionImpl* = 0); + QPID_CLIENT_EXTERN Subscription(const Subscription&); + QPID_CLIENT_EXTERN ~Subscription(); + QPID_CLIENT_EXTERN Subscription& operator=(const Subscription&); + + + /** The name of the subscription, used as the "destination" for messages from the broker. + * Usually the same as the queue name but can be set differently. + */ + QPID_CLIENT_EXTERN std::string getName() const; + + /** Name of the queue this subscription subscribes to */ + QPID_CLIENT_EXTERN std::string getQueue() const; + + /** Get the flow control and acknowledgement settings for this subscription */ + QPID_CLIENT_EXTERN const SubscriptionSettings& getSettings() const; + + /** Set the flow control parameters */ + QPID_CLIENT_EXTERN void setFlowControl(const FlowControl&); + + /** Automatically acknowledge (acquire and accept) batches of n messages. + * You can disable auto-acknowledgement by setting n=0, and use acquire() and accept() + * to manually acquire and accept messages. + */ + QPID_CLIENT_EXTERN void setAutoAck(unsigned int n); + + /** Get the set of ID's for messages received by this subscription but not yet acquired. + * This will always be empty if getSettings().acquireMode=ACQUIRE_MODE_PRE_ACQUIRED + */ + QPID_CLIENT_EXTERN SequenceSet getUnacquired() const; + + /** Get the set of ID's for messages received by this subscription but not yet accepted. */ + QPID_CLIENT_EXTERN SequenceSet getUnaccepted() const; + + /** Acquire messageIds and remove them from the unacquired set. + * oAdd them to the unaccepted set if getSettings().acceptMode == ACCEPT_MODE_EXPLICIT. + */ + QPID_CLIENT_EXTERN void acquire(const SequenceSet& messageIds); + + /** Accept messageIds and remove them from the unaccepted set. + *@pre messageIds is a subset of getUnaccepted() + */ + QPID_CLIENT_EXTERN void accept(const SequenceSet& messageIds); + + /** Release messageIds and remove them from the unaccepted set. + *@pre messageIds is a subset of getUnaccepted() + */ + QPID_CLIENT_EXTERN void release(const SequenceSet& messageIds); + + /* Acquire a single message */ + QPID_CLIENT_EXTERN void acquire(const Message& m) { acquire(SequenceSet(m.getId())); } + + /* Accept a single message */ + QPID_CLIENT_EXTERN void accept(const Message& m) { accept(SequenceSet(m.getId())); } + + /* Release a single message */ + QPID_CLIENT_EXTERN void release(const Message& m) { release(SequenceSet(m.getId())); } + + /** Get the session associated with this subscription */ + QPID_CLIENT_EXTERN Session getSession() const; + + /** Get the subscription manager associated with this subscription */ + QPID_CLIENT_EXTERN SubscriptionManager getSubscriptionManager(); + + /** Cancel the subscription. */ + QPID_CLIENT_EXTERN void cancel(); + + /** Grant the specified amount of message credit */ + QPID_CLIENT_EXTERN void grantMessageCredit(uint32_t); + + /** Grant the specified amount of byte credit */ + QPID_CLIENT_EXTERN void grantByteCredit(uint32_t); + + private: + friend class PrivateImplRef; + friend class SubscriptionManager; +}; +}} // namespace qpid::client + +#endif /*!QPID_CLIENT_SUBSCRIPTION_H*/ diff --git a/qpid/cpp/include/qpid/client/SubscriptionManager.h b/qpid/cpp/include/qpid/client/SubscriptionManager.h new file mode 100644 index 0000000000..632efe0f70 --- /dev/null +++ b/qpid/cpp/include/qpid/client/SubscriptionManager.h @@ -0,0 +1,286 @@ +#ifndef QPID_CLIENT_SUBSCRIPTIONMANAGER_H +#define QPID_CLIENT_SUBSCRIPTIONMANAGER_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/client/Session.h" +#include "qpid/client/Subscription.h" +#include "qpid/sys/Runnable.h" +#include "qpid/sys/Thread.h" +#include "qpid/client/ClientImportExport.h" +#include "qpid/client/MessageListener.h" +#include "qpid/client/LocalQueue.h" +#include "qpid/client/Handle.h" +#include + +namespace qpid { +namespace client { + +class SubscriptionManagerImpl; + +/** + * A class to help create and manage subscriptions. + * + * Set up your subscriptions, then call run() to have messages + * delivered. + * + * \ingroup clientapi + * + * \details + * + *

Subscribing and canceling subscriptions

+ * + *
    + *
  • + *

    subscribe()

    + *
     SubscriptionManager subscriptions(session);
    + * Listener listener(subscriptions);
    + * subscriptions.subscribe(listener, myQueue);
    + *
     SubscriptionManager subscriptions(session);
    + * LocalQueue local_queue;
    + * subscriptions.subscribe(local_queue, string("message_queue"));
  • + *
  • + *

    cancel()

    + *
    subscriptions.cancel();
  • + *
+ * + *

Waiting for messages (and returning)

+ * + *
    + *
  • + *

    run()

    + *
     // Give up control to receive messages
    + * subscriptions.run();
  • + *
  • + *

    stop()

    + *
    .// Use this code in a listener to return from run()
    + * subscriptions.stop();
  • + *
  • + *

    setAutoStop()

    + *
    .// Return from subscriptions.run() when last subscription is cancelled
    + *.subscriptions.setAutoStop(true);
    + *.subscriptons.run();
    + * 
  • + *
  • + *

    Ending a subscription in a listener

    + *
    + * void Listener::received(Message& message) {
    + *
    + *  if (message.getData() == "That's all, folks!") {
    + *       subscriptions.cancel(message.getDestination());
    + *   }
    + * }
    + * 
    + *
  • + *
+ * + */ +class SubscriptionManager : public sys::Runnable, public Handle +{ + public: + /** Create a new SubscriptionManager associated with a session */ + QPID_CLIENT_EXTERN SubscriptionManager(const Session& session); + QPID_CLIENT_EXTERN SubscriptionManager(const SubscriptionManager&); + QPID_CLIENT_EXTERN ~SubscriptionManager(); + QPID_CLIENT_EXTERN SubscriptionManager& operator=(const SubscriptionManager&); + + /** + * Subscribe a MessagesListener to receive messages from queue. + * + * Provide your own subclass of MessagesListener to process + * incoming messages. It will be called for each message received. + * + *@param listener Listener object to receive messages. + *@param queue Name of the queue to subscribe to. + *@param settings settings for the subscription. + *@param name unique destination name for the subscription, defaults to queue name. + */ + QPID_CLIENT_EXTERN Subscription subscribe(MessageListener& listener, + const std::string& queue, + const SubscriptionSettings& settings, + const std::string& name=std::string()); + + /** + * Subscribe a LocalQueue to receive messages from queue. + * + * Incoming messages are stored in the queue for you to retrieve. + * + *@param queue Name of the queue to subscribe to. + *@param flow initial FlowControl for the subscription. + *@param name unique destination name for the subscription, defaults to queue name. + * If not specified, the queue name is used. + */ + QPID_CLIENT_EXTERN Subscription subscribe(LocalQueue& localQueue, + const std::string& queue, + const SubscriptionSettings& settings, + const std::string& name=std::string()); + + /** + * Subscribe a MessagesListener to receive messages from queue. + * + * Provide your own subclass of MessagesListener to process + * incoming messages. It will be called for each message received. + * + *@param listener Listener object to receive messages. + *@param queue Name of the queue to subscribe to. + *@param name unique destination name for the subscription, defaults to queue name. + * If not specified, the queue name is used. + */ + QPID_CLIENT_EXTERN Subscription subscribe(MessageListener& listener, + const std::string& queue, + const std::string& name=std::string()); + + /** + * Subscribe a LocalQueue to receive messages from queue. + * + * Incoming messages are stored in the queue for you to retrieve. + * + *@param queue Name of the queue to subscribe to. + *@param name unique destination name for the subscription, defaults to queue name. + * If not specified, the queue name is used. + */ + QPID_CLIENT_EXTERN Subscription subscribe(LocalQueue& localQueue, + const std::string& queue, + const std::string& name=std::string()); + + + /** Get a single message from a queue. + *@param result is set to the message from the queue. + *@param timeout wait up this timeout for a message to appear. + *@return true if result was set, false if no message available after timeout. + */ + QPID_CLIENT_EXTERN bool get(Message& result, const std::string& queue, sys::Duration timeout=0); + + /** Get a single message from a queue. + *@param timeout wait up this timeout for a message to appear. + *@return message from the queue. + *@throw Exception if the timeout is exceeded. + */ + QPID_CLIENT_EXTERN Message get(const std::string& queue, sys::Duration timeout=sys::TIME_INFINITE); + + /** Get a subscription by name. + *@throw Exception if not found. + */ + QPID_CLIENT_EXTERN Subscription getSubscription(const std::string& name) const; + + /** Cancel a subscription. See also: Subscription.cancel() */ + QPID_CLIENT_EXTERN void cancel(const std::string& name); + + /** Deliver messages in the current thread until stop() is called. + * Only one thread may be running in a SubscriptionManager at a time. + * @see run + */ + QPID_CLIENT_EXTERN void run(); + + /** Start a new thread to deliver messages. + * Only one thread may be running in a SubscriptionManager at a time. + * @see start + */ + QPID_CLIENT_EXTERN void start(); + + /** + * Wait for the thread started by a call to start() to complete. + */ + QPID_CLIENT_EXTERN void wait(); + + /** If set true, run() will stop when all subscriptions + * are cancelled. If false, run will only stop when stop() + * is called. True by default. + */ + QPID_CLIENT_EXTERN void setAutoStop(bool set=true); + + /** Stop delivery. Causes run() to return, or the thread started with start() to exit. */ + QPID_CLIENT_EXTERN void stop(); + + static const uint32_t UNLIMITED=0xFFFFFFFF; + + /** Set the flow control for a subscription. */ + QPID_CLIENT_EXTERN void setFlowControl(const std::string& name, const FlowControl& flow); + + /** Set the flow control for a subscription. + *@param name: name of the subscription. + *@param messages: message credit. + *@param bytes: byte credit. + *@param window: if true use window-based flow control. + */ + QPID_CLIENT_EXTERN void setFlowControl(const std::string& name, uint32_t messages, uint32_t bytes, bool window=true); + + /** Set the default settings for subscribe() calls that don't + * include a SubscriptionSettings parameter. + */ + QPID_CLIENT_EXTERN void setDefaultSettings(const SubscriptionSettings& s); + + /** Get the default settings for subscribe() calls that don't + * include a SubscriptionSettings parameter. + */ + QPID_CLIENT_EXTERN const SubscriptionSettings& getDefaultSettings() const; + + /** Get the default settings for subscribe() calls that don't + * include a SubscriptionSettings parameter. + */ + QPID_CLIENT_EXTERN SubscriptionSettings& getDefaultSettings(); + + /** + * Set the default flow control settings for subscribe() calls + * that don't include a SubscriptionSettings parameter. + * + *@param messages: message credit. + *@param bytes: byte credit. + *@param window: if true use window-based flow control. + */ + QPID_CLIENT_EXTERN void setFlowControl(uint32_t messages, uint32_t bytes, bool window=true); + + /** + *Set the default accept-mode for subscribe() calls that don't + *include a SubscriptionSettings parameter. + */ + QPID_CLIENT_EXTERN void setAcceptMode(AcceptMode mode); + + /** + * Set the default acquire-mode subscribe()s that don't specify SubscriptionSettings. + */ + QPID_CLIENT_EXTERN void setAcquireMode(AcquireMode mode); + + QPID_CLIENT_EXTERN void registerFailoverHandler ( boost::function fh ); + + QPID_CLIENT_EXTERN Session getSession() const; + + SubscriptionManager(SubscriptionManagerImpl*); ///<@internal + + private: + typedef SubscriptionManagerImpl Impl; + friend class PrivateImplRef; +}; + +/** AutoCancel cancels a subscription in its destructor */ +class AutoCancel { + public: + AutoCancel(SubscriptionManager& sm_, const std::string& tag_) : sm(sm_), tag(tag_) {} + ~AutoCancel() { sm.cancel(tag); } + private: + SubscriptionManager& sm; + std::string tag; +}; + +}} // namespace qpid::client + +#endif /*!QPID_CLIENT_SUBSCRIPTIONMANAGER_H*/ diff --git a/qpid/cpp/include/qpid/client/SubscriptionSettings.h b/qpid/cpp/include/qpid/client/SubscriptionSettings.h new file mode 100644 index 0000000000..4d64119d3a --- /dev/null +++ b/qpid/cpp/include/qpid/client/SubscriptionSettings.h @@ -0,0 +1,92 @@ +#ifndef QPID_CLIENT_SUBSCRIPTIONSETTINGS_H +#define QPID_CLIENT_SUBSCRIPTIONSETTINGS_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#include "qpid/client/FlowControl.h" +#include "qpid/framing/enum.h" + +namespace qpid { +namespace client { + +/** Bring AMQP enum definitions for message class into this namespace. */ +using namespace qpid::framing::message; + +enum CompletionMode { + MANUAL_COMPLETION = 0, + COMPLETE_ON_DELIVERY = 1, + COMPLETE_ON_ACCEPT = 2 +}; +/** + * Settings for a subscription. + */ +struct SubscriptionSettings +{ + SubscriptionSettings( + FlowControl flow=FlowControl::unlimited(), + AcceptMode accept=ACCEPT_MODE_EXPLICIT, + AcquireMode acquire=ACQUIRE_MODE_PRE_ACQUIRED, + unsigned int autoAck_=1, + CompletionMode completion=COMPLETE_ON_DELIVERY + ) : flowControl(flow), acceptMode(accept), acquireMode(acquire), autoAck(autoAck_), completionMode(completion), exclusive(false) {} + + FlowControl flowControl; ///@< Flow control settings. @see FlowControl + AcceptMode acceptMode; ///@< ACCEPT_MODE_EXPLICIT or ACCEPT_MODE_NONE + AcquireMode acquireMode; ///@< ACQUIRE_MODE_PRE_ACQUIRED or ACQUIRE_MODE_NOT_ACQUIRED + + /** Automatically acknowledge (accept) batches of autoAck + * messages. 0 means no automatic acknowledgement. This has no + * effect for messsages received for a subscription with + * ACCEPT_MODE_NODE.*/ + unsigned int autoAck; + /** + * In windowing mode, completion of a message will cause the + * credit used up by that message to be reallocated. The + * subscriptions completion mode controls how completion is + * managed. + * + * If set to COMPLETE_ON_DELIVERY (which is the default), messages + * will be marked as completed once they have been received. The + * server will be explicitly notified of all completed messages + * for the session when the next accept is sent through the + * subscription (either explictly or through autAck). However the + * server may also periodically request information on the + * completed messages. + * + * If set to COMPLETE_ON_ACCEPT, messages will be marked as + * completed once they are accepted (via the Subscription class) + * and the server will also be notified of all completed messages + * for the session. + * + * If set to MANUAL_COMPLETION the application is responsible for + * completing messages (@see Session::markCompleted()). + */ + CompletionMode completionMode; + /** + * If set, requests that no other subscriber be allowed to access + * the queue while this subscription is active. + */ + bool exclusive; +}; + +}} // namespace qpid::client + +#endif /*!QPID_CLIENT_SUBSCRIPTIONSETTINGS_H*/ diff --git a/qpid/cpp/include/qpid/client/TypedResult.h b/qpid/cpp/include/qpid/client/TypedResult.h new file mode 100644 index 0000000000..8e1a16580c --- /dev/null +++ b/qpid/cpp/include/qpid/client/TypedResult.h @@ -0,0 +1,65 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#ifndef _TypedResult_ +#define _TypedResult_ + +#include "qpid/client/Completion.h" +#include "qpid/framing/StructHelper.h" + +namespace qpid { +namespace client { + +/** + * Returned by asynchronous commands that return a result. + * You can use get() to wait for completion and get the result value. + * \ingroup clientapi + */ +template class TypedResult : public Completion +{ + T result; + bool decoded; + +public: + ///@internal + TypedResult(const Completion& c) : Completion(c), decoded(false) {} + + /** + * Wait for the asynchronous command that returned this TypedResult to complete + * and return its result. + * + *@return The result returned by the command. + *@exception If the command returns an error, get() throws an exception. + * + */ + T& get() { + if (!decoded) { + framing::StructHelper helper; + helper.decode(result, getResult()); + decoded = true; + } + return result; + } +}; + +}} + +#endif diff --git a/qpid/cpp/include/qpid/console/Agent.h b/qpid/cpp/include/qpid/console/Agent.h new file mode 100644 index 0000000000..97d75da250 --- /dev/null +++ b/qpid/cpp/include/qpid/console/Agent.h @@ -0,0 +1,58 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#ifndef _QPID_CONSOLE_AGENT_H_ +#define _QPID_CONSOLE_AGENT_H_ + +#include "qpid/console/Broker.h" +#include "qpid/console/ConsoleImportExport.h" + +namespace qpid { +namespace console { + + /** + * + * \ingroup qmfconsoleapi + */ + class QPID_CONSOLE_EXTERN Agent { + public: + typedef std::vector Vector; + + Agent(Broker* _broker, uint32_t _bank, const std::string& _label) : + broker(_broker), brokerBank(broker->getBrokerBank()), + agentBank(_bank), label(_label) {} + Broker* getBroker() const { return broker; } + uint32_t getBrokerBank() const { return brokerBank; } + uint32_t getAgentBank() const { return agentBank; } + const std::string& getLabel() const { return label; } + + private: + Broker* broker; + const uint32_t brokerBank; + const uint32_t agentBank; + const std::string label; + }; + + QPID_CONSOLE_EXTERN std::ostream& operator<<(std::ostream& o, const Agent& agent); +} +} + + +#endif diff --git a/qpid/cpp/include/qpid/console/Broker.h b/qpid/cpp/include/qpid/console/Broker.h new file mode 100644 index 0000000000..af163b8bfd --- /dev/null +++ b/qpid/cpp/include/qpid/console/Broker.h @@ -0,0 +1,133 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#ifndef _QPID_CONSOLE_BROKER_H_ +#define _QPID_CONSOLE_BROKER_H_ + +#include "qpid/console/ConsoleImportExport.h" +#include "qpid/client/Connection.h" +#include "qpid/client/ConnectionSettings.h" +#include "qpid/client/SubscriptionManager.h" +#include "qpid/client/Session.h" +#include "qpid/client/AsyncSession.h" +#include "qpid/client/Message.h" +#include "qpid/client/MessageListener.h" +#include "qpid/sys/Thread.h" +#include "qpid/sys/Runnable.h" +#include "qpid/sys/Mutex.h" +#include "qpid/sys/Condition.h" +#include "qpid/Url.h" +#include "qpid/framing/Buffer.h" +#include "qpid/framing/Uuid.h" +#include +#include + +namespace qpid { +namespace console { + class SessionManager; + class Agent; + class Object; + + /** + * + * \ingroup qpidconsoleapi + */ + class Broker : public client::MessageListener { + public: + QPID_CONSOLE_EXTERN Broker(SessionManager& sm, + client::ConnectionSettings& settings); + QPID_CONSOLE_EXTERN ~Broker(); + + bool isConnected() const { return connected; } + const std::string& getError() const { return error; } + const std::string& getSessionId() const { return amqpSessionId; } + const framing::Uuid& getBrokerId() const { return brokerId; } + uint32_t getBrokerBank() const { return 1; } + void addBinding(const std::string& key) { + connThreadBody.bindExchange("qpid.management", key); + } + QPID_CONSOLE_EXTERN std::string getUrl() const; + + private: + friend class SessionManager; + friend class Object; + typedef std::map AgentMap; + static const int SYNC_TIME = 60; + + SessionManager& sessionManager; + AgentMap agents; + bool connected; + std::string error; + std::string amqpSessionId; + client::ConnectionSettings connectionSettings; + sys::Mutex lock; + sys::Condition cond; + framing::Uuid brokerId; + uint32_t reqsOutstanding; + bool syncInFlight; + bool topicBound; + Object* methodObject; + + friend class ConnectionThread; + class ConnectionThread : public sys::Runnable { + bool operational; + bool shuttingDown; + Broker& broker; + framing::Uuid sessionId; + client::Connection connection; + client::Session session; + client::SubscriptionManager* subscriptions; + std::stringstream queueName; + sys::Mutex connLock; + void run(); + public: + ConnectionThread(Broker& _broker) : + operational(false), shuttingDown(false), broker(_broker), subscriptions(0) {} + ~ConnectionThread(); + void sendBuffer(qpid::framing::Buffer& buf, + uint32_t length, + const std::string& exchange = "qpid.management", + const std::string& routingKey = "broker"); + void bindExchange(const std::string& exchange, const std::string& key); + void shutdown(); + }; + + ConnectionThread connThreadBody; + sys::Thread connThread; + + void encodeHeader(framing::Buffer& buf, uint8_t opcode, uint32_t seq = 0) const; + bool checkHeader(framing::Buffer& buf, uint8_t *opcode, uint32_t *seq) const; + void received(client::Message& msg); + void resetAgents(); + void updateAgent(const Object& object); + void waitForStable(); + void incOutstanding(); + void decOutstanding(); + void setBrokerId(const framing::Uuid& id) { brokerId = id; } + void appendAgents(std::vector& agents) const; + + friend QPID_CONSOLE_EXTERN std::ostream& operator<<(std::ostream& o, const Broker& k); + }; + + QPID_CONSOLE_EXTERN std::ostream& operator<<(std::ostream& o, const Broker& k); +} +} + +#endif diff --git a/qpid/cpp/include/qpid/console/ClassKey.h b/qpid/cpp/include/qpid/console/ClassKey.h new file mode 100644 index 0000000000..95cd2627f1 --- /dev/null +++ b/qpid/cpp/include/qpid/console/ClassKey.h @@ -0,0 +1,66 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#ifndef _QPID_CONSOLE_CLASSKEY_H_ +#define _QPID_CONSOLE_CLASSKEY_H_ + +#include +#include "qpid/console/ConsoleImportExport.h" +#include "qpid/console/Package.h" +#include "qpid/framing/Buffer.h" + +namespace qpid { +namespace console { + + /** + * + * \ingroup qmfconsoleapi + */ + class QPID_CONSOLE_EXTERN ClassKey { + public: + static const int HASH_SIZE = 16; + + ClassKey(const std::string& package, const std::string& name, const uint8_t* hash); + + const std::string& getPackageName() const { return package; } + const std::string& getClassName() const { return name; } + const uint8_t* getHash() const { return hash; } + std::string getHashString() const; + std::string str() const; + bool operator==(const ClassKey& other) const; + bool operator!=(const ClassKey& other) const; + bool operator<(const ClassKey& other) const; + bool operator>(const ClassKey& other) const; + bool operator<=(const ClassKey& other) const; + bool operator>=(const ClassKey& other) const; + void encode(framing::Buffer& buffer) const; + + private: + std::string package; + std::string name; + uint8_t hash[HASH_SIZE]; + }; + + QPID_CONSOLE_EXTERN std::ostream& operator<<(std::ostream& o, const ClassKey& k); +} +} + + +#endif diff --git a/qpid/cpp/include/qpid/console/ConsoleImportExport.h b/qpid/cpp/include/qpid/console/ConsoleImportExport.h new file mode 100644 index 0000000000..c2d7cb3a14 --- /dev/null +++ b/qpid/cpp/include/qpid/console/ConsoleImportExport.h @@ -0,0 +1,33 @@ +#ifndef QPID_CONSOLE_IMPORT_EXPORT_H +#define QPID_CONSOLE_IMPORT_EXPORT_H + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#if defined(WIN32) && !defined(QPID_DECLARE_STATIC) +#if defined(CONSOLE_EXPORT) || defined (qmfconsole_EXPORTS) +#define QPID_CONSOLE_EXTERN __declspec(dllexport) +#else +#define QPID_CONSOLE_EXTERN __declspec(dllimport) +#endif +#else +#define QPID_CONSOLE_EXTERN +#endif + +#endif diff --git a/qpid/cpp/include/qpid/console/ConsoleListener.h b/qpid/cpp/include/qpid/console/ConsoleListener.h new file mode 100644 index 0000000000..7a649da657 --- /dev/null +++ b/qpid/cpp/include/qpid/console/ConsoleListener.h @@ -0,0 +1,97 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#ifndef _QPID_CONSOLE_CONSOLE_LISTENER_H_ +#define _QPID_CONSOLE_CONSOLE_LISTENER_H_ + +#include +#include "qpid/console/ConsoleImportExport.h" +#include "qpid/console/Broker.h" +#include "qpid/console/ClassKey.h" +#include "qpid/console/Object.h" +#include "qpid/console/Event.h" + +namespace qpid { +namespace console { + + /** + * Implement a subclass of ConsoleListener and subscribe it using + * the SessionManager to receive indications. + * + * \ingroup qmfconsoleapi + */ + class QPID_CONSOLE_EXTERN ConsoleListener{ + public: + virtual ~ConsoleListener() {}; + + /** Invoked when a connection is established to a broker + */ + virtual void brokerConnected(const Broker&) {} + + /** Invoked when the connection to a broker is lost + */ + virtual void brokerDisconnected(const Broker&) {} + + /** Invoked when a QMF package is discovered. + */ + virtual void newPackage(const std::string&) {} + + /** Invoked when a new class is discovered. Session.getSchema can be + * used to obtain details about the class. + */ + virtual void newClass(const ClassKey&) {} + + /** Invoked when a QMF agent is discovered. + */ + virtual void newAgent(const Agent&) {} + + /** Invoked when a QMF agent disconects. + */ + virtual void delAgent(const Agent&) {} + + /** Invoked when an object is updated. + */ + virtual void objectProps(Broker&, Object&) {} + + /** Invoked when an object is updated. + */ + virtual void objectStats(Broker&, Object&) {} + + /** Invoked when an event is raised. + */ + virtual void event(Event&) {} + + /** + */ + //virtual void heartbeat(Agent&, uint64_t) {} + + /** + */ + virtual void brokerInfo(Broker&) {} + + /** + */ + //virtual void methodResponse(Broker&, uint32_t seq, MethodResponse&) {} + }; +} +} + + +#endif diff --git a/qpid/cpp/include/qpid/console/Event.h b/qpid/cpp/include/qpid/console/Event.h new file mode 100644 index 0000000000..ef4ecc791c --- /dev/null +++ b/qpid/cpp/include/qpid/console/Event.h @@ -0,0 +1,86 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#ifndef _QPID_CONSOLE_EVENT_H_ +#define _QPID_CONSOLE_EVENT_H_ + +#include "qpid/console/ConsoleImportExport.h" +#include "qpid/console/Object.h" +#include "qpid/framing/Uuid.h" +#include "qpid/framing/FieldTable.h" + +namespace qpid { +namespace framing { + class Buffer; +} +namespace console { + + class Broker; + struct SchemaClass; + class ClassKey; + + /** + * + * \ingroup qmfconsoleapi + */ + class Event { + public: + typedef enum { + SEV_EMERGENCY = 0, SEV_ALERT = 1, SEV_CRITICAL = 2, SEV_ERROR = 3, + SEV_WARNING = 4, SEV_NOTICE = 5, SEV_INFO = 6, SEV_DEBUG = 7 + } Severity; + + QPID_CONSOLE_EXTERN Event(Broker* broker, + SchemaClass* schemaClass, + framing::Buffer& buffer); + Broker* getBroker() const { return broker; } + QPID_CONSOLE_EXTERN const ClassKey& getClassKey() const; + SchemaClass* getSchema() const { return schema; } + const Object::AttributeMap& getAttributes() const { return attributes; } + uint64_t getTimestamp() const { return timestamp; } + uint8_t getSeverity() const { return severity; } + QPID_CONSOLE_EXTERN std::string getSeverityString() const; + + QPID_CONSOLE_EXTERN ObjectId attrRef(const std::string& key) const; + QPID_CONSOLE_EXTERN uint32_t attrUint(const std::string& key) const; + QPID_CONSOLE_EXTERN int32_t attrInt(const std::string& key) const; + QPID_CONSOLE_EXTERN uint64_t attrUint64(const std::string& key) const; + QPID_CONSOLE_EXTERN int64_t attrInt64(const std::string& key) const; + QPID_CONSOLE_EXTERN std::string attrString(const std::string& key) const; + QPID_CONSOLE_EXTERN bool attrBool(const std::string& key) const; + QPID_CONSOLE_EXTERN float attrFloat(const std::string& key) const; + QPID_CONSOLE_EXTERN double attrDouble(const std::string& key) const; + QPID_CONSOLE_EXTERN framing::Uuid attrUuid(const std::string& key) const; + QPID_CONSOLE_EXTERN framing::FieldTable attrMap(const std::string& key) const; + + private: + Broker* broker; + SchemaClass* schema; + uint64_t timestamp; + Severity severity; + Object::AttributeMap attributes; + }; + + QPID_CONSOLE_EXTERN std::ostream& operator<<(std::ostream& o, const Event& event); +} +} + + +#endif diff --git a/qpid/cpp/include/qpid/console/Object.h b/qpid/cpp/include/qpid/console/Object.h new file mode 100644 index 0000000000..5a29fdf792 --- /dev/null +++ b/qpid/cpp/include/qpid/console/Object.h @@ -0,0 +1,123 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#ifndef _QPID_CONSOLE_OBJECT_H_ +#define _QPID_CONSOLE_OBJECT_H_ + +#include "qpid/console/ConsoleImportExport.h" +#include "qpid/console/ObjectId.h" +#include "qpid/framing/Uuid.h" +#include "qpid/framing/FieldTable.h" +#include +#include +#include +#include + +namespace qpid { +namespace framing { + class Buffer; +} +namespace console { + + class Broker; + struct SchemaClass; + struct SchemaMethod; + class ObjectId; + class ClassKey; + class Value; + + /** + * \ingroup qmfconsoleapi + */ + struct MethodResponse { + uint32_t code; + std::string text; + std::map > arguments; + }; + + class Object { + public: + typedef std::vector Vector; + struct AttributeMap : public std::map > { + QPID_CONSOLE_EXTERN void addRef(const std::string& key, const ObjectId& val); + QPID_CONSOLE_EXTERN void addUint(const std::string& key, uint32_t val); + QPID_CONSOLE_EXTERN void addInt(const std::string& key, int32_t val); + QPID_CONSOLE_EXTERN void addUint64(const std::string& key, uint64_t val); + QPID_CONSOLE_EXTERN void addInt64(const std::string& key, int64_t val); + QPID_CONSOLE_EXTERN void addString(const std::string& key, const std::string& val); + QPID_CONSOLE_EXTERN void addBool(const std::string& key, bool val); + QPID_CONSOLE_EXTERN void addFloat(const std::string& key, float val); + QPID_CONSOLE_EXTERN void addDouble(const std::string& key, double val); + QPID_CONSOLE_EXTERN void addUuid(const std::string& key, const framing::Uuid& val); + QPID_CONSOLE_EXTERN void addMap(const std::string& key, const framing::FieldTable& val); + }; + + QPID_CONSOLE_EXTERN Object(Broker* broker, SchemaClass* schemaClass, framing::Buffer& buffer, bool prop, bool stat); + QPID_CONSOLE_EXTERN ~Object(); + + Broker* getBroker() const { return broker; } + const ObjectId& getObjectId() const { return objectId; } + QPID_CONSOLE_EXTERN const ClassKey& getClassKey() const; + SchemaClass* getSchema() const { return schema; } + uint64_t getCurrentTime() const { return currentTime; } + uint64_t getCreateTime() const { return createTime; } + uint64_t getDeleteTime() const { return deleteTime; } + bool isDeleted() const { return deleteTime != 0; } + QPID_CONSOLE_EXTERN std::string getIndex() const; + QPID_CONSOLE_EXTERN void mergeUpdate(const Object& updated); + const AttributeMap& getAttributes() const { return attributes; } + QPID_CONSOLE_EXTERN void invokeMethod(const std::string name, + const AttributeMap& args, + MethodResponse& result); + QPID_CONSOLE_EXTERN void handleMethodResp(framing::Buffer& buffer, + uint32_t sequence); + + QPID_CONSOLE_EXTERN ObjectId attrRef(const std::string& key) const; + QPID_CONSOLE_EXTERN uint32_t attrUint(const std::string& key) const; + QPID_CONSOLE_EXTERN int32_t attrInt(const std::string& key) const; + QPID_CONSOLE_EXTERN uint64_t attrUint64(const std::string& key) const; + QPID_CONSOLE_EXTERN int64_t attrInt64(const std::string& key) const; + QPID_CONSOLE_EXTERN std::string attrString(const std::string& key) const; + QPID_CONSOLE_EXTERN bool attrBool(const std::string& key) const; + QPID_CONSOLE_EXTERN float attrFloat(const std::string& key) const; + QPID_CONSOLE_EXTERN double attrDouble(const std::string& key) const; + QPID_CONSOLE_EXTERN framing::Uuid attrUuid(const std::string& key) const; + QPID_CONSOLE_EXTERN framing::FieldTable attrMap(const std::string& key) const; + + private: + Broker* broker; + SchemaClass* schema; + ObjectId objectId; + uint64_t currentTime; + uint64_t createTime; + uint64_t deleteTime; + AttributeMap attributes; + SchemaMethod* pendingMethod; + MethodResponse methodResponse; + + void parsePresenceMasks(framing::Buffer& buffer, std::set& excludeList); + }; + + QPID_CONSOLE_EXTERN std::ostream& operator<<(std::ostream& o, const Object& object); +} +} + + +#endif diff --git a/qpid/cpp/include/qpid/console/ObjectId.h b/qpid/cpp/include/qpid/console/ObjectId.h new file mode 100644 index 0000000000..7904c85598 --- /dev/null +++ b/qpid/cpp/include/qpid/console/ObjectId.h @@ -0,0 +1,69 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#ifndef _QPID_CONSOLE_OBJECTID_H +#define _QPID_CONSOLE_OBJECTID_H + +#include +#include "qpid/console/ConsoleImportExport.h" +#include "qpid/sys/IntegerTypes.h" + +namespace qpid { +namespace framing { + class Buffer; +} +namespace console { + + /** + * + * \ingroup qmfconsoleapi + */ + class QPID_CONSOLE_EXTERN ObjectId { + public: + ObjectId() : first(0), second(0) {} + ObjectId(framing::Buffer& buffer); + + uint8_t getFlags() const { return (first & 0xF000000000000000LL) >> 60; } + uint16_t getSequence() const { return (first & 0x0FFF000000000000LL) >> 48; } + uint32_t getBrokerBank() const { return (first & 0x0000FFFFF0000000LL) >> 28; } + uint32_t getAgentBank() const { return first & 0x000000000FFFFFFFLL; } + uint64_t getObject() const { return second; } + bool isDurable() const { return getSequence() == 0; } + void decode(framing::Buffer& buffer); + void encode(framing::Buffer& buffer); + void setValue(uint64_t f, uint64_t s) { first = f; second = s; } + + bool operator==(const ObjectId& other) const; + bool operator!=(const ObjectId& other) const; + bool operator<(const ObjectId& other) const; + bool operator>(const ObjectId& other) const; + bool operator<=(const ObjectId& other) const; + bool operator>=(const ObjectId& other) const; + + private: + uint64_t first; + uint64_t second; + }; + + QPID_CONSOLE_EXTERN std::ostream& operator<<(std::ostream& o, const ObjectId& id); +} +} + +#endif diff --git a/qpid/cpp/include/qpid/console/Package.h b/qpid/cpp/include/qpid/console/Package.h new file mode 100644 index 0000000000..3b59e366ff --- /dev/null +++ b/qpid/cpp/include/qpid/console/Package.h @@ -0,0 +1,78 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#ifndef _QPID_CONSOLE_PACKAGE_H_ +#define _QPID_CONSOLE_PACKAGE_H_ + +#include +#include +#include "qpid/console/ConsoleImportExport.h" +#include "qpid/sys/IntegerTypes.h" + +namespace qpid { +namespace console { + struct SchemaClass; + + /** + * + * \ingroup qmfconsoleapi + */ + class Package { + public: + Package(const std::string& n) : name(n) {} + const std::string& getName() const { return name; } + + private: + friend class SessionManager; + struct NameHash { + std::string name; + uint8_t hash[16]; + NameHash(const std::string& n, const uint8_t* h) : name(n) { + for (int i = 0; i < 16; i++) + hash[i] = h[i]; + } + }; + + struct NameHashComp { + bool operator() (const NameHash& lhs, const NameHash& rhs) const + { + if (lhs.name != rhs.name) + return lhs.name < rhs.name; + else + for (int i = 0; i < 16; i++) + if (lhs.hash[i] != rhs.hash[i]) + return lhs.hash[i] < rhs.hash[i]; + return false; + } + }; + + typedef std::map ClassMap; + + const std::string name; + ClassMap classes; + + SchemaClass* getClass(const std::string& className, uint8_t* hash); + void addClass(const std::string& className, uint8_t* hash, + SchemaClass* schemaClass); + }; +} +} + +#endif diff --git a/qpid/cpp/include/qpid/console/Schema.h b/qpid/cpp/include/qpid/console/Schema.h new file mode 100644 index 0000000000..6d4e41ab3e --- /dev/null +++ b/qpid/cpp/include/qpid/console/Schema.h @@ -0,0 +1,105 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#ifndef _QPID_CONSOLE_SCHEMA_H_ +#define _QPID_CONSOLE_SCHEMA_H_ + +#include "qpid/console/ClassKey.h" +#include +#include + +namespace qpid { +namespace framing { + class Buffer; +} +namespace console { + class Value; + + struct SchemaArgument { + SchemaArgument(framing::Buffer& buffer, bool forMethod = false); + boost::shared_ptr decodeValue(framing::Buffer& buffer); + + std::string name; + uint8_t typeCode; + bool dirInput; + bool dirOutput; + std::string unit; + int min; + int max; + int maxLen; + std::string desc; + std::string defaultVal; + }; + + struct SchemaProperty { + SchemaProperty(framing::Buffer& buffer); + boost::shared_ptr decodeValue(framing::Buffer& buffer); + + std::string name; + uint8_t typeCode; + uint8_t accessCode; + bool isIndex; + bool isOptional; + std::string unit; + int min; + int max; + int maxLen; + std::string desc; + }; + + struct SchemaStatistic { + SchemaStatistic(framing::Buffer& buffer); + boost::shared_ptr decodeValue(framing::Buffer& buffer); + + std::string name; + uint8_t typeCode; + std::string unit; + std::string desc; + }; + + struct SchemaMethod { + SchemaMethod(framing::Buffer& buffer); + ~SchemaMethod(); + + std::string name; + std::string desc; + std::vector arguments; + }; + + struct SchemaClass { + static const uint8_t KIND_TABLE = 1; + static const uint8_t KIND_EVENT = 2; + + SchemaClass(const uint8_t kind, const ClassKey& key, framing::Buffer& buffer); + ~SchemaClass(); + const ClassKey& getClassKey() const { return key; } + + const uint8_t kind; + const ClassKey key; + std::vector properties; + std::vector statistics; + std::vector methods; + std::vector arguments; + }; +} +} + + +#endif diff --git a/qpid/cpp/include/qpid/console/SequenceManager.h b/qpid/cpp/include/qpid/console/SequenceManager.h new file mode 100644 index 0000000000..ea0ccf3f77 --- /dev/null +++ b/qpid/cpp/include/qpid/console/SequenceManager.h @@ -0,0 +1,54 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#ifndef _QPID_CONSOLE_SEQUENCEMANAGER_H_ +#define _QPID_CONSOLE_SEQUENCEMANAGER_H_ + +#include "qpid/console/ConsoleImportExport.h" +#include "qpid/sys/Mutex.h" +#include +#include +#include + +namespace qpid { +namespace console { + + /** + * + * \ingroup qpidconsoleapi + */ + class SequenceManager { + public: + typedef std::set set; + + SequenceManager() : sequence(0) {} + QPID_CONSOLE_EXTERN uint32_t reserve(const std::string& context = ""); + QPID_CONSOLE_EXTERN std::string release(uint32_t seq); + + private: + sys::Mutex lock; + uint32_t sequence; + std::map pending; + }; +} +} + + +#endif diff --git a/qpid/cpp/include/qpid/console/SessionManager.h b/qpid/cpp/include/qpid/console/SessionManager.h new file mode 100644 index 0000000000..f27037a559 --- /dev/null +++ b/qpid/cpp/include/qpid/console/SessionManager.h @@ -0,0 +1,205 @@ +#ifndef _QPID_CONSOLE_SESSION_MANAGER_H +#define _QPID_CONSOLE_SESSION_MANAGER_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/console/ConsoleImportExport.h" +#include "qpid/console/Broker.h" +#include "qpid/console/Package.h" +#include "qpid/console/SequenceManager.h" +#include "qpid/console/ClassKey.h" +#include "qpid/console/Schema.h" +#include "qpid/console/Agent.h" +#include "qpid/console/Object.h" +#include "qpid/console/ObjectId.h" +#include "qpid/console/Value.h" +#include "qpid/sys/Mutex.h" +#include "qpid/sys/Condition.h" +#include "qpid/client/ConnectionSettings.h" +#include +#include + +namespace qpid { +namespace console { + +class ConsoleListener; + +/** + * + * \ingroup qmfconsoleapi + */ +class SessionManager +{ + public: + typedef std::vector NameVector; + typedef std::vector KeyVector; + QPID_CONSOLE_EXTERN ~SessionManager(); + + struct Settings { + bool rcvObjects; + bool rcvEvents; + bool rcvHeartbeats; + bool userBindings; + uint32_t methodTimeout; + uint32_t getTimeout; + + Settings() : rcvObjects(true), rcvEvents(true), rcvHeartbeats(true), + userBindings(false), methodTimeout(20), getTimeout(20) + {} + }; + + /** Create a new SessionManager + * + * Provide your own subclass of ConsoleListener to receive updates and indications + * asynchronously or leave it as its default and use only synchronous methods. + * + *@param listener Listener object to receive asynchronous indications. + *@param settings.rcvObjects Listener wishes to receive managed object data. + *@param settings.rcvEvents Listener wishes to receive events. + *@param settings.rcvHeartbeats Listener wishes to receive agent heartbeats. + *@param settings.userBindings If rcvObjects is true, userBindings allows the + * console client to control which object classes are received. See the bindPackage + * and bindClass methods. If userBindings is false, the listener will receive + * updates for all object classes. + */ + QPID_CONSOLE_EXTERN SessionManager(ConsoleListener* listener = 0, + Settings settings = Settings()); + + /** Connect a broker to the console session + * + *@param settings Connection settings for client access + *@return broker object if operation is successful + * an exception shall be thrown. + */ + QPID_CONSOLE_EXTERN Broker* addBroker(client::ConnectionSettings& settings); + + /** Disconnect a broker from the console session + * + *@param broker The broker object returned from an earlier call to addBroker. + */ + QPID_CONSOLE_EXTERN void delBroker(Broker* broker); + + /** Get a list of known management packages + * + *@param packages Vector of package names returned by the session manager. + */ + QPID_CONSOLE_EXTERN void getPackages(NameVector& packages); + + /** Get a list of class keys associated with a package + * + *@param classKeys List of class keys returned by the session manager. + *@param packageName Name of package being queried. + */ + QPID_CONSOLE_EXTERN void getClasses(KeyVector& classKeys, + const std::string& packageName); + + /** Get the schema of a class given its class key + * + *@param classKey Class key of the desired schema. + */ + QPID_CONSOLE_EXTERN SchemaClass& getSchema(const ClassKey& classKey); + + /** Request that updates be received for all classes within a package + * + * Note that this method is only meaningful if a ConsoleListener was provided at session + * creation and if the 'userBindings' flag was set to true. + * + *@param packageName Name of the package to which to bind. + */ + QPID_CONSOLE_EXTERN void bindPackage(const std::string& packageName); + + /** Request update to be received for a particular class + * + * Note that this method is only meaningful if a ConsoleListener was provided at session + * creation and if the 'userBindings' flag was set to true. + * + *@param classKey Class key of class to which to bind. + */ + QPID_CONSOLE_EXTERN void bindClass(const ClassKey& classKey); + QPID_CONSOLE_EXTERN void bindClass(const std::string& packageName, + const std::string& className); + + /** Get a list of qmf agents known to the session manager. + * + *@param agents Vector of Agent objects returned by the session manager. + *@param broker Return agents registered with this broker only. If NULL, return agents + * from all connected brokers. + */ + QPID_CONSOLE_EXTERN void getAgents(Agent::Vector& agents, + Broker* broker = 0); + + /** Get objects from agents. There are four variants of this method with different ways of + * specifying from which class objects are being queried. + * + *@param objects List of objects received. + *@param classKey ClassKey object identifying class to be queried. + *@param className Class name identifying class to be queried. + *@param objectId Object Id of the single object to be queried. + *@param broker Restrict the query to this broker, or all brokers if NULL. + *@param agent Restrict the query to this agent, or all agents if NULL. + */ + QPID_CONSOLE_EXTERN void getObjects(Object::Vector& objects, + const std::string& className, + Broker* broker = 0, + Agent* agent = 0); + //void getObjects(Object::Vector& objects, const ClassKey& classKey, + // Broker* broker = 0, Agent* agent = 0); + //void getObjects(Object::Vector& objects, const ObjectId& objectId, + // Broker* broker = 0, Agent* agent = 0); + +private: + friend class Broker; + friend class Broker::ConnectionThread; + friend class Object; + sys::Mutex lock; + sys::Mutex brokerListLock; + ConsoleListener* listener; + std::vector brokers; + std::map packages; + SequenceManager sequenceManager; + sys::Condition cv; + SequenceManager::set syncSequenceList; + Object::Vector getResult; + std::string error; + Settings settings; + NameVector bindingKeyList; + + void bindingKeys(); + void allBrokersStable(); + void startProtocol(Broker* broker); + void handleBrokerResp(Broker* broker, framing::Buffer& inBuffer, uint32_t sequence); + void handlePackageInd(Broker* broker, framing::Buffer& inBuffer, uint32_t sequence); + void handleCommandComplete(Broker* broker, framing::Buffer& inBuffer, uint32_t sequence); + void handleClassInd(Broker* broker, framing::Buffer& inBuffer, uint32_t sequence); + void handleMethodResp(Broker* broker, framing::Buffer& inBuffer, uint32_t sequence); + void handleHeartbeatInd(Broker* broker, framing::Buffer& inBuffer, uint32_t sequence); + void handleEventInd(Broker* broker, framing::Buffer& inBuffer, uint32_t sequence); + void handleSchemaResp(Broker* broker, framing::Buffer& inBuffer, uint32_t sequence); + void handleContentInd(Broker* broker, framing::Buffer& inBuffer, uint32_t sequence, bool prop, bool stat); + void handleBrokerConnect(Broker* broker); + void handleBrokerDisconnect(Broker* broker); + +}; + +}} // namespace qpid::console + +#endif /*!_QPID_CONSOLE_SESSION_MANAGER_H*/ diff --git a/qpid/cpp/include/qpid/console/Value.h b/qpid/cpp/include/qpid/console/Value.h new file mode 100644 index 0000000000..d9eb65053b --- /dev/null +++ b/qpid/cpp/include/qpid/console/Value.h @@ -0,0 +1,213 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#ifndef _QPID_CONSOLE_VALUE_H_ +#define _QPID_CONSOLE_VALUE_H_ + +#include "qpid/Exception.h" +#include "qpid/framing/Uuid.h" +#include "qpid/framing/FieldTable.h" +#include "qpid/console/ObjectId.h" +#include + +namespace qpid { +namespace framing { + class Buffer; +} +namespace console { + + /** + * \ingroup qmfconsoleapi + */ + class Value { + + public: + typedef boost::shared_ptr Ptr; + virtual ~Value() {} + virtual std::string str() const = 0; + + virtual bool isNull() const { return false; } + virtual bool isObjectId() const { return false; } + virtual bool isUint() const { return false; } + virtual bool isInt() const { return false; } + virtual bool isUint64() const { return false; } + virtual bool isInt64() const { return false; } + virtual bool isString() const { return false; } + virtual bool isBool() const { return false; } + virtual bool isFloat() const { return false; } + virtual bool isDouble() const { return false; } + virtual bool isUuid() const { return false; } + virtual bool isMap() const { return false; } + + virtual ObjectId asObjectId() const { incompatible(); return ObjectId(); } + virtual uint32_t asUint() const { incompatible(); return 0; } + virtual int32_t asInt() const { incompatible(); return 0; } + virtual uint64_t asUint64() const { incompatible(); return 0; } + virtual int64_t asInt64() const { incompatible(); return 0; } + virtual std::string asString() const { incompatible(); return std::string(); } + virtual bool asBool() const { incompatible(); return false; } + virtual float asFloat() const { incompatible(); return 0.0; } + virtual double asDouble() const { incompatible(); return 0.0; } + virtual framing::Uuid asUuid() const { incompatible(); return framing::Uuid(); } + virtual framing::FieldTable asMap() const { incompatible(); return framing::FieldTable(); } + + private: + void incompatible() const { + throw Exception("Incompatible Type"); + } + }; + + class NullValue : public Value { + public: + NullValue() {} + std::string str() const; + bool isNull() const { return true; } + }; + + class RefValue : public Value { + public: + RefValue(ObjectId v) : value(v) {} + RefValue(framing::Buffer& buffer); + std::string str() const; + bool isObjectId() const { return true; } + ObjectId asObjectId() const { return value; } + private: + ObjectId value; + }; + + class UintValue : public Value { + public: + UintValue(uint32_t v) : value(v) {} + std::string str() const; + bool isUint() const { return true; } + uint32_t asUint() const { return value; } + bool isUint64() const { return true; } + uint64_t asUint64() const { return (uint64_t) value; } + private: + uint32_t value; + }; + + class IntValue : public Value { + public: + IntValue(int32_t v) : value(v) {} + std::string str() const; + bool isInt() const { return true; } + int32_t asInt() const { return value; } + bool isInt64() const { return true; } + int64_t asInt64() const { return (int64_t) value; } + private: + int32_t value; + }; + + class Uint64Value : public Value { + public: + Uint64Value(uint64_t v) : value(v) {} + std::string str() const; + bool isUint64() const { return true; } + uint64_t asUint64() const { return value; } + private: + uint64_t value; + }; + + class Int64Value : public Value { + public: + Int64Value(int64_t v) : value(v) {} + std::string str() const; + bool isInt64() const { return true; } + int64_t asInt64() const { return value; } + private: + int64_t value; + }; + + class StringValue : public Value { + public: + StringValue(const std::string& v) : value(v) {} + StringValue(framing::Buffer& buffer, int tc); + std::string str() const { return value; } + bool isString() const { return true; } + std::string asString() const { return value; } + private: + std::string value; + }; + + class BoolValue : public Value { + public: + BoolValue(bool v) : value(v) {} + BoolValue(uint8_t v) : value(v != 0) {} + std::string str() const; + bool isBool() const { return true; } + bool asBool() const { return value; } + private: + bool value; + }; + + class FloatValue : public Value { + public: + FloatValue(float v) : value(v) {} + std::string str() const; + bool isFloat() const { return true; } + float asFloat() const { return value; } + bool isDouble() const { return true; } + double asDouble() const { return (double) value; } + private: + float value; + }; + + class DoubleValue : public Value { + public: + DoubleValue(double v) : value(v) {} + std::string str() const; + bool isDouble() const { return true; } + double asDouble() const { return value; } + private: + double value; + }; + + class UuidValue : public Value { + public: + UuidValue(const framing::Uuid& v) : value(v) {} + UuidValue(framing::Buffer& buffer); + std::string str() const { return value.str(); } + bool isUuid() const { return true; } + framing::Uuid asUuid() const { return value; } + private: + framing::Uuid value; + }; + + class MapValue : public Value { + public: + MapValue(const framing::FieldTable& v) : value(v) {} + MapValue(framing::Buffer& buffer); + std::string str() const; + bool isMap() const { return true; } + framing::FieldTable asMap() const { return value; } + private: + framing::FieldTable value; + }; + + class ValueFactory { + public: + static Value::Ptr newValue(int typeCode, framing::Buffer& buffer); + static void encodeValue(int typeCode, Value::Ptr value, framing::Buffer& buffer); + }; +} +} + +#endif diff --git a/qpid/cpp/include/qpid/framing/Array.h b/qpid/cpp/include/qpid/framing/Array.h new file mode 100644 index 0000000000..d3bdd36aa6 --- /dev/null +++ b/qpid/cpp/include/qpid/framing/Array.h @@ -0,0 +1,97 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#include "qpid/framing/amqp_types.h" +#include "qpid/framing/FieldValue.h" +#include "qpid/framing/TypeCode.h" +#include +#include +#include +#include "qpid/CommonImportExport.h" + +#ifndef _Array_ +#define _Array_ + +namespace qpid { +namespace framing { + +class Buffer; + +class Array +{ + public: + typedef boost::shared_ptr ValuePtr; + typedef std::vector ValueVector; + typedef ValueVector::const_iterator const_iterator; + typedef ValueVector::iterator iterator; + + QPID_COMMON_EXTERN uint32_t encodedSize() const; + QPID_COMMON_EXTERN void encode(Buffer& buffer) const; + QPID_COMMON_EXTERN void decode(Buffer& buffer); + + QPID_COMMON_EXTERN int count() const; + QPID_COMMON_EXTERN bool operator==(const Array& other) const; + + QPID_COMMON_EXTERN Array(); + QPID_COMMON_EXTERN Array(TypeCode type); + QPID_COMMON_EXTERN Array(uint8_t type); + //creates a longstr array + QPID_COMMON_EXTERN Array(const std::vector& in); + + QPID_COMMON_EXTERN TypeCode getType() const { return type; } + + // std collection interface. + QPID_COMMON_EXTERN const_iterator begin() const { return values.begin(); } + QPID_COMMON_EXTERN const_iterator end() const { return values.end(); } + QPID_COMMON_EXTERN iterator begin() { return values.begin(); } + QPID_COMMON_EXTERN iterator end(){ return values.end(); } + + QPID_COMMON_EXTERN ValuePtr front() const { return values.front(); } + QPID_COMMON_EXTERN ValuePtr back() const { return values.back(); } + QPID_COMMON_EXTERN size_t size() const { return values.size(); } + + QPID_COMMON_EXTERN void insert(iterator i, ValuePtr value); + QPID_COMMON_EXTERN void erase(iterator i) { values.erase(i); } + QPID_COMMON_EXTERN void push_back(ValuePtr value) { values.insert(end(), value); } + QPID_COMMON_EXTERN void pop_back() { values.pop_back(); } + + // Non-std interface + QPID_COMMON_EXTERN void add(ValuePtr value) { push_back(value); } + + template + void collect(std::vector& out) const + { + for (ValueVector::const_iterator i = values.begin(); i != values.end(); ++i) { + out.push_back((*i)->get()); + } + } + + private: + TypeCode type; + ValueVector values; + + friend QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& out, const Array& body); +}; + +} +} + + +#endif diff --git a/qpid/cpp/include/qpid/framing/Buffer.h b/qpid/cpp/include/qpid/framing/Buffer.h new file mode 100644 index 0000000000..8a6a5c0d5f --- /dev/null +++ b/qpid/cpp/include/qpid/framing/Buffer.h @@ -0,0 +1,136 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#include "qpid/framing/amqp_types.h" +#include "qpid/Exception.h" +#include "qpid/CommonImportExport.h" +#include + +#ifndef _Buffer_ +#define _Buffer_ + +namespace qpid { +namespace framing { + +struct OutOfBounds : qpid::Exception { + OutOfBounds() : qpid::Exception(std::string("Out of Bounds")) {} +}; + +class Content; +class FieldTable; + +class Buffer +{ + uint32_t size; + char* data; + uint32_t position; + uint32_t r_position; + + void checkAvailable(uint32_t count) { if (position + count > size) throw OutOfBounds(); } + + public: + + /** Buffer input/output iterator. + * Supports using an amqp_0_10::Codec with a framing::Buffer. + */ + class Iterator : public boost::iterator_facade< + Iterator, char, boost::random_access_traversal_tag> + { + public: + Iterator(Buffer& b) : buffer(&b) {} + + private: + friend class boost::iterator_core_access; + char& dereference() const { return buffer->data[buffer->position]; } + void increment() { ++buffer->position; } + bool equal(const Iterator& x) const { return buffer == x.buffer; } + + Buffer* buffer; + }; + + friend class Iterator; + + QPID_COMMON_EXTERN Buffer(char* data=0, uint32_t size=0); + + QPID_COMMON_EXTERN void record(); + QPID_COMMON_EXTERN void restore(bool reRecord = false); + QPID_COMMON_EXTERN void reset(); + + QPID_COMMON_EXTERN uint32_t available() { return size - position; } + QPID_COMMON_EXTERN uint32_t getSize() { return size; } + QPID_COMMON_EXTERN uint32_t getPosition() { return position; } + QPID_COMMON_EXTERN Iterator getIterator() { return Iterator(*this); } + QPID_COMMON_EXTERN char* getPointer() { return data; } + + QPID_COMMON_EXTERN void putOctet(uint8_t i); + QPID_COMMON_EXTERN void putShort(uint16_t i); + QPID_COMMON_EXTERN void putLong(uint32_t i); + QPID_COMMON_EXTERN void putLongLong(uint64_t i); + QPID_COMMON_EXTERN void putInt8(int8_t i); + QPID_COMMON_EXTERN void putInt16(int16_t i); + QPID_COMMON_EXTERN void putInt32(int32_t i); + QPID_COMMON_EXTERN void putInt64(int64_t i); + QPID_COMMON_EXTERN void putFloat(float f); + QPID_COMMON_EXTERN void putDouble(double f); + QPID_COMMON_EXTERN void putBin128(const uint8_t* b); + + QPID_COMMON_EXTERN uint8_t getOctet(); + QPID_COMMON_EXTERN uint16_t getShort(); + QPID_COMMON_EXTERN uint32_t getLong(); + QPID_COMMON_EXTERN uint64_t getLongLong(); + QPID_COMMON_EXTERN int8_t getInt8(); + QPID_COMMON_EXTERN int16_t getInt16(); + QPID_COMMON_EXTERN int32_t getInt32(); + QPID_COMMON_EXTERN int64_t getInt64(); + QPID_COMMON_EXTERN float getFloat(); + QPID_COMMON_EXTERN double getDouble(); + + template + QPID_COMMON_EXTERN uint64_t getUInt(); + + template + QPID_COMMON_EXTERN void putUInt(uint64_t); + + QPID_COMMON_EXTERN void putShortString(const string& s); + QPID_COMMON_EXTERN void putMediumString(const string& s); + QPID_COMMON_EXTERN void putLongString(const string& s); + QPID_COMMON_EXTERN void getShortString(string& s); + QPID_COMMON_EXTERN void getMediumString(string& s); + QPID_COMMON_EXTERN void getLongString(string& s); + QPID_COMMON_EXTERN void getBin128(uint8_t* b); + + QPID_COMMON_EXTERN void putRawData(const string& s); + QPID_COMMON_EXTERN void getRawData(string& s, uint32_t size); + + QPID_COMMON_EXTERN void putRawData(const uint8_t* data, size_t size); + QPID_COMMON_EXTERN void getRawData(uint8_t* data, size_t size); + + template void put(const T& data) { data.encode(*this); } + template void get(T& data) { data.decode(*this); } + + QPID_COMMON_EXTERN void dump(std::ostream&) const; +}; + +std::ostream& operator<<(std::ostream&, const Buffer&); + +}} // namespace qpid::framing + + +#endif diff --git a/qpid/cpp/include/qpid/framing/FieldTable.h b/qpid/cpp/include/qpid/framing/FieldTable.h new file mode 100644 index 0000000000..a3a5c8a4ee --- /dev/null +++ b/qpid/cpp/include/qpid/framing/FieldTable.h @@ -0,0 +1,125 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#include +#include +#include +#include +#include "qpid/framing/amqp_types.h" +#include "qpid/CommonImportExport.h" + +#ifndef _FieldTable_ +#define _FieldTable_ + +namespace qpid { + /** + * The framing namespace contains classes that are used to create, + * send and receive the basic packets from which AMQP is built. + */ +namespace framing { + +class Array; +class FieldValue; +class Buffer; + +/** + * A set of name-value pairs. (See the AMQP spec for more details on + * AMQP field tables). + * + * \ingroup clientapi + */ +class FieldTable +{ + public: + typedef boost::shared_ptr ValuePtr; + typedef std::map ValueMap; + typedef ValueMap::iterator iterator; + + QPID_COMMON_EXTERN FieldTable() {}; + QPID_COMMON_EXTERN FieldTable(const FieldTable& ft); + QPID_COMMON_EXTERN ~FieldTable(); + QPID_COMMON_EXTERN FieldTable& operator=(const FieldTable& ft); + QPID_COMMON_EXTERN uint32_t encodedSize() const; + QPID_COMMON_EXTERN void encode(Buffer& buffer) const; + QPID_COMMON_EXTERN void decode(Buffer& buffer); + + QPID_COMMON_EXTERN uint32_t qmfEncodedSize() const; + QPID_COMMON_EXTERN void qmfEncode(Buffer& buffer) const; + QPID_COMMON_EXTERN void qmfDecode(Buffer& buffer); + + QPID_COMMON_EXTERN int count() const; + QPID_COMMON_EXTERN void set(const std::string& name, const ValuePtr& value); + QPID_COMMON_EXTERN ValuePtr get(const std::string& name) const; + QPID_COMMON_EXTERN bool isSet(const std::string& name) const { return get(name).get() != 0; } + + QPID_COMMON_EXTERN void setString(const std::string& name, const std::string& value); + QPID_COMMON_EXTERN void setInt(const std::string& name, const int value); + QPID_COMMON_EXTERN void setInt64(const std::string& name, const int64_t value); + QPID_COMMON_EXTERN void setTimestamp(const std::string& name, const uint64_t value); + QPID_COMMON_EXTERN void setUInt64(const std::string& name, const uint64_t value); + QPID_COMMON_EXTERN void setTable(const std::string& name, const FieldTable& value); + QPID_COMMON_EXTERN void setArray(const std::string& name, const Array& value); + QPID_COMMON_EXTERN void setFloat(const std::string& name, const float value); + QPID_COMMON_EXTERN void setDouble(const std::string& name, const double value); + //void setDecimal(string& name, xxx& value); + + QPID_COMMON_EXTERN int getAsInt(const std::string& name) const; + QPID_COMMON_EXTERN uint64_t getAsUInt64(const std::string& name) const; + QPID_COMMON_EXTERN int64_t getAsInt64(const std::string& name) const; + QPID_COMMON_EXTERN std::string getAsString(const std::string& name) const; + + QPID_COMMON_EXTERN bool getTable(const std::string& name, FieldTable& value) const; + QPID_COMMON_EXTERN bool getArray(const std::string& name, Array& value) const; + QPID_COMMON_EXTERN bool getFloat(const std::string& name, float& value) const; + QPID_COMMON_EXTERN bool getDouble(const std::string& name, double& value) const; + //bool getTimestamp(const std::string& name, uint64_t& value) const; + //bool getDecimal(string& name, xxx& value); + QPID_COMMON_EXTERN void erase(const std::string& name); + + + QPID_COMMON_EXTERN bool operator==(const FieldTable& other) const; + + // Map-like interface. + // TODO: may need to duplicate into versions that return mutable iterator + ValueMap::const_iterator begin() const { return values.begin(); } + ValueMap::const_iterator end() const { return values.end(); } + ValueMap::const_iterator find(const std::string& s) const { return values.find(s); } + + std::pair insert(const ValueMap::value_type&); + void clear() { values.clear(); } + + // ### Hack Alert + + ValueMap::iterator getValues() { return values.begin(); } + + private: + ValueMap values; + + QPID_COMMON_EXTERN friend std::ostream& operator<<(std::ostream& out, const FieldTable& body); +}; + +//class FieldNotFoundException{}; +//class UnknownFieldName : public FieldNotFoundException{}; +//class IncorrectFieldType : public FieldNotFoundException{}; +} +} + + +#endif diff --git a/qpid/cpp/include/qpid/framing/FieldValue.h b/qpid/cpp/include/qpid/framing/FieldValue.h new file mode 100644 index 0000000000..97fc56d606 --- /dev/null +++ b/qpid/cpp/include/qpid/framing/FieldValue.h @@ -0,0 +1,321 @@ +#ifndef _framing_FieldValue_h +#define _framing_FieldValue_h +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/Exception.h" +#include "qpid/framing/amqp_types.h" +#include "qpid/framing/Buffer.h" +#include "qpid/framing/FieldTable.h" +#include "qpid/CommonImportExport.h" + +#include +#include +#include + +#include + +namespace qpid { +namespace framing { + +//class Array; +/** + * Exception that is the base exception for all field table errors. + * + * \ingroup clientapi + */ +class FieldValueException : public qpid::Exception {}; + +/** + * Exception thrown when we can't perform requested conversion + * + * \ingroup clientapi + */ +struct InvalidConversionException : public FieldValueException { + InvalidConversionException() {} +}; + +/** + * Value that can appear in an AMQP field table + * + * \ingroup clientapi + */ +class FieldValue { + public: + /* + * Abstract type for content of different types + */ + class Data { + public: + virtual ~Data() {}; + virtual uint32_t encodedSize() const = 0; + virtual void encode(Buffer& buffer) = 0; + virtual void decode(Buffer& buffer) = 0; + virtual bool operator==(const Data&) const = 0; + + virtual bool convertsToInt() const { return false; } + virtual bool convertsToString() const { return false; } + virtual int64_t getInt() const { throw InvalidConversionException();} + virtual std::string getString() const { throw InvalidConversionException(); } + + virtual void print(std::ostream& out) const = 0; + }; + + FieldValue(): data(0) {}; + // Default assignment operator is fine + void setType(uint8_t type); + uint8_t getType(); + Data& getData() { return *data; } + uint32_t encodedSize() const { return 1 + data->encodedSize(); }; + bool empty() const { return data.get() == 0; } + void encode(Buffer& buffer); + void decode(Buffer& buffer); + QPID_COMMON_EXTERN bool operator==(const FieldValue&) const; + QPID_COMMON_EXTERN bool operator!=(const FieldValue& v) const { return !(*this == v); } + + void print(std::ostream& out) const; + + template bool convertsTo() const { return false; } + template T get() const { throw InvalidConversionException(); } + + protected: + FieldValue(uint8_t t, Data* d): typeOctet(t), data(d) {} + + private: + uint8_t typeOctet; + std::auto_ptr data; +}; + +template <> +inline bool FieldValue::convertsTo() const { return data->convertsToInt(); } + +template <> +inline bool FieldValue::convertsTo() const { return data->convertsToInt(); } + +template <> +inline bool FieldValue::convertsTo() const { return data->convertsToString(); } + +template <> +inline int FieldValue::get() const { return data->getInt(); } + +template <> +inline int64_t FieldValue::get() const { return data->getInt(); } + +template <> +inline std::string FieldValue::get() const { return data->getString(); } + +inline std::ostream& operator<<(std::ostream& out, const FieldValue& v) { + v.print(out); + return out; +} + +template +class FixedWidthValue : public FieldValue::Data { + uint8_t octets[width]; + + public: + FixedWidthValue() {} + FixedWidthValue(const uint8_t (&data)[width]) : octets(data) {} + FixedWidthValue(const uint8_t* const data) + { + for (int i = 0; i < width; i++) octets[i] = data[i]; + } + FixedWidthValue(uint64_t v) + { + for (int i = width; i > 1; --i) { + octets[i-1] = (uint8_t) (0xFF & v); v >>= 8; + } + octets[0] = (uint8_t) (0xFF & v); + } + uint32_t encodedSize() const { return width; } + void encode(Buffer& buffer) { buffer.putRawData(octets, width); } + void decode(Buffer& buffer) { buffer.getRawData(octets, width); } + bool operator==(const Data& d) const { + const FixedWidthValue* rhs = dynamic_cast< const FixedWidthValue* >(&d); + if (rhs == 0) return false; + else return std::equal(&octets[0], &octets[width], &rhs->octets[0]); + } + + bool convertsToInt() const { return true; } + int64_t getInt() const + { + int64_t v = 0; + for (int i = 0; i < width-1; ++i) { + v |= octets[i]; v <<= 8; + } + v |= octets[width-1]; + return v; + } + uint8_t* rawOctets() { return octets; } + + void print(std::ostream& o) const { o << "F" << width << ":"; }; +}; + +template <> +class FixedWidthValue<0> : public FieldValue::Data { + public: + // Implicit default constructor is fine + uint32_t encodedSize() const { return 0; } + void encode(Buffer&) {}; + void decode(Buffer&) {}; + bool operator==(const Data& d) const { + const FixedWidthValue<0>* rhs = dynamic_cast< const FixedWidthValue<0>* >(&d); + return rhs != 0; + } + void print(std::ostream& o) const { o << "F0"; }; +}; + +template +class VariableWidthValue : public FieldValue::Data { + std::vector octets; + + public: + VariableWidthValue() {} + VariableWidthValue(const std::vector& data) : octets(data) {} + VariableWidthValue(const uint8_t* start, const uint8_t* end) : octets(start, end) {} + uint32_t encodedSize() const { return lenwidth + octets.size(); } + void encode(Buffer& buffer) { + buffer.putUInt(octets.size()); + if (octets.size() > 0) + buffer.putRawData(&octets[0], octets.size()); + }; + void decode(Buffer& buffer) { + uint32_t len = buffer.getUInt(); + octets.resize(len); + if (len > 0) + buffer.getRawData(&octets[0], len); + } + bool operator==(const Data& d) const { + const VariableWidthValue* rhs = dynamic_cast< const VariableWidthValue* >(&d); + if (rhs == 0) return false; + else return octets==rhs->octets; + } + + bool convertsToString() const { return true; } + std::string getString() const { return std::string(octets.begin(), octets.end()); } + + void print(std::ostream& o) const { o << "V" << lenwidth << ":" << octets.size() << ":"; }; +}; + +template +class EncodedValue : public FieldValue::Data { + T value; + public: + + EncodedValue() {} + EncodedValue(const T& v) : value(v) {} + + T& getValue() { return value; } + const T& getValue() const { return value; } + + uint32_t encodedSize() const { return value.encodedSize(); } + + void encode(Buffer& buffer) { + value.encode(buffer); + }; + void decode(Buffer& buffer) { + value.decode(buffer); + } + bool operator==(const Data& d) const { + const EncodedValue* rhs = dynamic_cast< const EncodedValue* >(&d); + if (rhs == 0) return false; + else return value==rhs->value; + } + + void print(std::ostream& o) const { o << "[" << value << "]"; }; +}; + +class Str8Value : public FieldValue { + public: + QPID_COMMON_EXTERN Str8Value(const std::string& v); +}; + +class Str16Value : public FieldValue { + public: + QPID_COMMON_EXTERN Str16Value(const std::string& v); +}; + +class Struct32Value : public FieldValue { + public: + QPID_COMMON_EXTERN Struct32Value(const std::string& v); +}; + +class FloatValue : public FieldValue +{ + public: + QPID_COMMON_EXTERN FloatValue(float f); +}; +class DoubleValue : public FieldValue +{ + public: + QPID_COMMON_EXTERN DoubleValue(double f); +}; + +/* + * Basic integer value encodes as signed 32 bit + */ +class IntegerValue : public FieldValue { + public: + QPID_COMMON_EXTERN IntegerValue(int v); +}; + +class TimeValue : public FieldValue { + public: + QPID_COMMON_EXTERN TimeValue(uint64_t v); +}; + +class Integer64Value : public FieldValue { + public: + QPID_COMMON_EXTERN Integer64Value(int64_t v); +}; + +class Unsigned64Value : public FieldValue { + public: + QPID_COMMON_EXTERN Unsigned64Value(uint64_t v); +}; + +class FieldTableValue : public FieldValue { + public: + QPID_COMMON_EXTERN FieldTableValue(const FieldTable&); +}; + +class ArrayValue : public FieldValue { + public: + QPID_COMMON_EXTERN ArrayValue(const Array&); +}; + +template +bool getEncodedValue(FieldTable::ValuePtr vptr, T& value) +{ + if (vptr) { + const EncodedValue* ev = dynamic_cast< EncodedValue* >(&(vptr->getData())); + if (ev != 0) { + value = ev->getValue(); + return true; + } + } + return false; +} + + +}} // qpid::framing + +#endif diff --git a/qpid/cpp/include/qpid/framing/ProtocolVersion.h b/qpid/cpp/include/qpid/framing/ProtocolVersion.h new file mode 100644 index 0000000000..e7e75d75f6 --- /dev/null +++ b/qpid/cpp/include/qpid/framing/ProtocolVersion.h @@ -0,0 +1,58 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#ifndef _ProtocolVersion_ +#define _ProtocolVersion_ + +#include "qpid/framing/amqp_types.h" +#include "qpid/CommonImportExport.h" + +namespace qpid +{ +namespace framing +{ + +class ProtocolVersion +{ +private: + uint8_t major_; + uint8_t minor_; + +public: + explicit ProtocolVersion(uint8_t _major=0, uint8_t _minor=0) + : major_(_major), minor_(_minor) {} + + QPID_COMMON_EXTERN uint8_t getMajor() const { return major_; } + QPID_COMMON_EXTERN void setMajor(uint8_t major) { major_ = major; } + QPID_COMMON_EXTERN uint8_t getMinor() const { return minor_; } + QPID_COMMON_EXTERN void setMinor(uint8_t minor) { minor_ = minor; } + QPID_COMMON_EXTERN const std::string toString() const; + + QPID_COMMON_EXTERN ProtocolVersion& operator=(ProtocolVersion p); + + QPID_COMMON_EXTERN bool operator==(ProtocolVersion p) const; + QPID_COMMON_EXTERN bool operator!=(ProtocolVersion p) const { return ! (*this == p); } +}; + +} // namespace framing +} // namespace qpid + + +#endif // ifndef _ProtocolVersion_ diff --git a/qpid/cpp/include/qpid/framing/SequenceNumber.h b/qpid/cpp/include/qpid/framing/SequenceNumber.h new file mode 100644 index 0000000000..1e53058df8 --- /dev/null +++ b/qpid/cpp/include/qpid/framing/SequenceNumber.h @@ -0,0 +1,79 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#ifndef _framing_SequenceNumber_h +#define _framing_SequenceNumber_h + +#include "qpid/framing/amqp_types.h" +#include +#include +#include "qpid/CommonImportExport.h" + +namespace qpid { +namespace framing { + +class Buffer; + +/** + * 4-byte sequence number that 'wraps around'. + */ +class SequenceNumber : public +boost::equality_comparable< + SequenceNumber, boost::less_than_comparable< + SequenceNumber, boost::incrementable< + SequenceNumber, boost::decrementable > > > +{ + int32_t value; + + public: + SequenceNumber(uint32_t v=0) : value(v) {} + + SequenceNumber& operator++() { ++value; return *this; } + SequenceNumber& operator--() { --value; return *this; } + bool operator==(const SequenceNumber& other) const { return value == other.value; } + bool operator<(const SequenceNumber& other) const { return (value - other.value) < 0; } + uint32_t getValue() const { return uint32_t(value); } + operator uint32_t() const { return uint32_t(value); } + + void encode(Buffer& buffer) const; + void decode(Buffer& buffer); + uint32_t encodedSize() const; + + template void serialize(S& s) { s(value); } + + friend inline int32_t operator-(const SequenceNumber& a, const SequenceNumber& b); +}; + +inline int32_t operator-(const SequenceNumber& a, const SequenceNumber& b) { + return int32_t(a.value - b.value); +} + +struct Window +{ + SequenceNumber hwm; + SequenceNumber lwm; +}; + +QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& o, const SequenceNumber& n); + +}} // namespace qpid::framing + + +#endif diff --git a/qpid/cpp/include/qpid/framing/SequenceSet.h b/qpid/cpp/include/qpid/framing/SequenceSet.h new file mode 100644 index 0000000000..39395e9ad7 --- /dev/null +++ b/qpid/cpp/include/qpid/framing/SequenceSet.h @@ -0,0 +1,69 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#ifndef _framing_SequenceSet_h +#define _framing_SequenceSet_h + +#include "qpid/framing/SequenceNumber.h" +#include "qpid/RangeSet.h" +#include "qpid/CommonImportExport.h" + +namespace qpid { +namespace framing { +class Buffer; + +class SequenceSet : public RangeSet { + public: + SequenceSet() {} + SequenceSet(const RangeSet& r) + : RangeSet(r) {} + SequenceSet(const SequenceNumber& s) { add(s); } + SequenceSet(const SequenceNumber& start, const SequenceNumber finish) { add(start,finish); } + + + void encode(Buffer& buffer) const; + void decode(Buffer& buffer); + uint32_t encodedSize() const; + + QPID_COMMON_EXTERN bool contains(const SequenceNumber& s) const; + QPID_COMMON_EXTERN void add(const SequenceNumber& s); + QPID_COMMON_EXTERN void add(const SequenceNumber& start, const SequenceNumber& finish); // Closed range + QPID_COMMON_EXTERN void add(const SequenceSet& set); + QPID_COMMON_EXTERN void remove(const SequenceNumber& s); + QPID_COMMON_EXTERN void remove(const SequenceNumber& start, const SequenceNumber& finish); // Closed range + QPID_COMMON_EXTERN void remove(const SequenceSet& set); + + template void for_each(T& t) const { + for (RangeIterator i = rangesBegin(); i != rangesEnd(); i++) + t(i->first(), i->last()); + } + + template void for_each(const T& t) const { + for (RangeIterator i = rangesBegin(); i != rangesEnd(); i++) + t(i->first(), i->last()); + } + + friend QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream&, const SequenceSet&); +}; + +}} // namespace qpid::framing + + +#endif diff --git a/qpid/cpp/include/qpid/framing/StructHelper.h b/qpid/cpp/include/qpid/framing/StructHelper.h new file mode 100644 index 0000000000..fc9a7909cc --- /dev/null +++ b/qpid/cpp/include/qpid/framing/StructHelper.h @@ -0,0 +1,57 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#ifndef _StructHelper_ +#define _StructHelper_ + +#include "qpid/Exception.h" +#include "qpid/CommonImportExport.h" +#include "qpid/framing/Buffer.h" + +#include // For alloca + +namespace qpid { +namespace framing { + +class StructHelper +{ +public: + + template void encode(const T t, std::string& data) { + uint32_t size = t.bodySize() + 2/*type*/; + data.resize(size); + Buffer wbuffer(const_cast(data.data()), size); + wbuffer.putShort(T::TYPE); + t.encodeStructBody(wbuffer); + } + + template void decode(T& t, const std::string& data) { + Buffer rbuffer(const_cast(data.data()), data.length()); + uint16_t type = rbuffer.getShort(); + if (type == T::TYPE) { + t.decodeStructBody(rbuffer); + } else { + throw Exception("Type code does not match"); + } + } +}; + +}} +#endif diff --git a/qpid/cpp/include/qpid/framing/Uuid.h b/qpid/cpp/include/qpid/framing/Uuid.h new file mode 100644 index 0000000000..0dfa7a58e7 --- /dev/null +++ b/qpid/cpp/include/qpid/framing/Uuid.h @@ -0,0 +1,91 @@ +#ifndef QPID_FRAMING_UUID_H +#define QPID_FRAMING_UUID_H + +/* + * + * Copyright (c) 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "qpid/CommonImportExport.h" +#include "qpid/sys/uuid.h" +#include "qpid/sys/IntegerTypes.h" + +#include + +#include +#include + +namespace qpid { +namespace framing { + +class Buffer; + +/** + * A UUID is represented as a boost::array of 16 bytes. + * + * Full value semantics, operators ==, < etc. are provided by + * boost::array so Uuid can be the key type in a map etc. + */ +struct Uuid : public boost::array { + /** If unique is true, generate a unique ID else a null ID. */ + Uuid(bool unique=false) { if (unique) generate(); else clear(); } + + /** Copy from 16 bytes of data. */ + Uuid(const uint8_t* data) { assign(data); } + + /** Copy from 16 bytes of data. */ + void assign(const uint8_t* data) { + uuid_copy(c_array(), data); + } + + /** Set to a new unique identifier. */ + void generate() { uuid_generate(c_array()); } + + /** Set to all zeros. */ + void clear() { uuid_clear(c_array()); } + + /** Test for null (all zeros). */ + // Force int 0/!0 to false/true; avoids compile warnings. + bool isNull() { + return !!uuid_is_null(data()); + } + + // Default op= and copy ctor are fine. + // boost::array gives us ==, < etc. + + QPID_COMMON_EXTERN void encode(framing::Buffer& buf) const; + QPID_COMMON_EXTERN void decode(framing::Buffer& buf); + QPID_COMMON_EXTERN uint32_t encodedSize() const { return size(); } + + /** String value in format 1b4e28ba-2fa1-11d2-883f-b9a761bde3fb. */ + QPID_COMMON_EXTERN std::string str() const; + + template void serialize(S& s) { + s.raw(begin(), size()); + } +}; + +/** Print in format 1b4e28ba-2fa1-11d2-883f-b9a761bde3fb. */ +QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream&, Uuid); + +/** Read from format 1b4e28ba-2fa1-11d2-883f-b9a761bde3fb. */ +QPID_COMMON_EXTERN std::istream& operator>>(std::istream&, Uuid&); + +}} // namespace qpid::framing + + + +#endif /*!QPID_FRAMING_UUID_H*/ diff --git a/qpid/cpp/include/qpid/framing/amqp_types.h b/qpid/cpp/include/qpid/framing/amqp_types.h new file mode 100644 index 0000000000..d9088b7a12 --- /dev/null +++ b/qpid/cpp/include/qpid/framing/amqp_types.h @@ -0,0 +1,66 @@ +#ifndef AMQP_TYPES_H +#define AMQP_TYPES_H +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +/** \file + * Definitions and forward declarations of all types used + * in AMQP messages. + */ + +#include "qpid/sys/IntegerTypes.h" +#include + +namespace qpid { +namespace framing { + +using std::string; +typedef uint8_t FrameType; +typedef uint16_t ChannelId; +typedef uint32_t BatchOffset; +typedef uint8_t ClassId; +typedef uint8_t MethodId; +typedef uint16_t ReplyCode; + +// Types represented by classes. +class Content; +class FieldTable; +class SequenceNumberSet; +struct Uuid; + +// Useful constants + +/** Maximum channel ID used by broker. Reserve high bit for internal use.*/ +const ChannelId CHANNEL_MAX=(ChannelId(~1))>>1; +const ChannelId CHANNEL_HIGH_BIT= ChannelId(~CHANNEL_MAX); + +// Forward declare class types +class FramingContent; +class FieldTable; +class SequenceNumberSet; +class SequenceSet; +struct Uuid; + +// Enum types +enum DeliveryMode { TRANSIENT = 1, PERSISTENT = 2}; + +}} // namespace qpid::framing +#endif diff --git a/qpid/cpp/include/qpid/framing/amqp_types_full.h b/qpid/cpp/include/qpid/framing/amqp_types_full.h new file mode 100644 index 0000000000..c5d84dedea --- /dev/null +++ b/qpid/cpp/include/qpid/framing/amqp_types_full.h @@ -0,0 +1,38 @@ +#ifndef _framing_amqp_types_decl_h +#define _framing_amqp_types_decl_h + +/* + * + * Copyright (c) 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +/** \file + * Definitions and full declarations of all types used + * in AMQP messages. + * + * It's better to include amqp_types.h in another header instead of this file + * unless the header actually needs the full declarations. Including + * full declarations when forward declarations would increase compile + * times. + */ + +#include "qpid/framing/amqp_types.h" +#include "qpid/framing/Array.h" +#include "qpid/framing/FieldTable.h" +#include "qpid/framing/SequenceSet.h" +#include "qpid/framing/Uuid.h" + +#endif /*!_framing_amqp_types_decl_h*/ diff --git a/qpid/cpp/include/qpid/log/Logger.h b/qpid/cpp/include/qpid/log/Logger.h new file mode 100644 index 0000000000..d7da1f077a --- /dev/null +++ b/qpid/cpp/include/qpid/log/Logger.h @@ -0,0 +1,114 @@ +#ifndef QPID_LOG_LOGGER_H +#define QPID_LOG_LOGGER_H + +/* + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "qpid/log/Selector.h" +#include "qpid/log/Options.h" +#include "qpid/sys/Mutex.h" +#include +#include +#include +#include "qpid/CommonImportExport.h" + +namespace qpid { +namespace log { + +/** + * Central logging agent. + * + * Thread safe, singleton. + * + * The Logger provides all needed functionality for selecting and + * formatting logging output. The actual outputting of log records + * is handled by Logger::Output-derived classes instantiated by the + * platform's sink-related options. + */ +class Logger : private boost::noncopyable { + public: + /** Flags indicating what to include in the log output */ + enum FormatFlag { FILE=1, LINE=2, FUNCTION=4, LEVEL=8, TIME=16, THREAD=32}; + + /** + * Logging output sink. + * + * The Output sink provides an interface to direct logging output to. + * Logging sinks are primarily platform-specific as provided for on + * each platform. + * + * Implementations of Output must be thread safe. + */ + class Output { + public: + QPID_COMMON_EXTERN Output(); + QPID_COMMON_EXTERN virtual ~Output(); + /** Receives the statemnt of origin and formatted message to log. */ + virtual void log(const Statement&, const std::string&) =0; + }; + + QPID_COMMON_EXTERN static Logger& instance(); + + QPID_COMMON_EXTERN Logger(); + QPID_COMMON_EXTERN ~Logger(); + + /** Select the messages to be logged. */ + QPID_COMMON_EXTERN void select(const Selector& s); + + /** Set the formatting flags, bitwise OR of FormatFlag values. */ + QPID_COMMON_EXTERN void format(int formatFlags); + + /** Set format flags from options object. + *@returns computed flags. + */ + QPID_COMMON_EXTERN int format(const Options&); + + /** Configure logger from Options */ + QPID_COMMON_EXTERN void configure(const Options& o); + + /** Add a statement. */ + QPID_COMMON_EXTERN void add(Statement& s); + + /** Log a message. */ + QPID_COMMON_EXTERN void log(const Statement&, const std::string&); + + /** Add an output destination for messages */ + QPID_COMMON_EXTERN void output(std::auto_ptr out); + + /** Set a prefix for all messages */ + QPID_COMMON_EXTERN void setPrefix(const std::string& prefix); + + /** Reset the logger. */ + QPID_COMMON_EXTERN void clear(); + + /** Get the options used to configure the logger. */ + QPID_COMMON_EXTERN const Options& getOptions() const { return options; } + + + private: + typedef boost::ptr_vector Outputs; + typedef std::set Statements; + + sys::Mutex lock; + inline void enable_unlocked(Statement* s); + + Statements statements; + Outputs outputs; + Selector selector; + int flags; + std::string prefix; + Options options; +}; + +}} // namespace qpid::log + + +#endif /*!QPID_LOG_LOGGER_H*/ diff --git a/qpid/cpp/include/qpid/log/Options.h b/qpid/cpp/include/qpid/log/Options.h new file mode 100644 index 0000000000..bbc47b47d3 --- /dev/null +++ b/qpid/cpp/include/qpid/log/Options.h @@ -0,0 +1,50 @@ +#ifndef QPID_LOG_OPTIONS_H +#define QPID_LOG_OPTIONS_H + +/* + * + * Copyright (c) 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#include "qpid/Options.h" +#include "qpid/CommonImportExport.h" +#include "qpid/log/SinkOptions.h" +#include +#include + +namespace qpid { +namespace log { + +/** Logging options for config parser. */ +struct Options : public qpid::Options { + /** Pass argv[0] for use in syslog output */ + QPID_COMMON_EXTERN Options(const std::string& argv0_=std::string(), + const std::string& name_="Logging options"); + QPID_COMMON_EXTERN Options(const Options &); + + QPID_COMMON_EXTERN Options& operator=(const Options&); + + std::string argv0; + std::string name; + std::vector selectors; + bool time, level, thread, source, function; + bool trace; + std::string prefix; + std::auto_ptr sinkOptions; +}; + +}} // namespace qpid::log + +#endif /*!QPID_LOG_OPTIONS_H*/ diff --git a/qpid/cpp/include/qpid/log/Selector.h b/qpid/cpp/include/qpid/log/Selector.h new file mode 100644 index 0000000000..061152d7e2 --- /dev/null +++ b/qpid/cpp/include/qpid/log/Selector.h @@ -0,0 +1,71 @@ +#ifndef SELECTOR_H +#define SELECTOR_H + +/* + * + * Copyright (c) 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "qpid/log/Statement.h" +#include "qpid/CommonImportExport.h" +#include + +namespace qpid { +namespace log { +struct Options; + +/** + * A selector identifies the set of log messages to enable. + * + * Thread object unsafe, pass-by-value type. + */ +class Selector { + public: + /** Empty selector selects nothing */ + Selector() {} + + /** Set selector from Options */ + QPID_COMMON_EXTERN Selector(const Options&); + + /** Equavlient to: Selector s; s.enable(l, s) */ + Selector(Level l, const std::string& s=std::string()) { + enable(l,s); + } + + Selector(const std::string& enableStr) { enable(enableStr); } + /** + * Enable messages with level in levels where the file + * name contains substring. Empty string matches all. + */ + void enable(Level level, const std::string& substring=std::string()) { + substrings[level].push_back(substring); + } + + /** Enable based on a 'level[+]:file' string */ + QPID_COMMON_EXTERN void enable(const std::string& enableStr); + + /** True if level is enabled for file. */ + QPID_COMMON_EXTERN bool isEnabled(Level level, const char* function); + + private: + std::vector substrings[LevelTraits::COUNT]; +}; + + +}} // namespace qpid::log + + +#endif /*!SELECTOR_H*/ diff --git a/qpid/cpp/include/qpid/log/SinkOptions.h b/qpid/cpp/include/qpid/log/SinkOptions.h new file mode 100644 index 0000000000..7ec2cfbc17 --- /dev/null +++ b/qpid/cpp/include/qpid/log/SinkOptions.h @@ -0,0 +1,64 @@ +#ifndef QPID_LOG_SINKOPTIONS_H +#define QPID_LOG_SINKOPTIONS_H + +/* + * + * Copyright (c) 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "qpid/Options.h" +#include + +namespace qpid { +namespace log { + +class Logger; + +/** + * Logging sink options. + * + * Most logging sink options will be platform-specific, even if some are + * duplicated. The range of platforms to which this code may be ported + * can't be assumed to all have C++ iostreams or files. Thus, this class + * is primarily for implementing in a platform-specific way. + */ +struct SinkOptions : public qpid::Options { + + // Create a platform's SinkOptions. Pass argv0 as the program name, + // useful for syslog-type logging. + static SinkOptions *create(const std::string& argv0=std::string()); + + SinkOptions(const std::string& name="Logging sink options") + : qpid::Options(name) + {} + virtual ~SinkOptions() {} + + virtual SinkOptions& operator=(const SinkOptions&) = 0; + + // This allows the caller to indicate that there's no normal outputs + // available. For example, when running as a daemon. In these cases, the + // platform's "syslog"-type output should replace the default stderr + // unless some other sink has been selected. + virtual void detached(void) = 0; + + // The Logger acting on these options calls setup() to request any + // Sinks be set up and fed back to the logger. + virtual void setup(Logger *logger) = 0; +}; + +}} // namespace qpid::log + +#endif /*!QPID_LOG_OPTIONS_H*/ diff --git a/qpid/cpp/include/qpid/log/Statement.h b/qpid/cpp/include/qpid/log/Statement.h new file mode 100644 index 0000000000..8f73175630 --- /dev/null +++ b/qpid/cpp/include/qpid/log/Statement.h @@ -0,0 +1,121 @@ +#ifndef STATEMENT_H +#define STATEMENT_H + +/* + * + * Copyright (c) 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "qpid/Msg.h" +#include "qpid/CommonImportExport.h" +#include + +namespace qpid { +namespace log { + +/** Debugging severity levels + * - trace: High-volume debugging messages. + * - debug: Debugging messages. + * - info: Informational messages. + * - notice: Normal but significant condition. + * - warning: Warn of a possible problem. + * - error: A definite error has occured. + * - critical: System in danger of severe failure. + */ +enum Level { trace, debug, info, notice, warning, error, critical }; +struct LevelTraits { + static const int COUNT=critical+1; + + /** Get level from string name. + *@exception if name invalid. + */ + static Level level(const char* name); + + /** Get level from string name. + *@exception if name invalid. + */ + static Level level(const std::string& name) { + return level(name.c_str()); + } + + /** String name of level */ + static const char* name(Level); +}; + +/** POD struct representing a logging statement in source code. */ +struct Statement { + bool enabled; + const char* file; + int line; + const char* function; + Level level; + + QPID_COMMON_EXTERN void log(const std::string& message); + + struct Initializer { + QPID_COMMON_EXTERN Initializer(Statement& s); + Statement& statement; + }; +}; + +///@internal static initializer for a Statement. +#define QPID_LOG_STATEMENT_INIT(level) \ + { 0, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, (::qpid::log::level) } + +/** + * Like QPID_LOG but computes an additional boolean test expression + * to determine if the message should be logged. Evaluation of both + * the test and message expressions occurs only if the requested log level + * is enabled. + *@param LEVEL severity Level for message, should be one of: + * debug, info, notice, warning, error, critical. NB no qpid::log:: prefix. + *@param TEST message is logged only if expression TEST evaluates to true. + *@param MESSAGE any object with an @eostream operator<<, or a sequence + * like of ostreamable objects separated by @e<<. + */ +#define QPID_LOG_IF(LEVEL, TEST, MESSAGE) \ + do { \ + using ::qpid::log::Statement; \ + static Statement stmt_= QPID_LOG_STATEMENT_INIT(LEVEL); \ + static Statement::Initializer init_(stmt_); \ + if (stmt_.enabled && (TEST)) \ + stmt_.log(::qpid::Msg() << MESSAGE); \ + } while(0) + +/** + * Macro for log statements. Example of use: + * @code + * QPID_LOG(debug, "There are " << foocount << " foos in the bar."); + * QPID_LOG(error, boost::format("Dohickey %s exploded") % dohicky.name()); + * @endcode + * + * You can subscribe to log messages by level, by component, by filename + * or a combination @see Configuration. + + *@param LEVEL severity Level for message, should be one of: + * debug, info, notice, warning, error, critical. NB no qpid::log:: prefix. + *@param MESSAGE any object with an @eostream operator<<, or a sequence + * like of ostreamable objects separated by @e<<. + */ +#define QPID_LOG(LEVEL, MESSAGE) QPID_LOG_IF(LEVEL, true, MESSAGE); + +}} // namespace qpid::log + + + + +#endif /*!STATEMENT_H*/ + diff --git a/qpid/cpp/include/qpid/management/Args.h b/qpid/cpp/include/qpid/management/Args.h new file mode 100644 index 0000000000..5d1cb7e01d --- /dev/null +++ b/qpid/cpp/include/qpid/management/Args.h @@ -0,0 +1,44 @@ +#ifndef _Args_ +#define _Args_ + +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + + +namespace qpid { +namespace management { + +class Args +{ + public: + + virtual ~Args (void) = 0; + +}; + +inline Args::~Args (void) {} + +class ArgsNone : public Args +{ +}; + +}} + + +#endif /*!_Args_*/ diff --git a/qpid/cpp/include/qpid/management/Manageable.h b/qpid/cpp/include/qpid/management/Manageable.h new file mode 100644 index 0000000000..8062479ac6 --- /dev/null +++ b/qpid/cpp/include/qpid/management/Manageable.h @@ -0,0 +1,72 @@ +#ifndef _Manageable_ +#define _Manageable_ + +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +#include "qpid/management/ManagementObject.h" +#include "qpid/management/Args.h" +#include +#include "qpid/CommonImportExport.h" + +namespace qpid { +namespace management { + +class QPID_COMMON_EXTERN Manageable +{ + public: + + virtual ~Manageable(void) = 0; + + // status_t is a type used to pass completion status from the method handler. + // + typedef uint32_t status_t; + static std::string StatusText(status_t status, std::string text = std::string()); + + static const status_t STATUS_OK = 0; + static const status_t STATUS_UNKNOWN_OBJECT = 1; + static const status_t STATUS_UNKNOWN_METHOD = 2; + static const status_t STATUS_NOT_IMPLEMENTED = 3; + static const status_t STATUS_INVALID_PARAMETER = 4; + static const status_t STATUS_FEATURE_NOT_IMPLEMENTED = 5; + static const status_t STATUS_FORBIDDEN = 6; + static const status_t STATUS_EXCEPTION = 7; + static const status_t STATUS_USER = 0x00010000; + + // Every "Manageable" object must hold a reference to exactly one + // management object. This object is always of a class derived from + // the pure-virtual "ManagementObject". + // + // This accessor function returns a pointer to the management object. + // + virtual ManagementObject* GetManagementObject(void) const = 0; + + // Every "Manageable" object must implement ManagementMethod. This + // function is called when a remote management client invokes a method + // on this object. The input and output arguments are specific to the + // method being called and must be down-cast to the appropriate sub class + // before use. + virtual status_t ManagementMethod(uint32_t methodId, Args& args, std::string& text); +}; + +inline Manageable::~Manageable(void) {} + +}} + +#endif /*!_Manageable_*/ diff --git a/qpid/cpp/include/qpid/management/ManagementEvent.h b/qpid/cpp/include/qpid/management/ManagementEvent.h new file mode 100644 index 0000000000..01b9ae49ec --- /dev/null +++ b/qpid/cpp/include/qpid/management/ManagementEvent.h @@ -0,0 +1,49 @@ +#ifndef _ManagementEvent_ +#define _ManagementEvent_ + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/management/ManagementObject.h" +#include +#include + +namespace qpid { +namespace management { + +class ManagementAgent; + +class ManagementEvent : public ManagementItem { +public: + typedef void (*writeSchemaCall_t)(qpid::framing::Buffer&); + virtual ~ManagementEvent() {} + + virtual writeSchemaCall_t getWriteSchemaCall(void) = 0; + virtual std::string& getEventName() const = 0; + virtual std::string& getPackageName() const = 0; + virtual uint8_t* getMd5Sum() const = 0; + virtual uint8_t getSeverity() const = 0; + virtual void encode(qpid::framing::Buffer&) const = 0; +}; + +}} + +#endif /*!_ManagementEvent_*/ diff --git a/qpid/cpp/include/qpid/management/ManagementObject.h b/qpid/cpp/include/qpid/management/ManagementObject.h new file mode 100644 index 0000000000..d0a443d6cb --- /dev/null +++ b/qpid/cpp/include/qpid/management/ManagementObject.h @@ -0,0 +1,187 @@ +#ifndef _ManagementObject_ +#define _ManagementObject_ + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/sys/Time.h" +#include "qpid/sys/Mutex.h" +#include +#include "qpid/CommonImportExport.h" +#include + +namespace qpid { +namespace management { + +class Manageable; +class ObjectId; + + +class AgentAttachment { + friend class ObjectId; +private: + uint64_t first; +public: + AgentAttachment() : first(0) {} + QPID_COMMON_EXTERN void setBanks(uint32_t broker, uint32_t bank); + uint64_t getFirst() const { return first; } +}; + + +class ObjectId { +protected: + const AgentAttachment* agent; + uint64_t first; + uint64_t second; + void fromString(const std::string&); +public: + QPID_COMMON_EXTERN ObjectId() : agent(0), first(0), second(0) {} + QPID_COMMON_EXTERN ObjectId(framing::Buffer& buf) : agent(0) { decode(buf); } + QPID_COMMON_EXTERN ObjectId(uint8_t flags, uint16_t seq, uint32_t broker, uint32_t bank, uint64_t object); + QPID_COMMON_EXTERN ObjectId(AgentAttachment* _agent, uint8_t flags, uint16_t seq, uint64_t object); + QPID_COMMON_EXTERN ObjectId(std::istream&); + QPID_COMMON_EXTERN ObjectId(const std::string&); + QPID_COMMON_EXTERN bool operator==(const ObjectId &other) const; + QPID_COMMON_EXTERN bool operator<(const ObjectId &other) const; + QPID_COMMON_EXTERN void encode(framing::Buffer& buffer); + QPID_COMMON_EXTERN void decode(framing::Buffer& buffer); + friend QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream&, const ObjectId&); +}; + +class ManagementItem { +public: + static const uint8_t TYPE_U8 = 1; + static const uint8_t TYPE_U16 = 2; + static const uint8_t TYPE_U32 = 3; + static const uint8_t TYPE_U64 = 4; + static const uint8_t TYPE_SSTR = 6; + static const uint8_t TYPE_LSTR = 7; + static const uint8_t TYPE_ABSTIME = 8; + static const uint8_t TYPE_DELTATIME = 9; + static const uint8_t TYPE_REF = 10; + static const uint8_t TYPE_BOOL = 11; + static const uint8_t TYPE_FLOAT = 12; + static const uint8_t TYPE_DOUBLE = 13; + static const uint8_t TYPE_UUID = 14; + static const uint8_t TYPE_FTABLE = 15; + static const uint8_t TYPE_S8 = 16; + static const uint8_t TYPE_S16 = 17; + static const uint8_t TYPE_S32 = 18; + static const uint8_t TYPE_S64 = 19; + + static const uint8_t ACCESS_RC = 1; + static const uint8_t ACCESS_RW = 2; + static const uint8_t ACCESS_RO = 3; + + static const uint8_t DIR_I = 1; + static const uint8_t DIR_O = 2; + static const uint8_t DIR_IO = 3; + + static const uint8_t FLAG_CONFIG = 0x01; + static const uint8_t FLAG_INDEX = 0x02; + static const uint8_t FLAG_END = 0x80; + + const static uint8_t CLASS_KIND_TABLE = 1; + const static uint8_t CLASS_KIND_EVENT = 2; + + + +public: + virtual ~ManagementItem() {} +}; + +class ManagementObject : public ManagementItem +{ +protected: + + uint64_t createTime; + uint64_t destroyTime; + uint64_t updateTime; + ObjectId objectId; + bool configChanged; + bool instChanged; + bool deleted; + Manageable* coreObject; + sys::Mutex accessLock; + uint32_t flags; + + static int nextThreadIndex; + bool forcePublish; + + QPID_COMMON_EXTERN int getThreadIndex(); + QPID_COMMON_EXTERN void writeTimestamps(qpid::framing::Buffer& buf); + + public: + QPID_COMMON_EXTERN static int maxThreads; + typedef void (*writeSchemaCall_t) (qpid::framing::Buffer&); + + ManagementObject(Manageable* _core) : + createTime(uint64_t(qpid::sys::Duration(qpid::sys::now()))), + destroyTime(0), updateTime(createTime), configChanged(true), + instChanged(true), deleted(false), + coreObject(_core), forcePublish(false) {} + virtual ~ManagementObject() {} + + virtual writeSchemaCall_t getWriteSchemaCall() = 0; + virtual void writeProperties(qpid::framing::Buffer& buf) = 0; + virtual void writeStatistics(qpid::framing::Buffer& buf, + bool skipHeaders = false) = 0; + virtual void doMethod(std::string& methodName, + qpid::framing::Buffer& inBuf, + qpid::framing::Buffer& outBuf) = 0; + QPID_COMMON_EXTERN virtual void setReference(ObjectId objectId); + + virtual std::string& getClassName() const = 0; + virtual std::string& getPackageName() const = 0; + virtual uint8_t* getMd5Sum() const = 0; + + void setObjectId(ObjectId oid) { objectId = oid; } + ObjectId getObjectId() { return objectId; } + inline bool getConfigChanged() { return configChanged; } + virtual bool getInstChanged() { return instChanged; } + virtual bool hasInst() { return true; } + inline void setForcePublish(bool f) { forcePublish = f; } + inline bool getForcePublish() { return forcePublish; } + inline void setUpdateTime() { updateTime = (uint64_t(sys::Duration(sys::now()))); } + + inline void resourceDestroy() { + destroyTime = uint64_t (qpid::sys::Duration(qpid::sys::now())); + deleted = true; + } + inline bool isDeleted() { return deleted; } + inline void setFlags(uint32_t f) { flags = f; } + inline uint32_t getFlags() { return flags; } + bool isSameClass(ManagementObject& other) { + for (int idx = 0; idx < 16; idx++) + if (other.getMd5Sum()[idx] != getMd5Sum()[idx]) + return false; + return other.getClassName() == getClassName() && + other.getPackageName() == getPackageName(); + } +}; + +typedef std::map ManagementObjectMap; + +}} + + + +#endif /*!_ManagementObject_*/ diff --git a/qpid/cpp/include/qpid/sys/Condition.h b/qpid/cpp/include/qpid/sys/Condition.h new file mode 100644 index 0000000000..9be4b357fe --- /dev/null +++ b/qpid/cpp/include/qpid/sys/Condition.h @@ -0,0 +1,33 @@ +#ifndef _sys_Condition_h +#define _sys_Condition_h + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#ifdef USE_APR_PLATFORM +#include "apr/Condition.h" +#elif defined (_WIN32) +#include "windows/Condition.h" +#else +#include "posix/Condition.h" +#endif + +#endif /*!_sys_Condition_h*/ diff --git a/qpid/cpp/include/qpid/sys/IOHandle.h b/qpid/cpp/include/qpid/sys/IOHandle.h new file mode 100644 index 0000000000..283e021162 --- /dev/null +++ b/qpid/cpp/include/qpid/sys/IOHandle.h @@ -0,0 +1,61 @@ +#ifndef _sys_IOHandle_h +#define _sys_IOHandle_h + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/CommonImportExport.h" + +namespace qpid { +namespace sys { + +/** + * This is a class intended to abstract the Unix concept of file descriptor + * or the Windows concept of HANDLE + */ +// Windows-related classes +class AsynchAcceptorPrivate; +class AsynchAcceptResult; +namespace windows { + class AsynchIO; +} + +// General classes +class PollerHandle; +class IOHandlePrivate; +class IOHandle { + + friend class AsynchAcceptorPrivate; + friend class AsynchAcceptResult; + friend class windows::AsynchIO; + + friend class PollerHandle; + +protected: + IOHandlePrivate* const impl; + + IOHandle(IOHandlePrivate*); + QPID_COMMON_EXTERN virtual ~IOHandle(); +}; + +}} + +#endif // _sys_IOHandle_h diff --git a/qpid/cpp/include/qpid/sys/IntegerTypes.h b/qpid/cpp/include/qpid/sys/IntegerTypes.h new file mode 100755 index 0000000000..89635f033e --- /dev/null +++ b/qpid/cpp/include/qpid/sys/IntegerTypes.h @@ -0,0 +1,31 @@ +#ifndef QPID_SYS_INTEGERTYPES_H +#define QPID_SYS_INTEGERTYPES_H + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#if (defined(_WINDOWS) || defined (WIN32)) && defined(_MSC_VER) +#include "qpid/sys/windows/IntegerTypes.h" +#endif +#if !defined _WINDOWS && !defined WIN32 +#include "qpid/sys/posix/IntegerTypes.h" +#endif + +#endif /*!QPID_SYS_INTEGERTYPES_H*/ diff --git a/qpid/cpp/include/qpid/sys/Monitor.h b/qpid/cpp/include/qpid/sys/Monitor.h new file mode 100644 index 0000000000..123bf92dcb --- /dev/null +++ b/qpid/cpp/include/qpid/sys/Monitor.h @@ -0,0 +1,49 @@ +#ifndef _sys_Monitor_h +#define _sys_Monitor_h + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/sys/Condition.h" + +namespace qpid { +namespace sys { + +/** + * A monitor is a condition variable and a mutex + */ +class Monitor : public Mutex, public Condition { + public: + inline void wait(); + inline bool wait(const AbsTime& absoluteTime); +}; + + +void Monitor::wait() { + Condition::wait(*this); +} + +bool Monitor::wait(const AbsTime& absoluteTime) { + return Condition::wait(*this, absoluteTime); +} + +}} +#endif /*!_sys_Monitor_h*/ diff --git a/qpid/cpp/include/qpid/sys/Mutex.h b/qpid/cpp/include/qpid/sys/Mutex.h new file mode 100644 index 0000000000..43a83d4fc3 --- /dev/null +++ b/qpid/cpp/include/qpid/sys/Mutex.h @@ -0,0 +1,91 @@ +#ifndef _sys_Mutex_h +#define _sys_Mutex_h + +/* + * + * Copyright (c) 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +namespace qpid { +namespace sys { + +/** + * Scoped lock template: calls lock() in ctor, unlock() in dtor. + * L can be any class with lock() and unlock() functions. + */ +template +class ScopedLock +{ + public: + ScopedLock(L& l) : mutex(l) { l.lock(); } + ~ScopedLock() { mutex.unlock(); } + private: + L& mutex; +}; + +template +class ScopedUnlock +{ + public: + ScopedUnlock(L& l) : mutex(l) { l.unlock(); } + ~ScopedUnlock() { mutex.lock(); } + private: + L& mutex; +}; + +template +class ScopedRlock +{ + public: + ScopedRlock(L& l) : mutex(l) { l.rlock(); } + ~ScopedRlock() { mutex.unlock(); } + private: + L& mutex; +}; + +template +class ScopedWlock +{ + public: + ScopedWlock(L& l) : mutex(l) { l.wlock(); } + ~ScopedWlock() { mutex.unlock(); } + private: + L& mutex; +}; + +template +class ConditionalScopedLock +{ + public: + ConditionalScopedLock(L& l) : mutex(l) { acquired = l.trylock(); } + ~ConditionalScopedLock() { if (acquired) mutex.unlock(); } + bool lockAcquired() { return acquired; } + private: + L& mutex; + bool acquired; +}; + +}} + +#ifdef USE_APR_PLATFORM +#include "apr/Mutex.h" +#elif defined (_WIN32) +#include "windows/Mutex.h" +#else +#include "posix/Mutex.h" +#endif + +#endif /*!_sys_Mutex_h*/ diff --git a/qpid/cpp/include/qpid/sys/Runnable.h b/qpid/cpp/include/qpid/sys/Runnable.h new file mode 100644 index 0000000000..0f1243a277 --- /dev/null +++ b/qpid/cpp/include/qpid/sys/Runnable.h @@ -0,0 +1,51 @@ +#ifndef _Runnable_ +#define _Runnable_ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include +#include "qpid/CommonImportExport.h" + +namespace qpid { +namespace sys { + +/** + * Interface for objects that can be run, e.g. in a thread. + */ +class Runnable +{ + public: + /** Type to represent a runnable as a Functor */ + typedef boost::function0 Functor; + + QPID_COMMON_EXTERN virtual ~Runnable(); + + /** Derived classes override run(). */ + virtual void run() = 0; + + /** Create a functor object that will call this->run(). */ + Functor functor(); +}; + +}} + + +#endif diff --git a/qpid/cpp/include/qpid/sys/StrError.h b/qpid/cpp/include/qpid/sys/StrError.h new file mode 100644 index 0000000000..36489dd0fc --- /dev/null +++ b/qpid/cpp/include/qpid/sys/StrError.h @@ -0,0 +1,36 @@ +#ifndef _sys_StrError_h +#define _sys_StrError_h + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include +#include "qpid/CommonImportExport.h" + +namespace qpid { +namespace sys { + +/** Get the error message for a system number err, e.g. errno. */ +QPID_COMMON_EXTERN std::string strError(int err); + +}} // namespace qpid + +#endif // _sys_StrError_h diff --git a/qpid/cpp/include/qpid/sys/SystemInfo.h b/qpid/cpp/include/qpid/sys/SystemInfo.h new file mode 100644 index 0000000000..09f9980173 --- /dev/null +++ b/qpid/cpp/include/qpid/sys/SystemInfo.h @@ -0,0 +1,85 @@ +#ifndef QPID_SYS_SYSTEMINFO_H +#define QPID_SYS_SYSTEMINFO_H + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/sys/IntegerTypes.h" +#include "qpid/Address.h" +#include "qpid/CommonImportExport.h" + +namespace qpid { +namespace sys { + +/** + * Retrieve information about the system we are running on. + * Results may be dependent on OS/hardware. + */ +namespace SystemInfo { + /** + * Estimate available concurrency, e.g. number of CPU cores. + * -1 means estimate not available on this platform. + */ + QPID_COMMON_EXTERN long concurrency(); + + /** + * Get the local host name and set it in the specified TcpAddress. + * Returns false if it can't be obtained and sets errno to any error value. + */ + QPID_COMMON_EXTERN bool getLocalHostname (TcpAddress &address); + + QPID_COMMON_EXTERN void getLocalIpAddresses (uint16_t port, std::vector
&addrList); + + /** + * Retrieve system identifiers and versions. This is information that can + * generally be retrieved via POSIX uname(). + * + * @param osName Receives the OS name; e.g., GNU/Linux or Windows + * @param nodeName Receives the nodename. This may or may not match the + * set hostname from getLocalHostname(). + * @param release Receives the OS release identifier. + * @param version Receives the OS release version (kernel, build, sp, etc.) + * @param machine Receives the hardware type. + */ + QPID_COMMON_EXTERN void getSystemId (std::string &osName, + std::string &nodeName, + std::string &release, + std::string &version, + std::string &machine); + + /** + * Get the process ID of the current process. + */ + QPID_COMMON_EXTERN uint32_t getProcessId(); + + /** + * Get the process ID of the parent of the current process. + */ + QPID_COMMON_EXTERN uint32_t getParentProcessId(); + + /** + * Get the name of the current process (i.e. the name of the executable) + */ + QPID_COMMON_EXTERN std::string getProcessName(); + + +}}} // namespace qpid::sys::SystemInfo + +#endif /*!QPID_SYS_SYSTEMINFO_H*/ diff --git a/qpid/cpp/include/qpid/sys/Thread.h b/qpid/cpp/include/qpid/sys/Thread.h new file mode 100644 index 0000000000..bfea4b4944 --- /dev/null +++ b/qpid/cpp/include/qpid/sys/Thread.h @@ -0,0 +1,65 @@ +#ifndef _sys_Thread_h +#define _sys_Thread_h + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#include +#include "qpid/CommonImportExport.h" + +#ifdef _WIN32 +# define QPID_TSS __declspec(thread) +#elif defined (__GNUC__) +# define QPID_TSS __thread +#elif defined (__SUNPRO_CC) +# define QPID_TSS __thread +#else +# error "Dont know how to define QPID_TSS for this platform" +#endif + +namespace qpid { +namespace sys { + +class Runnable; +class ThreadPrivate; + +class Thread +{ + boost::shared_ptr impl; + + public: + QPID_COMMON_EXTERN Thread(); + QPID_COMMON_EXTERN explicit Thread(qpid::sys::Runnable*); + QPID_COMMON_EXTERN explicit Thread(qpid::sys::Runnable&); + + QPID_COMMON_EXTERN void join(); + + QPID_COMMON_EXTERN unsigned long id(); + + QPID_COMMON_EXTERN static Thread current(); + + /** ID of current thread for logging. + * Workaround for broken Thread::current() in APR + */ + static unsigned long logId() { return current().id(); } +}; + +}} +#endif /*!_sys_Thread_h*/ diff --git a/qpid/cpp/include/qpid/sys/Time.h b/qpid/cpp/include/qpid/sys/Time.h new file mode 100644 index 0000000000..c19757747b --- /dev/null +++ b/qpid/cpp/include/qpid/sys/Time.h @@ -0,0 +1,173 @@ +#ifndef _sys_Time_h +#define _sys_Time_h + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/sys/IntegerTypes.h" +/* + * The platform defines its notion of time as a TimePrivate type. The + * platform's implementation knows how to handle this type. + */ +#if defined (_WIN32) +# include "windows/Time.h" +#else +# include "posix/Time.h" +#endif + +#include "qpid/CommonImportExport.h" + +#include +#include + +namespace qpid { +namespace sys { + +class Duration; + +/** + * @class AbsTime + * + * Class to represent an instant in time. + * + * The time resolution is in nanosecs, and this is held with 64 bits + * giving a total time span from about 25 million years ago to 25 million + * years hence. As an aside the internal time can sensibly be negative + * meaning before the epoch (probably 1/1/1970 although this class doesn't + * care). + * + * The AbsTime class is a value class and so you don't need to add any + * accessors to its internal state. If you think you want to replace its value, + * you need to construct a new AbsTime and assign it, viz: + * + * AbsTime when = AbsTime::now(); + * ... + * when = AbsTime(when, 2*TIME_SEC); // Advance timer 2 secs + * + * If for some reason you need access to the internal nanosec value you need + * to convert the AbsTime to a Duration and use its conversion to int64_t, viz: + * + * AbsTime now = AbsTime::now(); + * + * int64_t ns = Duration(now); + * + * However note that the nanosecond value that is returned here is not + * defined to be anything in particular and could vary from platform to + * platform. + * + * There are some sensible operations that are currently missing from + * AbsTime, but nearly all that's needed can be done with a mixture of + * AbsTimes and Durations. + * + * For example, convenience operators to add a Duration and AbsTime returning + * an AbsTime would fit here (although you can already perform the operation + * with one of the AbsTime constructors). However trying to add 2 AbsTimes + * doesn't make sense. + */ +class AbsTime { + friend class Duration; + + TimePrivate timepoint; + +public: + QPID_COMMON_EXTERN inline AbsTime() {} + QPID_COMMON_EXTERN AbsTime(const AbsTime& time0, const Duration& duration); + // Default assignment operation fine + // Default copy constructor fine + + QPID_COMMON_EXTERN static AbsTime now(); + QPID_COMMON_EXTERN static AbsTime FarFuture(); + const TimePrivate& getPrivate(void) const { return timepoint; } + bool operator==(const AbsTime& t) const { return t.timepoint == timepoint; } + template void serialize(S& s) { s(timepoint); } + + friend bool operator<(const AbsTime& a, const AbsTime& b); + friend bool operator>(const AbsTime& a, const AbsTime& b); + QPID_COMMON_EXTERN friend std::ostream& operator << (std::ostream&, const AbsTime&); +}; + +QPID_COMMON_EXTERN std::ostream& operator << (std::ostream&, const AbsTime&); + +/** + * @class Duration + * Class to represent the duration between instants of time. + * + * As AbsTime, this class also uses nanosecs for its time + * resolution where possible. For the most part a duration can be dealt + * with like a 64 bit integer, and indeed there is an implicit conversion which + * makes this quite convenient. + */ +class Duration { + static int64_t max() { return std::numeric_limits::max(); } + int64_t nanosecs; + + friend class AbsTime; + +public: + QPID_COMMON_EXTERN inline Duration(int64_t time0); + QPID_COMMON_EXTERN explicit Duration(const AbsTime& time0); + QPID_COMMON_EXTERN explicit Duration(const AbsTime& start, const AbsTime& finish); + inline operator int64_t() const; +}; + +std::ostream& operator << (std::ostream&, const Duration&); + +inline AbsTime now() { return AbsTime::now(); } + +inline bool operator<(const AbsTime& a, const AbsTime& b) +{ return a.timepoint < b.timepoint; } +inline bool operator>(const AbsTime& a, const AbsTime& b) +{ return a.timepoint > b.timepoint; } + +Duration::Duration(int64_t time0) : + nanosecs(time0) +{} + +Duration::operator int64_t() const +{ return nanosecs; } + +/** Nanoseconds per second. */ +const Duration TIME_SEC = 1000*1000*1000; +/** Nanoseconds per millisecond */ +const Duration TIME_MSEC = 1000*1000; +/** Nanoseconds per microseconds. */ +const Duration TIME_USEC = 1000; +/** Nanoseconds per nanosecond. */ +const Duration TIME_NSEC = 1; + +/** Value to represent an infinite timeout */ +const Duration TIME_INFINITE = std::numeric_limits::max(); + +/** Time greater than any other time */ +const AbsTime FAR_FUTURE = AbsTime::FarFuture(); + +/** Portable sleep for a number of seconds */ +QPID_COMMON_EXTERN void sleep(int secs); + +/** Portable sleep for a number of microseconds */ +QPID_COMMON_EXTERN void usleep(uint64_t usecs); + +/** Output formatted date/time for now*/ +void outputFormattedNow(std::ostream&); + +}} + +#endif /*!_sys_Time_h*/ diff --git a/qpid/cpp/include/qpid/sys/posix/Condition.h b/qpid/cpp/include/qpid/sys/posix/Condition.h new file mode 100644 index 0000000000..279039735a --- /dev/null +++ b/qpid/cpp/include/qpid/sys/posix/Condition.h @@ -0,0 +1,86 @@ +#ifndef _sys_posix_Condition_h +#define _sys_posix_Condition_h + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/sys/posix/PrivatePosix.h" + +#include "qpid/sys/Mutex.h" +#include "qpid/sys/Time.h" + +#include +#include +#include + +namespace qpid { +namespace sys { + +/** + * A condition variable for thread synchronization. + */ +class Condition +{ + public: + inline Condition(); + inline ~Condition(); + inline void wait(Mutex&); + inline bool wait(Mutex&, const AbsTime& absoluteTime); + inline void notify(); + inline void notifyAll(); + + private: + pthread_cond_t condition; +}; + +Condition::Condition() { + QPID_POSIX_ASSERT_THROW_IF(pthread_cond_init(&condition, 0)); +} + +Condition::~Condition() { + QPID_POSIX_ABORT_IF(pthread_cond_destroy(&condition)); +} + +void Condition::wait(Mutex& mutex) { + QPID_POSIX_ASSERT_THROW_IF(pthread_cond_wait(&condition, &mutex.mutex)); +} + +bool Condition::wait(Mutex& mutex, const AbsTime& absoluteTime){ + struct timespec ts; + toTimespec(ts, Duration(absoluteTime)); + int status = pthread_cond_timedwait(&condition, &mutex.mutex, &ts); + if (status != 0) { + if (status == ETIMEDOUT) return false; + throw QPID_POSIX_ERROR(status); + } + return true; +} + +void Condition::notify(){ + QPID_POSIX_ASSERT_THROW_IF(pthread_cond_signal(&condition)); +} + +void Condition::notifyAll(){ + QPID_POSIX_ASSERT_THROW_IF(pthread_cond_broadcast(&condition)); +} + +}} +#endif /*!_sys_posix_Condition_h*/ diff --git a/qpid/cpp/include/qpid/sys/posix/IntegerTypes.h b/qpid/cpp/include/qpid/sys/posix/IntegerTypes.h new file mode 100755 index 0000000000..ce97f7bde8 --- /dev/null +++ b/qpid/cpp/include/qpid/sys/posix/IntegerTypes.h @@ -0,0 +1,26 @@ +#ifndef QPID_SYS_POSIX_INTEGERTYPES_H +#define QPID_SYS_POSIX_INTEGERTYPES_H + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include + +#endif /*!QPID_SYS_INTEGERTYPES_H*/ diff --git a/qpid/cpp/include/qpid/sys/posix/Mutex.h b/qpid/cpp/include/qpid/sys/posix/Mutex.h new file mode 100644 index 0000000000..e2b21b5a56 --- /dev/null +++ b/qpid/cpp/include/qpid/sys/posix/Mutex.h @@ -0,0 +1,158 @@ +#ifndef _sys_posix_Mutex_h +#define _sys_posix_Mutex_h + +/* + * + * Copyright (c) 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "qpid/sys/posix/check.h" + +#include +#include + +namespace qpid { +namespace sys { + +class Condition; + +/** + * Mutex lock. + */ +class Mutex : private boost::noncopyable { + friend class Condition; + static const pthread_mutexattr_t* getAttribute(); + +public: + typedef ::qpid::sys::ScopedLock ScopedLock; + typedef ::qpid::sys::ScopedUnlock ScopedUnlock; + + inline Mutex(); + inline ~Mutex(); + inline void lock(); + inline void unlock(); + inline bool trylock(); + + +protected: + pthread_mutex_t mutex; +}; + +/** + * RW lock. + */ +class RWlock : private boost::noncopyable { + friend class Condition; + +public: + typedef ::qpid::sys::ScopedRlock ScopedRlock; + typedef ::qpid::sys::ScopedWlock ScopedWlock; + + inline RWlock(); + inline ~RWlock(); + inline void wlock(); // will write-lock + inline void rlock(); // will read-lock + inline void unlock(); + inline void trywlock(); // will write-try + inline void tryrlock(); // will read-try + +protected: + pthread_rwlock_t rwlock; +}; + + +/** + * PODMutex is a POD, can be static-initialized with + * PODMutex m = QPID_PODMUTEX_INITIALIZER + */ +struct PODMutex +{ + typedef ::qpid::sys::ScopedLock ScopedLock; + + inline void lock(); + inline void unlock(); + inline bool trylock(); + + // Must be public to be a POD: + pthread_mutex_t mutex; +}; + +#define QPID_MUTEX_INITIALIZER { PTHREAD_MUTEX_INITIALIZER } + +void PODMutex::lock() { + QPID_POSIX_ASSERT_THROW_IF(pthread_mutex_lock(&mutex)); +} + +void PODMutex::unlock() { + QPID_POSIX_ASSERT_THROW_IF(pthread_mutex_unlock(&mutex)); +} + +bool PODMutex::trylock() { + return pthread_mutex_trylock(&mutex) == 0; +} + +Mutex::Mutex() { + QPID_POSIX_ASSERT_THROW_IF(pthread_mutex_init(&mutex, getAttribute())); +} + +Mutex::~Mutex(){ + QPID_POSIX_ABORT_IF(pthread_mutex_destroy(&mutex)); +} + +void Mutex::lock() { + QPID_POSIX_ASSERT_THROW_IF(pthread_mutex_lock(&mutex)); +} + +void Mutex::unlock() { + QPID_POSIX_ASSERT_THROW_IF(pthread_mutex_unlock(&mutex)); +} + +bool Mutex::trylock() { + return pthread_mutex_trylock(&mutex) == 0; +} + + +RWlock::RWlock() { + QPID_POSIX_ASSERT_THROW_IF(pthread_rwlock_init(&rwlock, NULL)); +} + +RWlock::~RWlock(){ + QPID_POSIX_ABORT_IF(pthread_rwlock_destroy(&rwlock)); +} + +void RWlock::wlock() { + QPID_POSIX_ASSERT_THROW_IF(pthread_rwlock_wrlock(&rwlock)); +} + +void RWlock::rlock() { + QPID_POSIX_ASSERT_THROW_IF(pthread_rwlock_rdlock(&rwlock)); +} + +void RWlock::unlock() { + QPID_POSIX_ASSERT_THROW_IF(pthread_rwlock_unlock(&rwlock)); +} + +void RWlock::trywlock() { + QPID_POSIX_ASSERT_THROW_IF(pthread_rwlock_trywrlock(&rwlock)); +} + +void RWlock::tryrlock() { + QPID_POSIX_ASSERT_THROW_IF(pthread_rwlock_tryrdlock(&rwlock)); +} + + +}} +#endif /*!_sys_posix_Mutex_h*/ diff --git a/qpid/cpp/include/qpid/sys/posix/PrivatePosix.h b/qpid/cpp/include/qpid/sys/posix/PrivatePosix.h new file mode 100644 index 0000000000..6ffd3d8383 --- /dev/null +++ b/qpid/cpp/include/qpid/sys/posix/PrivatePosix.h @@ -0,0 +1,72 @@ +#ifndef _sys_posix_PrivatePosix_h +#define _sys_posix_PrivatePosix_h + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/sys/Time.h" +#include "qpid/sys/IOHandle.h" + +struct timespec; +struct timeval; + +namespace qpid { +namespace sys { + +// Private Time related implementation details +struct timespec& toTimespec(struct timespec& ts, const Duration& t); +struct timeval& toTimeval(struct timeval& tv, const Duration& t); +Duration toTime(const struct timespec& ts); + +// Private fd related implementation details +class IOHandlePrivate { +public: + IOHandlePrivate(int f = -1) : + fd(f) + {} + + int fd; +}; + +int toFd(const IOHandlePrivate* h); + +// Posix fd as an IOHandle +class PosixIOHandle : public IOHandle { +public: + PosixIOHandle(int fd) : + IOHandle(new IOHandlePrivate(fd)) + {} +}; + +// Dummy IOHandle for places it's required in the API +// but we promise not to actually try to do any operations on the IOHandle +class NullIOHandle : public IOHandle { +public: + NullIOHandle() : + IOHandle(new IOHandlePrivate) + {} +}; + +extern NullIOHandle DummyIOHandle; + +}} + +#endif /*!_sys_posix_PrivatePosix_h*/ diff --git a/qpid/cpp/include/qpid/sys/posix/Time.h b/qpid/cpp/include/qpid/sys/posix/Time.h new file mode 100755 index 0000000000..62d734c816 --- /dev/null +++ b/qpid/cpp/include/qpid/sys/posix/Time.h @@ -0,0 +1,34 @@ +#ifndef QPID_SYS_POSIX_TIME_H +#define QPID_SYS_POSIX_TIME_H + +/* + * + * Copyright (c) 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "qpid/sys/IntegerTypes.h" + +namespace qpid { +namespace sys { + +/** + * Class to represent an instant in time. + */ +typedef int64_t TimePrivate; + +}} // namespace qpid::sys + +#endif /*!QPID_SYS_POSIX_TIME_H*/ diff --git a/qpid/cpp/include/qpid/sys/posix/check.h b/qpid/cpp/include/qpid/sys/posix/check.h new file mode 100644 index 0000000000..bbc66d389b --- /dev/null +++ b/qpid/cpp/include/qpid/sys/posix/check.h @@ -0,0 +1,52 @@ +#ifndef _posix_check_h +#define _posix_check_h + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/Exception.h" + +#include +#include +#include +#include + +#define QPID_POSIX_ERROR(ERRNO) qpid::Exception(QPID_MSG(qpid::sys::strError(ERRNO))) + +/** THROW QPID_POSIX_ERROR(errno) if RESULT is less than zero */ +#define QPID_POSIX_CHECK(RESULT) \ + if ((RESULT) < 0) throw QPID_POSIX_ERROR((errno)) + +/** Throw a posix error if ERRNO is non-zero */ +#define QPID_POSIX_THROW_IF(ERRNO) \ + do { int e=(ERRNO); if (e) throw QPID_POSIX_ERROR(e); } while(0) + +/** Same as _THROW_IF in a release build, but abort a debug build */ +#ifdef NDEBUG +#define QPID_POSIX_ASSERT_THROW_IF(ERRNO) QPID_POSIX_THROW_IF(ERRNO) +#else +#define QPID_POSIX_ASSERT_THROW_IF(ERRNO) \ + do { int e=(ERRNO); if (e) { errno=e; ::perror(0); assert(0); } } while(0) +#endif + +#define QPID_POSIX_ABORT_IF(ERRNO) if ((int) ERRNO) { errno=ERRNO; ::perror(0); abort(); } + +#endif /*!_posix_check_h*/ diff --git a/qpid/cpp/include/qpid/sys/uuid.h b/qpid/cpp/include/qpid/sys/uuid.h new file mode 100644 index 0000000000..804ab34463 --- /dev/null +++ b/qpid/cpp/include/qpid/sys/uuid.h @@ -0,0 +1,28 @@ +#ifndef _sys_uuid_h +#define _sys_uuid_h + +/* + * + * Copyright (c) 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifdef _WIN32 +# include "qpid/sys/windows/uuid.h" +#else +# include +#endif /* _WIN32 */ + +#endif /* _sys_uuid_h */ -- cgit v1.2.1 From 4f91c17ec4407e5f134904344a2f967348fd397e Mon Sep 17 00:00:00 2001 From: "Stephen D. Huston" Date: Thu, 16 Jul 2009 18:59:12 +0000 Subject: Move necessary files due to header file reorg; fixes Windows build git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@794777 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/sys/windows/Condition.h | 81 +++++++++++ qpid/cpp/include/qpid/sys/windows/Mutex.h | 189 ++++++++++++++++++++++++++ qpid/cpp/include/qpid/sys/windows/Time.h | 36 +++++ 3 files changed, 306 insertions(+) create mode 100755 qpid/cpp/include/qpid/sys/windows/Condition.h create mode 100755 qpid/cpp/include/qpid/sys/windows/Mutex.h create mode 100644 qpid/cpp/include/qpid/sys/windows/Time.h (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/sys/windows/Condition.h b/qpid/cpp/include/qpid/sys/windows/Condition.h new file mode 100755 index 0000000000..c31f7b4823 --- /dev/null +++ b/qpid/cpp/include/qpid/sys/windows/Condition.h @@ -0,0 +1,81 @@ +#ifndef _sys_windows_Condition_h +#define _sys_windows_Condition_h + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/sys/Mutex.h" +#include "qpid/sys/Time.h" + +#include +#include +#include +#include +#include +#undef STATUS_INVALID_PARAMETER // Hack for windows.h namespace pollution + +namespace qpid { +namespace sys { + +// Private Time related implementation details +void toPtime(boost::posix_time::ptime& pt, const AbsTime& t); + +/** + * A condition variable for thread synchronization. + */ +class Condition : private boost::noncopyable +{ + public: + inline Condition(); + inline ~Condition(); + inline void wait(Mutex&); + inline bool wait(Mutex&, const AbsTime& absoluteTime); + inline void notify(); + inline void notifyAll(); + + private: + boost::condition_variable_any condition; +}; + +Condition::Condition() { +} + +Condition::~Condition() { +} + +void Condition::wait(Mutex& mutex) { + condition.wait(mutex.mutex); +} + +bool Condition::wait(Mutex& mutex, const AbsTime& absoluteTime){ + return condition.timed_wait(mutex.mutex, absoluteTime.getPrivate()); +} + +void Condition::notify(){ + condition.notify_one(); +} + +void Condition::notifyAll(){ + condition.notify_all(); +} + +}} +#endif /*!_sys_windows_Condition_h*/ diff --git a/qpid/cpp/include/qpid/sys/windows/Mutex.h b/qpid/cpp/include/qpid/sys/windows/Mutex.h new file mode 100755 index 0000000000..12768640d5 --- /dev/null +++ b/qpid/cpp/include/qpid/sys/windows/Mutex.h @@ -0,0 +1,189 @@ +#ifndef _sys_windows_Mutex_h +#define _sys_windows_Mutex_h + +/* + * + * Copyright (c) 2008 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 "qpid/sys/windows/check.h" + +#include +#if (BOOST_VERSION < 103500) +#error The Windows port requires Boost version 1.35.0 or later +#endif + +#include +#include +#include +#include +#include +#undef STATUS_INVALID_PARAMETER // Hack for windows.h namespace pollution + +namespace qpid { +namespace sys { + +class Condition; + +/** + * Mutex lock. + */ +class Mutex : private boost::noncopyable { + friend class Condition; + +public: + typedef ::qpid::sys::ScopedLock ScopedLock; + typedef ::qpid::sys::ScopedUnlock ScopedUnlock; + + inline Mutex(); + inline ~Mutex(); + inline void lock(); + inline void unlock(); + inline bool trylock(); + + +protected: + boost::recursive_mutex mutex; +}; + +/** + * RW lock. + */ +class RWlock : private boost::noncopyable { + friend class Condition; + +public: + typedef ::qpid::sys::ScopedRlock ScopedRlock; + typedef ::qpid::sys::ScopedWlock ScopedWlock; + + inline RWlock(); + inline ~RWlock(); + inline void wlock(); // will write-lock + inline void rlock(); // will read-lock + inline void unlock(); + inline void trywlock(); // will write-try + inline void tryrlock(); // will read-try + +protected: + boost::shared_mutex rwMutex; + boost::thread_specific_ptr haveWrite; + + inline bool &write (void); +}; + + +/** + * PODMutex is a POD, can be static-initialized with + * PODMutex m = QPID_PODMUTEX_INITIALIZER + */ +struct PODMutex +{ + typedef ::qpid::sys::ScopedLock ScopedLock; + + inline void lock(); + inline void unlock(); + inline bool trylock(); + + // Must be public to be a POD: + boost::recursive_mutex mutex; +}; + +#define QPID_MUTEX_INITIALIZER 0 + +void PODMutex::lock() { + mutex.lock(); +} + +void PODMutex::unlock() { + mutex.unlock(); +} + +bool PODMutex::trylock() { + return mutex.try_lock(); +} + +Mutex::Mutex() { +} + +Mutex::~Mutex(){ +} + +void Mutex::lock() { + mutex.lock(); +} + +void Mutex::unlock() { + mutex.unlock(); +} + +bool Mutex::trylock() { + return mutex.try_lock(); +} + + +RWlock::RWlock() { +} + +RWlock::~RWlock(){ +} + +void RWlock::wlock() { + bool &writer = write(); + rwMutex.lock(); + writer = true; // Remember this thread has write lock held. +} + +void RWlock::rlock() { + bool &writer = write(); + rwMutex.lock_shared(); + writer = false; // Remember this thread has shared lock held. +} + +void RWlock::unlock() { + bool &writer = write(); + if (writer) + rwMutex.unlock(); + else + rwMutex.unlock_shared(); +} + +void RWlock::trywlock() { + bool &writer = write(); + // shared_mutex::try_lock() seems to not be available... emulate it with + // a timed lock(). + boost::system_time now = boost::get_system_time(); + if (rwMutex.timed_lock(now)) + writer = true; +} + +void RWlock::tryrlock() { + bool &writer = write(); + if (rwMutex.try_lock_shared()) + writer = false; +} + +bool & RWlock::write (void) { + // Accessing thread-specific and stack-local info, so no locks needed. + bool *writePtr = haveWrite.get(); + if (writePtr == 0) { + writePtr = new bool(false); + haveWrite.reset(writePtr); + } + return *writePtr; +} + +}} +#endif /*!_sys_windows_Mutex_h*/ diff --git a/qpid/cpp/include/qpid/sys/windows/Time.h b/qpid/cpp/include/qpid/sys/windows/Time.h new file mode 100644 index 0000000000..2987b1c8b2 --- /dev/null +++ b/qpid/cpp/include/qpid/sys/windows/Time.h @@ -0,0 +1,36 @@ +#ifndef QPID_SYS_WINDOWS_TIME_H +#define QPID_SYS_WINDOWS_TIME_H + +/* + * + * Copyright (c) 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +namespace qpid { +namespace sys { + +/** + * Class to represent an instant in time. Boost has this stuff already done + * so just reuse it. We can also grab this for quick use with the Condition + * wait operations. + */ +typedef boost::posix_time::ptime TimePrivate; + +}} // namespace qpid::sys + +#endif /*!QPID_SYS_WINDOWS_TIME_H*/ -- cgit v1.2.1 From 8619e4917cf1100bb79a39631d6ad2960444dab3 Mon Sep 17 00:00:00 2001 From: "Stephen D. Huston" Date: Fri, 17 Jul 2009 19:30:55 +0000 Subject: Move remaining needed Windows files from src/qpid/sys/windows to include/qpid/sys/windows git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@795202 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/sys/windows/IntegerTypes.h | 38 +++++++++++++++++++ qpid/cpp/include/qpid/sys/windows/check.h | 48 ++++++++++++++++++++++++ qpid/cpp/include/qpid/sys/windows/uuid.h | 38 +++++++++++++++++++ 3 files changed, 124 insertions(+) create mode 100755 qpid/cpp/include/qpid/sys/windows/IntegerTypes.h create mode 100755 qpid/cpp/include/qpid/sys/windows/check.h create mode 100644 qpid/cpp/include/qpid/sys/windows/uuid.h (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/sys/windows/IntegerTypes.h b/qpid/cpp/include/qpid/sys/windows/IntegerTypes.h new file mode 100755 index 0000000000..47b1d16a76 --- /dev/null +++ b/qpid/cpp/include/qpid/sys/windows/IntegerTypes.h @@ -0,0 +1,38 @@ +#ifndef QPID_SYS_WINDOWS_INTEGERTYPES_H +#define QPID_SYS_WINDOWS_INTEGERTYPES_H + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +typedef unsigned char uint8_t; +typedef char int8_t; +typedef unsigned short uint16_t; +typedef short int16_t; +typedef unsigned int uint32_t; +typedef int int32_t; +typedef unsigned __int64 uint64_t; +typedef __int64 int64_t; + +// Visual Studio doesn't define other common types, so set them up here too. +typedef int pid_t; +typedef int ssize_t; +typedef unsigned int uint; + +#endif /*!QPID_SYS_WINDOWS_INTEGERTYPES_H*/ diff --git a/qpid/cpp/include/qpid/sys/windows/check.h b/qpid/cpp/include/qpid/sys/windows/check.h new file mode 100755 index 0000000000..aba38814b2 --- /dev/null +++ b/qpid/cpp/include/qpid/sys/windows/check.h @@ -0,0 +1,48 @@ +#ifndef _windows_check_h +#define _windows_check_h + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/Exception.h" +#include "qpid/sys/StrError.h" + +#define QPID_WINDOWS_ERROR(ERRVAL) qpid::Exception(QPID_MSG(qpid::sys::strError(ERRVAL))) +#define QPID_WINDOWS_CRT_ERROR(ERRNO) qpid::Exception(QPID_MSG(qpid::sys::strError(ERRNO))) + +/** THROW QPID_WINDOWS_ERROR(::GetLastError()) if RESULT is NULL */ +#define QPID_WINDOWS_CHECK_NULL(RESULT) \ + if ((RESULT) == NULL) throw QPID_WINDOWS_ERROR((::GetLastError())) + +#define QPID_WINDOWS_CHECK_NOT(RESULT,VAL) \ + if ((RESULT) == (VAL)) throw QPID_WINDOWS_ERROR((::GetLastError())) + +#define QPID_WINDOWS_CHECK_ASYNC_START(STATUS) \ + if (!(STATUS) && ::WSAGetLastError() != ERROR_IO_PENDING) \ + throw QPID_WINDOWS_ERROR((::WSAGetLastError())) + +#define QPID_WINDOWS_CHECK_CRT_NZ(VAL) \ + if ((VAL) == 0) throw QPID_WINDOWS_CRT_ERROR(errno) + +#define QPID_WINSOCK_CHECK(OP) \ + if ((OP) == SOCKET_ERROR) throw QPID_WINDOWS_ERROR((::WSAGetLastError())) + +#endif /*!_windows_check_h*/ diff --git a/qpid/cpp/include/qpid/sys/windows/uuid.h b/qpid/cpp/include/qpid/sys/windows/uuid.h new file mode 100644 index 0000000000..c79abe95c6 --- /dev/null +++ b/qpid/cpp/include/qpid/sys/windows/uuid.h @@ -0,0 +1,38 @@ +#ifndef _sys_windows_uuid_h +#define _sys_windows_uuid_h + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/CommonImportExport.h" +#include + +namespace qpid { namespace sys { const size_t UuidSize = 16; }} +typedef uint8_t uuid_t[qpid::sys::UuidSize]; + +QPID_COMMON_EXTERN void uuid_clear (uuid_t uu); +QPID_COMMON_EXTERN void uuid_copy (uuid_t dst, const uuid_t src); +QPID_COMMON_EXTERN void uuid_generate (uuid_t out); +QPID_COMMON_EXTERN int uuid_is_null (const uuid_t uu); // Returns 1 if null, else 0 +QPID_COMMON_EXTERN int uuid_parse (const char *in, uuid_t uu); // Returns 0 on success, else -1 +QPID_COMMON_EXTERN void uuid_unparse (const uuid_t uu, char *out); + +#endif /*!_sys_windows_uuid_h*/ -- cgit v1.2.1 From 7d5ae16e63c38e15e316c9b66ee9e1ecdf26b2db Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Tue, 4 Aug 2009 19:27:57 +0000 Subject: Explicit Msg::op<< overrides for integral types, fixes a store compile problem. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@800931 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/Msg.h | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/Msg.h b/qpid/cpp/include/qpid/Msg.h index 5149a94d7f..6e08a89571 100644 --- a/qpid/cpp/include/qpid/Msg.h +++ b/qpid/cpp/include/qpid/Msg.h @@ -43,14 +43,29 @@ struct Msg { Msg(const Msg& m) : os(m.str()) {} std::string str() const { return os.str(); } operator std::string() const { return str(); } + + Msg& operator<<(long n) { os << n; return *this; } + Msg& operator<<(unsigned long n) { os << n; return *this; } + Msg& operator<<(bool n) { os << n; return *this; } + Msg& operator<<(short n) { os << n; return *this; } + Msg& operator<<(unsigned short n) { os << n; return *this; } + Msg& operator<<(int n) { os << n; return *this; } + Msg& operator<<(unsigned int n) { os << n; return *this; } +#ifdef _GLIBCXX_USE_LONG_LONG + Msg& operator<<(long long n) { os << n; return *this; } + Msg& operator<<(unsigned long long n) { os << n; return *this; } +#endif + Msg& operator<<(double n) { os << n; return *this; } + Msg& operator<<(float n) { os << n; return *this; } + Msg& operator<<(long double n) { os << n; return *this; } + + template Msg& operator<<(const T& t) { os < const Msg& operator<<(const Msg& m, const T& t) { - const_cast(m.os)< Date: Wed, 19 Aug 2009 18:31:31 +0000 Subject: Introduce the public includes for the QMF interfaces. Rename Agent to AgentEngine to differentiate the API from the underlying engine. Note that some of these public headers will overlap with the emerging "messaging" API (notably Connection.h and ConnectionSettings.h). It is desirable that these components of the API become common between "messaging" and "qmf". As such, once the differences are reconciled, they will most likely be removed from the qmf space and placed in the messaging space. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@805916 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/Agent.h | 283 ++++++++++++++++++++++++++++++ qpid/cpp/include/qmf/AgentObject.h | 93 ++++++++++ qpid/cpp/include/qmf/Connection.h | 118 +++++++++++++ qpid/cpp/include/qmf/ConnectionSettings.h | 135 ++++++++++++++ qpid/cpp/include/qmf/QmfImportExport.h | 33 ++++ 5 files changed, 662 insertions(+) create mode 100644 qpid/cpp/include/qmf/Agent.h create mode 100644 qpid/cpp/include/qmf/AgentObject.h create mode 100644 qpid/cpp/include/qmf/Connection.h create mode 100644 qpid/cpp/include/qmf/ConnectionSettings.h create mode 100644 qpid/cpp/include/qmf/QmfImportExport.h (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qmf/Agent.h b/qpid/cpp/include/qmf/Agent.h new file mode 100644 index 0000000000..2ba639ca37 --- /dev/null +++ b/qpid/cpp/include/qmf/Agent.h @@ -0,0 +1,283 @@ +#ifndef _QmfAgent_ +#define _QmfAgent_ + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include "qmf/QmfImportExport.h" + +namespace qmf { + + class AgentImpl; + class Connection; + class ObjectId; + class AgentObject; + class Value; + class Event; + class SchemaObjectClass; + + /** + * AgentListener is used by agents that select the internalStore=false option (see Agent + * constructor) or by agents that wish to provide access control for queries and methods. + */ + class AgentListener { + QMF_EXTERN virtual ~AgentListener(); + + /** + * allowQuery is called before a query operation is executed. If true is returned + * by this function, the query will proceed. If false is returned, the query will + * be forbidden. + * + * @param q The query being requested. + * @param userId The authenticated identity of the user requesting the query. + */ + virtual bool allowQuery(const Query& q, const char* userId); + + /** + * allowMethod is called before a method call is executed. If true is returned + * by this function, the method call will proceed. If false is returned, the method + * call will be forbidden. + * + * @param name The name of the method being called. + * @param args A value object (of type "map") that contains both input and output arguments. + * @param oid The objectId that identifies the instance of the object being called. + * @param cls The Schema describing the object being called. + * @param userId The authenticated identity of the requesting user. + */ + virtual bool allowMethod(const char* name, const Value& args, const ObjectId& oid, + const SchemaObjectClass& cls, const char* userId); + + /** + * query is called when the agent receives a query request. The handler must invoke + * Agent::queryResponse zero or more times (using the supplied context) followed by + * a single invocation of Agent::queryComplete. These calls do not need to be made + * synchronously in the context of this function. They may occur before or after this + * function returns. + * + * This function will only be invoked if internalStore=false in the Agent's constructor. + * + * @param context A context value to use in resulting calls to queryResponse and quertComplete. + * @param q The query requested by the console. + * @param userId the authenticated identity of the user requesting the query. + */ + virtual void query(uint32_t context, const Query& q, const char* userId); + + /** + * syncStart is called when a console requests a standing query. This function must + * behave exactly like AgentListener::query (i.e. send zero or more responses followed + * by a queryComplete) except it then remembers the context and the query and makes + * subsequent queryResponse calls whenever appropriate according the the query. + * + * The standing query shall stay in effect until syncStop is called with the same context + * value or until a specified period of time elapses without receiving a syncTouch for the + * context. + * + * This function will only be invoked if internalStore=false in the Agent's constructor. + * + * @param context A context value to use in resulting calls to queryResponse and queryComplete. + * @param q The query requested by the console. + * @param userId the authenticated identity of the user requesting the query. + */ + virtual void syncStart(uint32_t context, const Query& q, const char* userId); + + /** + * syncTouch is called when the console that requested a standing query refreshes its + * interest in the query. The console must periodically "touch" a standing query to keep + * it alive. This prevents standing queries from accumulating when the console disconnects + * before it can stop the query. + * + * This function will only be invoked if internalStore=false in the Agent's constructor. + * + * @param context The context supplied in a previous call to syncStart. + * @param userId The authenticated identity of the requesting user. + */ + virtual void syncTouch(uint32_t context, const char* userId); + + /** + * syncStop is called when the console that requested a standing query no longer wishes to + * receive data associated with that query. The application shall stop processing this + * query and shall remove its record of the context value. + * + * This function will only be invoked if internalStore=false in the Agent's constructor. + * + * @param context The context supplied in a previous call to syncStart. + * @param userId The authenticated identity of the requesting user. + */ + virtual void syncStop(uint32_t context, const char* userId); + + /** + * methodCall is called when a console invokes a method on a QMF object. The application + * must call Agent::methodResponse once in response to this function. The response does + * not need to be called synchronously in the context of this function. It may be called + * before or after this function returns. + * + * This function will only be invoked if internalStore=false in the Agent's constructor. + * + * @param context A context value to use in resulting call to methodResponse. + * @param name The name of the method being called. + * @param args A value object (of type "map") that contains both input and output arguments. + * @param oid The objectId that identifies the instance of the object being called. + * @param cls The Schema describing the object being called. + * @param userId The authenticated identity of the requesting user. + */ + virtual void methodCall(uint32_t context, const char* name, Value& args, + const ObjectId& oid, const SchemaObjectClass& cls, const char* userId); + }; + + /** + * The Agent class is the QMF Agent portal. It should be instantiated once and associated with a + * Connection (setConnection) to connect an agent to the QMF infrastructure. + */ + class Agent { + public: + /** + * Create an instance of the Agent class. + * + * @param label An optional string label that can be used to identify the agent. + * + * @param internalStore If true, objects shall be tracked internally by the agent. + * If false, the user of the agent must track the objects. + * If the agent is tracking the objects, queries and syncs are handled by + * the agent. The only involvement the user has is to optionally authorize + * individual operations. If the user is tracking the objects, the user code + * must implement queries and syncs (standing queries). + * + * @param listener A pointer to a class that implements the AgentListener interface. + * This must be supplied if any of the following conditions are true: + * - The agent model contains methods + * - The user wishes to individually authorize query and sync operations. + * - internalStore = false + */ + QMF_EXTERN Agent(char* label="qmfa", bool internalStore=true, AgentListener* listener=0); + + /** + * Destroy an instance of the Agent class. + */ + QMF_EXTERN ~Agent(); + + /** + * Set the persistent store file. This file, if specified, is used to store state information + * about the Agent. For example, if object-ids must be persistent across restarts of the Agent + * program, this file path must be supplied. + * + * @param path Full path to a file that is both writable and readable by the Agent program. + */ + QMF_EXTERN void setStoreDir(const char* path); + + /** + * Provide a connection (to a Qpid broker) over which the agent can communicate. + * + * @param conn Pointer to a Connection object. + */ + QMF_EXTERN void setConnection(Connection* conn); + + /** + * Register a class schema (object or event) with the agent. The agent must have a registered + * schema for an object class or an event class before it can handle objects or events of that + * class. + * + * @param cls Pointer to the schema structure describing the class. + */ + QMF_EXTERN void registerClass(SchemaObjectClass* cls); + QMF_EXTERN void registerClass(SchemaEventClass* cls); + + /** + * Add an object to the agent (for internal storage mode only). + * + * @param obj Reference to the object to be managed by the agent. + * + * @param persistent Iff true, the object ID assigned to the object shall indicate persistence + * (i.e. the object ID shall be the same across restarts of the agent program). + * + * @param oid 64-bit value for the oid (if zero, the agent will assign the value). + * + * @param oidLo 32-bit value for the lower 32-bits of the oid. + * + * @param oidHi 32-bit value for the upper 32-bits of the oid. + */ + QMF_EXTERN const ObjectId* addObject(AgentObject& obj, bool persistent=false, uint64_t oid=0); + QMF_EXTERN const ObjectId* addObject(AgentObject& obj, bool persistent, uint32_t oidLo, uint32_t oidHi); + + /** + * Allocate an object ID for an object (for external storage mode only). + * + * @param persistent Iff true, the object ID allocated shall indicate persistence + * (i.e. the object ID shall be the same across restarts of the agent program). + * + * @param oid 64-bit value for the oid (if zero, the agent will assign the value). + * + * @param oidLo 32-bit value for the lower 32-bits of the oid. + * + * @param oidHi 32-bit value for the upper 32-bits of the oid. + */ + QMF_EXTERN const ObjectId* allocObjectId(bool persistent=false, uint64_t oid=0); + QMF_EXTERN const ObjectId* allocObjectId(bool persistent, uint32_t oidLo, uint32_t oidHi); + + /** + * Raise a QMF event. + * + * @param event Reference to an event object to be raised to the QMF infrastructure. + */ + QMF_EXTERN void raiseEvent(Event& event); + + /** + * Provide a response to a query (for external storage mode only). + * + * @param context The context value supplied in the query (via the AgentListener interface). + * + * @param object A reference to the agent that matched the query criteria. + * + * @param prop If true, transmit the property attributes of this object. + * + * @param stat If true, transmit the statistic attributes of this object. + */ + QMF_EXTERN void queryResponse(uint32_t context, AgentObject& object, bool prop = true, bool stat = true); + + /** + * Indicate that a query (or the initial dump of a sync) is complete (for external storage mode only). + * + * @param context The context value supplied in the query/sync (via the AgentListener interface). + */ + QMF_EXTERN void queryComplete(uint32_t context); + + /** + * Provide the response to a method call. + * + * @param context The context value supplied in the method request (via the AgentListener interface). + * + * @param args The argument list from the method call. Must include the output arguments (may include + * the input arguments). + * + * @param status Numerical return status: zero indicates no error, non-zero indicates error. + * + * @param exception Pointer to an exception value. If status is non-zero, the exception value is + * sent to the caller. It is optional (i.e. leave the pointer as 0), or may be + * set to any legal value. A string may be supplied, but an unmanaged object of + * any schema may also be passed. + */ + QMF_EXTERN void methodResponse(uint32_t context, const Value& args, uint32_t status=0, + const Value* exception=0); + + private: + AgentImpl* impl; + }; + +} + +#endif diff --git a/qpid/cpp/include/qmf/AgentObject.h b/qpid/cpp/include/qmf/AgentObject.h new file mode 100644 index 0000000000..d6073bca3c --- /dev/null +++ b/qpid/cpp/include/qmf/AgentObject.h @@ -0,0 +1,93 @@ +#ifndef _QmfAgentObject_ +#define _QmfAgentObject_ + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include "qmf/QmfImportExport.h" + +namespace qmf { + + class AgentObjectImpl; + class SchemaObjectClass; + class ObjectId; + class Value; + class Agent; + + /** + * AgentObject is an extension of Object with agent-specific methods added. + */ + class AgentObject : public Object { + public: + /** + * Create a new Object of a specific type. + * + * @param type Pointer to the schema class to use as a type for this object. + */ + QMF_EXTERN AgentObject(const SchemaObjectClass* type); + + /** + * Schedule this object for deletion. Agent objects should never be directly + * destroyed, rather this method should be called and all pointers to this + * object dropped. The agent will clean up and properly delete the object at + * the appropraite time. + */ + QMF_EXTERN void destroy(); + + /** + * Set the object ID for this object if it is to be managed by the agent. + * + * @param oid The new object ID for the managed object. + */ + QMF_EXTERN void setObjectId(ObjectId& oid); + + /** + * Handler for invoked method calls. This will only be called for objects that + * are being managed and stored by an agent (see internalStore argument in Agent::Agent). + * If this function is not overridden in a child class, the default implementation will + * cause AgentListener::methodCall to be invoked in the application program. + * + * If this function is overridden in a sub-class, the implementation must perform + * the actions associated with the method call (i.e. implement the method). Once the + * method execution is complete, it must call Agent::methodResponse with the result + * of the method execution. Agent::methodResponse does not need to be called + * synchronously in the context of this function call. It may be called at a later + * time from a different thread. + * + * @param context Context supplied by the agent and required to be passed in the + * call to Agent::methodResponse + * + * @param name The name of the method. + * + * @param args A Value (of type map) that contains the input and output arguments. + * + * @param userId The authenticated identity of the user who invoked the method. + */ + QMF_EXTERN virtual void methodInvoked(uint32_t context, const char* name, Value& args, + const char* userId); + private: + friend class Agent; + virtual ~AgentObject(); + void setAgent(Agent* agent); + AgentObjectImpl* impl; + }; + +} + +#endif diff --git a/qpid/cpp/include/qmf/Connection.h b/qpid/cpp/include/qmf/Connection.h new file mode 100644 index 0000000000..dbe8e97cfe --- /dev/null +++ b/qpid/cpp/include/qmf/Connection.h @@ -0,0 +1,118 @@ +#ifndef _QmfConnection_ +#define _QmfConnection_ + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include "qmf/QmfImportExport.h" +#include "qmf/ConnectionSettings.h" + +namespace qmf { + + enum ConnectionState { + CONNECTION_UP = 1, + CONNECTION_DOWN = 2 + }; + + /** + * Implement a subclass of ConnectionListener and provide it with the + * Connection constructor to receive notification of changes in the + * connection state. + * + * \ingroup qmfapi + */ + class ConnectionListener { + QMF_EXTERN virtual ~ConnectionListener(); + + /** + * Called each time the state of the connection changes. + */ + virtual void newState(ConnectionState state); + + /** + * Called if the connection requires input from an interactive client. + * + * @param prompt Text of the prompt - describes what information is required. + * @param answer The interactive user input. + * @param answerLen on Input - the maximum number of bytes that can be copied to answer. + * on Output - the number of bytes copied to answer. + */ + virtual void interactivePrompt(const char* prompt, char* answer, uint32_t answerLen); + }; + + class ConnectionImpl; + + /** + * The Connection class represents a connection to a QPID broker that can + * be used by agents and consoles, possibly multiple at the same time. + * + * \ingroup qmfapi + */ + class Connection { + public: + + /** + * Creates a connection object and begins the process of attempting to + * connect to the QPID broker. + * + * @param settings The settings that control how the connection is set + * up. + * + * @param listener An optional pointer to a subclass of + * ConnectionListener to receive notifications of events related to + * this connection. + */ + QMF_EXTERN Connection(const ConnectionSettings& settings, + const ConnectionListener* listener = 0); + + /** + * Destroys a connection, causing the connection to be closed. + */ + QMF_EXTERN ~Connection(); + + /** + * Set the administrative state of the connection (enabled or disabled). + * + * @param enabled True => enable connection, False => disable connection + */ + QMF_EXTERN void setAdminState(bool enabled); + + /** + * Return the current operational state of the connection (up or down). + * + * @return the current connection state. + */ + QMF_EXTERN ConnectionState getOperState() const; + + /** + * Get the error message from the last failure to connect. + * + * @return Null-terminated string containing the error message. + */ + QMF_EXTERN const char* getLastError() const; + + private: + friend class AgentImpl; + friend class ConsoleImpl; + ConnectionImpl* impl; + }; + +} + +#endif diff --git a/qpid/cpp/include/qmf/ConnectionSettings.h b/qpid/cpp/include/qmf/ConnectionSettings.h new file mode 100644 index 0000000000..b5f3be7eef --- /dev/null +++ b/qpid/cpp/include/qmf/ConnectionSettings.h @@ -0,0 +1,135 @@ +#ifndef _QmfConnectionSettings_ +#define _QmfConnectionSettings_ + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include "qmf/QmfImportExport.h" + +namespace qmf { + + class ConnectionSettingsImpl; + class Value; + + /** + * Settings for AMQP connections to the broker. + */ + class ConnectionSettings { + public: + + /** + * Create a set of default connection settings. + * + * If no further attributes are set, the settings will cause a connection to be made to + * the default broker (on localhost or at a host/port supplied by service discovery) and + * authentication will be the best-available (GSSAPI/Kerberos, Anonymous, Plain with prompts + * for username and password). + */ + QMF_EXTERN ConnectionSettings(); + + /** + * Create a set of connection settings by URL. + * + * @param url Universal resource locator describing the broker address and additional attributes. + * + * The URL is of the form: + * amqp[s]://host[:port][?key=value[&key=value]*] + * + * For example: + * amqp://localhost + * amqp://broker?transport=rdma&authmech=GSSAPI&authservice=qpidd + * amqps://broker?authmech=PLAIN&authuser=guest&authpass=guest + */ + QMF_EXTERN ConnectionSettings(const char* url); + + /** + * Destroy the connection settings object. + */ + QMF_EXTERN ~ConnectionSettings(); + + /** + * Set an attribute to control connection setup. + * + * @param key A null-terminated string that is an attribute name. + * + * @param value Reference to a value to be stored as the attribute. The type of the value + * is specific to the key. + */ + QMF_EXTERN void setAttr(const char* key, const Value& value); + + /** + * Get the value of an attribute. + * + * @param key A null-terminated attribute name. + */ + QMF_EXTERN const Value& getAttr(const char* key) const; + + /** + * Get the attribute string (the portion of the URL following the '?') for the settings. + * + * @return A pointer to the attribute string. If the content of this string needs to be + * available beyond the scope of the calling function, it should be copied. The + * returned pointer may become invalid if the set of attributes is changed. + */ + QMF_EXTERN const char* getAttrString() const; + + /** + * Shortcuts for setting the transport for the connection. + * + * @param port The port value for the connection address. + */ + QMF_EXTERN void transportTcp(uint16_t port = 5672); + QMF_EXTERN void transportSsl(uint16_t port = 5671); + QMF_EXTERN void transportRdma(uint16_t port = 5672); + + /** + * Shortcuts for setting authentication mechanisms. + * + * @param username Null-terminated authentication user name. + * + * @param password Null-terminated authentication password. + * + * @param serviceName Null-terminated GSSAPI service name (Kerberos service principal) + * + * @param minSsf Minimum security factor for connections. 0 = encryption not required. + * + * @param maxSsf Maximum security factor for connections. 0 = encryption not permitted. + */ + QMF_EXTERN void authAnonymous(const char* username = 0); + QMF_EXTERN void authPlain(const char* username = 0, const char* password = 0); + QMF_EXTERN void authGssapi(const char* serviceName, uint32_t minSsf = 0, uint32_t maxSsf = 256); + + /** + * Shortcut for setting connection retry attributes. + * + * @param delayMin Minimum delay (in seconds) between connection attempts. + * + * @param delaxMax Maximum delay (in seconds) between connection attempts. + * + * @param delayFactor Factor to multiply the delay by between failed connection attempts. + */ + QMF_EXTERN void setRetry(int delayMin = 1, int delayMax = 128, int delayFactor = 2); + + private: + ConnectionSettingsImpl* impl; + }; + +} + +#endif diff --git a/qpid/cpp/include/qmf/QmfImportExport.h b/qpid/cpp/include/qmf/QmfImportExport.h new file mode 100644 index 0000000000..8353a3cc16 --- /dev/null +++ b/qpid/cpp/include/qmf/QmfImportExport.h @@ -0,0 +1,33 @@ +#ifndef QMF_IMPORT_EXPORT_H +#define QMF_IMPORT_EXPORT_H + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#if defined(WIN32) && !defined(QPID_DECLARE_STATIC) +# if defined(QMF_EXPORT) || defined (qmf_EXPORTS) +# define QMF_EXTERN __declspec(dllexport) +# else +# define QMF_EXTERN __declspec(dllimport) +# endif +#else +# define QMF_EXTERN +#endif + +#endif -- cgit v1.2.1 From eaad487ef5d7233af17e9abf6f226fa962ebc931 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Wed, 19 Aug 2009 20:01:57 +0000 Subject: Fixed doxygen generation for the C++ APIs git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@805955 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/Agent.h | 4 ++++ qpid/cpp/include/qmf/AgentObject.h | 2 ++ qpid/cpp/include/qmf/Connection.h | 5 +++++ qpid/cpp/include/qmf/ConnectionSettings.h | 2 ++ 4 files changed, 13 insertions(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qmf/Agent.h b/qpid/cpp/include/qmf/Agent.h index 2ba639ca37..e61cd737d0 100644 --- a/qpid/cpp/include/qmf/Agent.h +++ b/qpid/cpp/include/qmf/Agent.h @@ -35,6 +35,8 @@ namespace qmf { /** * AgentListener is used by agents that select the internalStore=false option (see Agent * constructor) or by agents that wish to provide access control for queries and methods. + * + * \ingroup qmfapi */ class AgentListener { QMF_EXTERN virtual ~AgentListener(); @@ -143,6 +145,8 @@ namespace qmf { /** * The Agent class is the QMF Agent portal. It should be instantiated once and associated with a * Connection (setConnection) to connect an agent to the QMF infrastructure. + * + * \ingroup qmfapi */ class Agent { public: diff --git a/qpid/cpp/include/qmf/AgentObject.h b/qpid/cpp/include/qmf/AgentObject.h index d6073bca3c..a1878605eb 100644 --- a/qpid/cpp/include/qmf/AgentObject.h +++ b/qpid/cpp/include/qmf/AgentObject.h @@ -32,6 +32,8 @@ namespace qmf { /** * AgentObject is an extension of Object with agent-specific methods added. + * + * \ingroup qmfapi */ class AgentObject : public Object { public: diff --git a/qpid/cpp/include/qmf/Connection.h b/qpid/cpp/include/qmf/Connection.h index dbe8e97cfe..b910cdad19 100644 --- a/qpid/cpp/include/qmf/Connection.h +++ b/qpid/cpp/include/qmf/Connection.h @@ -25,6 +25,11 @@ namespace qmf { + /** + * Operational states for Connections. + * + * \ingroup qmfapi + */ enum ConnectionState { CONNECTION_UP = 1, CONNECTION_DOWN = 2 diff --git a/qpid/cpp/include/qmf/ConnectionSettings.h b/qpid/cpp/include/qmf/ConnectionSettings.h index b5f3be7eef..53a83dfd2a 100644 --- a/qpid/cpp/include/qmf/ConnectionSettings.h +++ b/qpid/cpp/include/qmf/ConnectionSettings.h @@ -29,6 +29,8 @@ namespace qmf { /** * Settings for AMQP connections to the broker. + * + * \ingroup qmfapi */ class ConnectionSettings { public: -- cgit v1.2.1 From a129efee1a584da6540aa4118ddbf6a40ecaa763 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Thu, 20 Aug 2009 13:25:06 +0000 Subject: Add List class to handle encoding of AMQP 0-10 list type. Fill out accessors for different FieldValue types. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@806162 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/framing/FieldTable.h | 8 +- qpid/cpp/include/qpid/framing/FieldValue.h | 117 ++++++++++++++++++++++++++++- qpid/cpp/include/qpid/framing/List.h | 76 +++++++++++++++++++ 3 files changed, 198 insertions(+), 3 deletions(-) create mode 100644 qpid/cpp/include/qpid/framing/List.h (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/framing/FieldTable.h b/qpid/cpp/include/qpid/framing/FieldTable.h index a3a5c8a4ee..b2331cd4e1 100644 --- a/qpid/cpp/include/qpid/framing/FieldTable.h +++ b/qpid/cpp/include/qpid/framing/FieldTable.h @@ -51,6 +51,8 @@ class FieldTable typedef boost::shared_ptr ValuePtr; typedef std::map ValueMap; typedef ValueMap::iterator iterator; + typedef ValueMap::const_reference const_reference; + typedef ValueMap::value_type value_type; QPID_COMMON_EXTERN FieldTable() {}; QPID_COMMON_EXTERN FieldTable(const FieldTable& ft); @@ -97,12 +99,16 @@ class FieldTable QPID_COMMON_EXTERN bool operator==(const FieldTable& other) const; // Map-like interface. - // TODO: may need to duplicate into versions that return mutable iterator ValueMap::const_iterator begin() const { return values.begin(); } ValueMap::const_iterator end() const { return values.end(); } ValueMap::const_iterator find(const std::string& s) const { return values.find(s); } + ValueMap::iterator begin() { return values.begin(); } + ValueMap::iterator end() { return values.end(); } + ValueMap::iterator find(const std::string& s) { return values.find(s); } + std::pair insert(const ValueMap::value_type&); + ValueMap::iterator insert(ValueMap::iterator, const ValueMap::value_type&); void clear() { values.clear(); } // ### Hack Alert diff --git a/qpid/cpp/include/qpid/framing/FieldValue.h b/qpid/cpp/include/qpid/framing/FieldValue.h index 97fc56d606..6c2f5b5876 100644 --- a/qpid/cpp/include/qpid/framing/FieldValue.h +++ b/qpid/cpp/include/qpid/framing/FieldValue.h @@ -24,6 +24,7 @@ #include "qpid/Exception.h" #include "qpid/framing/amqp_types.h" #include "qpid/framing/Buffer.h" +#include "qpid/framing/Endian.h" #include "qpid/framing/FieldTable.h" #include "qpid/CommonImportExport.h" @@ -36,7 +37,6 @@ namespace qpid { namespace framing { -//class Array; /** * Exception that is the base exception for all field table errors. * @@ -53,6 +53,8 @@ struct InvalidConversionException : public FieldValueException { InvalidConversionException() {} }; +class List; + /** * Value that can appear in an AMQP field table * @@ -96,12 +98,17 @@ class FieldValue { template bool convertsTo() const { return false; } template T get() const { throw InvalidConversionException(); } + template T getIntegerValue() const; + template T getFloatingPointValue() const; + template bool get(T&) const; + protected: FieldValue(uint8_t t, Data* d): typeOctet(t), data(d) {} private: uint8_t typeOctet; std::auto_ptr data; + }; template <> @@ -165,10 +172,52 @@ class FixedWidthValue : public FieldValue::Data { return v; } uint8_t* rawOctets() { return octets; } + uint8_t* rawOctets() const { return octets; } void print(std::ostream& o) const { o << "F" << width << ":"; }; }; +template +inline T FieldValue::getIntegerValue() const +{ + FixedWidthValue* const fwv = dynamic_cast< FixedWidthValue* const>(data.get()); + if (fwv) { + uint8_t* octets = fwv->rawOctets(); + T v = 0; + for (int i = 0; i < W-1; ++i) { + v |= octets[i]; v <<= 8; + } + v |= octets[W-1]; + return v; + } else { + throw InvalidConversionException(); + } +} + +template +inline T FieldValue::getFloatingPointValue() const { + FixedWidthValue* const fwv = dynamic_cast< FixedWidthValue* const>(data.get()); + if (fwv) { + T value; + uint8_t* const octets = Endian::convertIfRequired(fwv->rawOctets(), W); + uint8_t* const target = reinterpret_cast(&value); + for (uint i = 0; i < W; ++i) target[i] = octets[i]; + return value; + } else { + throw InvalidConversionException(); + } +} + +template <> +inline float FieldValue::get() const { + return getFloatingPointValue(); +} + +template <> +inline double FieldValue::get() const { + return getFloatingPointValue(); +} + template <> class FixedWidthValue<0> : public FieldValue::Data { public: @@ -243,6 +292,27 @@ class EncodedValue : public FieldValue::Data { void print(std::ostream& o) const { o << "[" << value << "]"; }; }; +/** + * Accessor that can be used to get values of type FieldTable, Array + * and List. + */ +template +inline bool FieldValue::get(T& t) const +{ + const EncodedValue* v = dynamic_cast< EncodedValue* >(data.get()); + if (v != 0) { + t = v->getValue(); + return true; + } else { + try { + t = get(); + return true; + } catch (const InvalidConversionException&) { + return false; + } + } +} + class Str8Value : public FieldValue { public: QPID_COMMON_EXTERN Str8Value(const std::string& v); @@ -294,6 +364,7 @@ class Unsigned64Value : public FieldValue { class FieldTableValue : public FieldValue { public: + typedef FieldTable ValueType; QPID_COMMON_EXTERN FieldTableValue(const FieldTable&); }; @@ -302,6 +373,49 @@ class ArrayValue : public FieldValue { QPID_COMMON_EXTERN ArrayValue(const Array&); }; +class VoidValue : public FieldValue { + public: + QPID_COMMON_EXTERN VoidValue(); +}; + +class BoolValue : public FieldValue { + public: + QPID_COMMON_EXTERN BoolValue(bool); +}; + +class Unsigned8Value : public FieldValue { + public: + QPID_COMMON_EXTERN Unsigned8Value(uint8_t); +}; + +class Unsigned16Value : public FieldValue { + public: + QPID_COMMON_EXTERN Unsigned16Value(uint16_t); +}; + +class Unsigned32Value : public FieldValue { + public: + QPID_COMMON_EXTERN Unsigned32Value(uint32_t); +}; + +class Integer8Value : public FieldValue { + public: + QPID_COMMON_EXTERN Integer8Value(int8_t); +}; + +class Integer16Value : public FieldValue { + public: + QPID_COMMON_EXTERN Integer16Value(int16_t); +}; + +typedef IntegerValue Integer32Value; + +class ListValue : public FieldValue { + public: + typedef List ValueType; + QPID_COMMON_EXTERN ListValue(const List&); +}; + template bool getEncodedValue(FieldTable::ValuePtr vptr, T& value) { @@ -315,7 +429,6 @@ bool getEncodedValue(FieldTable::ValuePtr vptr, T& value) return false; } - }} // qpid::framing #endif diff --git a/qpid/cpp/include/qpid/framing/List.h b/qpid/cpp/include/qpid/framing/List.h new file mode 100644 index 0000000000..cb1129ebf8 --- /dev/null +++ b/qpid/cpp/include/qpid/framing/List.h @@ -0,0 +1,76 @@ +#ifndef QPID_FRAMING_LIST_H +#define QPID_FRAMING_LIST_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#include "qpid/CommonImportExport.h" +#include "qpid/framing/amqp_types.h" +#include +#include +#include + +namespace qpid { +namespace framing { + +class Buffer; +class FieldValue; + +/** + * Representation of an AMQP 0-10 list + */ +class List +{ + public: + typedef boost::shared_ptr ValuePtr; + typedef std::list Values; + typedef Values::const_iterator const_iterator; + typedef Values::iterator iterator; + typedef Values::const_reference const_reference; + + QPID_COMMON_EXTERN uint32_t encodedSize() const; + QPID_COMMON_EXTERN void encode(Buffer& buffer) const; + QPID_COMMON_EXTERN void decode(Buffer& buffer); + + QPID_COMMON_EXTERN bool operator==(const List& other) const; + + // std collection interface. + QPID_COMMON_EXTERN const_iterator begin() const { return values.begin(); } + QPID_COMMON_EXTERN const_iterator end() const { return values.end(); } + QPID_COMMON_EXTERN iterator begin() { return values.begin(); } + QPID_COMMON_EXTERN iterator end(){ return values.end(); } + + QPID_COMMON_EXTERN ValuePtr front() const { return values.front(); } + QPID_COMMON_EXTERN ValuePtr back() const { return values.back(); } + QPID_COMMON_EXTERN size_t size() const { return values.size(); } + + QPID_COMMON_EXTERN iterator insert(iterator i, ValuePtr value) { return values.insert(i, value); } + QPID_COMMON_EXTERN void erase(iterator i) { values.erase(i); } + QPID_COMMON_EXTERN void push_back(ValuePtr value) { values.insert(end(), value); } + QPID_COMMON_EXTERN void pop_back() { values.pop_back(); } + + private: + Values values; + + friend QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& out, const List& list); +}; +}} // namespace qpid::framing + +#endif /*!QPID_FRAMING_LIST_H*/ -- cgit v1.2.1 From e3845b342a25a1aaca995d6c4e9a053a1a98fbf7 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Thu, 20 Aug 2009 16:18:57 +0000 Subject: Fixed distcheck target, broken by my last commit. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@806237 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/framing/FieldValue.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/framing/FieldValue.h b/qpid/cpp/include/qpid/framing/FieldValue.h index 6c2f5b5876..23d436ecb6 100644 --- a/qpid/cpp/include/qpid/framing/FieldValue.h +++ b/qpid/cpp/include/qpid/framing/FieldValue.h @@ -24,7 +24,6 @@ #include "qpid/Exception.h" #include "qpid/framing/amqp_types.h" #include "qpid/framing/Buffer.h" -#include "qpid/framing/Endian.h" #include "qpid/framing/FieldTable.h" #include "qpid/CommonImportExport.h" @@ -105,6 +104,8 @@ class FieldValue { protected: FieldValue(uint8_t t, Data* d): typeOctet(t), data(d) {} + static uint8_t* convertIfRequired(uint8_t* const octets, int width); + private: uint8_t typeOctet; std::auto_ptr data; @@ -199,7 +200,7 @@ inline T FieldValue::getFloatingPointValue() const { FixedWidthValue* const fwv = dynamic_cast< FixedWidthValue* const>(data.get()); if (fwv) { T value; - uint8_t* const octets = Endian::convertIfRequired(fwv->rawOctets(), W); + uint8_t* const octets = convertIfRequired(fwv->rawOctets(), W); uint8_t* const target = reinterpret_cast(&value); for (uint i = 0; i < W; ++i) target[i] = octets[i]; return value; -- cgit v1.2.1 From b9615420016232ee391da7e3ffd05f0631fc2a47 Mon Sep 17 00:00:00 2001 From: "Stephen D. Huston" Date: Thu, 20 Aug 2009 22:43:06 +0000 Subject: Add needed extern decorators for Windows; applies patch QPID-2061-1.patch in QPID-2061 git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@806384 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/framing/FieldValue.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/framing/FieldValue.h b/qpid/cpp/include/qpid/framing/FieldValue.h index 23d436ecb6..f8db6dd382 100644 --- a/qpid/cpp/include/qpid/framing/FieldValue.h +++ b/qpid/cpp/include/qpid/framing/FieldValue.h @@ -83,7 +83,7 @@ class FieldValue { FieldValue(): data(0) {}; // Default assignment operator is fine void setType(uint8_t type); - uint8_t getType(); + QPID_COMMON_EXTERN uint8_t getType(); Data& getData() { return *data; } uint32_t encodedSize() const { return 1 + data->encodedSize(); }; bool empty() const { return data.get() == 0; } -- cgit v1.2.1 From 04a39245e7c60e50be02bcc576f05fc33e9a568b Mon Sep 17 00:00:00 2001 From: Jonathan Robie Date: Fri, 21 Aug 2009 16:58:31 +0000 Subject: Added documentation for AMQP 0-10 URL format. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@806641 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/client/Connection.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/client/Connection.h b/qpid/cpp/include/qpid/client/Connection.h index b7b967d232..0f5999cdcc 100644 --- a/qpid/cpp/include/qpid/client/Connection.h +++ b/qpid/cpp/include/qpid/client/Connection.h @@ -43,7 +43,21 @@ class ConnectionImpl; * * \ingroup clientapi * + * Some methods use an AMQP 0-10 URL to specify connection parameters. + * This is defined in the AMQP 0-10 specification (http://jira.amqp.org/confluence/display/AMQP/AMQP+Specification). + * + * amqp_url = "amqp:" prot_addr_list + * prot_addr_list = [prot_addr ","]* prot_addr + * prot_addr = tcp_prot_addr | tls_prot_addr + * + * tcp_prot_addr = tcp_id tcp_addr + * tcp_id = "tcp:" | "" + * tcp_addr = [host [":" port] ] + * host = + * port = number]]> + * */ + class Connection { framing::ProtocolVersion version; -- cgit v1.2.1 From 95931ede08d91630c1cb8b1d3c3ca2d22079e4ba Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Fri, 21 Aug 2009 21:19:22 +0000 Subject: Implemented the new QMF ConnectionSettings and incorporated into the bindings. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@806725 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/Connection.h | 2 ++ qpid/cpp/include/qmf/ConnectionSettings.h | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qmf/Connection.h b/qpid/cpp/include/qmf/Connection.h index b910cdad19..f648b1427f 100644 --- a/qpid/cpp/include/qmf/Connection.h +++ b/qpid/cpp/include/qmf/Connection.h @@ -47,6 +47,8 @@ namespace qmf { /** * Called each time the state of the connection changes. + * + * @param state the new state */ virtual void newState(ConnectionState state); diff --git a/qpid/cpp/include/qmf/ConnectionSettings.h b/qpid/cpp/include/qmf/ConnectionSettings.h index 53a83dfd2a..9bd6922a56 100644 --- a/qpid/cpp/include/qmf/ConnectionSettings.h +++ b/qpid/cpp/include/qmf/ConnectionSettings.h @@ -21,6 +21,7 @@ */ #include "qmf/QmfImportExport.h" +#include "qpid/sys/IntegerTypes.h" namespace qmf { @@ -35,6 +36,8 @@ namespace qmf { class ConnectionSettings { public: + ConnectionSettings(const ConnectionSettings& copy); + /** * Create a set of default connection settings. * @@ -79,8 +82,10 @@ namespace qmf { * Get the value of an attribute. * * @param key A null-terminated attribute name. + * + * @return The value associated with the attribute name. */ - QMF_EXTERN const Value& getAttr(const char* key) const; + QMF_EXTERN Value getAttr(const char* key) const; /** * Get the attribute string (the portion of the URL following the '?') for the settings. @@ -129,6 +134,7 @@ namespace qmf { QMF_EXTERN void setRetry(int delayMin = 1, int delayMax = 128, int delayFactor = 2); private: + friend class ResilientConnectionImpl; ConnectionSettingsImpl* impl; }; -- cgit v1.2.1 From 2011905fd149799baadec09683a0e2ca9c83c859 Mon Sep 17 00:00:00 2001 From: "Stephen D. Huston" Date: Sat, 22 Aug 2009 00:51:00 +0000 Subject: Added QPID_COMMON_EXPORT to convertIfRequired to satisfy Windows build. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@806769 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/framing/FieldValue.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/framing/FieldValue.h b/qpid/cpp/include/qpid/framing/FieldValue.h index f8db6dd382..ce4d06d2c8 100644 --- a/qpid/cpp/include/qpid/framing/FieldValue.h +++ b/qpid/cpp/include/qpid/framing/FieldValue.h @@ -104,7 +104,7 @@ class FieldValue { protected: FieldValue(uint8_t t, Data* d): typeOctet(t), data(d) {} - static uint8_t* convertIfRequired(uint8_t* const octets, int width); + QPID_COMMON_EXTERN static uint8_t* convertIfRequired(uint8_t* const octets, int width); private: uint8_t typeOctet; -- cgit v1.2.1 From 86484cac17437cd15f2d313a40a7362b2ced6000 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Tue, 25 Aug 2009 17:57:34 +0000 Subject: QPID-664: Initial checkin of high level messaging api for c++ git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@807731 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/client/amqp0_10/Codecs.h | 61 ++++++++ qpid/cpp/include/qpid/messaging/Address.h | 57 ++++++++ qpid/cpp/include/qpid/messaging/Codec.h | 44 ++++++ qpid/cpp/include/qpid/messaging/Connection.h | 67 +++++++++ qpid/cpp/include/qpid/messaging/Filter.h | 48 +++++++ qpid/cpp/include/qpid/messaging/Message.h | 90 ++++++++++++ qpid/cpp/include/qpid/messaging/MessageContent.h | 90 ++++++++++++ qpid/cpp/include/qpid/messaging/MessageListener.h | 49 +++++++ qpid/cpp/include/qpid/messaging/Receiver.h | 115 +++++++++++++++ qpid/cpp/include/qpid/messaging/Sender.h | 57 ++++++++ qpid/cpp/include/qpid/messaging/Session.h | 99 +++++++++++++ qpid/cpp/include/qpid/messaging/Variant.h | 167 ++++++++++++++++++++++ 12 files changed, 944 insertions(+) create mode 100644 qpid/cpp/include/qpid/client/amqp0_10/Codecs.h create mode 100644 qpid/cpp/include/qpid/messaging/Address.h create mode 100644 qpid/cpp/include/qpid/messaging/Codec.h create mode 100644 qpid/cpp/include/qpid/messaging/Connection.h create mode 100644 qpid/cpp/include/qpid/messaging/Filter.h create mode 100644 qpid/cpp/include/qpid/messaging/Message.h create mode 100644 qpid/cpp/include/qpid/messaging/MessageContent.h create mode 100644 qpid/cpp/include/qpid/messaging/MessageListener.h create mode 100644 qpid/cpp/include/qpid/messaging/Receiver.h create mode 100644 qpid/cpp/include/qpid/messaging/Sender.h create mode 100644 qpid/cpp/include/qpid/messaging/Session.h create mode 100644 qpid/cpp/include/qpid/messaging/Variant.h (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/client/amqp0_10/Codecs.h b/qpid/cpp/include/qpid/client/amqp0_10/Codecs.h new file mode 100644 index 0000000000..5ef0b9fffe --- /dev/null +++ b/qpid/cpp/include/qpid/client/amqp0_10/Codecs.h @@ -0,0 +1,61 @@ +#ifndef QPID_CLIENT_AMQP0_10_CODECS_H +#define QPID_CLIENT_AMQP0_10_CODECS_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#include "qpid/messaging/Codec.h" + +namespace qpid { +namespace client { +namespace amqp0_10 { + + +/** + * Codec for encoding/decoding a map of Variants using the AMQP 0-10 + * map encoding. + */ +class MapCodec : public qpid::messaging::Codec +{ + public: + void encode(const qpid::messaging::Variant&, std::string&); + void decode(const std::string&, qpid::messaging::Variant&); + + static const std::string contentType; + private: +}; + +/** + * Codec for encoding/decoding a list of Variants using the AMQP 0-10 + * list encoding. + */ +class ListCodec : public qpid::messaging::Codec +{ + public: + void encode(const qpid::messaging::Variant&, std::string&); + void decode(const std::string&, qpid::messaging::Variant&); + + static const std::string contentType; + private: +}; + +}}} // namespace qpid::client::amqp0_10 + +#endif /*!QPID_CLIENT_AMQP0_10_CODECS_H*/ diff --git a/qpid/cpp/include/qpid/messaging/Address.h b/qpid/cpp/include/qpid/messaging/Address.h new file mode 100644 index 0000000000..da563a21bf --- /dev/null +++ b/qpid/cpp/include/qpid/messaging/Address.h @@ -0,0 +1,57 @@ +#ifndef QPID_MESSAGING_ADDRESS_H +#define QPID_MESSAGING_ADDRESS_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#include +#include "qpid/client/ClientImportExport.h" + +namespace qpid { +namespace client { +} + +namespace messaging { + +/** + * Represents an address to which messages can be sent and from which + * messages can be received. Often a simple name is sufficient for + * this. However this struct allows the type of address to be + * specified allowing more sophisticated treatment if necessary. + */ +struct Address +{ + std::string value; + std::string type; + + QPID_CLIENT_EXTERN Address(); + QPID_CLIENT_EXTERN Address(const std::string& address); + QPID_CLIENT_EXTERN Address(const std::string& address, const std::string& type); + QPID_CLIENT_EXTERN operator const std::string&() const; + QPID_CLIENT_EXTERN const std::string& toStr() const; + QPID_CLIENT_EXTERN operator bool() const; + QPID_CLIENT_EXTERN bool operator !() const; +}; + +QPID_CLIENT_EXTERN std::ostream& operator<<(std::ostream& out, const Address& address); + +}} // namespace qpid::messaging + +#endif /*!QPID_MESSAGING_ADDRESS_H*/ diff --git a/qpid/cpp/include/qpid/messaging/Codec.h b/qpid/cpp/include/qpid/messaging/Codec.h new file mode 100644 index 0000000000..bacec5c786 --- /dev/null +++ b/qpid/cpp/include/qpid/messaging/Codec.h @@ -0,0 +1,44 @@ +#ifndef QPID_MESSAGING_CODEC_H +#define QPID_MESSAGING_CODEC_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#include +#include "qpid/client/ClientImportExport.h" + +namespace qpid { +namespace messaging { + +class Variant; +/** + * + */ +class Codec +{ + public: + QPID_CLIENT_EXTERN virtual ~Codec() {} + virtual void encode(const Variant&, std::string&) = 0; + virtual void decode(const std::string&, Variant&) = 0; + private: +}; +}} // namespace qpid::messaging + +#endif /*!QPID_MESSAGING_CODEC_H*/ diff --git a/qpid/cpp/include/qpid/messaging/Connection.h b/qpid/cpp/include/qpid/messaging/Connection.h new file mode 100644 index 0000000000..5517e45af9 --- /dev/null +++ b/qpid/cpp/include/qpid/messaging/Connection.h @@ -0,0 +1,67 @@ +#ifndef QPID_MESSAGING_CONNECTION_H +#define QPID_MESSAGING_CONNECTION_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#include +#include "qpid/client/ClientImportExport.h" +#include "qpid/client/Handle.h" +#include "qpid/messaging/Variant.h" + +namespace qpid { +namespace client { + +template class PrivateImplRef; + +} + +namespace messaging { + +class ConnectionImpl; +class Session; + +class Connection : public qpid::client::Handle +{ + public: + static Connection open(const std::string& url, const Variant::Map& options = Variant::Map()); + + QPID_CLIENT_EXTERN Connection(ConnectionImpl* impl = 0); + QPID_CLIENT_EXTERN Connection(const Connection&); + QPID_CLIENT_EXTERN ~Connection(); + QPID_CLIENT_EXTERN Connection& operator=(const Connection&); + QPID_CLIENT_EXTERN void close(); + QPID_CLIENT_EXTERN Session newSession(); + private: + friend class qpid::client::PrivateImplRef; + +}; + +struct InvalidOptionString : public qpid::Exception +{ + InvalidOptionString(const std::string& msg); +}; + +QPID_CLIENT_EXTERN void parseOptionString(const std::string&, Variant::Map&); +QPID_CLIENT_EXTERN Variant::Map parseOptionString(const std::string&); + +}} // namespace qpid::messaging + +#endif /*!QPID_MESSAGING_CONNECTION_H*/ diff --git a/qpid/cpp/include/qpid/messaging/Filter.h b/qpid/cpp/include/qpid/messaging/Filter.h new file mode 100644 index 0000000000..5cd844cf73 --- /dev/null +++ b/qpid/cpp/include/qpid/messaging/Filter.h @@ -0,0 +1,48 @@ +#ifndef QPID_MESSAGING_FILTER_H +#define QPID_MESSAGING_FILTER_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#include +#include +#include "qpid/client/ClientImportExport.h" + +namespace qpid { +namespace client { +} + +namespace messaging { + +struct Filter +{ + std::string type; + std::vector patterns; + + QPID_CLIENT_EXTERN Filter(std::string type, std::string pattern); + QPID_CLIENT_EXTERN Filter(std::string type, std::string pattern1, std::string pattern2); + + static QPID_CLIENT_EXTERN const std::string WILDCARD; + static QPID_CLIENT_EXTERN const std::string EXACT_MATCH; +}; + +}} // namespace qpid::messaging + +#endif /*!QPID_MESSAGING_FILTER_H*/ diff --git a/qpid/cpp/include/qpid/messaging/Message.h b/qpid/cpp/include/qpid/messaging/Message.h new file mode 100644 index 0000000000..39edae3637 --- /dev/null +++ b/qpid/cpp/include/qpid/messaging/Message.h @@ -0,0 +1,90 @@ +#ifndef QPID_MESSAGING_MESSAGE_H +#define QPID_MESSAGING_MESSAGE_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include +#include "qpid/messaging/Variant.h" +#include "qpid/messaging/MessageContent.h" +#include "qpid/client/ClientImportExport.h" + +namespace qpid { +namespace client { +} + +namespace messaging { + +class Address; +class Codec; +class MessageImpl; + +/** + * Representation of a message. + */ +class Message +{ + public: + QPID_CLIENT_EXTERN Message(const std::string& bytes = std::string()); + QPID_CLIENT_EXTERN Message(const char*, size_t); + QPID_CLIENT_EXTERN Message(const Message&); + QPID_CLIENT_EXTERN ~Message(); + + QPID_CLIENT_EXTERN Message& operator=(const Message&); + + QPID_CLIENT_EXTERN void setReplyTo(const Address&); + QPID_CLIENT_EXTERN const Address& getReplyTo() const; + + QPID_CLIENT_EXTERN void setSubject(const std::string&); + QPID_CLIENT_EXTERN const std::string& getSubject() const; + + QPID_CLIENT_EXTERN void setContentType(const std::string&); + QPID_CLIENT_EXTERN const std::string& getContentType() const; + + QPID_CLIENT_EXTERN const VariantMap& getHeaders() const; + QPID_CLIENT_EXTERN VariantMap& getHeaders(); + + QPID_CLIENT_EXTERN const std::string& getBytes() const; + QPID_CLIENT_EXTERN std::string& getBytes(); + QPID_CLIENT_EXTERN void setBytes(const std::string&); + QPID_CLIENT_EXTERN void setBytes(const char* chars, size_t count); + QPID_CLIENT_EXTERN const char* getRawContent() const; + QPID_CLIENT_EXTERN size_t getContentSize() const; + + + QPID_CLIENT_EXTERN MessageContent& getContent(); + QPID_CLIENT_EXTERN const MessageContent& getContent() const; + QPID_CLIENT_EXTERN void setContent(const std::string& s); + QPID_CLIENT_EXTERN void setContent(const Variant::Map&); + QPID_CLIENT_EXTERN void setContent(const Variant::List&); + + QPID_CLIENT_EXTERN void encode(Codec&); + QPID_CLIENT_EXTERN void decode(Codec&); + + //TODO: move this out of the public API + QPID_CLIENT_EXTERN void setInternalId(void*); + QPID_CLIENT_EXTERN void* getInternalId(); + private: + MessageImpl* impl; +}; +}} // namespace qpid::messaging + +#endif /*!QPID_MESSAGING_MESSAGE_H*/ diff --git a/qpid/cpp/include/qpid/messaging/MessageContent.h b/qpid/cpp/include/qpid/messaging/MessageContent.h new file mode 100644 index 0000000000..7c3a636c07 --- /dev/null +++ b/qpid/cpp/include/qpid/messaging/MessageContent.h @@ -0,0 +1,90 @@ +#ifndef QPID_MESSAGING_MESSAGECONTENT_H +#define QPID_MESSAGING_MESSAGECONTENT_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/messaging/Variant.h" +#include +#include "qpid/client/ClientImportExport.h" + +namespace qpid { +namespace messaging { + +/** + * + */ +class MessageContent +{ + public: + QPID_CLIENT_EXTERN virtual ~MessageContent() {} + + virtual const std::string& asString() const = 0; + virtual std::string& asString() = 0; + + virtual const char* asChars() const = 0; + virtual size_t size() const = 0; + + virtual const Variant::Map& asMap() const = 0; + virtual Variant::Map& asMap() = 0; + virtual bool isMap() const = 0; + + virtual const Variant::List& asList() const = 0; + virtual Variant::List& asList() = 0; + virtual bool isList() const = 0; + + virtual void clear() = 0; + + virtual Variant& operator[](const std::string&) = 0; + + + virtual std::ostream& print(std::ostream& out) const = 0; + + + //operator<< for variety of types... (is this a good idea?) + virtual MessageContent& operator<<(const std::string&) = 0; + virtual MessageContent& operator<<(const char*) = 0; + virtual MessageContent& operator<<(bool) = 0; + virtual MessageContent& operator<<(int8_t) = 0; + virtual MessageContent& operator<<(int16_t) = 0; + virtual MessageContent& operator<<(int32_t) = 0; + virtual MessageContent& operator<<(int64_t) = 0; + virtual MessageContent& operator<<(uint8_t) = 0; + virtual MessageContent& operator<<(uint16_t) = 0; + virtual MessageContent& operator<<(uint32_t) = 0; + virtual MessageContent& operator<<(uint64_t) = 0; + virtual MessageContent& operator<<(double) = 0; + virtual MessageContent& operator<<(float) = 0; + + //assignment from string, map and list + virtual MessageContent& operator=(const std::string&) = 0; + virtual MessageContent& operator=(const char*) = 0; + virtual MessageContent& operator=(const Variant::Map&) = 0; + virtual MessageContent& operator=(const Variant::List&) = 0; + + private: +}; + +QPID_CLIENT_EXTERN std::ostream& operator<<(std::ostream& out, const MessageContent& content); + +}} // namespace qpid::messaging + +#endif /*!QPID_MESSAGING_MESSAGECONTENT_H*/ diff --git a/qpid/cpp/include/qpid/messaging/MessageListener.h b/qpid/cpp/include/qpid/messaging/MessageListener.h new file mode 100644 index 0000000000..72811e7b9c --- /dev/null +++ b/qpid/cpp/include/qpid/messaging/MessageListener.h @@ -0,0 +1,49 @@ +#ifndef QPID_MESSAGING_MESSAGELISTENER_H +#define QPID_MESSAGING_MESSAGELISTENER_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#include "qpid/client/ClientImportExport.h" + +namespace qpid { +namespace messaging { + +class Message; + +/** + * To use a push style interface for receiving messages, applications + * provide implementations of this interface and pass an implementing + * instance to MessageSource::subscribe(). + * + * Messages arriving for that subscription will then be passed to the + * implementation via the received() method. + */ +class MessageListener +{ + public: + QPID_CLIENT_EXTERN virtual ~MessageListener() {} + virtual void received(Message&) = 0; + private: +}; + +}} // namespace qpid::messaging + +#endif /*!QPID_MESSAGING_MESSAGELISTENER_H*/ diff --git a/qpid/cpp/include/qpid/messaging/Receiver.h b/qpid/cpp/include/qpid/messaging/Receiver.h new file mode 100644 index 0000000000..e51e1093d1 --- /dev/null +++ b/qpid/cpp/include/qpid/messaging/Receiver.h @@ -0,0 +1,115 @@ +#ifndef QPID_MESSAGING_RECEIVER_H +#define QPID_MESSAGING_RECEIVER_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#include "qpid/Exception.h" +#include "qpid/client/ClientImportExport.h" +#include "qpid/client/Handle.h" +#include "qpid/sys/Time.h" + +namespace qpid { +namespace client { + +template class PrivateImplRef; + +} + +namespace messaging { + +class Message; +class MessageListener; +class ReceiverImpl; + +/** + * A pull style interface for message retrieval. + */ +class Receiver : public qpid::client::Handle +{ + public: + struct NoMessageAvailable : qpid::Exception {}; + + QPID_CLIENT_EXTERN Receiver(ReceiverImpl* impl = 0); + QPID_CLIENT_EXTERN Receiver(const Receiver&); + QPID_CLIENT_EXTERN ~Receiver(); + QPID_CLIENT_EXTERN Receiver& operator=(const Receiver&); + /** + * Retrieves a message from this receivers local queue, or waits + * for upto the specified timeout for a message to become + * available. Returns false if there is no message to give after + * waiting for the specified timeout. + */ + QPID_CLIENT_EXTERN bool get(Message& message, qpid::sys::Duration timeout=qpid::sys::TIME_INFINITE); + /** + * Retrieves a message from this receivers local queue, or waits + * for upto the specified timeout for a message to become + * available. Throws NoMessageAvailable if there is no + * message to give after waiting for the specified timeout. + */ + QPID_CLIENT_EXTERN Message get(qpid::sys::Duration timeout=qpid::sys::TIME_INFINITE); + /** + * Retrieves a message for this receivers subscription or waits + * for upto the specified timeout for one to become + * available. Unlike get() this method will check with the server + * that there is no message for the subscription this receiver is + * serving before returning false. + */ + QPID_CLIENT_EXTERN bool fetch(Message& message, qpid::sys::Duration timeout=qpid::sys::TIME_INFINITE); + /** + * Retrieves a message for this receivers subscription or waits + * for upto the specified timeout for one to become + * available. Unlike get() this method will check with the server + * that there is no message for the subscription this receiver is + * serving before throwing an exception. + */ + QPID_CLIENT_EXTERN Message fetch(qpid::sys::Duration timeout=qpid::sys::TIME_INFINITE); + + /** + * Enables the message flow for this receiver + */ + QPID_CLIENT_EXTERN void start(); + /** + * Stops the message flow for this receiver (without actually + * cancelling the subscription). + */ + QPID_CLIENT_EXTERN void stop(); + /** + * Sets the capacity for the receiver. The capacity determines how + * many incoming messages can be held in the receiver before being + * requested by a client via fetch() (or pushed to a listener). + */ + QPID_CLIENT_EXTERN void setCapacity(uint32_t); + + /** + * Cancels this receiver + */ + QPID_CLIENT_EXTERN void cancel(); + + /** + * Set a message listener for receiving messages asynchronously. + */ + QPID_CLIENT_EXTERN void setListener(MessageListener* listener); + private: + friend class qpid::client::PrivateImplRef; +}; +}} // namespace qpid::messaging + +#endif /*!QPID_MESSAGING_RECEIVER_H*/ diff --git a/qpid/cpp/include/qpid/messaging/Sender.h b/qpid/cpp/include/qpid/messaging/Sender.h new file mode 100644 index 0000000000..657c4b8cfe --- /dev/null +++ b/qpid/cpp/include/qpid/messaging/Sender.h @@ -0,0 +1,57 @@ +#ifndef QPID_MESSAGING_SENDER_H +#define QPID_MESSAGING_SENDER_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#include "qpid/client/ClientImportExport.h" +#include "qpid/client/Handle.h" + +namespace qpid { +namespace client { + +template class PrivateImplRef; + +} + +namespace messaging { + +class Message; +class SenderImpl; + +/** + * Interface through which messages are sent. + */ +class Sender : public qpid::client::Handle +{ + public: + QPID_CLIENT_EXTERN Sender(SenderImpl* impl = 0); + QPID_CLIENT_EXTERN Sender(const Sender&); + QPID_CLIENT_EXTERN ~Sender(); + QPID_CLIENT_EXTERN Sender& operator=(const Sender&); + + QPID_CLIENT_EXTERN void send(Message& message); + QPID_CLIENT_EXTERN void cancel(); + private: + friend class qpid::client::PrivateImplRef; +}; +}} // namespace qpid::messaging + +#endif /*!QPID_MESSAGING_SENDER_H*/ diff --git a/qpid/cpp/include/qpid/messaging/Session.h b/qpid/cpp/include/qpid/messaging/Session.h new file mode 100644 index 0000000000..3a354c009f --- /dev/null +++ b/qpid/cpp/include/qpid/messaging/Session.h @@ -0,0 +1,99 @@ +#ifndef QPID_MESSAGING_SESSION_H +#define QPID_MESSAGING_SESSION_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#include "qpid/client/ClientImportExport.h" +#include "qpid/client/Handle.h" +#include "qpid/sys/Time.h" +#include "Variant.h" + +namespace qpid { +namespace client { + +template class PrivateImplRef; + +} + +namespace messaging { + +class Address; +class Filter; +class Message; +class MessageListener; +class Sender; +class Receiver; +class SessionImpl; +class Subscription; + +/** + * A session represents a distinct 'conversation' which can involve + * sending and receiving messages from different sources and sinks. + */ +class Session : public qpid::client::Handle +{ + public: + QPID_CLIENT_EXTERN Session(SessionImpl* impl = 0); + QPID_CLIENT_EXTERN Session(const Session&); + QPID_CLIENT_EXTERN ~Session(); + QPID_CLIENT_EXTERN Session& operator=(const Session&); + + QPID_CLIENT_EXTERN void close(); + + QPID_CLIENT_EXTERN void commit(); + QPID_CLIENT_EXTERN void rollback(); + + /** + * Acknowledges all outstanding messages that have been received + * by the application on this session. + */ + QPID_CLIENT_EXTERN void acknowledge(); + /** + * Rejects the specified message. This will prevent the message + * being redelivered. + */ + QPID_CLIENT_EXTERN void reject(Message&); + + QPID_CLIENT_EXTERN void sync(); + QPID_CLIENT_EXTERN void flush(); + + QPID_CLIENT_EXTERN bool fetch(Message& message, qpid::sys::Duration timeout=qpid::sys::TIME_INFINITE); + QPID_CLIENT_EXTERN Message fetch(qpid::sys::Duration timeout=qpid::sys::TIME_INFINITE); + QPID_CLIENT_EXTERN bool dispatch(qpid::sys::Duration timeout=qpid::sys::TIME_INFINITE); + + QPID_CLIENT_EXTERN Sender createSender(const Address& address, const VariantMap& options = VariantMap()); + QPID_CLIENT_EXTERN Sender createSender(const std::string& address, const VariantMap& options = VariantMap()); + + QPID_CLIENT_EXTERN Receiver createReceiver(const Address& address, const VariantMap& options = VariantMap()); + QPID_CLIENT_EXTERN Receiver createReceiver(const Address& address, const Filter& filter, const VariantMap& options = VariantMap()); + QPID_CLIENT_EXTERN Receiver createReceiver(const std::string& address, const VariantMap& options = VariantMap()); + QPID_CLIENT_EXTERN Receiver createReceiver(const std::string& address, const Filter& filter, const VariantMap& options = VariantMap()); + + QPID_CLIENT_EXTERN Address createTempQueue(const std::string& baseName = std::string()); + + QPID_CLIENT_EXTERN void* getLastConfirmedSent(); + QPID_CLIENT_EXTERN void* getLastConfirmedAcknowledged(); + private: + friend class qpid::client::PrivateImplRef; +}; +}} // namespace qpid::messaging + +#endif /*!QPID_MESSAGING_SESSION_H*/ diff --git a/qpid/cpp/include/qpid/messaging/Variant.h b/qpid/cpp/include/qpid/messaging/Variant.h new file mode 100644 index 0000000000..ac000244c2 --- /dev/null +++ b/qpid/cpp/include/qpid/messaging/Variant.h @@ -0,0 +1,167 @@ +#ifndef QPID_MESSAGING_VARIANT_H +#define QPID_MESSAGING_VARIANT_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#include +#include +#include +#include +#include "qpid/Exception.h" +#include "qpid/sys/IntegerTypes.h" +#include "qpid/client/ClientImportExport.h" + +namespace qpid { +namespace client { +} + +namespace messaging { + +/** + * Thrown when an illegal conversion of a variant is attempted. + */ +struct InvalidConversion : public qpid::Exception +{ + InvalidConversion(const std::string& msg); +}; + +enum VariantType { + VOID = 0, + BOOL, + UINT8, + UINT16, + UINT32, + UINT64, + INT8, + INT16, + INT32, + INT64, + FLOAT, + DOUBLE, + STRING, + MAP, + LIST +}; + +class VariantImpl; + +/** + * Represents a value of variable type. + */ +class Variant +{ + public: + typedef std::map Map; + typedef std::list List; + + QPID_CLIENT_EXTERN Variant(); + QPID_CLIENT_EXTERN Variant(bool); + QPID_CLIENT_EXTERN Variant(uint8_t); + QPID_CLIENT_EXTERN Variant(uint16_t); + QPID_CLIENT_EXTERN Variant(uint32_t); + QPID_CLIENT_EXTERN Variant(uint64_t); + QPID_CLIENT_EXTERN Variant(int8_t); + QPID_CLIENT_EXTERN Variant(int16_t); + QPID_CLIENT_EXTERN Variant(int32_t); + QPID_CLIENT_EXTERN Variant(int64_t); + QPID_CLIENT_EXTERN Variant(float); + QPID_CLIENT_EXTERN Variant(double); + QPID_CLIENT_EXTERN Variant(const std::string&); + QPID_CLIENT_EXTERN Variant(const char*); + QPID_CLIENT_EXTERN Variant(const Map&); + QPID_CLIENT_EXTERN Variant(const List&); + QPID_CLIENT_EXTERN Variant(const Variant&); + + QPID_CLIENT_EXTERN ~Variant(); + + QPID_CLIENT_EXTERN VariantType getType() const; + + QPID_CLIENT_EXTERN Variant& operator=(bool); + QPID_CLIENT_EXTERN Variant& operator=(uint8_t); + QPID_CLIENT_EXTERN Variant& operator=(uint16_t); + QPID_CLIENT_EXTERN Variant& operator=(uint32_t); + QPID_CLIENT_EXTERN Variant& operator=(uint64_t); + QPID_CLIENT_EXTERN Variant& operator=(int8_t); + QPID_CLIENT_EXTERN Variant& operator=(int16_t); + QPID_CLIENT_EXTERN Variant& operator=(int32_t); + QPID_CLIENT_EXTERN Variant& operator=(int64_t); + QPID_CLIENT_EXTERN Variant& operator=(float); + QPID_CLIENT_EXTERN Variant& operator=(double); + QPID_CLIENT_EXTERN Variant& operator=(const std::string&); + QPID_CLIENT_EXTERN Variant& operator=(const char*); + QPID_CLIENT_EXTERN Variant& operator=(const Map&); + QPID_CLIENT_EXTERN Variant& operator=(const List&); + QPID_CLIENT_EXTERN Variant& operator=(const Variant&); + + QPID_CLIENT_EXTERN bool asBool() const; + QPID_CLIENT_EXTERN uint8_t asUint8() const; + QPID_CLIENT_EXTERN uint16_t asUint16() const; + QPID_CLIENT_EXTERN uint32_t asUint32() const; + QPID_CLIENT_EXTERN uint64_t asUint64() const; + QPID_CLIENT_EXTERN int8_t asInt8() const; + QPID_CLIENT_EXTERN int16_t asInt16() const; + QPID_CLIENT_EXTERN int32_t asInt32() const; + QPID_CLIENT_EXTERN int64_t asInt64() const; + QPID_CLIENT_EXTERN float asFloat() const; + QPID_CLIENT_EXTERN double asDouble() const; + QPID_CLIENT_EXTERN std::string asString() const; + + QPID_CLIENT_EXTERN operator bool() const; + QPID_CLIENT_EXTERN operator uint8_t() const; + QPID_CLIENT_EXTERN operator uint16_t() const; + QPID_CLIENT_EXTERN operator uint32_t() const; + QPID_CLIENT_EXTERN operator uint64_t() const; + QPID_CLIENT_EXTERN operator int8_t() const; + QPID_CLIENT_EXTERN operator int16_t() const; + QPID_CLIENT_EXTERN operator int32_t() const; + QPID_CLIENT_EXTERN operator int64_t() const; + QPID_CLIENT_EXTERN operator float() const; + QPID_CLIENT_EXTERN operator double() const; + QPID_CLIENT_EXTERN operator const char*() const; + + QPID_CLIENT_EXTERN const Map& asMap() const; + QPID_CLIENT_EXTERN Map& asMap(); + QPID_CLIENT_EXTERN const List& asList() const; + QPID_CLIENT_EXTERN List& asList(); + /** + * Unlike asString(), getString() will not do any conversions and + * will throw InvalidConversion if the type is not STRING. + */ + QPID_CLIENT_EXTERN const std::string& getString() const; + QPID_CLIENT_EXTERN std::string& getString(); + + QPID_CLIENT_EXTERN void setEncoding(const std::string&); + QPID_CLIENT_EXTERN const std::string& getEncoding() const; + + QPID_CLIENT_EXTERN void reset(); + private: + VariantImpl* impl; +}; + +QPID_CLIENT_EXTERN std::ostream& operator<<(std::ostream& out, const Variant& value); +QPID_CLIENT_EXTERN std::ostream& operator<<(std::ostream& out, const Variant::Map& map); +QPID_CLIENT_EXTERN std::ostream& operator<<(std::ostream& out, const Variant::List& list); + +typedef Variant::Map VariantMap; + +}} // namespace qpid::messaging + +#endif /*!QPID_MESSAGING_VARIANT_H*/ -- cgit v1.2.1 From ad2aa98ba7e4f71f52ee4f3937f72ff08e932c27 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Wed, 26 Aug 2009 08:45:03 +0000 Subject: Add required include (absence believed to cause failures on some platforms) git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@807924 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Address.h | 1 + 1 file changed, 1 insertion(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Address.h b/qpid/cpp/include/qpid/messaging/Address.h index da563a21bf..e66c52f4c2 100644 --- a/qpid/cpp/include/qpid/messaging/Address.h +++ b/qpid/cpp/include/qpid/messaging/Address.h @@ -23,6 +23,7 @@ */ #include #include "qpid/client/ClientImportExport.h" +#include namespace qpid { namespace client { -- cgit v1.2.1 From d6cca94a48acaaada880a4fd7a870794094a7959 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Wed, 26 Aug 2009 16:55:43 +0000 Subject: Hide internal message ID behind API git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@808121 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Message.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Message.h b/qpid/cpp/include/qpid/messaging/Message.h index 39edae3637..329388048e 100644 --- a/qpid/cpp/include/qpid/messaging/Message.h +++ b/qpid/cpp/include/qpid/messaging/Message.h @@ -79,11 +79,9 @@ class Message QPID_CLIENT_EXTERN void encode(Codec&); QPID_CLIENT_EXTERN void decode(Codec&); - //TODO: move this out of the public API - QPID_CLIENT_EXTERN void setInternalId(void*); - QPID_CLIENT_EXTERN void* getInternalId(); private: MessageImpl* impl; + friend class MessageImplAccess; }; }} // namespace qpid::messaging -- cgit v1.2.1 From 0ecf92a9a83e46ff31460183d57bceebc599418d Mon Sep 17 00:00:00 2001 From: "Stephen D. Huston" Date: Mon, 31 Aug 2009 22:43:29 +0000 Subject: Changes to make messaging API build on Windows: Prepend VAR_ to Variant types enum to avoid name clashes, add 'reference' type for FieldTable ValueMap to satisfy STL, refer to structs as such, not as class (avoids compile warning) git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@809772 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/framing/FieldTable.h | 3 ++- qpid/cpp/include/qpid/framing/List.h | 1 + qpid/cpp/include/qpid/messaging/Connection.h | 2 +- qpid/cpp/include/qpid/messaging/Message.h | 6 +++--- qpid/cpp/include/qpid/messaging/Session.h | 4 ++-- qpid/cpp/include/qpid/messaging/Variant.h | 30 ++++++++++++++-------------- 6 files changed, 24 insertions(+), 22 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/framing/FieldTable.h b/qpid/cpp/include/qpid/framing/FieldTable.h index b2331cd4e1..fd09cfc6f6 100644 --- a/qpid/cpp/include/qpid/framing/FieldTable.h +++ b/qpid/cpp/include/qpid/framing/FieldTable.h @@ -52,6 +52,7 @@ class FieldTable typedef std::map ValueMap; typedef ValueMap::iterator iterator; typedef ValueMap::const_reference const_reference; + typedef ValueMap::reference reference; typedef ValueMap::value_type value_type; QPID_COMMON_EXTERN FieldTable() {}; @@ -108,7 +109,7 @@ class FieldTable ValueMap::iterator find(const std::string& s) { return values.find(s); } std::pair insert(const ValueMap::value_type&); - ValueMap::iterator insert(ValueMap::iterator, const ValueMap::value_type&); + QPID_COMMON_EXTERN ValueMap::iterator insert(ValueMap::iterator, const ValueMap::value_type&); void clear() { values.clear(); } // ### Hack Alert diff --git a/qpid/cpp/include/qpid/framing/List.h b/qpid/cpp/include/qpid/framing/List.h index cb1129ebf8..0f17c7884c 100644 --- a/qpid/cpp/include/qpid/framing/List.h +++ b/qpid/cpp/include/qpid/framing/List.h @@ -44,6 +44,7 @@ class List typedef Values::const_iterator const_iterator; typedef Values::iterator iterator; typedef Values::const_reference const_reference; + typedef Values::reference reference; QPID_COMMON_EXTERN uint32_t encodedSize() const; QPID_COMMON_EXTERN void encode(Buffer& buffer) const; diff --git a/qpid/cpp/include/qpid/messaging/Connection.h b/qpid/cpp/include/qpid/messaging/Connection.h index 5517e45af9..19dae586a4 100644 --- a/qpid/cpp/include/qpid/messaging/Connection.h +++ b/qpid/cpp/include/qpid/messaging/Connection.h @@ -41,7 +41,7 @@ class Session; class Connection : public qpid::client::Handle { public: - static Connection open(const std::string& url, const Variant::Map& options = Variant::Map()); + static QPID_CLIENT_EXTERN Connection open(const std::string& url, const Variant::Map& options = Variant::Map()); QPID_CLIENT_EXTERN Connection(ConnectionImpl* impl = 0); QPID_CLIENT_EXTERN Connection(const Connection&); diff --git a/qpid/cpp/include/qpid/messaging/Message.h b/qpid/cpp/include/qpid/messaging/Message.h index 329388048e..e68d8a1141 100644 --- a/qpid/cpp/include/qpid/messaging/Message.h +++ b/qpid/cpp/include/qpid/messaging/Message.h @@ -33,9 +33,9 @@ namespace client { namespace messaging { -class Address; +struct Address; class Codec; -class MessageImpl; +struct MessageImpl; /** * Representation of a message. @@ -81,7 +81,7 @@ class Message private: MessageImpl* impl; - friend class MessageImplAccess; + friend struct MessageImplAccess; }; }} // namespace qpid::messaging diff --git a/qpid/cpp/include/qpid/messaging/Session.h b/qpid/cpp/include/qpid/messaging/Session.h index 3a354c009f..1d88882db6 100644 --- a/qpid/cpp/include/qpid/messaging/Session.h +++ b/qpid/cpp/include/qpid/messaging/Session.h @@ -35,8 +35,8 @@ template class PrivateImplRef; namespace messaging { -class Address; -class Filter; +struct Address; +struct Filter; class Message; class MessageListener; class Sender; diff --git a/qpid/cpp/include/qpid/messaging/Variant.h b/qpid/cpp/include/qpid/messaging/Variant.h index ac000244c2..1e51914794 100644 --- a/qpid/cpp/include/qpid/messaging/Variant.h +++ b/qpid/cpp/include/qpid/messaging/Variant.h @@ -44,21 +44,21 @@ struct InvalidConversion : public qpid::Exception }; enum VariantType { - VOID = 0, - BOOL, - UINT8, - UINT16, - UINT32, - UINT64, - INT8, - INT16, - INT32, - INT64, - FLOAT, - DOUBLE, - STRING, - MAP, - LIST + VAR_VOID = 0, + VAR_BOOL, + VAR_UINT8, + VAR_UINT16, + VAR_UINT32, + VAR_UINT64, + VAR_INT8, + VAR_INT16, + VAR_INT32, + VAR_INT64, + VAR_FLOAT, + VAR_DOUBLE, + VAR_STRING, + VAR_MAP, + VAR_LIST }; class VariantImpl; -- cgit v1.2.1 From eaf99a69f4b09f05adba2039ccb9af046b16349a Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Mon, 31 Aug 2009 23:41:53 +0000 Subject: Working towards abstracting away the cross platform uuid mess: * Stop including indirectly from uuid.h in qpid/framing/Uuid.h and move inline definitions there into the implementation file git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@809781 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/framing/Uuid.h | 27 ++++++++++------------- qpid/cpp/include/qpid/sys/uuid.h | 28 ----------------------- qpid/cpp/include/qpid/sys/windows/uuid.h | 38 -------------------------------- 3 files changed, 12 insertions(+), 81 deletions(-) delete mode 100644 qpid/cpp/include/qpid/sys/uuid.h delete mode 100644 qpid/cpp/include/qpid/sys/windows/uuid.h (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/framing/Uuid.h b/qpid/cpp/include/qpid/framing/Uuid.h index 0dfa7a58e7..8e817178da 100644 --- a/qpid/cpp/include/qpid/framing/Uuid.h +++ b/qpid/cpp/include/qpid/framing/Uuid.h @@ -20,7 +20,6 @@ */ #include "qpid/CommonImportExport.h" -#include "qpid/sys/uuid.h" #include "qpid/sys/IntegerTypes.h" #include @@ -38,33 +37,31 @@ class Buffer; * * Full value semantics, operators ==, < etc. are provided by * boost::array so Uuid can be the key type in a map etc. + * + * TODO: change this implementation as it leaks boost into the + * client API */ struct Uuid : public boost::array { /** If unique is true, generate a unique ID else a null ID. */ - Uuid(bool unique=false) { if (unique) generate(); else clear(); } + Uuid(bool unique=false); /** Copy from 16 bytes of data. */ - Uuid(const uint8_t* data) { assign(data); } + Uuid(const uint8_t* data); + + // Default op= and copy ctor are fine. + // boost::array gives us ==, < etc. /** Copy from 16 bytes of data. */ - void assign(const uint8_t* data) { - uuid_copy(c_array(), data); - } + void assign(const uint8_t* data); /** Set to a new unique identifier. */ - void generate() { uuid_generate(c_array()); } + void generate(); /** Set to all zeros. */ - void clear() { uuid_clear(c_array()); } + void clear(); /** Test for null (all zeros). */ - // Force int 0/!0 to false/true; avoids compile warnings. - bool isNull() { - return !!uuid_is_null(data()); - } - - // Default op= and copy ctor are fine. - // boost::array gives us ==, < etc. + bool isNull(); QPID_COMMON_EXTERN void encode(framing::Buffer& buf) const; QPID_COMMON_EXTERN void decode(framing::Buffer& buf); diff --git a/qpid/cpp/include/qpid/sys/uuid.h b/qpid/cpp/include/qpid/sys/uuid.h deleted file mode 100644 index 804ab34463..0000000000 --- a/qpid/cpp/include/qpid/sys/uuid.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef _sys_uuid_h -#define _sys_uuid_h - -/* - * - * Copyright (c) 2006 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifdef _WIN32 -# include "qpid/sys/windows/uuid.h" -#else -# include -#endif /* _WIN32 */ - -#endif /* _sys_uuid_h */ diff --git a/qpid/cpp/include/qpid/sys/windows/uuid.h b/qpid/cpp/include/qpid/sys/windows/uuid.h deleted file mode 100644 index c79abe95c6..0000000000 --- a/qpid/cpp/include/qpid/sys/windows/uuid.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef _sys_windows_uuid_h -#define _sys_windows_uuid_h - -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -#include "qpid/CommonImportExport.h" -#include - -namespace qpid { namespace sys { const size_t UuidSize = 16; }} -typedef uint8_t uuid_t[qpid::sys::UuidSize]; - -QPID_COMMON_EXTERN void uuid_clear (uuid_t uu); -QPID_COMMON_EXTERN void uuid_copy (uuid_t dst, const uuid_t src); -QPID_COMMON_EXTERN void uuid_generate (uuid_t out); -QPID_COMMON_EXTERN int uuid_is_null (const uuid_t uu); // Returns 1 if null, else 0 -QPID_COMMON_EXTERN int uuid_parse (const char *in, uuid_t uu); // Returns 0 on success, else -1 -QPID_COMMON_EXTERN void uuid_unparse (const uuid_t uu, char *out); - -#endif /*!_sys_windows_uuid_h*/ -- cgit v1.2.1 From f8bcd637a512b3b97067aa41383290bb92e65913 Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Tue, 1 Sep 2009 15:54:29 +0000 Subject: Some QPID_COMMON_EXTERNs missed from previous uuid commit git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@810103 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/framing/Uuid.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/framing/Uuid.h b/qpid/cpp/include/qpid/framing/Uuid.h index 8e817178da..618515622d 100644 --- a/qpid/cpp/include/qpid/framing/Uuid.h +++ b/qpid/cpp/include/qpid/framing/Uuid.h @@ -43,10 +43,10 @@ class Buffer; */ struct Uuid : public boost::array { /** If unique is true, generate a unique ID else a null ID. */ - Uuid(bool unique=false); + QPID_COMMON_EXTERN Uuid(bool unique=false); /** Copy from 16 bytes of data. */ - Uuid(const uint8_t* data); + QPID_COMMON_EXTERN Uuid(const uint8_t* data); // Default op= and copy ctor are fine. // boost::array gives us ==, < etc. @@ -55,7 +55,7 @@ struct Uuid : public boost::array { void assign(const uint8_t* data); /** Set to a new unique identifier. */ - void generate(); + QPID_COMMON_EXTERN void generate(); /** Set to all zeros. */ void clear(); -- cgit v1.2.1 From 26022334bbaff31fa50242c68b38276aa9e0ffde Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Tue, 1 Sep 2009 20:47:15 +0000 Subject: Revisit fix for QPID-1737: (clash with Win32 symbol) Change all use of STATUS_INVALID_PARAMETER to STATUS_PARAMETER_INVALID git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@810227 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/management/Manageable.h | 2 +- qpid/cpp/include/qpid/sys/windows/Condition.h | 1 - qpid/cpp/include/qpid/sys/windows/Mutex.h | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/management/Manageable.h b/qpid/cpp/include/qpid/management/Manageable.h index 8062479ac6..7a72cc1592 100644 --- a/qpid/cpp/include/qpid/management/Manageable.h +++ b/qpid/cpp/include/qpid/management/Manageable.h @@ -43,7 +43,7 @@ class QPID_COMMON_EXTERN Manageable static const status_t STATUS_UNKNOWN_OBJECT = 1; static const status_t STATUS_UNKNOWN_METHOD = 2; static const status_t STATUS_NOT_IMPLEMENTED = 3; - static const status_t STATUS_INVALID_PARAMETER = 4; + static const status_t STATUS_PARAMETER_INVALID = 4; static const status_t STATUS_FEATURE_NOT_IMPLEMENTED = 5; static const status_t STATUS_FORBIDDEN = 6; static const status_t STATUS_EXCEPTION = 7; diff --git a/qpid/cpp/include/qpid/sys/windows/Condition.h b/qpid/cpp/include/qpid/sys/windows/Condition.h index c31f7b4823..979fae9b0a 100755 --- a/qpid/cpp/include/qpid/sys/windows/Condition.h +++ b/qpid/cpp/include/qpid/sys/windows/Condition.h @@ -30,7 +30,6 @@ #include #include #include -#undef STATUS_INVALID_PARAMETER // Hack for windows.h namespace pollution namespace qpid { namespace sys { diff --git a/qpid/cpp/include/qpid/sys/windows/Mutex.h b/qpid/cpp/include/qpid/sys/windows/Mutex.h index 12768640d5..5dcc69e836 100755 --- a/qpid/cpp/include/qpid/sys/windows/Mutex.h +++ b/qpid/cpp/include/qpid/sys/windows/Mutex.h @@ -31,7 +31,6 @@ #include #include #include -#undef STATUS_INVALID_PARAMETER // Hack for windows.h namespace pollution namespace qpid { namespace sys { -- cgit v1.2.1 From 32c4f003827349ed7cc24f7e870c8833b30c277d Mon Sep 17 00:00:00 2001 From: "Stephen D. Huston" Date: Fri, 4 Sep 2009 21:19:13 +0000 Subject: Pick up correct CMake-set macro (qmfcommon_EXPORTS) to flip import/export for qmfcommon lib git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@811553 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/QmfImportExport.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qmf/QmfImportExport.h b/qpid/cpp/include/qmf/QmfImportExport.h index 8353a3cc16..f5e1d9127c 100644 --- a/qpid/cpp/include/qmf/QmfImportExport.h +++ b/qpid/cpp/include/qmf/QmfImportExport.h @@ -21,7 +21,7 @@ */ #if defined(WIN32) && !defined(QPID_DECLARE_STATIC) -# if defined(QMF_EXPORT) || defined (qmf_EXPORTS) +# if defined(QMF_EXPORT) || defined (qmfcommon_EXPORTS) # define QMF_EXTERN __declspec(dllexport) # else # define QMF_EXTERN __declspec(dllimport) -- cgit v1.2.1 From a6f764698a484686d80bfb25dd32a8916e8573cc Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Mon, 7 Sep 2009 18:09:00 +0000 Subject: QPID-664: Added automatic message replay on reconnection. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@812243 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Sender.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Sender.h b/qpid/cpp/include/qpid/messaging/Sender.h index 657c4b8cfe..45ec659ecf 100644 --- a/qpid/cpp/include/qpid/messaging/Sender.h +++ b/qpid/cpp/include/qpid/messaging/Sender.h @@ -47,7 +47,7 @@ class Sender : public qpid::client::Handle QPID_CLIENT_EXTERN ~Sender(); QPID_CLIENT_EXTERN Sender& operator=(const Sender&); - QPID_CLIENT_EXTERN void send(Message& message); + QPID_CLIENT_EXTERN void send(const Message& message); QPID_CLIENT_EXTERN void cancel(); private: friend class qpid::client::PrivateImplRef; -- cgit v1.2.1 From 1dc1518686b9829d5bb60deb985b4bef74ff786b Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Mon, 14 Sep 2009 10:21:49 +0000 Subject: Added available and pendingAck properties to Receiver; added capacity and pending properties to Sender. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@814562 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Receiver.h | 33 ++++++++++++++++++++++++------ qpid/cpp/include/qpid/messaging/Sender.h | 19 +++++++++++++++++ qpid/cpp/include/qpid/messaging/Session.h | 14 ++++++++++--- 3 files changed, 57 insertions(+), 9 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Receiver.h b/qpid/cpp/include/qpid/messaging/Receiver.h index e51e1093d1..a4fdd7a34b 100644 --- a/qpid/cpp/include/qpid/messaging/Receiver.h +++ b/qpid/cpp/include/qpid/messaging/Receiver.h @@ -40,7 +40,7 @@ class MessageListener; class ReceiverImpl; /** - * A pull style interface for message retrieval. + * Interface through which messages are received. */ class Receiver : public qpid::client::Handle { @@ -75,7 +75,7 @@ class Receiver : public qpid::client::Handle QPID_CLIENT_EXTERN bool fetch(Message& message, qpid::sys::Duration timeout=qpid::sys::TIME_INFINITE); /** * Retrieves a message for this receivers subscription or waits - * for upto the specified timeout for one to become + * for up to the specified timeout for one to become * available. Unlike get() this method will check with the server * that there is no message for the subscription this receiver is * serving before throwing an exception. @@ -87,8 +87,8 @@ class Receiver : public qpid::client::Handle */ QPID_CLIENT_EXTERN void start(); /** - * Stops the message flow for this receiver (without actually - * cancelling the subscription). + * Stops the message flow for this receiver (but does not cancel + * the subscription). */ QPID_CLIENT_EXTERN void stop(); /** @@ -97,14 +97,35 @@ class Receiver : public qpid::client::Handle * requested by a client via fetch() (or pushed to a listener). */ QPID_CLIENT_EXTERN void setCapacity(uint32_t); + /** + * Returns the capacity of the receiver. The capacity determines + * how many incoming messages can be held in the receiver before + * being requested by a client via fetch() (or pushed to a + * listener). + */ + QPID_CLIENT_EXTERN uint32_t getCapacity(); + /** + * Returns the number of messages received and waiting to be + * fetched. + */ + QPID_CLIENT_EXTERN uint32_t available(); + /** + * Returns a count of the number of messages received on this + * receiver that have been acknowledged, but for which that + * acknowledgement has not yet been confirmed as processed by the + * server. + */ + QPID_CLIENT_EXTERN uint32_t pendingAck(); /** - * Cancels this receiver + * Cancels this receiver. */ QPID_CLIENT_EXTERN void cancel(); /** - * Set a message listener for receiving messages asynchronously. + * Set a message listener for this receiver. + * + * @see Session::dispatch() */ QPID_CLIENT_EXTERN void setListener(MessageListener* listener); private: diff --git a/qpid/cpp/include/qpid/messaging/Sender.h b/qpid/cpp/include/qpid/messaging/Sender.h index 45ec659ecf..9b83a04d60 100644 --- a/qpid/cpp/include/qpid/messaging/Sender.h +++ b/qpid/cpp/include/qpid/messaging/Sender.h @@ -23,6 +23,7 @@ */ #include "qpid/client/ClientImportExport.h" #include "qpid/client/Handle.h" +#include "qpid/sys/IntegerTypes.h" namespace qpid { namespace client { @@ -49,6 +50,24 @@ class Sender : public qpid::client::Handle QPID_CLIENT_EXTERN void send(const Message& message); QPID_CLIENT_EXTERN void cancel(); + + /** + * Sets the capacity for the sender. The capacity determines how + * many outgoing messages can be held pending confirmation of + * receipt by the broker. + */ + QPID_CLIENT_EXTERN void setCapacity(uint32_t); + /** + * Returns the capacity of the sender. + * @see setCapacity + */ + QPID_CLIENT_EXTERN uint32_t getCapacity(); + /** + * Returns the number of sent messages pending confirmation of + * receipt by the broker. (These are the 'in-doubt' messages). + */ + QPID_CLIENT_EXTERN uint32_t pending(); + private: friend class qpid::client::PrivateImplRef; }; diff --git a/qpid/cpp/include/qpid/messaging/Session.h b/qpid/cpp/include/qpid/messaging/Session.h index 1d88882db6..979e27adae 100644 --- a/qpid/cpp/include/qpid/messaging/Session.h +++ b/qpid/cpp/include/qpid/messaging/Session.h @@ -75,6 +75,17 @@ class Session : public qpid::client::Handle QPID_CLIENT_EXTERN void sync(); QPID_CLIENT_EXTERN void flush(); + /** + * Returns the number of messages received and waiting to be + * fetched. + */ + QPID_CLIENT_EXTERN uint32_t available(); + /** + * Returns a count of the number of messages received this session + * that have been acknowledged, but for which that acknowledgement + * has not yet been confirmed as processed by the server. + */ + QPID_CLIENT_EXTERN uint32_t pendingAck(); QPID_CLIENT_EXTERN bool fetch(Message& message, qpid::sys::Duration timeout=qpid::sys::TIME_INFINITE); QPID_CLIENT_EXTERN Message fetch(qpid::sys::Duration timeout=qpid::sys::TIME_INFINITE); QPID_CLIENT_EXTERN bool dispatch(qpid::sys::Duration timeout=qpid::sys::TIME_INFINITE); @@ -88,9 +99,6 @@ class Session : public qpid::client::Handle QPID_CLIENT_EXTERN Receiver createReceiver(const std::string& address, const Filter& filter, const VariantMap& options = VariantMap()); QPID_CLIENT_EXTERN Address createTempQueue(const std::string& baseName = std::string()); - - QPID_CLIENT_EXTERN void* getLastConfirmedSent(); - QPID_CLIENT_EXTERN void* getLastConfirmedAcknowledged(); private: friend class qpid::client::PrivateImplRef; }; -- cgit v1.2.1 From c8fa5fa308f6ad9be22612568ace703777fbb6d9 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Fri, 18 Sep 2009 20:15:15 +0000 Subject: Refactored the QMF engine to adhere to the following rules regarding the pimpl (Pointer to Implementation) pattern: 1) Impl classes have constructors matching the public constructors 2) Additional Impl constructors are accessed through a static factory function 3) All linkages to objects are to the public object 4) If a back-link (from Impl to public) is needed, the Impl class must be derived from boost::noncopyable 5) All public classes have non-default copy constructors that make a copy of the Impl class git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@816770 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/ConnectionSettings.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qmf/ConnectionSettings.h b/qpid/cpp/include/qmf/ConnectionSettings.h index 9bd6922a56..5ba49226fc 100644 --- a/qpid/cpp/include/qmf/ConnectionSettings.h +++ b/qpid/cpp/include/qmf/ConnectionSettings.h @@ -36,8 +36,6 @@ namespace qmf { class ConnectionSettings { public: - ConnectionSettings(const ConnectionSettings& copy); - /** * Create a set of default connection settings. * @@ -63,6 +61,11 @@ namespace qmf { */ QMF_EXTERN ConnectionSettings(const char* url); + /** + * Copy Constructor. + */ + ConnectionSettings(const ConnectionSettings& from); + /** * Destroy the connection settings object. */ -- cgit v1.2.1 From 4e9025e343b611268d8164d255282b2198332597 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Fri, 25 Sep 2009 20:24:22 +0000 Subject: QMF updates: - Refactored into two namespaces: 1) 'qmf' for the public QMF api (c++) 2) 'qmf::engine' for the public engine API (used for language bindings) - Added object and first_object calls to Console (in Ruby) - Made objects call compatible with the kwarg arguments used in the older API - Added to_s functions to classes that needed them git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@818994 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/ConnectionSettings.h | 146 ------------- qpid/cpp/include/qmf/ConsoleObject.h | 94 +++++++++ qpid/cpp/include/qmf/engine/Agent.h | 209 +++++++++++++++++++ qpid/cpp/include/qmf/engine/ConnectionSettings.h | 148 +++++++++++++ qpid/cpp/include/qmf/engine/Console.h | 228 +++++++++++++++++++++ qpid/cpp/include/qmf/engine/Event.h | 32 +++ qpid/cpp/include/qmf/engine/Message.h | 41 ++++ qpid/cpp/include/qmf/engine/Object.h | 56 +++++ qpid/cpp/include/qmf/engine/ObjectId.h | 62 ++++++ .../cpp/include/qmf/engine/QmfEngineImportExport.h | 33 +++ qpid/cpp/include/qmf/engine/Query.h | 110 ++++++++++ qpid/cpp/include/qmf/engine/ResilientConnection.h | 165 +++++++++++++++ qpid/cpp/include/qmf/engine/Schema.h | 209 +++++++++++++++++++ qpid/cpp/include/qmf/engine/Typecode.h | 53 +++++ qpid/cpp/include/qmf/engine/Value.h | 121 +++++++++++ 15 files changed, 1561 insertions(+), 146 deletions(-) delete mode 100644 qpid/cpp/include/qmf/ConnectionSettings.h create mode 100644 qpid/cpp/include/qmf/ConsoleObject.h create mode 100644 qpid/cpp/include/qmf/engine/Agent.h create mode 100644 qpid/cpp/include/qmf/engine/ConnectionSettings.h create mode 100644 qpid/cpp/include/qmf/engine/Console.h create mode 100644 qpid/cpp/include/qmf/engine/Event.h create mode 100644 qpid/cpp/include/qmf/engine/Message.h create mode 100644 qpid/cpp/include/qmf/engine/Object.h create mode 100644 qpid/cpp/include/qmf/engine/ObjectId.h create mode 100644 qpid/cpp/include/qmf/engine/QmfEngineImportExport.h create mode 100644 qpid/cpp/include/qmf/engine/Query.h create mode 100644 qpid/cpp/include/qmf/engine/ResilientConnection.h create mode 100644 qpid/cpp/include/qmf/engine/Schema.h create mode 100644 qpid/cpp/include/qmf/engine/Typecode.h create mode 100644 qpid/cpp/include/qmf/engine/Value.h (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qmf/ConnectionSettings.h b/qpid/cpp/include/qmf/ConnectionSettings.h deleted file mode 100644 index 5ba49226fc..0000000000 --- a/qpid/cpp/include/qmf/ConnectionSettings.h +++ /dev/null @@ -1,146 +0,0 @@ -#ifndef _QmfConnectionSettings_ -#define _QmfConnectionSettings_ - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include "qmf/QmfImportExport.h" -#include "qpid/sys/IntegerTypes.h" - -namespace qmf { - - class ConnectionSettingsImpl; - class Value; - - /** - * Settings for AMQP connections to the broker. - * - * \ingroup qmfapi - */ - class ConnectionSettings { - public: - - /** - * Create a set of default connection settings. - * - * If no further attributes are set, the settings will cause a connection to be made to - * the default broker (on localhost or at a host/port supplied by service discovery) and - * authentication will be the best-available (GSSAPI/Kerberos, Anonymous, Plain with prompts - * for username and password). - */ - QMF_EXTERN ConnectionSettings(); - - /** - * Create a set of connection settings by URL. - * - * @param url Universal resource locator describing the broker address and additional attributes. - * - * The URL is of the form: - * amqp[s]://host[:port][?key=value[&key=value]*] - * - * For example: - * amqp://localhost - * amqp://broker?transport=rdma&authmech=GSSAPI&authservice=qpidd - * amqps://broker?authmech=PLAIN&authuser=guest&authpass=guest - */ - QMF_EXTERN ConnectionSettings(const char* url); - - /** - * Copy Constructor. - */ - ConnectionSettings(const ConnectionSettings& from); - - /** - * Destroy the connection settings object. - */ - QMF_EXTERN ~ConnectionSettings(); - - /** - * Set an attribute to control connection setup. - * - * @param key A null-terminated string that is an attribute name. - * - * @param value Reference to a value to be stored as the attribute. The type of the value - * is specific to the key. - */ - QMF_EXTERN void setAttr(const char* key, const Value& value); - - /** - * Get the value of an attribute. - * - * @param key A null-terminated attribute name. - * - * @return The value associated with the attribute name. - */ - QMF_EXTERN Value getAttr(const char* key) const; - - /** - * Get the attribute string (the portion of the URL following the '?') for the settings. - * - * @return A pointer to the attribute string. If the content of this string needs to be - * available beyond the scope of the calling function, it should be copied. The - * returned pointer may become invalid if the set of attributes is changed. - */ - QMF_EXTERN const char* getAttrString() const; - - /** - * Shortcuts for setting the transport for the connection. - * - * @param port The port value for the connection address. - */ - QMF_EXTERN void transportTcp(uint16_t port = 5672); - QMF_EXTERN void transportSsl(uint16_t port = 5671); - QMF_EXTERN void transportRdma(uint16_t port = 5672); - - /** - * Shortcuts for setting authentication mechanisms. - * - * @param username Null-terminated authentication user name. - * - * @param password Null-terminated authentication password. - * - * @param serviceName Null-terminated GSSAPI service name (Kerberos service principal) - * - * @param minSsf Minimum security factor for connections. 0 = encryption not required. - * - * @param maxSsf Maximum security factor for connections. 0 = encryption not permitted. - */ - QMF_EXTERN void authAnonymous(const char* username = 0); - QMF_EXTERN void authPlain(const char* username = 0, const char* password = 0); - QMF_EXTERN void authGssapi(const char* serviceName, uint32_t minSsf = 0, uint32_t maxSsf = 256); - - /** - * Shortcut for setting connection retry attributes. - * - * @param delayMin Minimum delay (in seconds) between connection attempts. - * - * @param delaxMax Maximum delay (in seconds) between connection attempts. - * - * @param delayFactor Factor to multiply the delay by between failed connection attempts. - */ - QMF_EXTERN void setRetry(int delayMin = 1, int delayMax = 128, int delayFactor = 2); - - private: - friend class ResilientConnectionImpl; - ConnectionSettingsImpl* impl; - }; - -} - -#endif diff --git a/qpid/cpp/include/qmf/ConsoleObject.h b/qpid/cpp/include/qmf/ConsoleObject.h new file mode 100644 index 0000000000..acbc285e05 --- /dev/null +++ b/qpid/cpp/include/qmf/ConsoleObject.h @@ -0,0 +1,94 @@ +#ifndef _QmfConsoleObject_ +#define _QmfConsoleObject_ + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include "qmf/QmfImportExport.h" + +namespace qmf { + + class ConsoleObjectImpl; + class SchemaObjectClass; + class ObjectId; + class Value; + + /** + * ConsoleObject is an extension of Object with console-specific methods added. + * + * \ingroup qmfapi + */ + class ConsoleObject : public Object { + public: + /** + * Create a new Object of a specific type. + * + * @param type Pointer to the schema class to use as a type for this object. + */ + QMF_EXTERN ConsoleObject(const SchemaObjectClass* type); + + /** + * Destroy the object. + */ + QMF_EXTERN virtual ~ConsoleObject(); + + /** + * + */ + QMF_EXTERN const SchemaObjectClass* getSchema() const; + + /** + * + */ + QMF_EXTERN ObjectId* getObjectId() const; + + /** + * + */ + QMF_EXTERN uint64_t getCurrentTime() const; + QMF_EXTERN uint64_t getCreateTime() const; + QMF_EXTERN uint64_t getDeleteTime() const; + + /** + * + */ + QMF_EXTERN bool isDeleted() const; + + /** + * + */ + QMF_EXTERN void update(); + + /** + * + */ + QMF_EXTERN void invokeMethod(const char* name, const Value* arguments, MethodResult& result); + + /** + * + */ + QMF_EXTERN uint32_t invokeMethodAsync(const char* name, const Value* arguments = 0); + + private: + ConsoleObjectImpl* impl; + }; + +} + +#endif diff --git a/qpid/cpp/include/qmf/engine/Agent.h b/qpid/cpp/include/qmf/engine/Agent.h new file mode 100644 index 0000000000..71abf82254 --- /dev/null +++ b/qpid/cpp/include/qmf/engine/Agent.h @@ -0,0 +1,209 @@ +#ifndef _QmfEngineAgent_ +#define _QmfEngineAgent_ + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include +#include +#include +#include +#include +#include +#include + +namespace qmf { +namespace engine { + + /** + * AgentEvent + * + * This structure represents a QMF event coming from the agent to + * the application. + */ + struct AgentEvent { + enum EventKind { + GET_QUERY = 1, + START_SYNC = 2, + END_SYNC = 3, + METHOD_CALL = 4, + DECLARE_QUEUE = 5, + DELETE_QUEUE = 6, + BIND = 7, + UNBIND = 8, + SETUP_COMPLETE = 9 + }; + + EventKind kind; + uint32_t sequence; // Protocol sequence (for all kinds) + char* authUserId; // Authenticated user ID (for all kinds) + char* authToken; // Authentication token if issued (for all kinds) + char* name; // Name of the method/sync query + // (METHOD_CALL, START_SYNC, END_SYNC, DECLARE_QUEUE, BIND, UNBIND) + Object* object; // Object involved in method call (METHOD_CALL) + ObjectId* objectId; // ObjectId for method call (METHOD_CALL) + Query* query; // Query parameters (GET_QUERY, START_SYNC) + Value* arguments; // Method parameters (METHOD_CALL) + char* exchange; // Exchange for bind (BIND, UNBIND) + char* bindingKey; // Key for bind (BIND, UNBIND) + const SchemaObjectClass* objectClass; // (METHOD_CALL) + }; + + class AgentImpl; + + /** + * Agent - Protocol engine for the QMF agent + */ + class Agent { + public: + Agent(char* label, bool internalStore=true); + ~Agent(); + + /** + * Configure the directory path for storing persistent data. + *@param path Null-terminated string containing a directory path where files can be + * created, written, and read. If NULL, no persistent storage will be + * attempted. + */ + void setStoreDir(const char* path); + + /** + * Configure the directory path for files transferred over QMF. + *@param path Null-terminated string containing a directory path where files can be + * created, deleted, written, and read. If NULL, file transfers shall not + * be permitted. + */ + void setTransferDir(const char* path); + + /** + * Pass messages received from the AMQP session to the Agent engine. + *@param message AMQP messages received on the agent session. + */ + void handleRcvMessage(Message& message); + + /** + * Get the next message to be sent to the AMQP network. + *@param item The Message structure describing the message to be produced. + *@return true if the Message is valid, false if there are no messages to send. + */ + bool getXmtMessage(Message& item) const; + + /** + * Remove and discard one message from the head of the transmit queue. + */ + void popXmt(); + + /** + * Get the next application event from the agent engine. + *@param event The event iff the return value is true + *@return true if event is valid, false if there are no events to process + */ + bool getEvent(AgentEvent& event) const; + + /** + * Remove and discard one event from the head of the event queue. + */ + void popEvent(); + + /** + * A new AMQP session has been established for Agent communication. + */ + void newSession(); + + /** + * Start the QMF Agent protocol. This should be invoked after a SETUP_COMPLETE event + * is received from the Agent engine. + */ + void startProtocol(); + + /** + * This method is called periodically so the agent can supply a heartbeat. + */ + void heartbeat(); + + /** + * Respond to a method request. + *@param sequence The sequence number from the method request event. + *@param status The method's completion status. + *@param text Status text ("OK" or an error message) + *@param arguments The list of output arguments from the method call. + */ + void methodResponse(uint32_t sequence, uint32_t status, char* text, const Value& arguments); + + /** + * Send a content indication to the QMF bus. This is only needed for objects that are + * managed by the application. This is *NOT* needed for objects managed by the Agent + * (inserted using addObject). + *@param sequence The sequence number of the GET request or the SYNC_START request. + *@param object The object (annotated with "changed" flags) for publication. + *@param prop If true, changed object properties are transmitted. + *@param stat If true, changed object statistics are transmitted. + */ + void queryResponse(uint32_t sequence, Object& object, bool prop = true, bool stat = true); + + /** + * Indicate the completion of a query. This is not used for SYNC_START requests. + *@param sequence The sequence number of the GET request. + */ + void queryComplete(uint32_t sequence); + + /** + * Register a schema class with the Agent. + *@param cls A SchemaObejctClass object that defines data managed by the agent. + */ + void registerClass(SchemaObjectClass* cls); + + /** + * Register a schema class with the Agent. + *@param cls A SchemaEventClass object that defines events sent by the agent. + */ + void registerClass(SchemaEventClass* cls); + + /** + * Give an object to the Agent for storage and management. Once added, the agent takes + * responsibility for the life cycle of the object. + *@param obj The object to be managed by the Agent. + *@param persistId A unique non-zero value if the object-id is to be persistent. + *@return The objectId of the managed object. + */ + const ObjectId* addObject(Object& obj, uint64_t persistId); + // const ObjectId* addObject(Object& obj, uint32_t persistIdLo, uint32_t persistIdHi); + + /** + * Allocate an object-id for an object that will be managed by the application. + *@param persistId A unique non-zero value if the object-id is to be persistent. + *@return The objectId structure for the allocated ID. + */ + const ObjectId* allocObjectId(uint64_t persistId); + const ObjectId* allocObjectId(uint32_t persistIdLo, uint32_t persistIdHi); + + /** + * Raise an event into the QMF network.. + *@param event The event object for the event to be raised. + */ + void raiseEvent(Event& event); + + private: + AgentImpl* impl; + }; +} +} + +#endif + diff --git a/qpid/cpp/include/qmf/engine/ConnectionSettings.h b/qpid/cpp/include/qmf/engine/ConnectionSettings.h new file mode 100644 index 0000000000..33f7c85a94 --- /dev/null +++ b/qpid/cpp/include/qmf/engine/ConnectionSettings.h @@ -0,0 +1,148 @@ +#ifndef _QmfEngineConnectionSettings_ +#define _QmfEngineConnectionSettings_ + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include "qmf/engine/QmfEngineImportExport.h" +#include "qpid/sys/IntegerTypes.h" + +namespace qmf { +namespace engine { + + class ConnectionSettingsImpl; + class Value; + + /** + * Settings for AMQP connections to the broker. + * + * \ingroup qmfapi + */ + class ConnectionSettings { + public: + + /** + * Create a set of default connection settings. + * + * If no further attributes are set, the settings will cause a connection to be made to + * the default broker (on localhost or at a host/port supplied by service discovery) and + * authentication will be the best-available (GSSAPI/Kerberos, Anonymous, Plain with prompts + * for username and password). + */ + QMFE_EXTERN ConnectionSettings(); + + /** + * Create a set of connection settings by URL. + * + * @param url Universal resource locator describing the broker address and additional attributes. + * + * The URL is of the form: + * amqp[s]://host[:port][?key=value[&key=value]*] + * + * For example: + * amqp://localhost + * amqp://broker?transport=rdma&authmech=GSSAPI&authservice=qpidd + * amqps://broker?authmech=PLAIN&authuser=guest&authpass=guest + */ + QMFE_EXTERN ConnectionSettings(const char* url); + + /** + * Copy Constructor. + */ + ConnectionSettings(const ConnectionSettings& from); + + /** + * Destroy the connection settings object. + */ + QMFE_EXTERN ~ConnectionSettings(); + + /** + * Set an attribute to control connection setup. + * + * @param key A null-terminated string that is an attribute name. + * + * @param value Reference to a value to be stored as the attribute. The type of the value + * is specific to the key. + */ + QMFE_EXTERN void setAttr(const char* key, const Value& value); + + /** + * Get the value of an attribute. + * + * @param key A null-terminated attribute name. + * + * @return The value associated with the attribute name. + */ + QMFE_EXTERN Value getAttr(const char* key) const; + + /** + * Get the attribute string (the portion of the URL following the '?') for the settings. + * + * @return A pointer to the attribute string. If the content of this string needs to be + * available beyond the scope of the calling function, it should be copied. The + * returned pointer may become invalid if the set of attributes is changed. + */ + QMFE_EXTERN const char* getAttrString() const; + + /** + * Shortcuts for setting the transport for the connection. + * + * @param port The port value for the connection address. + */ + QMFE_EXTERN void transportTcp(uint16_t port = 5672); + QMFE_EXTERN void transportSsl(uint16_t port = 5671); + QMFE_EXTERN void transportRdma(uint16_t port = 5672); + + /** + * Shortcuts for setting authentication mechanisms. + * + * @param username Null-terminated authentication user name. + * + * @param password Null-terminated authentication password. + * + * @param serviceName Null-terminated GSSAPI service name (Kerberos service principal) + * + * @param minSsf Minimum security factor for connections. 0 = encryption not required. + * + * @param maxSsf Maximum security factor for connections. 0 = encryption not permitted. + */ + QMFE_EXTERN void authAnonymous(const char* username = 0); + QMFE_EXTERN void authPlain(const char* username = 0, const char* password = 0); + QMFE_EXTERN void authGssapi(const char* serviceName, uint32_t minSsf = 0, uint32_t maxSsf = 256); + + /** + * Shortcut for setting connection retry attributes. + * + * @param delayMin Minimum delay (in seconds) between connection attempts. + * + * @param delaxMax Maximum delay (in seconds) between connection attempts. + * + * @param delayFactor Factor to multiply the delay by between failed connection attempts. + */ + QMFE_EXTERN void setRetry(int delayMin = 1, int delayMax = 128, int delayFactor = 2); + + private: + friend class ResilientConnectionImpl; + ConnectionSettingsImpl* impl; + }; + +} +} + +#endif diff --git a/qpid/cpp/include/qmf/engine/Console.h b/qpid/cpp/include/qmf/engine/Console.h new file mode 100644 index 0000000000..49cf41f2bc --- /dev/null +++ b/qpid/cpp/include/qmf/engine/Console.h @@ -0,0 +1,228 @@ +#ifndef _QmfEngineConsole_ +#define _QmfEngineConsole_ + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace qmf { +namespace engine { + + class Console; + struct ConsoleImpl; + class BrokerProxyImpl; + class AgentProxy; + struct AgentProxyImpl; + struct MethodResponseImpl; + struct QueryResponseImpl; + struct QueryContext; + + /** + * + */ + class MethodResponse { + public: + MethodResponse(const MethodResponse& from); + ~MethodResponse(); + uint32_t getStatus() const; + const Value* getException() const; + const Value* getArgs() const; + + private: + friend struct MethodResponseImpl; + friend struct ConsoleImpl; + MethodResponse(MethodResponseImpl* impl); + MethodResponseImpl* impl; + }; + + /** + * + */ + class QueryResponse { + public: + ~QueryResponse(); + uint32_t getStatus() const; + const Value* getException() const; + uint32_t getObjectCount() const; + const Object* getObject(uint32_t idx) const; + + private: + friend struct QueryResponseImpl; + friend struct QueryContext; + QueryResponse(QueryResponseImpl* impl); + QueryResponseImpl *impl; + }; + + /** + * + */ + struct ConsoleEvent { + enum EventKind { + AGENT_ADDED = 1, + AGENT_DELETED = 2, + NEW_PACKAGE = 3, + NEW_CLASS = 4, + OBJECT_UPDATE = 5, + EVENT_RECEIVED = 7, + AGENT_HEARTBEAT = 8 + }; + + EventKind kind; + AgentProxy* agent; // (AGENT_[ADDED|DELETED|HEARTBEAT]) + char* name; // (NEW_PACKAGE) + SchemaClassKey* classKey; // (NEW_CLASS) + Object* object; // (OBJECT_UPDATE) + void* context; // (OBJECT_UPDATE) + Event* event; // (EVENT_RECEIVED) + uint64_t timestamp; // (AGENT_HEARTBEAT) + QueryResponse* queryResponse; // (QUERY_COMPLETE) + }; + + /** + * + */ + struct BrokerEvent { + enum EventKind { + BROKER_INFO = 10, + DECLARE_QUEUE = 11, + DELETE_QUEUE = 12, + BIND = 13, + UNBIND = 14, + SETUP_COMPLETE = 15, + STABLE = 16, + QUERY_COMPLETE = 17, + METHOD_RESPONSE = 18 + }; + + EventKind kind; + char* name; // ([DECLARE|DELETE]_QUEUE, [UN]BIND) + char* exchange; // ([UN]BIND) + char* bindingKey; // ([UN]BIND) + void* context; // (QUERY_COMPLETE, METHOD_RESPONSE) + QueryResponse* queryResponse; // (QUERY_COMPLETE) + MethodResponse* methodResponse; // (METHOD_RESPONSE) + }; + + /** + * + */ + class AgentProxy { + public: + ~AgentProxy(); + const char* getLabel() const; + + private: + friend struct AgentProxyImpl; + friend class BrokerProxyImpl; + AgentProxy(AgentProxyImpl* impl); + AgentProxyImpl* impl; + }; + + /** + * + */ + class BrokerProxy { + public: + BrokerProxy(Console& console); + ~BrokerProxy(); + + void sessionOpened(SessionHandle& sh); + void sessionClosed(); + void startProtocol(); + + void handleRcvMessage(Message& message); + bool getXmtMessage(Message& item) const; + void popXmt(); + + bool getEvent(BrokerEvent& event) const; + void popEvent(); + + uint32_t agentCount() const; + const AgentProxy* getAgent(uint32_t idx) const; + void sendQuery(const Query& query, void* context, const AgentProxy* agent = 0); + + private: + friend struct ConsoleImpl; + friend struct StaticContext; + BrokerProxyImpl* impl; + }; + + // TODO - move this to a public header + struct ConsoleSettings { + bool rcvObjects; + bool rcvEvents; + bool rcvHeartbeats; + bool userBindings; + + ConsoleSettings() : + rcvObjects(true), + rcvEvents(true), + rcvHeartbeats(true), + userBindings(false) {} + }; + + class Console { + public: + Console(const ConsoleSettings& settings = ConsoleSettings()); + ~Console(); + + bool getEvent(ConsoleEvent& event) const; + void popEvent(); + + void addConnection(BrokerProxy& broker, void* context); + void delConnection(BrokerProxy& broker); + + uint32_t packageCount() const; + const char* getPackageName(uint32_t idx) const; + + uint32_t classCount(const char* packageName) const; + const SchemaClassKey* getClass(const char* packageName, uint32_t idx) const; + + ClassKind getClassKind(const SchemaClassKey* key) const; + const SchemaObjectClass* getObjectClass(const SchemaClassKey* key) const; + const SchemaEventClass* getEventClass(const SchemaClassKey* key) const; + + void bindPackage(const char* packageName); + void bindClass(const SchemaClassKey* key); + void bindClass(const char* packageName, const char* className); + + /* + void startSync(const Query& query, void* context, SyncQuery& sync); + void touchSync(SyncQuery& sync); + void endSync(SyncQuery& sync); + */ + + private: + friend class BrokerProxyImpl; + friend struct AgentProxyImpl; + ConsoleImpl* impl; + }; +} +} + +#endif + diff --git a/qpid/cpp/include/qmf/engine/Event.h b/qpid/cpp/include/qmf/engine/Event.h new file mode 100644 index 0000000000..50ab5c1200 --- /dev/null +++ b/qpid/cpp/include/qmf/engine/Event.h @@ -0,0 +1,32 @@ +#ifndef _QmfEngineEvent_ +#define _QmfEngineEvent_ + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +namespace qmf { +namespace engine { + + class Event { + }; +} +} + +#endif + diff --git a/qpid/cpp/include/qmf/engine/Message.h b/qpid/cpp/include/qmf/engine/Message.h new file mode 100644 index 0000000000..1e95cc6afe --- /dev/null +++ b/qpid/cpp/include/qmf/engine/Message.h @@ -0,0 +1,41 @@ +#ifndef _QmfEngineMessage_ +#define _QmfEngineMessage_ + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include "qpid/sys/IntegerTypes.h" + +namespace qmf { +namespace engine { + + struct Message { + char* body; + uint32_t length; + char* destination; + char* routingKey; + char* replyExchange; + char* replyKey; + char* userId; + }; + +} +} + +#endif diff --git a/qpid/cpp/include/qmf/engine/Object.h b/qpid/cpp/include/qmf/engine/Object.h new file mode 100644 index 0000000000..ad67cfdb95 --- /dev/null +++ b/qpid/cpp/include/qmf/engine/Object.h @@ -0,0 +1,56 @@ +#ifndef _QmfEngineObject_ +#define _QmfEngineObject_ + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include +#include +#include + +namespace qmf { +namespace engine { + + struct ObjectImpl; + class Object { + public: + Object(const SchemaObjectClass* type); + Object(const Object& from); + virtual ~Object(); + + void destroy(); + const ObjectId* getObjectId() const; + void setObjectId(ObjectId* oid); + const SchemaObjectClass* getClass() const; + Value* getValue(const char* key) const; + void invokeMethod(const char* methodName, const Value* inArgs, void* context) const; + bool isDeleted() const; + void merge(const Object& from); + + private: + friend struct ObjectImpl; + friend class AgentImpl; + Object(ObjectImpl* impl); + ObjectImpl* impl; + }; +} +} + +#endif + diff --git a/qpid/cpp/include/qmf/engine/ObjectId.h b/qpid/cpp/include/qmf/engine/ObjectId.h new file mode 100644 index 0000000000..a4b868b578 --- /dev/null +++ b/qpid/cpp/include/qmf/engine/ObjectId.h @@ -0,0 +1,62 @@ +#ifndef _QmfEngineObjectId_ +#define _QmfEngineObjectId_ + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include + +namespace qmf { +namespace engine { + + // TODO: Add to/from string and << operator + + struct ObjectIdImpl; + class ObjectId { + public: + ObjectId(); + ObjectId(const ObjectId& from); + ~ObjectId(); + + uint64_t getObjectNum() const; + uint32_t getObjectNumHi() const; + uint32_t getObjectNumLo() const; + bool isDurable() const; + + bool operator==(const ObjectId& other) const; + bool operator<(const ObjectId& other) const; + bool operator>(const ObjectId& other) const; + bool operator<=(const ObjectId& other) const; + bool operator>=(const ObjectId& other) const; + + private: + friend struct ObjectIdImpl; + friend struct ObjectImpl; + friend class BrokerProxyImpl; + friend struct QueryImpl; + friend struct ValueImpl; + friend class AgentImpl; + ObjectId(ObjectIdImpl* impl); + ObjectIdImpl* impl; + }; +} +} + +#endif + diff --git a/qpid/cpp/include/qmf/engine/QmfEngineImportExport.h b/qpid/cpp/include/qmf/engine/QmfEngineImportExport.h new file mode 100644 index 0000000000..70164c749f --- /dev/null +++ b/qpid/cpp/include/qmf/engine/QmfEngineImportExport.h @@ -0,0 +1,33 @@ +#ifndef QMF_ENGINE_IMPORT_EXPORT_H +#define QMF_ENGINE_IMPORT_EXPORT_H + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#if defined(WIN32) && !defined(QPID_DECLARE_STATIC) +# if defined(QMF_EXPORT) || defined (qmfcommon_EXPORTS) +# define QMFE_EXTERN __declspec(dllexport) +# else +# define QMFE_EXTERN __declspec(dllimport) +# endif +#else +# define QMFE_EXTERN +#endif + +#endif diff --git a/qpid/cpp/include/qmf/engine/Query.h b/qpid/cpp/include/qmf/engine/Query.h new file mode 100644 index 0000000000..1b11ea83f2 --- /dev/null +++ b/qpid/cpp/include/qmf/engine/Query.h @@ -0,0 +1,110 @@ +#ifndef _QmfEngineQuery_ +#define _QmfEngineQuery_ + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include +#include + +namespace qmf { +namespace engine { + + class Object; + struct QueryElementImpl; + struct QueryImpl; + struct QueryExpressionImpl; + class SchemaClassKey; + + enum ValueOper { + O_EQ = 1, + O_NE = 2, + O_LT = 3, + O_LE = 4, + O_GT = 5, + O_GE = 6, + O_RE_MATCH = 7, + O_RE_NOMATCH = 8 + }; + + struct QueryOperand { + virtual ~QueryOperand() {} + virtual bool evaluate(const Object* object) const = 0; + }; + + struct QueryElement : public QueryOperand { + QueryElement(const char* attrName, const Value* value, ValueOper oper); + QueryElement(QueryElementImpl* impl); + virtual ~QueryElement(); + bool evaluate(const Object* object) const; + + QueryElementImpl* impl; + }; + + enum ExprOper { + E_NOT = 1, + E_AND = 2, + E_OR = 3, + E_XOR = 4 + }; + + struct QueryExpression : public QueryOperand { + QueryExpression(ExprOper oper, const QueryOperand* operand1, const QueryOperand* operand2); + QueryExpression(QueryExpressionImpl* impl); + virtual ~QueryExpression(); + bool evaluate(const Object* object) const; + + QueryExpressionImpl* impl; + }; + + class Query { + public: + Query(const char* className, const char* packageName); + Query(const SchemaClassKey* key); + Query(const ObjectId* oid); + Query(const Query& from); + ~Query(); + + void setSelect(const QueryOperand* criterion); + void setLimit(uint32_t maxResults); + void setOrderBy(const char* attrName, bool decreasing); + + const char* getPackage() const; + const char* getClass() const; + const ObjectId* getObjectId() const; + + bool haveSelect() const; + bool haveLimit() const; + bool haveOrderBy() const; + const QueryOperand* getSelect() const; + uint32_t getLimit() const; + const char* getOrderBy() const; + bool getDecreasing() const; + + private: + friend struct QueryImpl; + friend class BrokerProxyImpl; + Query(QueryImpl* impl); + QueryImpl* impl; + }; +} +} + +#endif + diff --git a/qpid/cpp/include/qmf/engine/ResilientConnection.h b/qpid/cpp/include/qmf/engine/ResilientConnection.h new file mode 100644 index 0000000000..359c8ea6ff --- /dev/null +++ b/qpid/cpp/include/qmf/engine/ResilientConnection.h @@ -0,0 +1,165 @@ +#ifndef _QmfEngineResilientConnection_ +#define _QmfEngineResilientConnection_ + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include +#include +#include + +namespace qmf { +namespace engine { + + class ResilientConnectionImpl; + + /** + * Represents events that occur, unsolicited, from ResilientConnection. + */ + struct ResilientConnectionEvent { + enum EventKind { + CONNECTED = 1, + DISCONNECTED = 2, + SESSION_CLOSED = 3, + RECV = 4 + }; + + EventKind kind; + void* sessionContext; // SESSION_CLOSED, RECV + char* errorText; // DISCONNECTED, SESSION_CLOSED + Message message; // RECV + }; + + class SessionHandle { + friend class ResilientConnectionImpl; + void* impl; + }; + + /** + * ResilientConnection represents a Qpid connection that is resilient. + * + * Upon creation, ResilientConnection attempts to establish a connection to the + * messaging broker. If it fails, it will continue to retry at an interval that + * increases over time (to a maximum interval). If an extablished connection is + * dropped, a reconnect will be attempted. + */ + class ResilientConnection { + public: + + /** + * Create a new resilient connection. + *@param settings Settings that define how the connection is to be made. + *@param delayMin Minimum delay (in seconds) between retries. + *@param delayMax Maximum delay (in seconds) between retries. + *@param delayFactor Factor to multiply retry delay by after each failure. + */ + ResilientConnection(const ConnectionSettings& settings); + ~ResilientConnection(); + + /** + * Get the connected status of the resilient connection. + *@return true iff the connection is established. + */ + bool isConnected() const; + + /** + * Get the next event (if present) from the connection. + *@param event Returned event if one is available. + *@return true if event is valid, false if there are no more events to handle. + */ + bool getEvent(ResilientConnectionEvent& event); + + /** + * Discard the event on the front of the queue. This should be invoked after processing + * the event from getEvent. + */ + void popEvent(); + + /** + * Create a new AMQP session. + *@param name Unique name for the session. + *@param sessionContext Optional user-context value that will be provided in events + * pertaining to this session. + *@param handle Output handle to be stored and used in subsequent calls pertaining to + * this session. + *@return true iff the session was successfully created. + */ + bool createSession(const char* name, void* sessionContext, SessionHandle& handle); + + /** + * Destroy a created session. + *@param handle SessionHandle returned by createSession. + */ + void destroySession(SessionHandle handle); + + /** + * Send a message into the AMQP broker via a session. + *@param handle The session handle of the session to transmit through. + *@param message The QMF message to transmit. + */ + void sendMessage(SessionHandle handle, Message& message); + + /** + * Declare an exclusive, auto-delete queue for a session. + *@param handle The session handle for the owner of the queue. + *@param queue The name of the queue. + */ + void declareQueue(SessionHandle handle, char* queue); + + /** + * Delete a queue. + *@param handle The session handle for the owner of the queue. + *@param queue The name of the queue. + */ + void deleteQueue(SessionHandle handle, char* queue); + + /** + * Bind a queue to an exchange. + *@param handle The session handle of the session to use for binding. + *@param exchange The name of the exchange for binding. + *@param queue The name of the queue for binding. + *@param key The binding key. + */ + void bind(SessionHandle handle, char* exchange, char* queue, char* key); + + /** + * Remove a binding. + *@param handle The session handle of the session to use for un-binding. + *@param exchange The name of the exchange. + *@param queue The name of the queue. + *@param key The binding key. + */ + void unbind(SessionHandle handle, char* exchange, char* queue, char* key); + + /** + * Establish a file descriptor for event notification. + *@param fd A file descriptor into which the connection shall write a character each + * time an event is enqueued. This fd may be in a pair, the other fd of which + * is used in a select loop to control execution. + */ + void setNotifyFd(int fd); + + private: + ResilientConnectionImpl* impl; + }; +} +} + +#endif + diff --git a/qpid/cpp/include/qmf/engine/Schema.h b/qpid/cpp/include/qmf/engine/Schema.h new file mode 100644 index 0000000000..fceb29990d --- /dev/null +++ b/qpid/cpp/include/qmf/engine/Schema.h @@ -0,0 +1,209 @@ +#ifndef _QmfEngineSchema_ +#define _QmfEngineSchema_ + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include +#include + +namespace qmf { +namespace engine { + + enum Access { ACCESS_READ_CREATE = 1, ACCESS_READ_WRITE = 2, ACCESS_READ_ONLY = 3 }; + enum Direction { DIR_IN = 1, DIR_OUT = 2, DIR_IN_OUT = 3 }; + enum ClassKind { CLASS_OBJECT = 1, CLASS_EVENT = 2 }; + + struct SchemaArgumentImpl; + struct SchemaMethodImpl; + struct SchemaPropertyImpl; + struct SchemaStatisticImpl; + struct SchemaObjectClassImpl; + struct SchemaEventClassImpl; + struct SchemaClassKeyImpl; + + /** + */ + class SchemaArgument { + public: + SchemaArgument(const char* name, Typecode typecode); + SchemaArgument(const SchemaArgument& from); + ~SchemaArgument(); + void setDirection(Direction dir); + void setUnit(const char* val); + void setDesc(const char* desc); + const char* getName() const; + Typecode getType() const; + Direction getDirection() const; + const char* getUnit() const; + const char* getDesc() const; + + private: + friend struct SchemaArgumentImpl; + friend struct SchemaMethodImpl; + friend struct SchemaEventClassImpl; + SchemaArgument(SchemaArgumentImpl* impl); + SchemaArgumentImpl* impl; + }; + + /** + */ + class SchemaMethod { + public: + SchemaMethod(const char* name); + SchemaMethod(const SchemaMethod& from); + ~SchemaMethod(); + void addArgument(const SchemaArgument* argument); + void setDesc(const char* desc); + const char* getName() const; + const char* getDesc() const; + int getArgumentCount() const; + const SchemaArgument* getArgument(int idx) const; + + private: + friend struct SchemaMethodImpl; + friend struct SchemaObjectClassImpl; + friend class AgentImpl; + SchemaMethod(SchemaMethodImpl* impl); + SchemaMethodImpl* impl; + }; + + /** + */ + class SchemaProperty { + public: + SchemaProperty(const char* name, Typecode typecode); + SchemaProperty(const SchemaProperty& from); + ~SchemaProperty(); + void setAccess(Access access); + void setIndex(bool val); + void setOptional(bool val); + void setUnit(const char* val); + void setDesc(const char* desc); + const char* getName() const; + Typecode getType() const; + Access getAccess() const; + bool isIndex() const; + bool isOptional() const; + const char* getUnit() const; + const char* getDesc() const; + + private: + friend struct SchemaPropertyImpl; + friend struct SchemaObjectClassImpl; + SchemaProperty(SchemaPropertyImpl* impl); + SchemaPropertyImpl* impl; + }; + + /** + */ + class SchemaStatistic { + public: + SchemaStatistic(const char* name, Typecode typecode); + SchemaStatistic(const SchemaStatistic& from); + ~SchemaStatistic(); + void setUnit(const char* val); + void setDesc(const char* desc); + const char* getName() const; + Typecode getType() const; + const char* getUnit() const; + const char* getDesc() const; + + private: + friend struct SchemaStatisticImpl; + friend struct SchemaObjectClassImpl; + SchemaStatistic(SchemaStatisticImpl* impl); + SchemaStatisticImpl* impl; + }; + + /** + */ + class SchemaClassKey { + public: + SchemaClassKey(const SchemaClassKey& from); + ~SchemaClassKey(); + + const char* getPackageName() const; + const char* getClassName() const; + const uint8_t* getHash() const; + + bool operator==(const SchemaClassKey& other) const; + bool operator<(const SchemaClassKey& other) const; + + private: + friend struct SchemaClassKeyImpl; + friend class BrokerProxyImpl; + friend struct ConsoleImpl; + SchemaClassKey(SchemaClassKeyImpl* impl); + SchemaClassKeyImpl* impl; + }; + + /** + */ + class SchemaObjectClass { + public: + SchemaObjectClass(const char* package, const char* name); + SchemaObjectClass(const SchemaObjectClass& from); + ~SchemaObjectClass(); + void addProperty(const SchemaProperty* property); + void addStatistic(const SchemaStatistic* statistic); + void addMethod(const SchemaMethod* method); + + const SchemaClassKey* getClassKey() const; + int getPropertyCount() const; + int getStatisticCount() const; + int getMethodCount() const; + const SchemaProperty* getProperty(int idx) const; + const SchemaStatistic* getStatistic(int idx) const; + const SchemaMethod* getMethod(int idx) const; + + private: + friend struct SchemaObjectClassImpl; + friend class BrokerProxyImpl; + friend class AgentImpl; + SchemaObjectClass(SchemaObjectClassImpl* impl); + SchemaObjectClassImpl* impl; + }; + + /** + */ + class SchemaEventClass { + public: + SchemaEventClass(const char* package, const char* name); + SchemaEventClass(const SchemaEventClass& from); + ~SchemaEventClass(); + void addArgument(const SchemaArgument* argument); + void setDesc(const char* desc); + + const SchemaClassKey* getClassKey() const; + int getArgumentCount() const; + const SchemaArgument* getArgument(int idx) const; + + private: + friend struct SchemaEventClassImpl; + friend class BrokerProxyImpl; + friend class AgentImpl; + SchemaEventClass(SchemaEventClassImpl* impl); + SchemaEventClassImpl* impl; + }; +} +} + +#endif + diff --git a/qpid/cpp/include/qmf/engine/Typecode.h b/qpid/cpp/include/qmf/engine/Typecode.h new file mode 100644 index 0000000000..613f96a483 --- /dev/null +++ b/qpid/cpp/include/qmf/engine/Typecode.h @@ -0,0 +1,53 @@ +#ifndef _QmfEngineTypecode_ +#define _QmfEngineTypecode_ + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +namespace qmf { +namespace engine { + + enum Typecode { + TYPE_UINT8 = 1, + TYPE_UINT16 = 2, + TYPE_UINT32 = 3, + TYPE_UINT64 = 4, + TYPE_SSTR = 6, + TYPE_LSTR = 7, + TYPE_ABSTIME = 8, + TYPE_DELTATIME = 9, + TYPE_REF = 10, + TYPE_BOOL = 11, + TYPE_FLOAT = 12, + TYPE_DOUBLE = 13, + TYPE_UUID = 14, + TYPE_MAP = 15, + TYPE_INT8 = 16, + TYPE_INT16 = 17, + TYPE_INT32 = 18, + TYPE_INT64 = 19, + TYPE_OBJECT = 20, + TYPE_LIST = 21, + TYPE_ARRAY = 22 + }; +} +} + +#endif + diff --git a/qpid/cpp/include/qmf/engine/Value.h b/qpid/cpp/include/qmf/engine/Value.h new file mode 100644 index 0000000000..8eae382caf --- /dev/null +++ b/qpid/cpp/include/qmf/engine/Value.h @@ -0,0 +1,121 @@ +#ifndef _QmfEngineValue_ +#define _QmfEngineValue_ + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include +#include + +namespace qmf { +namespace engine { + + class Object; + struct ValueImpl; + + class Value { + public: + // Value(); + Value(const Value& from); + Value(Typecode t, Typecode arrayType = TYPE_UINT8); + ~Value(); + + Typecode getType() const; + bool isNull() const; + void setNull(); + + bool isObjectId() const; + const ObjectId& asObjectId() const; + void setObjectId(const ObjectId& oid); + + bool isUint() const; + uint32_t asUint() const; + void setUint(uint32_t val); + + bool isInt() const; + int32_t asInt() const; + void setInt(int32_t val); + + bool isUint64() const; + uint64_t asUint64() const; + void setUint64(uint64_t val); + + bool isInt64() const; + int64_t asInt64() const; + void setInt64(int64_t val); + + bool isString() const; + const char* asString() const; + void setString(const char* val); + + bool isBool() const; + bool asBool() const; + void setBool(bool val); + + bool isFloat() const; + float asFloat() const; + void setFloat(float val); + + bool isDouble() const; + double asDouble() const; + void setDouble(double val); + + bool isUuid() const; + const uint8_t* asUuid() const; + void setUuid(const uint8_t* val); + + bool isObject() const; + const Object* asObject() const; + void setObject(Object* val); + + bool isMap() const; + bool keyInMap(const char* key) const; + Value* byKey(const char* key); + const Value* byKey(const char* key) const; + void deleteKey(const char* key); + void insert(const char* key, Value* val); + uint32_t keyCount() const; + const char* key(uint32_t idx) const; + + bool isList() const; + uint32_t listItemCount() const; + Value* listItem(uint32_t idx); + void appendToList(Value* val); + void deleteListItem(uint32_t idx); + + bool isArray() const; + Typecode arrayType() const; + uint32_t arrayItemCount() const; + Value* arrayItem(uint32_t idx); + void appendToArray(Value* val); + void deleteArrayItem(uint32_t idx); + + private: + friend struct ValueImpl; + friend class BrokerProxyImpl; + friend struct ObjectImpl; + friend class AgentImpl; + Value(ValueImpl* impl); + ValueImpl* impl; + }; +} +} + +#endif + -- cgit v1.2.1 From 70cf28cc70064a4f693cd8549aa12a698bcee967 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Sun, 27 Sep 2009 19:13:59 +0000 Subject: Adding missing file git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@819381 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/ConnectionSettings.h | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 qpid/cpp/include/qmf/ConnectionSettings.h (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qmf/ConnectionSettings.h b/qpid/cpp/include/qmf/ConnectionSettings.h new file mode 100644 index 0000000000..11af73d797 --- /dev/null +++ b/qpid/cpp/include/qmf/ConnectionSettings.h @@ -0,0 +1,32 @@ +#ifndef _QmfConnectionSettings_ +#define _QmfConnectionSettings_ + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +namespace qmf { + namespace engine { + class ConnectionSettings; + } + + typedef class engine::ConnectionSettings ConnectionSettings; +} + +#endif + -- cgit v1.2.1 From 74fecbf7759d549824bf92266c51a3d5180b6b33 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Tue, 29 Sep 2009 03:21:49 +0000 Subject: QMF Engine updates: - Connected console handler callbacks - Added string representations for a number of object classes - Added a feature that completes query requests sent to disconnected agents git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@819819 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/engine/Console.h | 7 ++++++- qpid/cpp/include/qmf/engine/ObjectId.h | 1 + qpid/cpp/include/qmf/engine/Schema.h | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qmf/engine/Console.h b/qpid/cpp/include/qmf/engine/Console.h index 49cf41f2bc..f53f351760 100644 --- a/qpid/cpp/include/qmf/engine/Console.h +++ b/qpid/cpp/include/qmf/engine/Console.h @@ -94,12 +94,14 @@ namespace engine { EventKind kind; AgentProxy* agent; // (AGENT_[ADDED|DELETED|HEARTBEAT]) char* name; // (NEW_PACKAGE) - SchemaClassKey* classKey; // (NEW_CLASS) + const SchemaClassKey* classKey; // (NEW_CLASS) Object* object; // (OBJECT_UPDATE) void* context; // (OBJECT_UPDATE) Event* event; // (EVENT_RECEIVED) uint64_t timestamp; // (AGENT_HEARTBEAT) QueryResponse* queryResponse; // (QUERY_COMPLETE) + bool hasProps; + bool hasStats; }; /** @@ -136,6 +138,8 @@ namespace engine { const char* getLabel() const; private: + friend struct StaticContext; + friend struct QueryContext; friend struct AgentProxyImpl; friend class BrokerProxyImpl; AgentProxy(AgentProxyImpl* impl); @@ -219,6 +223,7 @@ namespace engine { private: friend class BrokerProxyImpl; friend struct AgentProxyImpl; + friend struct StaticContext; ConsoleImpl* impl; }; } diff --git a/qpid/cpp/include/qmf/engine/ObjectId.h b/qpid/cpp/include/qmf/engine/ObjectId.h index a4b868b578..b71473a799 100644 --- a/qpid/cpp/include/qmf/engine/ObjectId.h +++ b/qpid/cpp/include/qmf/engine/ObjectId.h @@ -38,6 +38,7 @@ namespace engine { uint32_t getObjectNumHi() const; uint32_t getObjectNumLo() const; bool isDurable() const; + const char* str() const; bool operator==(const ObjectId& other) const; bool operator<(const ObjectId& other) const; diff --git a/qpid/cpp/include/qmf/engine/Schema.h b/qpid/cpp/include/qmf/engine/Schema.h index fceb29990d..16f11a83f9 100644 --- a/qpid/cpp/include/qmf/engine/Schema.h +++ b/qpid/cpp/include/qmf/engine/Schema.h @@ -142,6 +142,7 @@ namespace engine { const char* getPackageName() const; const char* getClassName() const; const uint8_t* getHash() const; + const char* asString() const; bool operator==(const SchemaClassKey& other) const; bool operator<(const SchemaClassKey& other) const; -- cgit v1.2.1 From 1442aac5016d54db03dff3411751f560097606b0 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Fri, 2 Oct 2009 13:01:51 +0000 Subject: define content- and view- classes separately from message class git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@821000 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/ListContent.h | 90 ++++++++++++++++++++++++ qpid/cpp/include/qpid/messaging/ListView.h | 67 ++++++++++++++++++ qpid/cpp/include/qpid/messaging/MapContent.h | 90 ++++++++++++++++++++++++ qpid/cpp/include/qpid/messaging/MapView.h | 70 ++++++++++++++++++ qpid/cpp/include/qpid/messaging/Message.h | 22 ++---- qpid/cpp/include/qpid/messaging/MessageContent.h | 90 ------------------------ 6 files changed, 322 insertions(+), 107 deletions(-) create mode 100644 qpid/cpp/include/qpid/messaging/ListContent.h create mode 100644 qpid/cpp/include/qpid/messaging/ListView.h create mode 100644 qpid/cpp/include/qpid/messaging/MapContent.h create mode 100644 qpid/cpp/include/qpid/messaging/MapView.h delete mode 100644 qpid/cpp/include/qpid/messaging/MessageContent.h (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/ListContent.h b/qpid/cpp/include/qpid/messaging/ListContent.h new file mode 100644 index 0000000000..1c4e13716d --- /dev/null +++ b/qpid/cpp/include/qpid/messaging/ListContent.h @@ -0,0 +1,90 @@ +#ifndef QPID_MESSAGING_LISTCONTENT_H +#define QPID_MESSAGING_LISTCONTENT_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#include "qpid/client/ClientImportExport.h" +#include "Variant.h" + +namespace qpid { +namespace messaging { + +class ListContentImpl; +class Message; + +/** + * Allows message content to be manipulated as a list. + */ +class ListContent +{ + public: + typedef Variant::List::iterator iterator; + typedef Variant::List::reverse_iterator reverse_iterator; + typedef Variant::List::const_iterator const_iterator; + typedef Variant::List::const_reverse_iterator const_reverse_iterator; + + QPID_CLIENT_EXTERN ListContent(Message&); + QPID_CLIENT_EXTERN ~ListContent(); + + QPID_CLIENT_EXTERN const_iterator begin() const; + QPID_CLIENT_EXTERN iterator begin(); + QPID_CLIENT_EXTERN const_iterator end() const; + QPID_CLIENT_EXTERN iterator end(); + QPID_CLIENT_EXTERN const_reverse_iterator rbegin() const; + QPID_CLIENT_EXTERN reverse_iterator rbegin(); + QPID_CLIENT_EXTERN const_reverse_iterator rend() const; + QPID_CLIENT_EXTERN reverse_iterator rend(); + + QPID_CLIENT_EXTERN bool empty() const; + QPID_CLIENT_EXTERN size_t size() const; + + QPID_CLIENT_EXTERN const Variant& front() const; + QPID_CLIENT_EXTERN Variant& front(); + QPID_CLIENT_EXTERN const Variant& back() const; + QPID_CLIENT_EXTERN Variant& back(); + + QPID_CLIENT_EXTERN void push_front(const Variant&); + QPID_CLIENT_EXTERN void push_back(const Variant&); + + QPID_CLIENT_EXTERN void pop_front(); + QPID_CLIENT_EXTERN void pop_back(); + + QPID_CLIENT_EXTERN iterator insert(iterator position, const Variant&); + QPID_CLIENT_EXTERN void insert(iterator position, size_t n, const Variant&); + QPID_CLIENT_EXTERN iterator erase(iterator position); + QPID_CLIENT_EXTERN iterator erase(iterator first, iterator last); + QPID_CLIENT_EXTERN void clear(); + + QPID_CLIENT_EXTERN void encode(); + + QPID_CLIENT_EXTERN const Variant::List& asList() const; + QPID_CLIENT_EXTERN Variant::List& asList(); + private: + ListContentImpl* impl; + + QPID_CLIENT_EXTERN ListContent& operator=(const ListContent&); +}; + +QPID_CLIENT_EXTERN std::ostream& operator<<(std::ostream& out, const ListContent& m); + +}} // namespace qpid::messaging + +#endif /*!QPID_MESSAGING_LISTCONTENT_H*/ diff --git a/qpid/cpp/include/qpid/messaging/ListView.h b/qpid/cpp/include/qpid/messaging/ListView.h new file mode 100644 index 0000000000..4970a20072 --- /dev/null +++ b/qpid/cpp/include/qpid/messaging/ListView.h @@ -0,0 +1,67 @@ +#ifndef QPID_MESSAGING_LISTVIEW_H +#define QPID_MESSAGING_LISTVIEW_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/client/ClientImportExport.h" +#include "Variant.h" + +namespace qpid { +namespace messaging { + +class ListViewImpl; +class Message; + +/** + * Provides a view of message content as a list + */ +class ListView +{ + public: + typedef Variant::List::const_iterator const_iterator; + typedef Variant::List::const_reverse_iterator const_reverse_iterator; + + QPID_CLIENT_EXTERN ListView(const Message&); + QPID_CLIENT_EXTERN ~ListView(); + QPID_CLIENT_EXTERN ListView& operator=(const ListView&); + + QPID_CLIENT_EXTERN const_iterator begin() const; + QPID_CLIENT_EXTERN const_iterator end() const; + QPID_CLIENT_EXTERN const_reverse_iterator rbegin() const; + QPID_CLIENT_EXTERN const_reverse_iterator rend() const; + + QPID_CLIENT_EXTERN bool empty() const; + QPID_CLIENT_EXTERN size_t size() const; + + QPID_CLIENT_EXTERN const Variant& front() const; + QPID_CLIENT_EXTERN const Variant& back() const; + + QPID_CLIENT_EXTERN const Variant::List& asList() const; + private: + ListViewImpl* impl; +}; + +QPID_CLIENT_EXTERN std::ostream& operator<<(std::ostream& out, const ListView& m); + +}} // namespace qpid::messaging + +#endif /*!QPID_MESSAGING_LISTVIEW_H*/ diff --git a/qpid/cpp/include/qpid/messaging/MapContent.h b/qpid/cpp/include/qpid/messaging/MapContent.h new file mode 100644 index 0000000000..b05cb31295 --- /dev/null +++ b/qpid/cpp/include/qpid/messaging/MapContent.h @@ -0,0 +1,90 @@ +#ifndef QPID_MESSAGING_MAPCONTENT_H +#define QPID_MESSAGING_MAPCONTENT_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/client/ClientImportExport.h" +#include "Variant.h" +#include +#include + +namespace qpid { +namespace messaging { + +class MapContentImpl; +class Message; + +/** + * Allows message content to be manipulated as a map + */ +class MapContent +{ + public: + typedef std::string key_type; + typedef std::pair value_type; + typedef std::map::const_iterator const_iterator; + typedef std::map::iterator iterator; + typedef std::map::const_reverse_iterator const_reverse_iterator; + typedef std::map::reverse_iterator reverse_iterator; + + QPID_CLIENT_EXTERN MapContent(Message&); + QPID_CLIENT_EXTERN ~MapContent(); + + QPID_CLIENT_EXTERN const_iterator begin() const; + QPID_CLIENT_EXTERN const_iterator end() const; + QPID_CLIENT_EXTERN const_reverse_iterator rbegin() const; + QPID_CLIENT_EXTERN const_reverse_iterator rend() const; + QPID_CLIENT_EXTERN iterator begin(); + QPID_CLIENT_EXTERN iterator end(); + QPID_CLIENT_EXTERN reverse_iterator rbegin(); + QPID_CLIENT_EXTERN reverse_iterator rend(); + + QPID_CLIENT_EXTERN bool empty() const; + QPID_CLIENT_EXTERN size_t size() const; + + QPID_CLIENT_EXTERN const_iterator find(const key_type&) const; + QPID_CLIENT_EXTERN iterator find(const key_type&); + QPID_CLIENT_EXTERN const Variant& operator[](const key_type&) const; + QPID_CLIENT_EXTERN Variant& operator[](const key_type&); + + QPID_CLIENT_EXTERN std::pair insert(const value_type&); + QPID_CLIENT_EXTERN iterator insert(iterator position, const value_type&); + QPID_CLIENT_EXTERN void erase(iterator position); + QPID_CLIENT_EXTERN void erase(iterator first, iterator last); + QPID_CLIENT_EXTERN size_t erase(const key_type&); + QPID_CLIENT_EXTERN void clear(); + + QPID_CLIENT_EXTERN void encode(); + + QPID_CLIENT_EXTERN const std::map& asMap() const; + QPID_CLIENT_EXTERN std::map& asMap(); + private: + MapContentImpl* impl; + + QPID_CLIENT_EXTERN MapContent& operator=(const MapContent&); +}; + +QPID_CLIENT_EXTERN std::ostream& operator<<(std::ostream& out, const MapContent& m); + +}} // namespace qpid::messaging + +#endif /*!QPID_MESSAGING_MAPCONTENT_H*/ diff --git a/qpid/cpp/include/qpid/messaging/MapView.h b/qpid/cpp/include/qpid/messaging/MapView.h new file mode 100644 index 0000000000..910dfca5c2 --- /dev/null +++ b/qpid/cpp/include/qpid/messaging/MapView.h @@ -0,0 +1,70 @@ +#ifndef QPID_MESSAGING_MAPVIEW_H +#define QPID_MESSAGING_MAPVIEW_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#include "qpid/client/ClientImportExport.h" +#include "Variant.h" +#include +#include + +namespace qpid { +namespace messaging { + +class MapViewImpl; +class Message; + +/** + * Provides a view of message content as a list + */ +class MapView +{ + public: + typedef std::string key_type; + typedef std::pair value_type; + typedef std::map::const_iterator const_iterator; + typedef std::map::const_reverse_iterator const_reverse_iterator; + + QPID_CLIENT_EXTERN MapView(const Message&); + QPID_CLIENT_EXTERN ~MapView(); + QPID_CLIENT_EXTERN MapView& operator=(const MapView&); + + QPID_CLIENT_EXTERN const_iterator begin() const; + QPID_CLIENT_EXTERN const_iterator end() const; + QPID_CLIENT_EXTERN const_reverse_iterator rbegin() const; + QPID_CLIENT_EXTERN const_reverse_iterator rend() const; + + QPID_CLIENT_EXTERN bool empty() const; + QPID_CLIENT_EXTERN size_t size() const; + + QPID_CLIENT_EXTERN const_iterator find(const key_type&) const; + QPID_CLIENT_EXTERN const Variant& operator[](const key_type&) const; + + QPID_CLIENT_EXTERN const std::map& asMap() const; + private: + MapViewImpl* impl; +}; + +QPID_CLIENT_EXTERN std::ostream& operator<<(std::ostream& out, const MapView& m); + +}} // namespace qpid::messaging + +#endif /*!QPID_MESSAGING_MAPVIEW_H*/ diff --git a/qpid/cpp/include/qpid/messaging/Message.h b/qpid/cpp/include/qpid/messaging/Message.h index e68d8a1141..4477d5a2e9 100644 --- a/qpid/cpp/include/qpid/messaging/Message.h +++ b/qpid/cpp/include/qpid/messaging/Message.h @@ -24,7 +24,6 @@ #include #include "qpid/messaging/Variant.h" -#include "qpid/messaging/MessageContent.h" #include "qpid/client/ClientImportExport.h" namespace qpid { @@ -62,22 +61,11 @@ class Message QPID_CLIENT_EXTERN const VariantMap& getHeaders() const; QPID_CLIENT_EXTERN VariantMap& getHeaders(); - QPID_CLIENT_EXTERN const std::string& getBytes() const; - QPID_CLIENT_EXTERN std::string& getBytes(); - QPID_CLIENT_EXTERN void setBytes(const std::string&); - QPID_CLIENT_EXTERN void setBytes(const char* chars, size_t count); - QPID_CLIENT_EXTERN const char* getRawContent() const; - QPID_CLIENT_EXTERN size_t getContentSize() const; - - - QPID_CLIENT_EXTERN MessageContent& getContent(); - QPID_CLIENT_EXTERN const MessageContent& getContent() const; - QPID_CLIENT_EXTERN void setContent(const std::string& s); - QPID_CLIENT_EXTERN void setContent(const Variant::Map&); - QPID_CLIENT_EXTERN void setContent(const Variant::List&); - - QPID_CLIENT_EXTERN void encode(Codec&); - QPID_CLIENT_EXTERN void decode(Codec&); + QPID_CLIENT_EXTERN const std::string& getContent() const; + QPID_CLIENT_EXTERN std::string& getContent(); + QPID_CLIENT_EXTERN void setContent(const std::string&); + QPID_CLIENT_EXTERN void setContent(const char* chars, size_t count); + QPID_CLIENT_EXTERN void getContent(std::pair& content) const; private: MessageImpl* impl; diff --git a/qpid/cpp/include/qpid/messaging/MessageContent.h b/qpid/cpp/include/qpid/messaging/MessageContent.h deleted file mode 100644 index 7c3a636c07..0000000000 --- a/qpid/cpp/include/qpid/messaging/MessageContent.h +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef QPID_MESSAGING_MESSAGECONTENT_H -#define QPID_MESSAGING_MESSAGECONTENT_H - -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -#include "qpid/messaging/Variant.h" -#include -#include "qpid/client/ClientImportExport.h" - -namespace qpid { -namespace messaging { - -/** - * - */ -class MessageContent -{ - public: - QPID_CLIENT_EXTERN virtual ~MessageContent() {} - - virtual const std::string& asString() const = 0; - virtual std::string& asString() = 0; - - virtual const char* asChars() const = 0; - virtual size_t size() const = 0; - - virtual const Variant::Map& asMap() const = 0; - virtual Variant::Map& asMap() = 0; - virtual bool isMap() const = 0; - - virtual const Variant::List& asList() const = 0; - virtual Variant::List& asList() = 0; - virtual bool isList() const = 0; - - virtual void clear() = 0; - - virtual Variant& operator[](const std::string&) = 0; - - - virtual std::ostream& print(std::ostream& out) const = 0; - - - //operator<< for variety of types... (is this a good idea?) - virtual MessageContent& operator<<(const std::string&) = 0; - virtual MessageContent& operator<<(const char*) = 0; - virtual MessageContent& operator<<(bool) = 0; - virtual MessageContent& operator<<(int8_t) = 0; - virtual MessageContent& operator<<(int16_t) = 0; - virtual MessageContent& operator<<(int32_t) = 0; - virtual MessageContent& operator<<(int64_t) = 0; - virtual MessageContent& operator<<(uint8_t) = 0; - virtual MessageContent& operator<<(uint16_t) = 0; - virtual MessageContent& operator<<(uint32_t) = 0; - virtual MessageContent& operator<<(uint64_t) = 0; - virtual MessageContent& operator<<(double) = 0; - virtual MessageContent& operator<<(float) = 0; - - //assignment from string, map and list - virtual MessageContent& operator=(const std::string&) = 0; - virtual MessageContent& operator=(const char*) = 0; - virtual MessageContent& operator=(const Variant::Map&) = 0; - virtual MessageContent& operator=(const Variant::List&) = 0; - - private: -}; - -QPID_CLIENT_EXTERN std::ostream& operator<<(std::ostream& out, const MessageContent& content); - -}} // namespace qpid::messaging - -#endif /*!QPID_MESSAGING_MESSAGECONTENT_H*/ -- cgit v1.2.1 From a07fbb63c409c0171261abc0906e8bc59506a88d Mon Sep 17 00:00:00 2001 From: Jonathan Robie Date: Fri, 2 Oct 2009 13:05:32 +0000 Subject: Deprecated enableQueueEvents() in the doxygen comments. Use setInt() instead. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@821003 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/client/QueueOptions.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/client/QueueOptions.h b/qpid/cpp/include/qpid/client/QueueOptions.h index 9418cb092d..f8a4963f06 100644 --- a/qpid/cpp/include/qpid/client/QueueOptions.h +++ b/qpid/cpp/include/qpid/client/QueueOptions.h @@ -90,7 +90,22 @@ class QueueOptions: public framing::FieldTable * Turns on event generation for this queue (either enqueue only * or for enqueue and dequeue events); the events can then be * processed by a regsitered broker plugin. + * + * DEPRECATED + * + * This is confusing to anyone who sees only the function call + * and not the variable name / doxygen. Consider the following call: + * + * options.enableQueueEvents(false); + * + * It looks like it disables queue events, but what it really does is + * enable both enqueue and dequeue events. + * + * Use setInt() instead: + * + * options.setInt("qpid.queue_event_generation", 2); */ + QPID_CLIENT_EXTERN void enableQueueEvents(bool enqueueOnly); static QPID_CLIENT_EXTERN const std::string strMaxCountKey; -- cgit v1.2.1 From 0f7c02dae11afed532bf60302cf2185f422fd23c Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Fri, 2 Oct 2009 17:45:58 +0000 Subject: QMF Fixes: - In ruby: waitForStable => wait_for_stable - Setting an unknown attribute on connection settings now throws an exception - Added connected? accessor to Connection git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@821109 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/engine/ConnectionSettings.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qmf/engine/ConnectionSettings.h b/qpid/cpp/include/qmf/engine/ConnectionSettings.h index 33f7c85a94..36312400b1 100644 --- a/qpid/cpp/include/qmf/engine/ConnectionSettings.h +++ b/qpid/cpp/include/qmf/engine/ConnectionSettings.h @@ -79,8 +79,10 @@ namespace engine { * * @param value Reference to a value to be stored as the attribute. The type of the value * is specific to the key. + * + * @return True if success, False if invalid attribute */ - QMFE_EXTERN void setAttr(const char* key, const Value& value); + QMFE_EXTERN bool setAttr(const char* key, const Value& value); /** * Get the value of an attribute. -- cgit v1.2.1 From 2df0b393db42d098f590f6b00fb96b0c15b1f6f9 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Fri, 2 Oct 2009 21:43:22 +0000 Subject: QMF Fixes in Ruby Console: - AgentProxy object now has broker_bank and agent_bank accessors - Fixed a bug in the returning og reference values (ObjectId) - Added package_name accessor to SchemaObjectClass - Added accessors for agent/broker bank to ObjectId git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@821181 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/engine/Console.h | 2 ++ qpid/cpp/include/qmf/engine/ObjectId.h | 4 ++++ 2 files changed, 6 insertions(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qmf/engine/Console.h b/qpid/cpp/include/qmf/engine/Console.h index f53f351760..ce72360da7 100644 --- a/qpid/cpp/include/qmf/engine/Console.h +++ b/qpid/cpp/include/qmf/engine/Console.h @@ -136,6 +136,8 @@ namespace engine { public: ~AgentProxy(); const char* getLabel() const; + uint32_t getBrokerBank() const; + uint32_t getAgentBank() const; private: friend struct StaticContext; diff --git a/qpid/cpp/include/qmf/engine/ObjectId.h b/qpid/cpp/include/qmf/engine/ObjectId.h index b71473a799..2055972c00 100644 --- a/qpid/cpp/include/qmf/engine/ObjectId.h +++ b/qpid/cpp/include/qmf/engine/ObjectId.h @@ -39,6 +39,10 @@ namespace engine { uint32_t getObjectNumLo() const; bool isDurable() const; const char* str() const; + uint8_t getFlags() const; + uint16_t getSequence() const; + uint32_t getBrokerBank() const; + uint32_t getAgentBank() const; bool operator==(const ObjectId& other) const; bool operator<(const ObjectId& other) const; -- cgit v1.2.1 From ad5d4d17121fbef1805a248699ef0d412436a299 Mon Sep 17 00:00:00 2001 From: "Stephen D. Huston" Date: Wed, 7 Oct 2009 23:38:06 +0000 Subject: Pick up size_t def from Windows rather than making one up and possibly clashing with other packages. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@822963 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/sys/windows/IntegerTypes.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/sys/windows/IntegerTypes.h b/qpid/cpp/include/qpid/sys/windows/IntegerTypes.h index 47b1d16a76..7b2c57ad8e 100755 --- a/qpid/cpp/include/qpid/sys/windows/IntegerTypes.h +++ b/qpid/cpp/include/qpid/sys/windows/IntegerTypes.h @@ -21,6 +21,8 @@ * */ +#include /* Windows system types */ + typedef unsigned char uint8_t; typedef char int8_t; typedef unsigned short uint16_t; @@ -32,7 +34,7 @@ typedef __int64 int64_t; // Visual Studio doesn't define other common types, so set them up here too. typedef int pid_t; -typedef int ssize_t; +typedef SSIZE_T ssize_t; typedef unsigned int uint; #endif /*!QPID_SYS_WINDOWS_INTEGERTYPES_H*/ -- cgit v1.2.1 From 38af3e10a6467dd741ad9187af7d16a7f1af53b4 Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Fri, 9 Oct 2009 03:38:09 +0000 Subject: Split responsibility for name lookup in AsynchConnector::connect into new SocketAddress class. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@823390 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/sys/posix/PrivatePosix.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/sys/posix/PrivatePosix.h b/qpid/cpp/include/qpid/sys/posix/PrivatePosix.h index 6ffd3d8383..79cb950275 100644 --- a/qpid/cpp/include/qpid/sys/posix/PrivatePosix.h +++ b/qpid/cpp/include/qpid/sys/posix/PrivatePosix.h @@ -27,6 +27,7 @@ struct timespec; struct timeval; +struct addrinfo; namespace qpid { namespace sys { @@ -36,6 +37,10 @@ struct timespec& toTimespec(struct timespec& ts, const Duration& t); struct timeval& toTimeval(struct timeval& tv, const Duration& t); Duration toTime(const struct timespec& ts); +// Private SocketAddress details +class SocketAddress; +const struct addrinfo& getAddrInfo(const SocketAddress&); + // Private fd related implementation details class IOHandlePrivate { public: -- cgit v1.2.1 From 9cd8ed4d2748595520e2287f37ba1c9c846dddd2 Mon Sep 17 00:00:00 2001 From: "Stephen D. Huston" Date: Tue, 20 Oct 2009 17:10:05 +0000 Subject: Carry over recent AsynchIO-level changes to Windows. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@827735 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/sys/IOHandle.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/sys/IOHandle.h b/qpid/cpp/include/qpid/sys/IOHandle.h index 283e021162..68e9d92a04 100644 --- a/qpid/cpp/include/qpid/sys/IOHandle.h +++ b/qpid/cpp/include/qpid/sys/IOHandle.h @@ -35,6 +35,8 @@ namespace sys { class AsynchAcceptorPrivate; class AsynchAcceptResult; namespace windows { + class AsynchAcceptor; + class AsynchAcceptResult; class AsynchIO; } @@ -43,8 +45,8 @@ class PollerHandle; class IOHandlePrivate; class IOHandle { - friend class AsynchAcceptorPrivate; - friend class AsynchAcceptResult; + friend class windows::AsynchAcceptResult; + friend class windows::AsynchAcceptor; friend class windows::AsynchIO; friend class PollerHandle; @@ -52,7 +54,7 @@ class IOHandle { protected: IOHandlePrivate* const impl; - IOHandle(IOHandlePrivate*); + IOHandle(IOHandlePrivate*); QPID_COMMON_EXTERN virtual ~IOHandle(); }; -- cgit v1.2.1 From bc24dd44e6eb170a428d419087a4d528cb11558c Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Wed, 21 Oct 2009 21:53:53 +0000 Subject: Tidied up dependencies in IOHandle so that it is no longer dependent on the windows implementation classes. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@828230 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/sys/IOHandle.h | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/sys/IOHandle.h b/qpid/cpp/include/qpid/sys/IOHandle.h index 68e9d92a04..45fc8c240a 100644 --- a/qpid/cpp/include/qpid/sys/IOHandle.h +++ b/qpid/cpp/include/qpid/sys/IOHandle.h @@ -31,25 +31,11 @@ namespace sys { * This is a class intended to abstract the Unix concept of file descriptor * or the Windows concept of HANDLE */ -// Windows-related classes -class AsynchAcceptorPrivate; -class AsynchAcceptResult; -namespace windows { - class AsynchAcceptor; - class AsynchAcceptResult; - class AsynchIO; -} - -// General classes class PollerHandle; class IOHandlePrivate; class IOHandle { - - friend class windows::AsynchAcceptResult; - friend class windows::AsynchAcceptor; - friend class windows::AsynchIO; - friend class PollerHandle; + friend class IOHandlePrivate; protected: IOHandlePrivate* const impl; -- cgit v1.2.1 From 98b1f8a8787b6b0f6b5f269a1b62364abf7b7068 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Thu, 22 Oct 2009 13:51:14 +0000 Subject: Added operators for present/not-present in the object (i.e. for optional properties). git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@828694 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/engine/Query.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qmf/engine/Query.h b/qpid/cpp/include/qmf/engine/Query.h index 1b11ea83f2..3ed08c5d8e 100644 --- a/qpid/cpp/include/qmf/engine/Query.h +++ b/qpid/cpp/include/qmf/engine/Query.h @@ -40,7 +40,9 @@ namespace engine { O_GT = 5, O_GE = 6, O_RE_MATCH = 7, - O_RE_NOMATCH = 8 + O_RE_NOMATCH = 8, + O_PRESENT = 9, + O_NOT_PRESENT = 10 }; struct QueryOperand { -- cgit v1.2.1 From 0207a7cd0c71cec7f488c8c326ce05825073a57a Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Fri, 23 Oct 2009 18:31:10 +0000 Subject: Removed references to broker and agent bank from API, replaced with the more generic (and forward compatible) "key". In the Ruby binding, ensured that ruby objects reference their own copies of the wrapped c++ objects to protect from problems when the c++ objects are deleted out from under the wrappers. Added agent discriminator to the console::objects method. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@829167 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/engine/Console.h | 1 + 1 file changed, 1 insertion(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qmf/engine/Console.h b/qpid/cpp/include/qmf/engine/Console.h index ce72360da7..8463023468 100644 --- a/qpid/cpp/include/qmf/engine/Console.h +++ b/qpid/cpp/include/qmf/engine/Console.h @@ -134,6 +134,7 @@ namespace engine { */ class AgentProxy { public: + AgentProxy(const AgentProxy& from); ~AgentProxy(); const char* getLabel() const; uint32_t getBrokerBank() const; -- cgit v1.2.1 From 2a9e3ffb12f3b621a2d8d3b4c84627cc0613b9cc Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Mon, 26 Oct 2009 20:11:08 +0000 Subject: Separate FailoverListener from client::Connection. client::ConnectionImpl used to contain a FailoverListener to subscribe for updates on the amq.failover exchange. This caused some lifecycle issues including memory leaks. Now FailoverListener is a public API class that the user must create associated with a session to get known-broker updates. Removed the weak_ptr logic in client::SessionImpl which was only required because of FailoverListener. Made SessionImpl::close() idempotent. Gets rid of spurious warning messages in some tests. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@829931 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/client/Connection.h | 6 +- qpid/cpp/include/qpid/client/FailoverListener.h | 81 +++++++++++++++++++++++++ qpid/cpp/include/qpid/client/FailoverManager.h | 8 ++- 3 files changed, 91 insertions(+), 4 deletions(-) create mode 100644 qpid/cpp/include/qpid/client/FailoverListener.h (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/client/Connection.h b/qpid/cpp/include/qpid/client/Connection.h index 0f5999cdcc..bcf2962557 100644 --- a/qpid/cpp/include/qpid/client/Connection.h +++ b/qpid/cpp/include/qpid/client/Connection.h @@ -200,7 +200,11 @@ class Connection QPID_CLIENT_EXTERN bool isOpen() const; - QPID_CLIENT_EXTERN std::vector getKnownBrokers(); + /** In a cluster, returns the initial set of known broker URLs + * at the time of connection. + */ + QPID_CLIENT_EXTERN std::vector getInitialBrokers(); + QPID_CLIENT_EXTERN void registerFailureCallback ( boost::function fn ); /** diff --git a/qpid/cpp/include/qpid/client/FailoverListener.h b/qpid/cpp/include/qpid/client/FailoverListener.h new file mode 100644 index 0000000000..8414b80f2b --- /dev/null +++ b/qpid/cpp/include/qpid/client/FailoverListener.h @@ -0,0 +1,81 @@ +#ifndef QPID_CLIENT_FAILOVERLISTENER_H +#define QPID_CLIENT_FAILOVERLISTENER_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/client/ClientImportExport.h" +#include "qpid/client/MessageListener.h" +#include "qpid/client/Connection.h" +#include "qpid/client/Session.h" +#include "qpid/client/SubscriptionManager.h" +#include "qpid/Url.h" +#include "qpid/sys/Mutex.h" +#include "qpid/sys/Runnable.h" +#include "qpid/sys/Thread.h" +#include + +namespace qpid { +namespace client { + + +/** + * Listen for updates from the amq.failover exchange. + * + * In a cluster, the amq.failover exchange provides updates whenever + * the cluster membership changes. This class subscribes to the + * failover exchange and providees the latest list of known brokers. + * + * You can also subscribe to amq.failover yourself and use + * FailoverListener::decode to extract a list of broker URLs from a + * failover exchange message. + */ +class FailoverListener : private MessageListener, private qpid::sys::Runnable +{ + public: + /** The name of the standard failover exchange amq.failover */ + static QPID_CLIENT_EXTERN const std::string AMQ_FAILOVER; + + /** Extract the broker list from a failover exchange message */ + static QPID_CLIENT_EXTERN std::vector getKnownBrokers(const Message& m); + + /** Subscribe to amq.failover exchange. */ + QPID_CLIENT_EXTERN FailoverListener(Connection); + + QPID_CLIENT_EXTERN ~FailoverListener(); + + /** Returns the latest list of known broker URLs. */ + QPID_CLIENT_EXTERN std::vector getKnownBrokers() const; + + private: + void received(Message& msg); + void run(); + + mutable sys::Mutex lock; + Connection connection; + Session session; + SubscriptionManager subscriptions; + sys::Thread thread; + std::vector knownBrokers; +}; +}} // namespace qpid::client + +#endif /*!QPID_CLIENT_FAILOVERLISTENER_H*/ diff --git a/qpid/cpp/include/qpid/client/FailoverManager.h b/qpid/cpp/include/qpid/client/FailoverManager.h index d50fcff8bb..0d30e2ed60 100644 --- a/qpid/cpp/include/qpid/client/FailoverManager.h +++ b/qpid/cpp/include/qpid/client/FailoverManager.h @@ -22,12 +22,13 @@ * */ -#include "qpid/client/Connection.h" -#include "qpid/client/ConnectionSettings.h" #include "qpid/Exception.h" #include "qpid/client/AsyncSession.h" -#include "qpid/sys/Monitor.h" #include "qpid/client/ClientImportExport.h" +#include "qpid/client/Connection.h" +#include "qpid/client/ConnectionSettings.h" +#include "qpid/client/FailoverListener.h" +#include "qpid/sys/Monitor.h" #include namespace qpid { @@ -123,6 +124,7 @@ class FailoverManager qpid::sys::Monitor lock; Connection connection; + std::auto_ptr failoverListener; ConnectionSettings settings; ReconnectionStrategy* strategy; State state; -- cgit v1.2.1 From 6c99eda3cdf6a6a068baf8302e23a396f5d6153e Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Thu, 29 Oct 2009 11:12:32 +0000 Subject: Added extra info to doxygen comments regarding use of SubscriptionManager::get(). git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@830896 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/client/SubscriptionManager.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/client/SubscriptionManager.h b/qpid/cpp/include/qpid/client/SubscriptionManager.h index 632efe0f70..e70e05f73a 100644 --- a/qpid/cpp/include/qpid/client/SubscriptionManager.h +++ b/qpid/cpp/include/qpid/client/SubscriptionManager.h @@ -164,6 +164,9 @@ class SubscriptionManager : public sys::Runnable, public Handle Date: Fri, 30 Oct 2009 22:50:51 +0000 Subject: Correct the macro used to detect DLL building to match the new target name changed in CMakeLists.txt a while back. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@831482 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/engine/QmfEngineImportExport.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qmf/engine/QmfEngineImportExport.h b/qpid/cpp/include/qmf/engine/QmfEngineImportExport.h index 70164c749f..373617e046 100644 --- a/qpid/cpp/include/qmf/engine/QmfEngineImportExport.h +++ b/qpid/cpp/include/qmf/engine/QmfEngineImportExport.h @@ -21,7 +21,7 @@ */ #if defined(WIN32) && !defined(QPID_DECLARE_STATIC) -# if defined(QMF_EXPORT) || defined (qmfcommon_EXPORTS) +# if defined(QMF_EXPORT) || defined (qmfengine_EXPORTS) # define QMFE_EXTERN __declspec(dllexport) # else # define QMFE_EXTERN __declspec(dllimport) -- cgit v1.2.1 From 2f97b506e14dc6935a37e9356d4f57563518fe83 Mon Sep 17 00:00:00 2001 From: "Stephen D. Huston" Date: Fri, 30 Oct 2009 22:51:17 +0000 Subject: Refer to struct/class consistently across files. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@831483 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/engine/Console.h | 6 +++--- qpid/cpp/include/qmf/engine/Schema.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qmf/engine/Console.h b/qpid/cpp/include/qmf/engine/Console.h index 8463023468..03b3993395 100644 --- a/qpid/cpp/include/qmf/engine/Console.h +++ b/qpid/cpp/include/qmf/engine/Console.h @@ -33,7 +33,7 @@ namespace qmf { namespace engine { class Console; - struct ConsoleImpl; + class ConsoleImpl; class BrokerProxyImpl; class AgentProxy; struct AgentProxyImpl; @@ -54,7 +54,7 @@ namespace engine { private: friend struct MethodResponseImpl; - friend struct ConsoleImpl; + friend class ConsoleImpl; MethodResponse(MethodResponseImpl* impl); MethodResponseImpl* impl; }; @@ -173,7 +173,7 @@ namespace engine { void sendQuery(const Query& query, void* context, const AgentProxy* agent = 0); private: - friend struct ConsoleImpl; + friend class ConsoleImpl; friend struct StaticContext; BrokerProxyImpl* impl; }; diff --git a/qpid/cpp/include/qmf/engine/Schema.h b/qpid/cpp/include/qmf/engine/Schema.h index 16f11a83f9..9f5b444558 100644 --- a/qpid/cpp/include/qmf/engine/Schema.h +++ b/qpid/cpp/include/qmf/engine/Schema.h @@ -150,7 +150,7 @@ namespace engine { private: friend struct SchemaClassKeyImpl; friend class BrokerProxyImpl; - friend struct ConsoleImpl; + friend class ConsoleImpl; SchemaClassKey(SchemaClassKeyImpl* impl); SchemaClassKeyImpl* impl; }; -- cgit v1.2.1 From bc2e9c9883b2aa322c0724e176af89bee7625983 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Wed, 11 Nov 2009 13:15:44 +0000 Subject: Added support for address parsing, create/assert/delete policies git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@834869 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Address.h | 62 +++++++++++++++++++++++++------ qpid/cpp/include/qpid/messaging/Filter.h | 48 ------------------------ qpid/cpp/include/qpid/messaging/Message.h | 2 +- qpid/cpp/include/qpid/messaging/Session.h | 16 +++----- qpid/cpp/include/qpid/messaging/Variant.h | 4 +- 5 files changed, 58 insertions(+), 74 deletions(-) delete mode 100644 qpid/cpp/include/qpid/messaging/Filter.h (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Address.h b/qpid/cpp/include/qpid/messaging/Address.h index e66c52f4c2..f232af5d56 100644 --- a/qpid/cpp/include/qpid/messaging/Address.h +++ b/qpid/cpp/include/qpid/messaging/Address.h @@ -22,33 +22,71 @@ * */ #include +#include "qpid/Exception.h" +#include "qpid/messaging/Variant.h" #include "qpid/client/ClientImportExport.h" #include namespace qpid { -namespace client { -} - namespace messaging { +struct InvalidAddress : public qpid::Exception +{ + InvalidAddress(const std::string& msg); +}; + +struct MalformedAddress : public qpid::Exception +{ + MalformedAddress(const std::string& msg); +}; + +class AddressImpl; + /** * Represents an address to which messages can be sent and from which * messages can be received. Often a simple name is sufficient for - * this. However this struct allows the type of address to be - * specified allowing more sophisticated treatment if necessary. + * this, however this can be augmented with a subject pattern and + * options. + * + * All parts of an address can be specified in a string of the + * following form: + * + *
[ / ] [ { : , ... } ] + * + * Here the
is a simple name for the addressed entity and + * is a subject or subject pattern for messages sent to or + * received from this address. The options are specified as a series + * of key value pairs enclosed in curly brackets (denoting a map). */ -struct Address +class Address { - std::string value; - std::string type; - + public: QPID_CLIENT_EXTERN Address(); QPID_CLIENT_EXTERN Address(const std::string& address); - QPID_CLIENT_EXTERN Address(const std::string& address, const std::string& type); - QPID_CLIENT_EXTERN operator const std::string&() const; - QPID_CLIENT_EXTERN const std::string& toStr() const; + QPID_CLIENT_EXTERN Address(const std::string& name, const std::string& subject, + const Variant::Map& options, const std::string& type = ""); + QPID_CLIENT_EXTERN Address(const Address& address); + QPID_CLIENT_EXTERN ~Address(); + Address& operator=(const Address&); + QPID_CLIENT_EXTERN const std::string& getName() const; + QPID_CLIENT_EXTERN void setName(const std::string&); + QPID_CLIENT_EXTERN const std::string& getSubject() const; + QPID_CLIENT_EXTERN void setSubject(const std::string&); + QPID_CLIENT_EXTERN bool hasSubject() const; + QPID_CLIENT_EXTERN const Variant::Map& getOptions() const; + QPID_CLIENT_EXTERN Variant::Map& getOptions(); + QPID_CLIENT_EXTERN void setOptions(const Variant::Map&); + + QPID_CLIENT_EXTERN std::string getType() const; + QPID_CLIENT_EXTERN void setType(const std::string&); + + QPID_CLIENT_EXTERN const Variant& getOption(const std::string& key) const; + + QPID_CLIENT_EXTERN std::string toStr() const; QPID_CLIENT_EXTERN operator bool() const; QPID_CLIENT_EXTERN bool operator !() const; + private: + AddressImpl* impl; }; QPID_CLIENT_EXTERN std::ostream& operator<<(std::ostream& out, const Address& address); diff --git a/qpid/cpp/include/qpid/messaging/Filter.h b/qpid/cpp/include/qpid/messaging/Filter.h deleted file mode 100644 index 5cd844cf73..0000000000 --- a/qpid/cpp/include/qpid/messaging/Filter.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef QPID_MESSAGING_FILTER_H -#define QPID_MESSAGING_FILTER_H - -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -#include -#include -#include "qpid/client/ClientImportExport.h" - -namespace qpid { -namespace client { -} - -namespace messaging { - -struct Filter -{ - std::string type; - std::vector patterns; - - QPID_CLIENT_EXTERN Filter(std::string type, std::string pattern); - QPID_CLIENT_EXTERN Filter(std::string type, std::string pattern1, std::string pattern2); - - static QPID_CLIENT_EXTERN const std::string WILDCARD; - static QPID_CLIENT_EXTERN const std::string EXACT_MATCH; -}; - -}} // namespace qpid::messaging - -#endif /*!QPID_MESSAGING_FILTER_H*/ diff --git a/qpid/cpp/include/qpid/messaging/Message.h b/qpid/cpp/include/qpid/messaging/Message.h index 4477d5a2e9..1acccecad0 100644 --- a/qpid/cpp/include/qpid/messaging/Message.h +++ b/qpid/cpp/include/qpid/messaging/Message.h @@ -32,7 +32,7 @@ namespace client { namespace messaging { -struct Address; +class Address; class Codec; struct MessageImpl; diff --git a/qpid/cpp/include/qpid/messaging/Session.h b/qpid/cpp/include/qpid/messaging/Session.h index 979e27adae..4e3f950ef3 100644 --- a/qpid/cpp/include/qpid/messaging/Session.h +++ b/qpid/cpp/include/qpid/messaging/Session.h @@ -24,7 +24,7 @@ #include "qpid/client/ClientImportExport.h" #include "qpid/client/Handle.h" #include "qpid/sys/Time.h" -#include "Variant.h" +#include namespace qpid { namespace client { @@ -35,8 +35,7 @@ template class PrivateImplRef; namespace messaging { -struct Address; -struct Filter; +class Address; class Message; class MessageListener; class Sender; @@ -90,13 +89,10 @@ class Session : public qpid::client::Handle QPID_CLIENT_EXTERN Message fetch(qpid::sys::Duration timeout=qpid::sys::TIME_INFINITE); QPID_CLIENT_EXTERN bool dispatch(qpid::sys::Duration timeout=qpid::sys::TIME_INFINITE); - QPID_CLIENT_EXTERN Sender createSender(const Address& address, const VariantMap& options = VariantMap()); - QPID_CLIENT_EXTERN Sender createSender(const std::string& address, const VariantMap& options = VariantMap()); - - QPID_CLIENT_EXTERN Receiver createReceiver(const Address& address, const VariantMap& options = VariantMap()); - QPID_CLIENT_EXTERN Receiver createReceiver(const Address& address, const Filter& filter, const VariantMap& options = VariantMap()); - QPID_CLIENT_EXTERN Receiver createReceiver(const std::string& address, const VariantMap& options = VariantMap()); - QPID_CLIENT_EXTERN Receiver createReceiver(const std::string& address, const Filter& filter, const VariantMap& options = VariantMap()); + QPID_CLIENT_EXTERN Sender createSender(const Address& address); + QPID_CLIENT_EXTERN Sender createSender(const std::string& address); + QPID_CLIENT_EXTERN Receiver createReceiver(const Address& address); + QPID_CLIENT_EXTERN Receiver createReceiver(const std::string& address); QPID_CLIENT_EXTERN Address createTempQueue(const std::string& baseName = std::string()); private: diff --git a/qpid/cpp/include/qpid/messaging/Variant.h b/qpid/cpp/include/qpid/messaging/Variant.h index 1e51914794..c63138178b 100644 --- a/qpid/cpp/include/qpid/messaging/Variant.h +++ b/qpid/cpp/include/qpid/messaging/Variant.h @@ -30,9 +30,6 @@ #include "qpid/client/ClientImportExport.h" namespace qpid { -namespace client { -} - namespace messaging { /** @@ -93,6 +90,7 @@ class Variant QPID_CLIENT_EXTERN ~Variant(); QPID_CLIENT_EXTERN VariantType getType() const; + QPID_CLIENT_EXTERN bool isVoid() const; QPID_CLIENT_EXTERN Variant& operator=(bool); QPID_CLIENT_EXTERN Variant& operator=(uint8_t); -- cgit v1.2.1 From 2eeb406c9c51eafb16e95e9d0be19baed2ded40a Mon Sep 17 00:00:00 2001 From: "Stephen D. Huston" Date: Wed, 11 Nov 2009 21:28:27 +0000 Subject: Add missing extern decls. Fixes broken Windows build. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@835078 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/framing/FieldValue.h | 2 +- qpid/cpp/include/qpid/messaging/Address.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/framing/FieldValue.h b/qpid/cpp/include/qpid/framing/FieldValue.h index ce4d06d2c8..60a887761f 100644 --- a/qpid/cpp/include/qpid/framing/FieldValue.h +++ b/qpid/cpp/include/qpid/framing/FieldValue.h @@ -92,7 +92,7 @@ class FieldValue { QPID_COMMON_EXTERN bool operator==(const FieldValue&) const; QPID_COMMON_EXTERN bool operator!=(const FieldValue& v) const { return !(*this == v); } - void print(std::ostream& out) const; + QPID_COMMON_EXTERN void print(std::ostream& out) const; template bool convertsTo() const { return false; } template T get() const { throw InvalidConversionException(); } diff --git a/qpid/cpp/include/qpid/messaging/Address.h b/qpid/cpp/include/qpid/messaging/Address.h index f232af5d56..f255de14f0 100644 --- a/qpid/cpp/include/qpid/messaging/Address.h +++ b/qpid/cpp/include/qpid/messaging/Address.h @@ -67,7 +67,7 @@ class Address const Variant::Map& options, const std::string& type = ""); QPID_CLIENT_EXTERN Address(const Address& address); QPID_CLIENT_EXTERN ~Address(); - Address& operator=(const Address&); + QPID_CLIENT_EXTERN Address& operator=(const Address&); QPID_CLIENT_EXTERN const std::string& getName() const; QPID_CLIENT_EXTERN void setName(const std::string&); QPID_CLIENT_EXTERN const std::string& getSubject() const; -- cgit v1.2.1 From 42b9543988f073f22f5d6ecef54f53e8035c316e Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Thu, 12 Nov 2009 10:30:53 +0000 Subject: Merge branch 'next_receiver_changes' into trunk git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@835323 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Session.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Session.h b/qpid/cpp/include/qpid/messaging/Session.h index 4e3f950ef3..d77ddf3e43 100644 --- a/qpid/cpp/include/qpid/messaging/Session.h +++ b/qpid/cpp/include/qpid/messaging/Session.h @@ -88,13 +88,14 @@ class Session : public qpid::client::Handle QPID_CLIENT_EXTERN bool fetch(Message& message, qpid::sys::Duration timeout=qpid::sys::TIME_INFINITE); QPID_CLIENT_EXTERN Message fetch(qpid::sys::Duration timeout=qpid::sys::TIME_INFINITE); QPID_CLIENT_EXTERN bool dispatch(qpid::sys::Duration timeout=qpid::sys::TIME_INFINITE); + QPID_CLIENT_EXTERN bool nextReceiver(Receiver&, qpid::sys::Duration timeout=qpid::sys::TIME_INFINITE); + QPID_CLIENT_EXTERN Receiver nextReceiver(qpid::sys::Duration timeout=qpid::sys::TIME_INFINITE); + QPID_CLIENT_EXTERN Sender createSender(const Address& address); QPID_CLIENT_EXTERN Sender createSender(const std::string& address); QPID_CLIENT_EXTERN Receiver createReceiver(const Address& address); QPID_CLIENT_EXTERN Receiver createReceiver(const std::string& address); - - QPID_CLIENT_EXTERN Address createTempQueue(const std::string& baseName = std::string()); private: friend class qpid::client::PrivateImplRef; }; -- cgit v1.2.1 From 47037a72d8f799e64cf57efbf01f6a2e519256a7 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Mon, 16 Nov 2009 11:58:45 +0000 Subject: Merge branch 'next_receiver_changes' into trunk git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@880718 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/MessageListener.h | 49 ----------------------- qpid/cpp/include/qpid/messaging/Receiver.h | 8 ---- qpid/cpp/include/qpid/messaging/Session.h | 20 +++++++-- 3 files changed, 16 insertions(+), 61 deletions(-) delete mode 100644 qpid/cpp/include/qpid/messaging/MessageListener.h (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/MessageListener.h b/qpid/cpp/include/qpid/messaging/MessageListener.h deleted file mode 100644 index 72811e7b9c..0000000000 --- a/qpid/cpp/include/qpid/messaging/MessageListener.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef QPID_MESSAGING_MESSAGELISTENER_H -#define QPID_MESSAGING_MESSAGELISTENER_H - -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -#include "qpid/client/ClientImportExport.h" - -namespace qpid { -namespace messaging { - -class Message; - -/** - * To use a push style interface for receiving messages, applications - * provide implementations of this interface and pass an implementing - * instance to MessageSource::subscribe(). - * - * Messages arriving for that subscription will then be passed to the - * implementation via the received() method. - */ -class MessageListener -{ - public: - QPID_CLIENT_EXTERN virtual ~MessageListener() {} - virtual void received(Message&) = 0; - private: -}; - -}} // namespace qpid::messaging - -#endif /*!QPID_MESSAGING_MESSAGELISTENER_H*/ diff --git a/qpid/cpp/include/qpid/messaging/Receiver.h b/qpid/cpp/include/qpid/messaging/Receiver.h index a4fdd7a34b..1d72e5fc49 100644 --- a/qpid/cpp/include/qpid/messaging/Receiver.h +++ b/qpid/cpp/include/qpid/messaging/Receiver.h @@ -36,7 +36,6 @@ template class PrivateImplRef; namespace messaging { class Message; -class MessageListener; class ReceiverImpl; /** @@ -121,13 +120,6 @@ class Receiver : public qpid::client::Handle * Cancels this receiver. */ QPID_CLIENT_EXTERN void cancel(); - - /** - * Set a message listener for this receiver. - * - * @see Session::dispatch() - */ - QPID_CLIENT_EXTERN void setListener(MessageListener* listener); private: friend class qpid::client::PrivateImplRef; }; diff --git a/qpid/cpp/include/qpid/messaging/Session.h b/qpid/cpp/include/qpid/messaging/Session.h index d77ddf3e43..4b23d355ec 100644 --- a/qpid/cpp/include/qpid/messaging/Session.h +++ b/qpid/cpp/include/qpid/messaging/Session.h @@ -45,7 +45,7 @@ class Subscription; /** * A session represents a distinct 'conversation' which can involve - * sending and receiving messages from different sources and sinks. + * sending and receiving messages to and from different addresses. */ class Session : public qpid::client::Handle { @@ -85,10 +85,22 @@ class Session : public qpid::client::Handle * has not yet been confirmed as processed by the server. */ QPID_CLIENT_EXTERN uint32_t pendingAck(); - QPID_CLIENT_EXTERN bool fetch(Message& message, qpid::sys::Duration timeout=qpid::sys::TIME_INFINITE); - QPID_CLIENT_EXTERN Message fetch(qpid::sys::Duration timeout=qpid::sys::TIME_INFINITE); - QPID_CLIENT_EXTERN bool dispatch(qpid::sys::Duration timeout=qpid::sys::TIME_INFINITE); + /** + * Retrieves the receiver for the next available message. If there + * are no available messages at present the call will block for up + * to the specified timeout waiting for one to arrive. Returns + * true if a message was available at the point of return, in + * which case the passed in receiver reference will be set to the + * receiver for that message or fals if no message was available. + */ QPID_CLIENT_EXTERN bool nextReceiver(Receiver&, qpid::sys::Duration timeout=qpid::sys::TIME_INFINITE); + /** + * Returns the receiver for the next available message. If there + * are no available messages at present the call will block for up + * to the specified timeout waiting for one to arrive. Will throw + * Receiver::NoMessageAvailable if no message became available in + * time. + */ QPID_CLIENT_EXTERN Receiver nextReceiver(qpid::sys::Duration timeout=qpid::sys::TIME_INFINITE); -- cgit v1.2.1 From 654bc85e36ae0e890773aa2c7a36aa91b15967fa Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Mon, 16 Nov 2009 15:57:43 +0000 Subject: QPID-664: Introduce ';' as delimiter bewteen name (and optionally subject) and the options map in address syntax. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@880819 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Address.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Address.h b/qpid/cpp/include/qpid/messaging/Address.h index f255de14f0..eaf5a02782 100644 --- a/qpid/cpp/include/qpid/messaging/Address.h +++ b/qpid/cpp/include/qpid/messaging/Address.h @@ -51,7 +51,7 @@ class AddressImpl; * All parts of an address can be specified in a string of the * following form: * - *
[ / ] [ { : , ... } ] + *
[ / ] ; [ { : , ... } ] * * Here the
is a simple name for the addressed entity and * is a subject or subject pattern for messages sent to or -- cgit v1.2.1 From 0303f6a08256c26f4d9701803b17ba810d395eeb Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Mon, 16 Nov 2009 17:30:23 +0000 Subject: QPID-664: Remove start()/stop() methods from api git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@880863 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Receiver.h | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Receiver.h b/qpid/cpp/include/qpid/messaging/Receiver.h index 1d72e5fc49..659a583547 100644 --- a/qpid/cpp/include/qpid/messaging/Receiver.h +++ b/qpid/cpp/include/qpid/messaging/Receiver.h @@ -80,16 +80,6 @@ class Receiver : public qpid::client::Handle * serving before throwing an exception. */ QPID_CLIENT_EXTERN Message fetch(qpid::sys::Duration timeout=qpid::sys::TIME_INFINITE); - - /** - * Enables the message flow for this receiver - */ - QPID_CLIENT_EXTERN void start(); - /** - * Stops the message flow for this receiver (but does not cancel - * the subscription). - */ - QPID_CLIENT_EXTERN void stop(); /** * Sets the capacity for the receiver. The capacity determines how * many incoming messages can be held in the receiver before being -- cgit v1.2.1 From 90dac069f01e048a2eebc93d3547307ac98f0cd0 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Tue, 17 Nov 2009 10:52:33 +0000 Subject: QPID-664: Added getReceiver()/getSender() methods to session in new api. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@881236 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Receiver.h | 6 ++++++ qpid/cpp/include/qpid/messaging/Sender.h | 5 +++++ qpid/cpp/include/qpid/messaging/Session.h | 27 ++++++++++++++++++++++++++- 3 files changed, 37 insertions(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Receiver.h b/qpid/cpp/include/qpid/messaging/Receiver.h index 659a583547..2dc62b1598 100644 --- a/qpid/cpp/include/qpid/messaging/Receiver.h +++ b/qpid/cpp/include/qpid/messaging/Receiver.h @@ -110,6 +110,12 @@ class Receiver : public qpid::client::Handle * Cancels this receiver. */ QPID_CLIENT_EXTERN void cancel(); + + /** + * Returns the name of this receiver. + */ + QPID_CLIENT_EXTERN const std::string& getName() const; + private: friend class qpid::client::PrivateImplRef; }; diff --git a/qpid/cpp/include/qpid/messaging/Sender.h b/qpid/cpp/include/qpid/messaging/Sender.h index 9b83a04d60..29af3810f4 100644 --- a/qpid/cpp/include/qpid/messaging/Sender.h +++ b/qpid/cpp/include/qpid/messaging/Sender.h @@ -24,6 +24,7 @@ #include "qpid/client/ClientImportExport.h" #include "qpid/client/Handle.h" #include "qpid/sys/IntegerTypes.h" +#include namespace qpid { namespace client { @@ -68,6 +69,10 @@ class Sender : public qpid::client::Handle */ QPID_CLIENT_EXTERN uint32_t pending(); + /** + * Returns the name of this sender. + */ + QPID_CLIENT_EXTERN const std::string& getName() const; private: friend class qpid::client::PrivateImplRef; }; diff --git a/qpid/cpp/include/qpid/messaging/Session.h b/qpid/cpp/include/qpid/messaging/Session.h index 4b23d355ec..edb6fa6331 100644 --- a/qpid/cpp/include/qpid/messaging/Session.h +++ b/qpid/cpp/include/qpid/messaging/Session.h @@ -21,6 +21,7 @@ * under the License. * */ +#include "qpid/Exception.h" #include "qpid/client/ClientImportExport.h" #include "qpid/client/Handle.h" #include "qpid/sys/Time.h" @@ -43,6 +44,11 @@ class Receiver; class SessionImpl; class Subscription; +struct KeyError : qpid::Exception +{ + QPID_CLIENT_EXTERN KeyError(const std::string&); +}; + /** * A session represents a distinct 'conversation' which can involve * sending and receiving messages to and from different addresses. @@ -103,11 +109,30 @@ class Session : public qpid::client::Handle */ QPID_CLIENT_EXTERN Receiver nextReceiver(qpid::sys::Duration timeout=qpid::sys::TIME_INFINITE); - + /** + * Create a new sender through which messages can be sent to the + * specified address. + */ QPID_CLIENT_EXTERN Sender createSender(const Address& address); QPID_CLIENT_EXTERN Sender createSender(const std::string& address); + + /** + * Create a new receiver through which messages can be received + * from the specified address. + */ QPID_CLIENT_EXTERN Receiver createReceiver(const Address& address); QPID_CLIENT_EXTERN Receiver createReceiver(const std::string& address); + + /** + * Returns the sender with the specified name or throws KeyError + * if there is none for that name. + */ + QPID_CLIENT_EXTERN Sender getSender(const std::string& name) const; + /** + * Returns the receiver with the specified name or throws KeyError + * if there is none for that name. + */ + QPID_CLIENT_EXTERN Receiver getReceiver(const std::string& name) const; private: friend class qpid::client::PrivateImplRef; }; -- cgit v1.2.1 From 8fafe77990b8c97221d1013bcd119f16356a10bf Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Tue, 17 Nov 2009 17:34:55 +0000 Subject: QPID-664: Allow application to set session name and retrieve session using that name; close all sessions when connection is closed. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@881394 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Connection.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Connection.h b/qpid/cpp/include/qpid/messaging/Connection.h index 19dae586a4..531f046bec 100644 --- a/qpid/cpp/include/qpid/messaging/Connection.h +++ b/qpid/cpp/include/qpid/messaging/Connection.h @@ -48,7 +48,8 @@ class Connection : public qpid::client::Handle QPID_CLIENT_EXTERN ~Connection(); QPID_CLIENT_EXTERN Connection& operator=(const Connection&); QPID_CLIENT_EXTERN void close(); - QPID_CLIENT_EXTERN Session newSession(); + QPID_CLIENT_EXTERN Session newSession(const std::string& name = std::string()); + QPID_CLIENT_EXTERN Session getSession(const std::string& name) const; private: friend class qpid::client::PrivateImplRef; -- cgit v1.2.1 From df29240dd9452a3972ed65693d00d970bd841533 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Tue, 17 Nov 2009 17:35:28 +0000 Subject: QPID-664: Add accessors for connection from session, and for session from sender/receiver. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@881395 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Receiver.h | 6 ++++++ qpid/cpp/include/qpid/messaging/Sender.h | 7 ++++++- qpid/cpp/include/qpid/messaging/Session.h | 7 +++++++ 3 files changed, 19 insertions(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Receiver.h b/qpid/cpp/include/qpid/messaging/Receiver.h index 2dc62b1598..51630b12a2 100644 --- a/qpid/cpp/include/qpid/messaging/Receiver.h +++ b/qpid/cpp/include/qpid/messaging/Receiver.h @@ -37,6 +37,7 @@ namespace messaging { class Message; class ReceiverImpl; +class Session; /** * Interface through which messages are received. @@ -116,6 +117,11 @@ class Receiver : public qpid::client::Handle */ QPID_CLIENT_EXTERN const std::string& getName() const; + /** + * Returns a handle to the session associated with this receiver. + */ + QPID_CLIENT_EXTERN Session getSession() const; + private: friend class qpid::client::PrivateImplRef; }; diff --git a/qpid/cpp/include/qpid/messaging/Sender.h b/qpid/cpp/include/qpid/messaging/Sender.h index 29af3810f4..335e61260c 100644 --- a/qpid/cpp/include/qpid/messaging/Sender.h +++ b/qpid/cpp/include/qpid/messaging/Sender.h @@ -37,7 +37,7 @@ namespace messaging { class Message; class SenderImpl; - +class Session; /** * Interface through which messages are sent. */ @@ -73,6 +73,11 @@ class Sender : public qpid::client::Handle * Returns the name of this sender. */ QPID_CLIENT_EXTERN const std::string& getName() const; + + /** + * Returns a handle to the session associated with this sender. + */ + QPID_CLIENT_EXTERN Session getSession() const; private: friend class qpid::client::PrivateImplRef; }; diff --git a/qpid/cpp/include/qpid/messaging/Session.h b/qpid/cpp/include/qpid/messaging/Session.h index edb6fa6331..46372cb849 100644 --- a/qpid/cpp/include/qpid/messaging/Session.h +++ b/qpid/cpp/include/qpid/messaging/Session.h @@ -37,6 +37,7 @@ template class PrivateImplRef; namespace messaging { class Address; +class Connection; class Message; class MessageListener; class Sender; @@ -133,6 +134,12 @@ class Session : public qpid::client::Handle * if there is none for that name. */ QPID_CLIENT_EXTERN Receiver getReceiver(const std::string& name) const; + /** + * Returns a handle to the connection this session is associated + * with. + */ + QPID_CLIENT_EXTERN Connection getConnection() const; + private: friend class qpid::client::PrivateImplRef; }; -- cgit v1.2.1 From ff530085b008663aca994c99b6e9ae3d90c24bf1 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Thu, 19 Nov 2009 11:46:00 +0000 Subject: QPID-664: Add spout & drain examples as per python client git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@882118 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Message.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Message.h b/qpid/cpp/include/qpid/messaging/Message.h index 1acccecad0..368fc89772 100644 --- a/qpid/cpp/include/qpid/messaging/Message.h +++ b/qpid/cpp/include/qpid/messaging/Message.h @@ -58,8 +58,8 @@ class Message QPID_CLIENT_EXTERN void setContentType(const std::string&); QPID_CLIENT_EXTERN const std::string& getContentType() const; - QPID_CLIENT_EXTERN const VariantMap& getHeaders() const; - QPID_CLIENT_EXTERN VariantMap& getHeaders(); + QPID_CLIENT_EXTERN const Variant::Map& getHeaders() const; + QPID_CLIENT_EXTERN Variant::Map& getHeaders(); QPID_CLIENT_EXTERN const std::string& getContent() const; QPID_CLIENT_EXTERN std::string& getContent(); -- cgit v1.2.1 From a420d41e0c1753a6fae347b3980db4bd11a24cc7 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Thu, 19 Nov 2009 23:07:55 +0000 Subject: QPID-664: Added some documentation for address options; tidied up the handling of queue- and subscribe- arguments git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@882350 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Address.h | 76 +++++++++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 4 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Address.h b/qpid/cpp/include/qpid/messaging/Address.h index eaf5a02782..aa7d366088 100644 --- a/qpid/cpp/include/qpid/messaging/Address.h +++ b/qpid/cpp/include/qpid/messaging/Address.h @@ -51,12 +51,80 @@ class AddressImpl; * All parts of an address can be specified in a string of the * following form: * + *
  * 
[ / ] ; [ { : , ... } ] + *
* - * Here the
is a simple name for the addressed entity and - * is a subject or subject pattern for messages sent to or - * received from this address. The options are specified as a series - * of key value pairs enclosed in curly brackets (denoting a map). + * Here the
is a simple name for the addressed + * entity and
is a subject or subject pattern for + * messages sent to or received from this address. The options are + * specified as a series of key value pairs enclosed in curly brackets + * (denoting a map). Values can be nested maps, or lists (which are + * denoted as a comma separated list of values inside square brackets, + * e.g. [a, b, c]). + * + * The currently supported options are as follows: + * + * create - whether the address should be automatically created or + * not. Can be one of always, never, sender or receiver; the + * properties of the node to be created can be specified via the + * node-properties option. + * + * assert - whether or not to assert any specified node-properties + * match the address. Can be one of always, never, sender or receiver. + * + * delete - whether or not to delete the addressed nide when a sender + * or receiver is cancelled. Can be one of always, never, sender or + * receiver. + * + * node-properties - a nested map of properties of the addressed + * entity or 'node'. These can be used when automatically creating it, + * or to assert certain properties. + * + * The valid node-properties are: + * + * type - queue or topic + * + * durable - true or false + * + * x-properties - a nested map that can contain implementation or + * protocol specifiec extedned properties. For the amqp 0-10 mapping, + * the fields in queue- or exchange- declare can be specified in here; + * anything that is not recognised as one of those will be passed + * through in the arguments field. + * + * For receivers there are some further options of interest: + * + * no-local - (only relevant for topics at present) specifies that the + * receiver does not want to receiver messages published to the topic + * that originate from a sender on the same connection + * + * browse - (only relevant for queues) specifies that the receiver + * does not wish to consume the messages, but merely browse them + * + * durable - (only relevant for topics at present) specifies that a + * durable subscription is required + * + * reliability - indicates the level of reliability that the receiver + * expects. Can be one of unreliable, at-most-once, at-least-once or + * exactly-once (the latter is not yet correctly supported). + * + * filter - (only relevant for topics at present) allows bindings to + * be created for the queue that match the given criteris (or list of + * criteria). + * + * x-properties - allows protocol or implementation specific options + * to be specified for a receiver; this is a nested map and currently + * the implementation only recognises two specific nested properties + * within it (all others are passed through in the arguments of the + * message-subscribe command): + * + * exclusive, which requests an exclusive subscription and + * is only relevant for queues + * + * x-queue-arguments, which ais only relevant for topics and + * allows arguments to the queue-declare for the subscription + * queue to be specified */ class Address { -- cgit v1.2.1 From cdf3554ea35bbac57e09092e81e574b9d0673f22 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Fri, 20 Nov 2009 10:23:56 +0000 Subject: Improved formatting of address documentation. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@882485 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Address.h | 82 ++++++++++++++++++------------- 1 file changed, 47 insertions(+), 35 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Address.h b/qpid/cpp/include/qpid/messaging/Address.h index aa7d366088..538cb6507c 100644 --- a/qpid/cpp/include/qpid/messaging/Address.h +++ b/qpid/cpp/include/qpid/messaging/Address.h @@ -51,12 +51,10 @@ class AddressImpl; * All parts of an address can be specified in a string of the * following form: * - *
- * 
[ / ] ; [ { : , ... } ] - *
+ * <address> [ / <subject> ] ; [ { <key> : <value> , ... } ] * - * Here the
is a simple name for the addressed - * entity and
is a subject or subject pattern for + * Here the <address> is a simple name for the addressed + * entity and <subject> is a subject or subject pattern for * messages sent to or received from this address. The options are * specified as a series of key value pairs enclosed in curly brackets * (denoting a map). Values can be nested maps, or lists (which are @@ -64,67 +62,81 @@ class AddressImpl; * e.g. [a, b, c]). * * The currently supported options are as follows: + * + * * - * create - whether the address should be automatically created or - * not. Can be one of always, never, sender or receiver; the - * properties of the node to be created can be specified via the - * node-properties option. + * * - * assert - whether or not to assert any specified node-properties - * match the address. Can be one of always, never, sender or receiver. + * * - * delete - whether or not to delete the addressed nide when a sender - * or receiver is cancelled. Can be one of always, never, sender or - * receiver. + * * - * node-properties - a nested map of properties of the addressed + * + * + *
createIndicate whether the address should be + * automatically created or not. Can be one of always, + * never, sender or receiver. The properties of + * the node to be created can be specified via the node-properties + * option (see below).
assertIndicate whether or not to assert any specified + * node-properties match the address. Can be one of always, + * never, sender or receiver.
deleteIndicate whether or not to delete the addressed + * nide when a sender or receiver is cancelled. Can be one of always, + * never, sender or receiver.
node-propertiesA nested map of properties of the addressed * entity or 'node'. These can be used when automatically creating it, * or to assert certain properties. * * The valid node-properties are: + *
    + *
  • type - queue or topic
  • * - * type - queue or topic - * - * durable - true or false + *
  • durable - true or false
  • * - * x-properties - a nested map that can contain implementation or + *
  • x-properties - a nested map that can contain implementation or * protocol specifiec extedned properties. For the amqp 0-10 mapping, * the fields in queue- or exchange- declare can be specified in here; * anything that is not recognised as one of those will be passed - * through in the arguments field. + * through in the arguments field.,/li> + *
+ *
* * For receivers there are some further options of interest: * - * no-local - (only relevant for topics at present) specifies that the + * + * + * * - * browse - (only relevant for queues) specifies that the receiver - * does not wish to consume the messages, but merely browse them + * * - * durable - (only relevant for topics at present) specifies that a - * durable subscription is required + * * - * reliability - indicates the level of reliability that the receiver + * * - * filter - (only relevant for topics at present) allows bindings to + * * - * x-properties - allows protocol or implementation specific options + * + *
no-local(only relevant for topics at present) specifies that the * receiver does not want to receiver messages published to the topic - * that originate from a sender on the same connection + * that originate from a sender on the same connection
browse(only relevant for queues) specifies that the receiver + * does not wish to consume the messages, but merely browse them
durable(only relevant for topics at present) specifies that a + * durable subscription is required
reliabilityindicates the level of reliability that the receiver * expects. Can be one of unreliable, at-most-once, at-least-once or - * exactly-once (the latter is not yet correctly supported). + * exactly-once (the latter is not yet correctly supported).
filter(only relevant for topics at present) allows bindings to * be created for the queue that match the given criteris (or list of - * criteria). + * criteria).
x-propertiesallows protocol or implementation specific options * to be specified for a receiver; this is a nested map and currently * the implementation only recognises two specific nested properties * within it (all others are passed through in the arguments of the * message-subscribe command): * - * exclusive, which requests an exclusive subscription and - * is only relevant for queues + *
    + *
  • exclusive, which requests an exclusive subscription and + * is only relevant for queues
  • * - * x-queue-arguments, which ais only relevant for topics and + *
  • x-queue-arguments, which ais only relevant for topics and * allows arguments to the queue-declare for the subscription - * queue to be specified + * queue to be specified
  • + *
+ *
*/ class Address { -- cgit v1.2.1 From 18b14a7190e120519086b11b2f5554c5b8e9e603 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Mon, 23 Nov 2009 12:50:58 +0000 Subject: QPID-664: Allow session to be specified as transactional; add basic test of transaction implementation. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@883325 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Connection.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Connection.h b/qpid/cpp/include/qpid/messaging/Connection.h index 531f046bec..f7c5ecfae9 100644 --- a/qpid/cpp/include/qpid/messaging/Connection.h +++ b/qpid/cpp/include/qpid/messaging/Connection.h @@ -48,7 +48,10 @@ class Connection : public qpid::client::Handle QPID_CLIENT_EXTERN ~Connection(); QPID_CLIENT_EXTERN Connection& operator=(const Connection&); QPID_CLIENT_EXTERN void close(); + QPID_CLIENT_EXTERN Session newSession(bool transactional, const std::string& name = std::string()); QPID_CLIENT_EXTERN Session newSession(const std::string& name = std::string()); + QPID_CLIENT_EXTERN Session newSession(const char* name); + QPID_CLIENT_EXTERN Session getSession(const std::string& name) const; private: friend class qpid::client::PrivateImplRef; -- cgit v1.2.1 From 892cfdf7c3578d27603c4ae4a54ac5aec101d521 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Mon, 23 Nov 2009 18:10:08 +0000 Subject: QPID-664: Added a little bit of doc on connection options. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@883439 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Connection.h | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Connection.h b/qpid/cpp/include/qpid/messaging/Connection.h index f7c5ecfae9..5c5246ff82 100644 --- a/qpid/cpp/include/qpid/messaging/Connection.h +++ b/qpid/cpp/include/qpid/messaging/Connection.h @@ -41,6 +41,35 @@ class Session; class Connection : public qpid::client::Handle { public: + /** + * Current implementation supports the following options: + * + * username + * password + * heartbeat + * tcp-nodelay + * sasl-mechanism + * sasl-min-ssf + * sasl-max-ssf + * + * (note also bounds, locale, max-channels and max-framesize, but not sure whether those should be docuemented here) + * + * Retry behaviour can be controlled through the following options: + * + * reconnection-timeout - determines how long it will try to + * reconnect for -1 means forever, 0 + * means don't try to reconnect + * min-retry-interval + * max-retry-interval + * + * The retry-interval is the time that the client waits for + * after a failed attempt to reconnect before retrying. It + * starts at the value of the min-retry-interval and is + * doubled every failure until the value of max-retry-interval + * is reached. + * + * + */ static QPID_CLIENT_EXTERN Connection open(const std::string& url, const Variant::Map& options = Variant::Map()); QPID_CLIENT_EXTERN Connection(ConnectionImpl* impl = 0); @@ -63,6 +92,11 @@ struct InvalidOptionString : public qpid::Exception InvalidOptionString(const std::string& msg); }; +/** + * TODO: need to change format of connection option string (currently + * name1=value1&name2=value2 etc, should probably use map syntax as + * per address options. + */ QPID_CLIENT_EXTERN void parseOptionString(const std::string&, Variant::Map&); QPID_CLIENT_EXTERN Variant::Map parseOptionString(const std::string&); -- cgit v1.2.1 From a53255f11a8f8ee49aadec889981cea03934cc72 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Tue, 24 Nov 2009 20:07:24 +0000 Subject: Support for restarting a persistent cluster. Option --cluster-size=N: members wait for N members before recovering store. Stores marked as clean/dirty. Automatically recover from clean store on restart. Stores marked with UUID to detect errors. Not yet implemented: consistency checks, manual recovery from all dirty stores. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@883842 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/framing/Uuid.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/framing/Uuid.h b/qpid/cpp/include/qpid/framing/Uuid.h index 618515622d..2cca6e9dfe 100644 --- a/qpid/cpp/include/qpid/framing/Uuid.h +++ b/qpid/cpp/include/qpid/framing/Uuid.h @@ -61,7 +61,9 @@ struct Uuid : public boost::array { void clear(); /** Test for null (all zeros). */ - bool isNull(); + bool isNull() const; + operator bool() const { return !isNull(); } + bool operator!() const { return isNull(); } QPID_COMMON_EXTERN void encode(framing::Buffer& buf) const; QPID_COMMON_EXTERN void decode(framing::Buffer& buf); -- cgit v1.2.1 From 3bc7e889caef716d8fdd8006f2d53b821ecef6c1 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Fri, 11 Dec 2009 13:52:48 +0000 Subject: QPID-2245 QMF protocol changes will make 0.6 incompatible with 0.5 git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@889619 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/framing/FieldTable.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/framing/FieldTable.h b/qpid/cpp/include/qpid/framing/FieldTable.h index fd09cfc6f6..62b4a4bc08 100644 --- a/qpid/cpp/include/qpid/framing/FieldTable.h +++ b/qpid/cpp/include/qpid/framing/FieldTable.h @@ -63,10 +63,6 @@ class FieldTable QPID_COMMON_EXTERN void encode(Buffer& buffer) const; QPID_COMMON_EXTERN void decode(Buffer& buffer); - QPID_COMMON_EXTERN uint32_t qmfEncodedSize() const; - QPID_COMMON_EXTERN void qmfEncode(Buffer& buffer) const; - QPID_COMMON_EXTERN void qmfDecode(Buffer& buffer); - QPID_COMMON_EXTERN int count() const; QPID_COMMON_EXTERN void set(const std::string& name, const ValuePtr& value); QPID_COMMON_EXTERN ValuePtr get(const std::string& name) const; -- cgit v1.2.1 From 6c2ff216a813a1cd19bc8e850aed437ca17fc09b Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Fri, 11 Dec 2009 18:00:39 +0000 Subject: QPID-2087: Some amplification of doxygen for SubscriptionSettings git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@889736 13f79535-47bb-0310-9956-ffa450edef68 --- .../cpp/include/qpid/client/SubscriptionSettings.h | 39 +++++++++++++++++++--- 1 file changed, 35 insertions(+), 4 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/client/SubscriptionSettings.h b/qpid/cpp/include/qpid/client/SubscriptionSettings.h index 4d64119d3a..b4cb302b56 100644 --- a/qpid/cpp/include/qpid/client/SubscriptionSettings.h +++ b/qpid/cpp/include/qpid/client/SubscriptionSettings.h @@ -49,13 +49,44 @@ struct SubscriptionSettings ) : flowControl(flow), acceptMode(accept), acquireMode(acquire), autoAck(autoAck_), completionMode(completion), exclusive(false) {} FlowControl flowControl; ///@< Flow control settings. @see FlowControl + /** + * The acceptMode determines whether the broker should expect + * delivery of messages to be acknowledged by the client + * indicating that it accepts them. A value of + * ACCEPT_MODE_EXPLICIT means that messages must be accepted + * (note: this may be done automatically by the library - see + * autoAck - or through an explicit call be the application - see + * Subscription::accept()) before they can be dequeued. A value of + * ACCEPT_MODE_NONE means that the broker can dequeue a message as + * soon as it is acquired. + */ AcceptMode acceptMode; ///@< ACCEPT_MODE_EXPLICIT or ACCEPT_MODE_NONE + /** + * The acquireMode determines whether messages are locked for the + * subscriber when delivered, and thus are not delivered to any + * other subscriber unless this subscriber releases them. + * + * The default is ACQUIRE_MODE_PRE_ACQUIRED meaning that the + * subscriber expects to have been given that message exclusively + * (i.e. the message will not be given to any other subscriber + * unless released explicitly or by this subscribers session + * failing without having accepted the message). + * + * Delivery of message in ACQUIRE_MODE_NOT_ACQUIRED mode means the + * message will still be available for other subscribers to + * receive. The application can if desired acquire a (set of) + * messages through an explicit acquire call - see + * Subscription::acquire(). + */ AcquireMode acquireMode; ///@< ACQUIRE_MODE_PRE_ACQUIRED or ACQUIRE_MODE_NOT_ACQUIRED - /** Automatically acknowledge (accept) batches of autoAck - * messages. 0 means no automatic acknowledgement. This has no - * effect for messsages received for a subscription with - * ACCEPT_MODE_NODE.*/ + /** + * Configures the frequency at which messages are automatically + * accepted (e.g. a value of 5 means that messages are accepted in + * batches of 5). A value of 0 means no automatic acknowledgement + * will occur and the application will itself be responsible for + * accepting messages. + */ unsigned int autoAck; /** * In windowing mode, completion of a message will cause the -- cgit v1.2.1 From e8ac34d6643375463dd59d7d614cddb59a01d5a6 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Tue, 15 Dec 2009 08:23:19 +0000 Subject: QPID-2212: revert previous attempt at fix; disable on windows only git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@890683 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/sys/ExceptionHolder.h | 74 +++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 qpid/cpp/include/qpid/sys/ExceptionHolder.h (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/sys/ExceptionHolder.h b/qpid/cpp/include/qpid/sys/ExceptionHolder.h new file mode 100644 index 0000000000..9eff1d64c7 --- /dev/null +++ b/qpid/cpp/include/qpid/sys/ExceptionHolder.h @@ -0,0 +1,74 @@ +#ifndef QPID_EXCEPTIONHOLDER_H +#define QPID_EXCEPTIONHOLDER_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include + + +namespace qpid { +namespace sys { + +struct Raisable { + virtual ~Raisable() {}; + virtual void raise() const=0; + virtual std::string what() const=0; +}; + +/** + * Holder for exceptions. Allows the thread that notices an error condition to + * create an exception and store it to be thrown by another thread. + */ +class ExceptionHolder : public Raisable { + public: + ExceptionHolder() {} + // Use default copy & assign. + + /** Take ownership of ex */ + template ExceptionHolder(Ex* ex) { wrap(ex); } + template ExceptionHolder(const boost::shared_ptr& ex) { wrap(ex.release()); } + + template ExceptionHolder& operator=(Ex* ex) { wrap(ex); return *this; } + template ExceptionHolder& operator=(boost::shared_ptr ex) { wrap(ex.release()); return *this; } + + void raise() const { if (wrapper.get()) wrapper->raise() ; } + std::string what() const { return wrapper.get() ? wrapper->what() : std::string(); } + bool empty() const { return !wrapper.get(); } + operator bool() const { return !empty(); } + void reset() { wrapper.reset(); } + + private: + template struct Wrapper : public Raisable { + Wrapper(Ex* ptr) : exception(ptr) {} + void raise() const { throw *exception; } + std::string what() const { return exception->what(); } + boost::shared_ptr exception; + }; + template void wrap(Ex* ex) { wrapper.reset(new Wrapper(ex)); } + boost::shared_ptr wrapper; +}; + + +}} // namespace qpid::sys + + +#endif /*!QPID_EXCEPTIONHOLDER_H*/ -- cgit v1.2.1 From 6ef9706fc3d447768b4d0d2b0cee8bea828677bd Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Tue, 15 Dec 2009 18:24:02 +0000 Subject: QPID-1951: Removed need for Windows versions of ssize_t and pid_t - Trivially removed Windows uses of ssize_t - Rearchitected how the Windows port finds an existing qpidd to stop it - Split Posix Lockfile functionality using pids into a new PidFile class git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@890929 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/sys/windows/IntegerTypes.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/sys/windows/IntegerTypes.h b/qpid/cpp/include/qpid/sys/windows/IntegerTypes.h index 7b2c57ad8e..ece1a618e9 100755 --- a/qpid/cpp/include/qpid/sys/windows/IntegerTypes.h +++ b/qpid/cpp/include/qpid/sys/windows/IntegerTypes.h @@ -21,8 +21,6 @@ * */ -#include /* Windows system types */ - typedef unsigned char uint8_t; typedef char int8_t; typedef unsigned short uint16_t; @@ -33,8 +31,6 @@ typedef unsigned __int64 uint64_t; typedef __int64 int64_t; // Visual Studio doesn't define other common types, so set them up here too. -typedef int pid_t; -typedef SSIZE_T ssize_t; typedef unsigned int uint; #endif /*!QPID_SYS_WINDOWS_INTEGERTYPES_H*/ -- cgit v1.2.1 From a0970a27bbac9300170ca19237f99da4aceb2969 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Thu, 17 Dec 2009 11:14:57 +0000 Subject: QPID-2289: Fixed copy constructor in qpid::messaging::Message, added in equality operator for qpid::messaging::Variant git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@891636 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Variant.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Variant.h b/qpid/cpp/include/qpid/messaging/Variant.h index c63138178b..de5cef4d67 100644 --- a/qpid/cpp/include/qpid/messaging/Variant.h +++ b/qpid/cpp/include/qpid/messaging/Variant.h @@ -149,6 +149,8 @@ class Variant QPID_CLIENT_EXTERN void setEncoding(const std::string&); QPID_CLIENT_EXTERN const std::string& getEncoding() const; + QPID_CLIENT_EXTERN bool isEqualTo(const Variant& a) const; + QPID_CLIENT_EXTERN void reset(); private: VariantImpl* impl; @@ -157,6 +159,7 @@ class Variant QPID_CLIENT_EXTERN std::ostream& operator<<(std::ostream& out, const Variant& value); QPID_CLIENT_EXTERN std::ostream& operator<<(std::ostream& out, const Variant::Map& map); QPID_CLIENT_EXTERN std::ostream& operator<<(std::ostream& out, const Variant::List& list); +QPID_CLIENT_EXTERN bool operator==(const Variant& a, const Variant& b); typedef Variant::Map VariantMap; -- cgit v1.2.1 From 25d63a161d11d504e51ead2f76e761f561503b69 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Tue, 5 Jan 2010 19:45:28 +0000 Subject: Added handling of MAP values for the wrapped QMF interfaces. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@896191 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/framing/FieldValue.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/framing/FieldValue.h b/qpid/cpp/include/qpid/framing/FieldValue.h index 60a887761f..7b4dee1529 100644 --- a/qpid/cpp/include/qpid/framing/FieldValue.h +++ b/qpid/cpp/include/qpid/framing/FieldValue.h @@ -83,7 +83,7 @@ class FieldValue { FieldValue(): data(0) {}; // Default assignment operator is fine void setType(uint8_t type); - QPID_COMMON_EXTERN uint8_t getType(); + QPID_COMMON_EXTERN uint8_t getType() const; Data& getData() { return *data; } uint32_t encodedSize() const { return 1 + data->encodedSize(); }; bool empty() const { return data.get() == 0; } -- cgit v1.2.1 From 291a25b980e537301b1ffc229e09e73a65113883 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Mon, 11 Jan 2010 17:23:18 +0000 Subject: Fix broker crash "confirmed N but only sent M" with managed agents running. The broker's ManagementAgent caches schemas from managed agents. This cache was not being replicated to new cluster members. If an agent such as sesame was running and connected to a newly-joined broker, that broker could send schema request messages which were not sent by other brokers that had the schema in cache. This resulted in the other brokers exiting with a "confirmed N but only sent M" message. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@897955 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/framing/Buffer.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/framing/Buffer.h b/qpid/cpp/include/qpid/framing/Buffer.h index 8a6a5c0d5f..50cc6fefe4 100644 --- a/qpid/cpp/include/qpid/framing/Buffer.h +++ b/qpid/cpp/include/qpid/framing/Buffer.h @@ -43,9 +43,8 @@ class Buffer uint32_t position; uint32_t r_position; - void checkAvailable(uint32_t count) { if (position + count > size) throw OutOfBounds(); } - public: + void checkAvailable(uint32_t count) { if (position + count > size) throw OutOfBounds(); } /** Buffer input/output iterator. * Supports using an amqp_0_10::Codec with a framing::Buffer. -- cgit v1.2.1 From df9f26495b4d1823601cccc2680384c2a23427a8 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Tue, 12 Jan 2010 12:02:38 +0000 Subject: QPID-664: Added some of the missing standard message headers. Added two new test utilities for sending and receiving with the new API (both still works in progress). git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@898296 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Message.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Message.h b/qpid/cpp/include/qpid/messaging/Message.h index 368fc89772..d1028ff330 100644 --- a/qpid/cpp/include/qpid/messaging/Message.h +++ b/qpid/cpp/include/qpid/messaging/Message.h @@ -58,6 +58,23 @@ class Message QPID_CLIENT_EXTERN void setContentType(const std::string&); QPID_CLIENT_EXTERN const std::string& getContentType() const; + QPID_CLIENT_EXTERN void setMessageId(const std::string&); + QPID_CLIENT_EXTERN const std::string& getMessageId() const; + + QPID_CLIENT_EXTERN void setUserId(const std::string&); + QPID_CLIENT_EXTERN const std::string& getUserId() const; + + QPID_CLIENT_EXTERN void setCorrelationId(const std::string&); + QPID_CLIENT_EXTERN const std::string& getCorrelationId() const; + + QPID_CLIENT_EXTERN void setTtl(uint64_t ttl); + QPID_CLIENT_EXTERN uint64_t getTtl() const; + + QPID_CLIENT_EXTERN void setDurable(bool durable); + QPID_CLIENT_EXTERN bool getDurable() const; + + QPID_CLIENT_EXTERN bool isRedelivered() const; + QPID_CLIENT_EXTERN const Variant::Map& getHeaders() const; QPID_CLIENT_EXTERN Variant::Map& getHeaders(); -- cgit v1.2.1 From fd64f22be60f12e03df8974b547cd9b3af331601 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Wed, 13 Jan 2010 11:57:19 +0000 Subject: Added raise_event support to the Ruby and Python wrapped agent APIs. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@898727 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/engine/Event.h | 17 +++++++++++++++++ qpid/cpp/include/qmf/engine/Schema.h | 4 +++- qpid/cpp/include/qmf/engine/Value.h | 1 + 3 files changed, 21 insertions(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qmf/engine/Event.h b/qpid/cpp/include/qmf/engine/Event.h index 50ab5c1200..4e5200a0a8 100644 --- a/qpid/cpp/include/qmf/engine/Event.h +++ b/qpid/cpp/include/qmf/engine/Event.h @@ -23,7 +23,24 @@ namespace qmf { namespace engine { + class SchemaEventClass; + class Value; + struct EventImpl; + class Event { + public: + Event(const SchemaEventClass* type); + Event(const Event& from); + ~Event(); + + const SchemaEventClass* getClass() const; + Value* getValue(const char* key) const; + + private: + friend struct EventImpl; + friend struct AgentImpl; + Event(EventImpl* impl); + EventImpl* impl; }; } } diff --git a/qpid/cpp/include/qmf/engine/Schema.h b/qpid/cpp/include/qmf/engine/Schema.h index 9f5b444558..f53e84324a 100644 --- a/qpid/cpp/include/qmf/engine/Schema.h +++ b/qpid/cpp/include/qmf/engine/Schema.h @@ -29,6 +29,7 @@ namespace engine { enum Access { ACCESS_READ_CREATE = 1, ACCESS_READ_WRITE = 2, ACCESS_READ_ONLY = 3 }; enum Direction { DIR_IN = 1, DIR_OUT = 2, DIR_IN_OUT = 3 }; enum ClassKind { CLASS_OBJECT = 1, CLASS_EVENT = 2 }; + enum Severity { SEV_EMERG = 0, SEV_ALERT = 1, SEV_CRIT = 2, SEV_ERROR = 3, SEV_WARN = 4, SEV_NOTICE = 5, SEV_INFORM = 6, SEV_DEBUG = 7 }; struct SchemaArgumentImpl; struct SchemaMethodImpl; @@ -186,13 +187,14 @@ namespace engine { */ class SchemaEventClass { public: - SchemaEventClass(const char* package, const char* name); + SchemaEventClass(const char* package, const char* name, Severity severity); SchemaEventClass(const SchemaEventClass& from); ~SchemaEventClass(); void addArgument(const SchemaArgument* argument); void setDesc(const char* desc); const SchemaClassKey* getClassKey() const; + Severity getSeverity() const; int getArgumentCount() const; const SchemaArgument* getArgument(int idx) const; diff --git a/qpid/cpp/include/qmf/engine/Value.h b/qpid/cpp/include/qmf/engine/Value.h index 8eae382caf..5b45061b78 100644 --- a/qpid/cpp/include/qmf/engine/Value.h +++ b/qpid/cpp/include/qmf/engine/Value.h @@ -110,6 +110,7 @@ namespace engine { friend struct ValueImpl; friend class BrokerProxyImpl; friend struct ObjectImpl; + friend struct EventImpl; friend class AgentImpl; Value(ValueImpl* impl); ValueImpl* impl; -- cgit v1.2.1 From 04db3be5386fbc601d11fab7da48b592c997c590 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Fri, 15 Jan 2010 15:17:01 +0000 Subject: QPID-2323: add a Uuid type and allow it as the value of a Variant. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@899657 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/framing/FieldValue.h | 16 +++++ qpid/cpp/include/qpid/messaging/Uuid.h | 93 ++++++++++++++++++++++++++++++ qpid/cpp/include/qpid/messaging/Variant.h | 8 ++- 3 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 qpid/cpp/include/qpid/messaging/Uuid.h (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/framing/FieldValue.h b/qpid/cpp/include/qpid/framing/FieldValue.h index 7b4dee1529..e5746c8065 100644 --- a/qpid/cpp/include/qpid/framing/FieldValue.h +++ b/qpid/cpp/include/qpid/framing/FieldValue.h @@ -99,6 +99,7 @@ class FieldValue { template T getIntegerValue() const; template T getFloatingPointValue() const; + template void getFixedWidthValue(unsigned char*) const; template bool get(T&) const; protected: @@ -209,6 +210,16 @@ inline T FieldValue::getFloatingPointValue() const { } } +template void FieldValue::getFixedWidthValue(unsigned char* value) const +{ + FixedWidthValue* const fwv = dynamic_cast< FixedWidthValue* const>(data.get()); + if (fwv) { + for (uint i = 0; i < W; ++i) value[i] = fwv->rawOctets()[i]; + } else { + throw InvalidConversionException(); + } +} + template <> inline float FieldValue::get() const { return getFloatingPointValue(); @@ -417,6 +428,11 @@ class ListValue : public FieldValue { QPID_COMMON_EXTERN ListValue(const List&); }; +class UuidValue : public FieldValue { + public: + QPID_COMMON_EXTERN UuidValue(const unsigned char*); +}; + template bool getEncodedValue(FieldTable::ValuePtr vptr, T& value) { diff --git a/qpid/cpp/include/qpid/messaging/Uuid.h b/qpid/cpp/include/qpid/messaging/Uuid.h new file mode 100644 index 0000000000..d1caac6013 --- /dev/null +++ b/qpid/cpp/include/qpid/messaging/Uuid.h @@ -0,0 +1,93 @@ +#ifndef QPID_MESSAGING_UUID_H +#define QPID_MESSAGING_UUID_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/client/ClientImportExport.h" +#include + +namespace qpid { +namespace messaging { + +class Uuid +{ + public: + static const size_t SIZE; + /** + * If unique is true, this will generate a new unique uuid, if not + * it will construct a null uuid. + */ + QPID_CLIENT_EXTERN Uuid(bool unique=false); + QPID_CLIENT_EXTERN Uuid(const Uuid&); + QPID_CLIENT_EXTERN Uuid& operator=(const Uuid&); + /** Copy the UUID from data16, which must point to a 16-byte UUID */ + QPID_CLIENT_EXTERN Uuid(const unsigned char* data16); + + /** Set to a new unique identifier. */ + QPID_CLIENT_EXTERN void generate(); + + /** Set to all zeros. */ + QPID_CLIENT_EXTERN void clear(); + + /** Test for null (all zeros). */ + QPID_CLIENT_EXTERN bool isNull() const; + QPID_CLIENT_EXTERN operator bool() const; + QPID_CLIENT_EXTERN bool operator!() const; + + /** String value in format 1b4e28ba-2fa1-11d2-883f-b9a761bde3fb. */ + QPID_CLIENT_EXTERN std::string str() const; + + QPID_CLIENT_EXTERN size_t size() const; + QPID_CLIENT_EXTERN const unsigned char* data() const; + + friend bool operator==(const Uuid&, const Uuid&); + friend bool operator!=(const Uuid&, const Uuid&); + friend bool operator<(const Uuid&, const Uuid&); + friend bool operator>(const Uuid&, const Uuid&); + friend bool operator<=(const Uuid&, const Uuid&); + friend bool operator>=(const Uuid&, const Uuid&); + friend std::ostream& operator<<(std::ostream&, Uuid); + friend std::istream& operator>>(std::istream&, Uuid&); + + private: + unsigned char bytes[16]; +}; + +/** Returns true if the uuids are equal, false otherwise. **/ +QPID_CLIENT_EXTERN bool operator==(const Uuid&, const Uuid&); +/** Returns true if the uuids are NOT equal, false if they are. **/ +QPID_CLIENT_EXTERN bool operator!=(const Uuid&, const Uuid&); + +QPID_CLIENT_EXTERN bool operator<(const Uuid&, const Uuid&); +QPID_CLIENT_EXTERN bool operator>(const Uuid&, const Uuid&); +QPID_CLIENT_EXTERN bool operator<=(const Uuid&, const Uuid&); +QPID_CLIENT_EXTERN bool operator>=(const Uuid&, const Uuid&); + +/** Print in format 1b4e28ba-2fa1-11d2-883f-b9a761bde3fb. */ +QPID_CLIENT_EXTERN std::ostream& operator<<(std::ostream&, Uuid); + +/** Read from format 1b4e28ba-2fa1-11d2-883f-b9a761bde3fb. */ +QPID_CLIENT_EXTERN std::istream& operator>>(std::istream&, Uuid&); + +}} // namespace qpid::messaging + +#endif /*!QPID_MESSAGING_UUID_H*/ diff --git a/qpid/cpp/include/qpid/messaging/Variant.h b/qpid/cpp/include/qpid/messaging/Variant.h index de5cef4d67..0bf62a9909 100644 --- a/qpid/cpp/include/qpid/messaging/Variant.h +++ b/qpid/cpp/include/qpid/messaging/Variant.h @@ -25,6 +25,7 @@ #include #include #include +#include "Uuid.h" #include "qpid/Exception.h" #include "qpid/sys/IntegerTypes.h" #include "qpid/client/ClientImportExport.h" @@ -55,7 +56,8 @@ enum VariantType { VAR_DOUBLE, VAR_STRING, VAR_MAP, - VAR_LIST + VAR_LIST, + VAR_UUID }; class VariantImpl; @@ -86,6 +88,7 @@ class Variant QPID_CLIENT_EXTERN Variant(const Map&); QPID_CLIENT_EXTERN Variant(const List&); QPID_CLIENT_EXTERN Variant(const Variant&); + QPID_CLIENT_EXTERN Variant(const Uuid&); QPID_CLIENT_EXTERN ~Variant(); @@ -108,6 +111,7 @@ class Variant QPID_CLIENT_EXTERN Variant& operator=(const Map&); QPID_CLIENT_EXTERN Variant& operator=(const List&); QPID_CLIENT_EXTERN Variant& operator=(const Variant&); + QPID_CLIENT_EXTERN Variant& operator=(const Uuid&); QPID_CLIENT_EXTERN bool asBool() const; QPID_CLIENT_EXTERN uint8_t asUint8() const; @@ -121,6 +125,7 @@ class Variant QPID_CLIENT_EXTERN float asFloat() const; QPID_CLIENT_EXTERN double asDouble() const; QPID_CLIENT_EXTERN std::string asString() const; + QPID_CLIENT_EXTERN Uuid asUuid() const; QPID_CLIENT_EXTERN operator bool() const; QPID_CLIENT_EXTERN operator uint8_t() const; @@ -134,6 +139,7 @@ class Variant QPID_CLIENT_EXTERN operator float() const; QPID_CLIENT_EXTERN operator double() const; QPID_CLIENT_EXTERN operator const char*() const; + QPID_CLIENT_EXTERN operator Uuid() const; QPID_CLIENT_EXTERN const Map& asMap() const; QPID_CLIENT_EXTERN Map& asMap(); -- cgit v1.2.1 From 4bf5652d3d79d64ce22bbb1c9c2cddcec4d30054 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Mon, 18 Jan 2010 10:45:20 +0000 Subject: Alter type of array index variable git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@900332 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/framing/FieldValue.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/framing/FieldValue.h b/qpid/cpp/include/qpid/framing/FieldValue.h index e5746c8065..f413d5a552 100644 --- a/qpid/cpp/include/qpid/framing/FieldValue.h +++ b/qpid/cpp/include/qpid/framing/FieldValue.h @@ -203,7 +203,7 @@ inline T FieldValue::getFloatingPointValue() const { T value; uint8_t* const octets = convertIfRequired(fwv->rawOctets(), W); uint8_t* const target = reinterpret_cast(&value); - for (uint i = 0; i < W; ++i) target[i] = octets[i]; + for (size_t i = 0; i < W; ++i) target[i] = octets[i]; return value; } else { throw InvalidConversionException(); @@ -214,7 +214,7 @@ template void FieldValue::getFixedWidthValue(unsigned char* value) const { FixedWidthValue* const fwv = dynamic_cast< FixedWidthValue* const>(data.get()); if (fwv) { - for (uint i = 0; i < W; ++i) value[i] = fwv->rawOctets()[i]; + for (size_t i = 0; i < W; ++i) value[i] = fwv->rawOctets()[i]; } else { throw InvalidConversionException(); } -- cgit v1.2.1 From 94f0f507eef4cdcf3422403350ef294a07ce85bd Mon Sep 17 00:00:00 2001 From: "Stephen D. Huston" Date: Tue, 19 Jan 2010 18:17:28 +0000 Subject: Apply QPID_CLIENT_EXTERN where needed; should have been in with r900592. Fixes QPID-2344. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@900880 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Uuid.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Uuid.h b/qpid/cpp/include/qpid/messaging/Uuid.h index d1caac6013..bbc9bd7a97 100644 --- a/qpid/cpp/include/qpid/messaging/Uuid.h +++ b/qpid/cpp/include/qpid/messaging/Uuid.h @@ -24,6 +24,7 @@ #include "qpid/client/ClientImportExport.h" #include +#include namespace qpid { namespace messaging { @@ -59,14 +60,14 @@ class Uuid QPID_CLIENT_EXTERN size_t size() const; QPID_CLIENT_EXTERN const unsigned char* data() const; - friend bool operator==(const Uuid&, const Uuid&); - friend bool operator!=(const Uuid&, const Uuid&); - friend bool operator<(const Uuid&, const Uuid&); - friend bool operator>(const Uuid&, const Uuid&); - friend bool operator<=(const Uuid&, const Uuid&); - friend bool operator>=(const Uuid&, const Uuid&); - friend std::ostream& operator<<(std::ostream&, Uuid); - friend std::istream& operator>>(std::istream&, Uuid&); + friend QPID_CLIENT_EXTERN bool operator==(const Uuid&, const Uuid&); + friend QPID_CLIENT_EXTERN bool operator!=(const Uuid&, const Uuid&); + friend QPID_CLIENT_EXTERN bool operator<(const Uuid&, const Uuid&); + friend QPID_CLIENT_EXTERN bool operator>(const Uuid&, const Uuid&); + friend QPID_CLIENT_EXTERN bool operator<=(const Uuid&, const Uuid&); + friend QPID_CLIENT_EXTERN bool operator>=(const Uuid&, const Uuid&); + friend QPID_CLIENT_EXTERN std::ostream& operator<<(std::ostream&, Uuid); + friend QPID_CLIENT_EXTERN std::istream& operator>>(std::istream&, Uuid&); private: unsigned char bytes[16]; -- cgit v1.2.1 From 84dff8ce35a6d8bdee54b2182a1b7f03ab3ca9dd Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Wed, 20 Jan 2010 15:54:59 +0000 Subject: Provide access to a sessions connection. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@901247 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/client/SessionBase_0_10.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/client/SessionBase_0_10.h b/qpid/cpp/include/qpid/client/SessionBase_0_10.h index afa458bcee..e76019dd4d 100644 --- a/qpid/cpp/include/qpid/client/SessionBase_0_10.h +++ b/qpid/cpp/include/qpid/client/SessionBase_0_10.h @@ -99,6 +99,8 @@ class SessionBase_0_10 { QPID_CLIENT_EXTERN bool isValid() const; + QPID_CLIENT_EXTERN Connection getConnection(); + protected: boost::shared_ptr impl; friend class SessionBase_0_10Access; -- cgit v1.2.1 From 640f833fecec770d75eae4392ef4dd56df109ea3 Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Thu, 21 Jan 2010 18:24:04 +0000 Subject: Fixes to make Win32 port build again (and remove some warnings) git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@901816 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/engine/Event.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qmf/engine/Event.h b/qpid/cpp/include/qmf/engine/Event.h index 4e5200a0a8..647b88dbf8 100644 --- a/qpid/cpp/include/qmf/engine/Event.h +++ b/qpid/cpp/include/qmf/engine/Event.h @@ -38,7 +38,7 @@ namespace engine { private: friend struct EventImpl; - friend struct AgentImpl; + friend class AgentImpl; Event(EventImpl* impl); EventImpl* impl; }; -- cgit v1.2.1 From 5b6df3a43ef7c3792ee3cc866e12debf785cbe60 Mon Sep 17 00:00:00 2001 From: "Stephen D. Huston" Date: Fri, 22 Jan 2010 16:56:18 +0000 Subject: Refer to ConnectionAccess as the struct it is, not class. Resolves compile warning on MSVC. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@902171 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/client/Connection.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/client/Connection.h b/qpid/cpp/include/qpid/client/Connection.h index bcf2962557..b5026d1135 100644 --- a/qpid/cpp/include/qpid/client/Connection.h +++ b/qpid/cpp/include/qpid/client/Connection.h @@ -212,7 +212,7 @@ class Connection */ QPID_CLIENT_EXTERN const ConnectionSettings& getNegotiatedSettings(); - friend class ConnectionAccess; ///<@internal + friend struct ConnectionAccess; ///<@internal friend class SessionBase_0_10; ///<@internal }; -- cgit v1.2.1 From 07a4c53807ff6f9be0d3300e8501d5ed12937d1b Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Tue, 26 Jan 2010 11:13:26 +0000 Subject: QPID-2288: add support for bindings in address options git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@903171 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Address.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Address.h b/qpid/cpp/include/qpid/messaging/Address.h index 538cb6507c..88863072bd 100644 --- a/qpid/cpp/include/qpid/messaging/Address.h +++ b/qpid/cpp/include/qpid/messaging/Address.h @@ -92,9 +92,11 @@ class AddressImpl; *
  • x-properties - a nested map that can contain implementation or * protocol specifiec extedned properties. For the amqp 0-10 mapping, * the fields in queue- or exchange- declare can be specified in here; - * anything that is not recognised as one of those will be passed - * through in the arguments field.,/li> - * + * a bindings entry may also be specified, whose value should be an + * array of strings of the form exchange/key; anything else will be + * passed through in the arguments field. + *
  • + * * * * -- cgit v1.2.1 From 4d27f50748e18ea40cd3a914bc5b53c0c892eaf4 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Wed, 27 Jan 2010 10:42:19 +0000 Subject: QPID-664: change cancel() to close() for consistency git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@903599 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Receiver.h | 2 +- qpid/cpp/include/qpid/messaging/Sender.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Receiver.h b/qpid/cpp/include/qpid/messaging/Receiver.h index 51630b12a2..0923178065 100644 --- a/qpid/cpp/include/qpid/messaging/Receiver.h +++ b/qpid/cpp/include/qpid/messaging/Receiver.h @@ -110,7 +110,7 @@ class Receiver : public qpid::client::Handle /** * Cancels this receiver. */ - QPID_CLIENT_EXTERN void cancel(); + QPID_CLIENT_EXTERN void close(); /** * Returns the name of this receiver. diff --git a/qpid/cpp/include/qpid/messaging/Sender.h b/qpid/cpp/include/qpid/messaging/Sender.h index 335e61260c..eb8ccc2f84 100644 --- a/qpid/cpp/include/qpid/messaging/Sender.h +++ b/qpid/cpp/include/qpid/messaging/Sender.h @@ -50,7 +50,7 @@ class Sender : public qpid::client::Handle QPID_CLIENT_EXTERN Sender& operator=(const Sender&); QPID_CLIENT_EXTERN void send(const Message& message); - QPID_CLIENT_EXTERN void cancel(); + QPID_CLIENT_EXTERN void close(); /** * Sets the capacity for the sender. The capacity determines how -- cgit v1.2.1 From 028816b02eefb5842c69a0d26496706316d5e4d5 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Wed, 27 Jan 2010 22:21:28 +0000 Subject: QPID_2634 Management updates in timer create inconsistencies in a cluster. Cluster plugin provides a PeriodicTimer implementation to the broker which executes tasks in the cluster dispatch thread simultaneously across the cluster. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@903869 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/sys/Time.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/sys/Time.h b/qpid/cpp/include/qpid/sys/Time.h index c19757747b..ad05b0d1c7 100644 --- a/qpid/cpp/include/qpid/sys/Time.h +++ b/qpid/cpp/include/qpid/sys/Time.h @@ -122,7 +122,7 @@ class Duration { friend class AbsTime; public: - QPID_COMMON_EXTERN inline Duration(int64_t time0); + QPID_COMMON_EXTERN inline Duration(int64_t time0 = 0); QPID_COMMON_EXTERN explicit Duration(const AbsTime& time0); QPID_COMMON_EXTERN explicit Duration(const AbsTime& start, const AbsTime& finish); inline operator int64_t() const; -- cgit v1.2.1 From 1e275cd7e3c1eb5e8e0fbe550b846bbfe2309d51 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Thu, 28 Jan 2010 08:37:37 +0000 Subject: QPID-664: change format of connection options string to match address options; make open() a non-static method. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@904000 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Connection.h | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Connection.h b/qpid/cpp/include/qpid/messaging/Connection.h index 5c5246ff82..36392da0b2 100644 --- a/qpid/cpp/include/qpid/messaging/Connection.h +++ b/qpid/cpp/include/qpid/messaging/Connection.h @@ -38,9 +38,16 @@ namespace messaging { class ConnectionImpl; class Session; +struct InvalidOptionString : public qpid::Exception +{ + InvalidOptionString(const std::string& msg); +}; + class Connection : public qpid::client::Handle { public: + QPID_CLIENT_EXTERN Connection(ConnectionImpl* impl); + QPID_CLIENT_EXTERN Connection(const Connection&); /** * Current implementation supports the following options: * @@ -70,12 +77,11 @@ class Connection : public qpid::client::Handle * * */ - static QPID_CLIENT_EXTERN Connection open(const std::string& url, const Variant::Map& options = Variant::Map()); - - QPID_CLIENT_EXTERN Connection(ConnectionImpl* impl = 0); - QPID_CLIENT_EXTERN Connection(const Connection&); + QPID_CLIENT_EXTERN Connection(const Variant::Map& options = Variant::Map()); + QPID_CLIENT_EXTERN Connection(const std::string& options); QPID_CLIENT_EXTERN ~Connection(); QPID_CLIENT_EXTERN Connection& operator=(const Connection&); + QPID_CLIENT_EXTERN void open(const std::string& url); QPID_CLIENT_EXTERN void close(); QPID_CLIENT_EXTERN Session newSession(bool transactional, const std::string& name = std::string()); QPID_CLIENT_EXTERN Session newSession(const std::string& name = std::string()); @@ -87,19 +93,6 @@ class Connection : public qpid::client::Handle }; -struct InvalidOptionString : public qpid::Exception -{ - InvalidOptionString(const std::string& msg); -}; - -/** - * TODO: need to change format of connection option string (currently - * name1=value1&name2=value2 etc, should probably use map syntax as - * per address options. - */ -QPID_CLIENT_EXTERN void parseOptionString(const std::string&, Variant::Map&); -QPID_CLIENT_EXTERN Variant::Map parseOptionString(const std::string&); - }} // namespace qpid::messaging #endif /*!QPID_MESSAGING_CONNECTION_H*/ -- cgit v1.2.1 From 6f16d9d4fa398056a817726ca8512f356422353d Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Fri, 29 Jan 2010 22:07:03 +0000 Subject: QPID-2251, QPID-1982 - Added alternative to non-portable FD notifier in the c++ QMF agent. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@904645 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/agent/ManagementAgent.h | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/agent/ManagementAgent.h b/qpid/cpp/include/qpid/agent/ManagementAgent.h index 1a8d0c4025..b0f0f1cec4 100644 --- a/qpid/cpp/include/qpid/agent/ManagementAgent.h +++ b/qpid/cpp/include/qpid/agent/ManagementAgent.h @@ -30,6 +30,12 @@ namespace qpid { namespace management { +class Notifyable { +public: + virtual ~Notifyable() {} + virtual void notify() = 0; +}; + class ManagementAgent { public: @@ -150,11 +156,20 @@ class ManagementAgent virtual uint32_t pollCallbacks(uint32_t callLimit = 0) = 0; // If "useExternalThread" was set to true in the constructor, this method provides - // a standard file descriptor that can be used in a select statement to signal that - // there are method callbacks ready (i.e. that "pollCallbacks" will result in at - // least one method call). When this fd is ready-for-read, pollCallbacks may be - // invoked. Calling pollCallbacks shall reset the ready-to-read state of the fd. + // a callback that is invoked whenever there is work to be done by pollCallbacks. + // This function is invoked on the agent's thread and should not perform any work + // except to signal the application's thread. + // + // There are two flavors of callback: + // A C version that uses a pointer to a function with a void* context + // A C++ version that uses a class derived from Notifyable + // + // Either type of callback may be used. If they are both provided, the C++ callback + // will be the only one invoked. // + typedef void (*cb_t)(void*); + virtual void setSignalCallback(cb_t callback, void* context) = 0; + virtual void setSignalCallback(Notifyable& notifyable) = 0; virtual int getSignalFd() = 0; }; -- cgit v1.2.1 From 7c27a4488fb09b2898c2a3a017f7e86c834abe28 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Fri, 29 Jan 2010 23:30:49 +0000 Subject: Improved the comments describing the notification mechanisms. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@904673 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/agent/ManagementAgent.h | 29 +++++++++++++++++---------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/agent/ManagementAgent.h b/qpid/cpp/include/qpid/agent/ManagementAgent.h index b0f0f1cec4..41b6423624 100644 --- a/qpid/cpp/include/qpid/agent/ManagementAgent.h +++ b/qpid/cpp/include/qpid/agent/ManagementAgent.h @@ -155,17 +155,24 @@ class ManagementAgent // virtual uint32_t pollCallbacks(uint32_t callLimit = 0) = 0; - // If "useExternalThread" was set to true in the constructor, this method provides - // a callback that is invoked whenever there is work to be done by pollCallbacks. - // This function is invoked on the agent's thread and should not perform any work - // except to signal the application's thread. - // - // There are two flavors of callback: - // A C version that uses a pointer to a function with a void* context - // A C++ version that uses a class derived from Notifyable - // - // Either type of callback may be used. If they are both provided, the C++ callback - // will be the only one invoked. + // In the "useExternalThread" scenario, there are three ways that an application can + // use to be notified that there is work to do. Of course the application may periodically + // call pollCallbacks if it wishes, but this will cause long latencies in the responses + // to method calls. + // + // The notification methods are: + // + // 1) Register a C-style callback by providing a pointer to a function + // 2) Register a C++-style callback by providing an object of a class that is derived + // from Notifyable + // 3) Call getSignalFd() to get a file descriptor that can be used in a select + // call. The file descriptor shall become readable when the agent has work to + // do. Note that this mechanism is specific to Posix-based operating environments. + // getSignalFd will probably not function correctly on Windows. + // + // If a callback is registered, the callback function will be called on the agent's + // thread. The callback function must perform no work other than to signal the application + // thread to call pollCallbacks. // typedef void (*cb_t)(void*); virtual void setSignalCallback(cb_t callback, void* context) = 0; -- cgit v1.2.1 From f31c2b59f37ff5648f85b2f950b434f9669f4425 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Tue, 2 Feb 2010 11:09:11 +0000 Subject: QPID-2380: recognise reliability option for sender (also added capacity to qpid_send test client and fixed handling of empty option string) git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@905579 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Address.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Address.h b/qpid/cpp/include/qpid/messaging/Address.h index 88863072bd..745949792d 100644 --- a/qpid/cpp/include/qpid/messaging/Address.h +++ b/qpid/cpp/include/qpid/messaging/Address.h @@ -120,7 +120,7 @@ class AddressImpl; * exactly-once (the latter is not yet correctly supported). * * filter(only relevant for topics at present) allows bindings to - * be created for the queue that match the given criteris (or list of + * be created for the queue that match the given criteria (or list of * criteria). * * x-propertiesallows protocol or implementation specific options -- cgit v1.2.1 From eaaad7d0cd69d7755e57992d2f083c617c30aa51 Mon Sep 17 00:00:00 2001 From: "Stephen D. Huston" Date: Tue, 2 Feb 2010 15:12:59 +0000 Subject: Add missing QPID_COMMON_EXTERN to pair-returning insert() - it's now called by qpidbroker. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@905669 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/framing/FieldTable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/framing/FieldTable.h b/qpid/cpp/include/qpid/framing/FieldTable.h index 62b4a4bc08..085f7ed110 100644 --- a/qpid/cpp/include/qpid/framing/FieldTable.h +++ b/qpid/cpp/include/qpid/framing/FieldTable.h @@ -104,7 +104,7 @@ class FieldTable ValueMap::iterator end() { return values.end(); } ValueMap::iterator find(const std::string& s) { return values.find(s); } - std::pair insert(const ValueMap::value_type&); + QPID_COMMON_EXTERN std::pair insert(const ValueMap::value_type&); QPID_COMMON_EXTERN ValueMap::iterator insert(ValueMap::iterator, const ValueMap::value_type&); void clear() { values.clear(); } -- cgit v1.2.1 From b5d8b71528b9fcb391bbc4c53c77807830d25581 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Wed, 3 Feb 2010 13:35:58 +0000 Subject: Changes to management code generation: 1) Added readProperties(Buffer) method to ManagementObject to help in the serialization and unserialization of data for cluster replication. 2) Added hooks to ManagementObject and ObjectId to prepare for QMFv2 object naming. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@906038 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/management/ManagementObject.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/management/ManagementObject.h b/qpid/cpp/include/qpid/management/ManagementObject.h index d0a443d6cb..c4921269ba 100644 --- a/qpid/cpp/include/qpid/management/ManagementObject.h +++ b/qpid/cpp/include/qpid/management/ManagementObject.h @@ -51,6 +51,7 @@ protected: const AgentAttachment* agent; uint64_t first; uint64_t second; + std::string v2Key; void fromString(const std::string&); public: QPID_COMMON_EXTERN ObjectId() : agent(0), first(0), second(0) {} @@ -63,6 +64,8 @@ public: QPID_COMMON_EXTERN bool operator<(const ObjectId &other) const; QPID_COMMON_EXTERN void encode(framing::Buffer& buffer); QPID_COMMON_EXTERN void decode(framing::Buffer& buffer); + QPID_COMMON_EXTERN void setV2Key(const std::string& key) { v2Key = key; } + QPID_COMMON_EXTERN const std::string& getV2Key() const { return v2Key; } friend QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream&, const ObjectId&); }; @@ -128,6 +131,7 @@ protected: QPID_COMMON_EXTERN int getThreadIndex(); QPID_COMMON_EXTERN void writeTimestamps(qpid::framing::Buffer& buf); + QPID_COMMON_EXTERN void readTimestamps(qpid::framing::Buffer& buf); public: QPID_COMMON_EXTERN static int maxThreads; @@ -141,12 +145,14 @@ protected: virtual ~ManagementObject() {} virtual writeSchemaCall_t getWriteSchemaCall() = 0; + virtual void readProperties(qpid::framing::Buffer& buf) = 0; virtual void writeProperties(qpid::framing::Buffer& buf) = 0; virtual void writeStatistics(qpid::framing::Buffer& buf, bool skipHeaders = false) = 0; virtual void doMethod(std::string& methodName, qpid::framing::Buffer& inBuf, qpid::framing::Buffer& outBuf) = 0; + virtual std::string getKey() const = 0; QPID_COMMON_EXTERN virtual void setReference(ObjectId objectId); virtual std::string& getClassName() const = 0; -- cgit v1.2.1 From 3a7f44a61ce4cada2bfce431e405652744368ab3 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Thu, 4 Feb 2010 17:25:19 +0000 Subject: Added encode/decode/encodedSize methods for management objects. Made methods on generated code public. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@906573 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/management/ManagementObject.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/management/ManagementObject.h b/qpid/cpp/include/qpid/management/ManagementObject.h index c4921269ba..6475ff5406 100644 --- a/qpid/cpp/include/qpid/management/ManagementObject.h +++ b/qpid/cpp/include/qpid/management/ManagementObject.h @@ -62,7 +62,8 @@ public: QPID_COMMON_EXTERN ObjectId(const std::string&); QPID_COMMON_EXTERN bool operator==(const ObjectId &other) const; QPID_COMMON_EXTERN bool operator<(const ObjectId &other) const; - QPID_COMMON_EXTERN void encode(framing::Buffer& buffer); + QPID_COMMON_EXTERN uint32_t encodedSize() const { return 16; }; + QPID_COMMON_EXTERN void encode(framing::Buffer& buffer) const; QPID_COMMON_EXTERN void decode(framing::Buffer& buffer); QPID_COMMON_EXTERN void setV2Key(const std::string& key) { v2Key = key; } QPID_COMMON_EXTERN const std::string& getV2Key() const { return v2Key; } @@ -119,19 +120,20 @@ protected: uint64_t destroyTime; uint64_t updateTime; ObjectId objectId; - bool configChanged; + mutable bool configChanged; bool instChanged; bool deleted; Manageable* coreObject; - sys::Mutex accessLock; + mutable sys::Mutex accessLock; uint32_t flags; static int nextThreadIndex; bool forcePublish; QPID_COMMON_EXTERN int getThreadIndex(); - QPID_COMMON_EXTERN void writeTimestamps(qpid::framing::Buffer& buf); + QPID_COMMON_EXTERN void writeTimestamps(qpid::framing::Buffer& buf) const; QPID_COMMON_EXTERN void readTimestamps(qpid::framing::Buffer& buf); + QPID_COMMON_EXTERN uint32_t writeTimestampsSize() const; public: QPID_COMMON_EXTERN static int maxThreads; @@ -146,7 +148,8 @@ protected: virtual writeSchemaCall_t getWriteSchemaCall() = 0; virtual void readProperties(qpid::framing::Buffer& buf) = 0; - virtual void writeProperties(qpid::framing::Buffer& buf) = 0; + virtual uint32_t writePropertiesSize() const = 0; + virtual void writeProperties(qpid::framing::Buffer& buf) const = 0; virtual void writeStatistics(qpid::framing::Buffer& buf, bool skipHeaders = false) = 0; virtual void doMethod(std::string& methodName, @@ -182,6 +185,10 @@ protected: return other.getClassName() == getClassName() && other.getPackageName() == getPackageName(); } + + QPID_COMMON_EXTERN void encode(qpid::framing::Buffer& buf) const { writeProperties(buf); } + QPID_COMMON_EXTERN void decode(qpid::framing::Buffer& buf) { readProperties(buf); } + QPID_COMMON_EXTERN uint32_t encodedSize() const { return writePropertiesSize(); } }; typedef std::map ManagementObjectMap; -- cgit v1.2.1 From 9523fa332a8fd0f713c3c12c941b061316597d84 Mon Sep 17 00:00:00 2001 From: Kenneth Anthony Giusti Date: Mon, 8 Feb 2010 21:33:54 +0000 Subject: QPID-2396: add assignment operator to ObjectId class. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@907808 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/engine/ObjectId.h | 1 + 1 file changed, 1 insertion(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qmf/engine/ObjectId.h b/qpid/cpp/include/qmf/engine/ObjectId.h index 2055972c00..51eb2bc9e7 100644 --- a/qpid/cpp/include/qmf/engine/ObjectId.h +++ b/qpid/cpp/include/qmf/engine/ObjectId.h @@ -49,6 +49,7 @@ namespace engine { bool operator>(const ObjectId& other) const; bool operator<=(const ObjectId& other) const; bool operator>=(const ObjectId& other) const; + ObjectId& operator=(const ObjectId &other); private: friend struct ObjectIdImpl; -- cgit v1.2.1 From fb7dd0362adbd0bbf863e3c13455accd3a40307c Mon Sep 17 00:00:00 2001 From: "Stephen D. Huston" Date: Wed, 10 Feb 2010 22:44:18 +0000 Subject: Add comment that destructor doesn't close connection; see QPID-2395 git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@908706 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/client/Connection.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/client/Connection.h b/qpid/cpp/include/qpid/client/Connection.h index b5026d1135..4d92d4b804 100644 --- a/qpid/cpp/include/qpid/client/Connection.h +++ b/qpid/cpp/include/qpid/client/Connection.h @@ -71,11 +71,15 @@ class Connection public: /** - * Creates a connection object, but does not open the connection. + * Creates a Connection object, but does not open the connection. * @see open() */ QPID_CLIENT_EXTERN Connection(); + /** + * Destroys a Connection object but does not close the connection if it + * was open. @see close() + */ QPID_CLIENT_EXTERN ~Connection(); /** -- cgit v1.2.1 From 6febb06e1476898cd18d59cc0edf212af3d1efb8 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Fri, 12 Feb 2010 18:23:47 +0000 Subject: QPID-2328 - Applied patch from Ian Main git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@909548 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/engine/ResilientConnection.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qmf/engine/ResilientConnection.h b/qpid/cpp/include/qmf/engine/ResilientConnection.h index 359c8ea6ff..c03d08cb96 100644 --- a/qpid/cpp/include/qmf/engine/ResilientConnection.h +++ b/qpid/cpp/include/qmf/engine/ResilientConnection.h @@ -155,6 +155,14 @@ namespace engine { */ void setNotifyFd(int fd); + /** + * Send a byte into the notify file descriptor. + * + * This can be used to wake up the event processing portion of the engine from either the + * wrapped implementation or the engine itself. + */ + void notify(); + private: ResilientConnectionImpl* impl; }; -- cgit v1.2.1 From 75be383734f46caa65a3d094238469c4002989ad Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Fri, 12 Feb 2010 21:23:27 +0000 Subject: Changes needed for QPID-2029 (Clustering and Management don't work well together) This update changes the indexing of object IDs in the broker-resident management agent from being based on the QMFv1 format (numeric) to the QMFv2 format (string name). This removes the need for numeric objectIds to be synchronized across a set of clustered brokers. Also included in this patch is a fix to a bug in binding creation. Previously, when a binding was created that already existed, the management object for the proposed binding (duplicate of the existing one) was created then destroyed. This is inefficient and causes problems when the name-based indexes collide. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@909610 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/management/ManagementObject.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/management/ManagementObject.h b/qpid/cpp/include/qpid/management/ManagementObject.h index 6475ff5406..b1c70f64d6 100644 --- a/qpid/cpp/include/qpid/management/ManagementObject.h +++ b/qpid/cpp/include/qpid/management/ManagementObject.h @@ -27,12 +27,14 @@ #include #include "qpid/CommonImportExport.h" #include +#include namespace qpid { namespace management { class Manageable; class ObjectId; +class ManagementObject; class AgentAttachment { @@ -65,7 +67,9 @@ public: QPID_COMMON_EXTERN uint32_t encodedSize() const { return 16; }; QPID_COMMON_EXTERN void encode(framing::Buffer& buffer) const; QPID_COMMON_EXTERN void decode(framing::Buffer& buffer); - QPID_COMMON_EXTERN void setV2Key(const std::string& key) { v2Key = key; } + QPID_COMMON_EXTERN void setV2Key(const std::string& _key) { v2Key = _key; } + QPID_COMMON_EXTERN void setV2Key(const ManagementObject& object); + QPID_COMMON_EXTERN bool equalV1(const ObjectId &other) const; QPID_COMMON_EXTERN const std::string& getV2Key() const { return v2Key; } friend QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream&, const ObjectId&); }; @@ -192,6 +196,7 @@ protected: }; typedef std::map ManagementObjectMap; +typedef std::vector ManagementObjectVector; }} -- cgit v1.2.1 From 588219ac990912cecf77c90eaa77fba3dcdd5668 Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Thu, 25 Feb 2010 20:53:08 +0000 Subject: Removed unecessary include of Msg.h in Exception.h git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@916453 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/Exception.h | 2 -- qpid/cpp/include/qpid/sys/posix/check.h | 1 + qpid/cpp/include/qpid/sys/windows/check.h | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/Exception.h b/qpid/cpp/include/qpid/Exception.h index 7b937c242a..fa7111160c 100644 --- a/qpid/cpp/include/qpid/Exception.h +++ b/qpid/cpp/include/qpid/Exception.h @@ -26,9 +26,7 @@ #include "qpid/framing/constants.h" #include "qpid/framing/enum.h" #include "qpid/sys/StrError.h" -#include "qpid/Msg.h" #include "qpid/CommonImportExport.h" -#include #include #include diff --git a/qpid/cpp/include/qpid/sys/posix/check.h b/qpid/cpp/include/qpid/sys/posix/check.h index bbc66d389b..1bfe5d6d78 100644 --- a/qpid/cpp/include/qpid/sys/posix/check.h +++ b/qpid/cpp/include/qpid/sys/posix/check.h @@ -23,6 +23,7 @@ */ #include "qpid/Exception.h" +#include "qpid/Msg.h" #include #include diff --git a/qpid/cpp/include/qpid/sys/windows/check.h b/qpid/cpp/include/qpid/sys/windows/check.h index aba38814b2..2a8e439bed 100755 --- a/qpid/cpp/include/qpid/sys/windows/check.h +++ b/qpid/cpp/include/qpid/sys/windows/check.h @@ -23,6 +23,7 @@ */ #include "qpid/Exception.h" +#include "qpid/Msg.h" #include "qpid/sys/StrError.h" #define QPID_WINDOWS_ERROR(ERRVAL) qpid::Exception(QPID_MSG(qpid::sys::strError(ERRVAL))) -- cgit v1.2.1 From e37be70fb4ff467b05fdb84bd3983633b910e8ee Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Fri, 26 Feb 2010 20:07:36 +0000 Subject: QPID-2423 - Add Constructors to set initial value of content for MapContent and ListContent git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@916803 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/ListContent.h | 1 + qpid/cpp/include/qpid/messaging/MapContent.h | 1 + 2 files changed, 2 insertions(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/ListContent.h b/qpid/cpp/include/qpid/messaging/ListContent.h index 1c4e13716d..f57a920a88 100644 --- a/qpid/cpp/include/qpid/messaging/ListContent.h +++ b/qpid/cpp/include/qpid/messaging/ListContent.h @@ -42,6 +42,7 @@ class ListContent typedef Variant::List::const_reverse_iterator const_reverse_iterator; QPID_CLIENT_EXTERN ListContent(Message&); + QPID_CLIENT_EXTERN ListContent(Message&, const Variant::List&); QPID_CLIENT_EXTERN ~ListContent(); QPID_CLIENT_EXTERN const_iterator begin() const; diff --git a/qpid/cpp/include/qpid/messaging/MapContent.h b/qpid/cpp/include/qpid/messaging/MapContent.h index b05cb31295..3a80a38732 100644 --- a/qpid/cpp/include/qpid/messaging/MapContent.h +++ b/qpid/cpp/include/qpid/messaging/MapContent.h @@ -47,6 +47,7 @@ class MapContent typedef std::map::reverse_iterator reverse_iterator; QPID_CLIENT_EXTERN MapContent(Message&); + QPID_CLIENT_EXTERN MapContent(Message&, const Variant::Map&); QPID_CLIENT_EXTERN ~MapContent(); QPID_CLIENT_EXTERN const_iterator begin() const; -- cgit v1.2.1 From a68130eb13c7082e23f235bf2c779cf5e278771a Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Wed, 3 Mar 2010 17:06:44 +0000 Subject: QPID-2402 & QPID-2406: Documented the units for the ttl property of Message. Eliminated use of qpid::sys::Duration from API. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@918575 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Duration.h | 39 ++++++++++++++++++++++++++++++ qpid/cpp/include/qpid/messaging/Message.h | 11 +++++++-- qpid/cpp/include/qpid/messaging/Receiver.h | 10 ++++---- qpid/cpp/include/qpid/messaging/Session.h | 5 ++-- 4 files changed, 56 insertions(+), 9 deletions(-) create mode 100644 qpid/cpp/include/qpid/messaging/Duration.h (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Duration.h b/qpid/cpp/include/qpid/messaging/Duration.h new file mode 100644 index 0000000000..5f95acf04d --- /dev/null +++ b/qpid/cpp/include/qpid/messaging/Duration.h @@ -0,0 +1,39 @@ +#ifndef QPID_MESSAGING_DURATION_H +#define QPID_MESSAGING_DURATION_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#include "qpid/sys/IntegerTypes.h" +#include + +namespace qpid { +namespace messaging { + +/** + * A duration is a time in milliseconds. + */ +typedef uint64_t Duration; +const Duration INFINITE_DURATION = std::numeric_limits::max(); +const Duration DURATION_SEC = 1000; + +}} // namespace qpid::messaging + +#endif /*!QPID_MESSAGING_DURATION_H*/ diff --git a/qpid/cpp/include/qpid/messaging/Message.h b/qpid/cpp/include/qpid/messaging/Message.h index d1028ff330..30e15d79a3 100644 --- a/qpid/cpp/include/qpid/messaging/Message.h +++ b/qpid/cpp/include/qpid/messaging/Message.h @@ -23,6 +23,7 @@ */ #include +#include "qpid/messaging/Duration.h" #include "qpid/messaging/Variant.h" #include "qpid/client/ClientImportExport.h" @@ -67,8 +68,14 @@ class Message QPID_CLIENT_EXTERN void setCorrelationId(const std::string&); QPID_CLIENT_EXTERN const std::string& getCorrelationId() const; - QPID_CLIENT_EXTERN void setTtl(uint64_t ttl); - QPID_CLIENT_EXTERN uint64_t getTtl() const; + /** + * Set the time to live for this message in milliseconds. + */ + QPID_CLIENT_EXTERN void setTtl(Duration ttl); + /** + *Get the time to live for this message in milliseconds. + */ + QPID_CLIENT_EXTERN Duration getTtl() const; QPID_CLIENT_EXTERN void setDurable(bool durable); QPID_CLIENT_EXTERN bool getDurable() const; diff --git a/qpid/cpp/include/qpid/messaging/Receiver.h b/qpid/cpp/include/qpid/messaging/Receiver.h index 0923178065..bc1f39bfc1 100644 --- a/qpid/cpp/include/qpid/messaging/Receiver.h +++ b/qpid/cpp/include/qpid/messaging/Receiver.h @@ -24,7 +24,7 @@ #include "qpid/Exception.h" #include "qpid/client/ClientImportExport.h" #include "qpid/client/Handle.h" -#include "qpid/sys/Time.h" +#include "qpid/messaging/Duration.h" namespace qpid { namespace client { @@ -57,14 +57,14 @@ class Receiver : public qpid::client::Handle * available. Returns false if there is no message to give after * waiting for the specified timeout. */ - QPID_CLIENT_EXTERN bool get(Message& message, qpid::sys::Duration timeout=qpid::sys::TIME_INFINITE); + QPID_CLIENT_EXTERN bool get(Message& message, Duration timeout=INFINITE_DURATION); /** * Retrieves a message from this receivers local queue, or waits * for upto the specified timeout for a message to become * available. Throws NoMessageAvailable if there is no * message to give after waiting for the specified timeout. */ - QPID_CLIENT_EXTERN Message get(qpid::sys::Duration timeout=qpid::sys::TIME_INFINITE); + QPID_CLIENT_EXTERN Message get(Duration timeout=INFINITE_DURATION); /** * Retrieves a message for this receivers subscription or waits * for upto the specified timeout for one to become @@ -72,7 +72,7 @@ class Receiver : public qpid::client::Handle * that there is no message for the subscription this receiver is * serving before returning false. */ - QPID_CLIENT_EXTERN bool fetch(Message& message, qpid::sys::Duration timeout=qpid::sys::TIME_INFINITE); + QPID_CLIENT_EXTERN bool fetch(Message& message, Duration timeout=INFINITE_DURATION); /** * Retrieves a message for this receivers subscription or waits * for up to the specified timeout for one to become @@ -80,7 +80,7 @@ class Receiver : public qpid::client::Handle * that there is no message for the subscription this receiver is * serving before throwing an exception. */ - QPID_CLIENT_EXTERN Message fetch(qpid::sys::Duration timeout=qpid::sys::TIME_INFINITE); + QPID_CLIENT_EXTERN Message fetch(Duration timeout=INFINITE_DURATION); /** * Sets the capacity for the receiver. The capacity determines how * many incoming messages can be held in the receiver before being diff --git a/qpid/cpp/include/qpid/messaging/Session.h b/qpid/cpp/include/qpid/messaging/Session.h index 46372cb849..87f69f268a 100644 --- a/qpid/cpp/include/qpid/messaging/Session.h +++ b/qpid/cpp/include/qpid/messaging/Session.h @@ -22,6 +22,7 @@ * */ #include "qpid/Exception.h" +#include "qpid/messaging/Duration.h" #include "qpid/client/ClientImportExport.h" #include "qpid/client/Handle.h" #include "qpid/sys/Time.h" @@ -100,7 +101,7 @@ class Session : public qpid::client::Handle * which case the passed in receiver reference will be set to the * receiver for that message or fals if no message was available. */ - QPID_CLIENT_EXTERN bool nextReceiver(Receiver&, qpid::sys::Duration timeout=qpid::sys::TIME_INFINITE); + QPID_CLIENT_EXTERN bool nextReceiver(Receiver&, Duration timeout=INFINITE_DURATION); /** * Returns the receiver for the next available message. If there * are no available messages at present the call will block for up @@ -108,7 +109,7 @@ class Session : public qpid::client::Handle * Receiver::NoMessageAvailable if no message became available in * time. */ - QPID_CLIENT_EXTERN Receiver nextReceiver(qpid::sys::Duration timeout=qpid::sys::TIME_INFINITE); + QPID_CLIENT_EXTERN Receiver nextReceiver(Duration timeout=INFINITE_DURATION); /** * Create a new sender through which messages can be sent to the -- cgit v1.2.1 From ab38a2dd7c26749f9bbeb3b3d0999c41cc146a80 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Thu, 11 Mar 2010 18:23:46 +0000 Subject: QPID-2382: Created separate utility class for handling updates from failover exchange; cleaned up reconnection options git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@921971 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Address.h | 17 ++++++++++------- qpid/cpp/include/qpid/messaging/Connection.h | 27 +++++++++++++++------------ 2 files changed, 25 insertions(+), 19 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Address.h b/qpid/cpp/include/qpid/messaging/Address.h index 745949792d..f3ca30bcd4 100644 --- a/qpid/cpp/include/qpid/messaging/Address.h +++ b/qpid/cpp/include/qpid/messaging/Address.h @@ -79,6 +79,11 @@ class AddressImpl; * nide when a sender or receiver is cancelled. Can be one of always, * never, sender or receiver. * + * reliabilityindicates the level of + * reliability expected. Can be one of unreliable, at-most-once, + * at-least-once or exactly-once (the latter is not yet correctly + * supported). + * * node-propertiesA nested map of properties of the addressed * entity or 'node'. These can be used when automatically creating it, * or to assert certain properties. @@ -109,16 +114,14 @@ class AddressImpl; * receiver does not want to receiver messages published to the topic * that originate from a sender on the same connection * - * browse(only relevant for queues) specifies that the receiver - * does not wish to consume the messages, but merely browse them + * mode(only relevant for queues) + * indicates whether the subscribe should consume (the default) or + * merely browse the messages. Valid values are 'consume' and + * 'browse' * * durable(only relevant for topics at present) specifies that a * durable subscription is required * - * reliabilityindicates the level of reliability that the receiver - * expects. Can be one of unreliable, at-most-once, at-least-once or - * exactly-once (the latter is not yet correctly supported). - * * filter(only relevant for topics at present) allows bindings to * be created for the queue that match the given criteria (or list of * criteria). @@ -133,7 +136,7 @@ class AddressImpl; *
  • exclusive, which requests an exclusive subscription and * is only relevant for queues
  • * - *
  • x-queue-arguments, which ais only relevant for topics and + *
  • x-queue-arguments, which is only relevant for topics and * allows arguments to the queue-declare for the subscription * queue to be specified
  • * diff --git a/qpid/cpp/include/qpid/messaging/Connection.h b/qpid/cpp/include/qpid/messaging/Connection.h index 36392da0b2..e2d1cc2ed4 100644 --- a/qpid/cpp/include/qpid/messaging/Connection.h +++ b/qpid/cpp/include/qpid/messaging/Connection.h @@ -58,29 +58,32 @@ class Connection : public qpid::client::Handle * sasl-mechanism * sasl-min-ssf * sasl-max-ssf + * protocol + * urls * - * (note also bounds, locale, max-channels and max-framesize, but not sure whether those should be docuemented here) + * (note also bounds, locale, max-channels and max-framesize, but + * not sure whether those should be documented here) * - * Retry behaviour can be controlled through the following options: - * - * reconnection-timeout - determines how long it will try to - * reconnect for -1 means forever, 0 - * means don't try to reconnect - * min-retry-interval - * max-retry-interval + * Reconnect behaviour can be controlled through the following options: * - * The retry-interval is the time that the client waits for - * after a failed attempt to reconnect before retrying. It + * reconnect: true/false (enables/disables reconnect entirely) + * reconnect-timeout: number of seconds (give up and report failure after specified time) + * reconnect-limit: n (give up and report failure after specified number of attempts) + * reconnect-interval-min: number of seconds (initial delay between failed reconnection attempts) + * reconnect-interval-max: number of seconds (maximum delay between failed reconnection attempts) + * reconnect-interval: shorthand for setting the same reconnect_interval_min/max + * + * The reconnect-interval is the time that the client waits + * for after a failed attempt to reconnect before retrying. It * starts at the value of the min-retry-interval and is * doubled every failure until the value of max-retry-interval * is reached. - * - * */ QPID_CLIENT_EXTERN Connection(const Variant::Map& options = Variant::Map()); QPID_CLIENT_EXTERN Connection(const std::string& options); QPID_CLIENT_EXTERN ~Connection(); QPID_CLIENT_EXTERN Connection& operator=(const Connection&); + QPID_CLIENT_EXTERN void setOption(const std::string& name, const Variant& value); QPID_CLIENT_EXTERN void open(const std::string& url); QPID_CLIENT_EXTERN void close(); QPID_CLIENT_EXTERN Session newSession(bool transactional, const std::string& name = std::string()); -- cgit v1.2.1 From d0c2371a44eebc4e54e2598846f4218cb1f0d32c Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Fri, 12 Mar 2010 08:20:48 +0000 Subject: QPID-2382: Checked in missing files from last commit git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@922175 13f79535-47bb-0310-9956-ffa450edef68 --- .../include/qpid/client/amqp0_10/FailoverUpdates.h | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 qpid/cpp/include/qpid/client/amqp0_10/FailoverUpdates.h (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/client/amqp0_10/FailoverUpdates.h b/qpid/cpp/include/qpid/client/amqp0_10/FailoverUpdates.h new file mode 100644 index 0000000000..0c1883553e --- /dev/null +++ b/qpid/cpp/include/qpid/client/amqp0_10/FailoverUpdates.h @@ -0,0 +1,53 @@ +#ifndef QPID_CLIENT_AMQP0_10_FAILOVERUPDATES_H +#define QPID_CLIENT_AMQP0_10_FAILOVERUPDATES_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +namespace qpid { + +namespace messaging { +class Connection; +} + +namespace client { +namespace amqp0_10 { + +struct FailoverUpdatesImpl; +/** + * A utility to listen for updates on cluster membership - published + * via the amq.failover exchange - and update the list of known urls + * for a connection accordingly. + */ +class FailoverUpdates +{ + public: + FailoverUpdates(qpid::messaging::Connection& connection); + ~FailoverUpdates(); + private: + FailoverUpdatesImpl* impl; + + //no need to copy instances of this class + FailoverUpdates(const FailoverUpdates&); + FailoverUpdates& operator=(const FailoverUpdates&); +}; +}}} // namespace qpid::client::amqp0_10 + +#endif /*!QPID_CLIENT_AMQP0_10_FAILOVERUPDATES_H*/ -- cgit v1.2.1 From 0bf534bb04b032d162a520643077420353e1e922 Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Fri, 12 Mar 2010 20:20:55 +0000 Subject: Correct Windows qmf lib build so that the library entry points get exported without any warning git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@922413 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/agent/QmfAgentImportExport.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/agent/QmfAgentImportExport.h b/qpid/cpp/include/qpid/agent/QmfAgentImportExport.h index 9eee4a18fd..e41425a7ba 100644 --- a/qpid/cpp/include/qpid/agent/QmfAgentImportExport.h +++ b/qpid/cpp/include/qpid/agent/QmfAgentImportExport.h @@ -21,7 +21,7 @@ */ #if defined(WIN32) && !defined(QPID_DECLARE_STATIC) -#if defined(QMF_AGENT_EXPORT) || defined (qmfagent_EXPORTS) +#if defined (qmf_EXPORTS) #define QMF_AGENT_EXTERN __declspec(dllexport) #else #define QMF_AGENT_EXTERN __declspec(dllimport) -- cgit v1.2.1 From 610ce55e9e7e9b8dfb8a81753fc7eba617d4641b Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Fri, 12 Mar 2010 20:27:12 +0000 Subject: Export FailoverUpdate symbols necessary to link on Windows git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@922414 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/client/amqp0_10/FailoverUpdates.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/client/amqp0_10/FailoverUpdates.h b/qpid/cpp/include/qpid/client/amqp0_10/FailoverUpdates.h index 0c1883553e..159745e67c 100644 --- a/qpid/cpp/include/qpid/client/amqp0_10/FailoverUpdates.h +++ b/qpid/cpp/include/qpid/client/amqp0_10/FailoverUpdates.h @@ -21,6 +21,8 @@ * under the License. * */ +#include "qpid/client/ClientImportExport.h" + namespace qpid { namespace messaging { @@ -39,8 +41,8 @@ struct FailoverUpdatesImpl; class FailoverUpdates { public: - FailoverUpdates(qpid::messaging::Connection& connection); - ~FailoverUpdates(); + QPID_CLIENT_EXTERN FailoverUpdates(qpid::messaging::Connection& connection); + QPID_CLIENT_EXTERN ~FailoverUpdates(); private: FailoverUpdatesImpl* impl; -- cgit v1.2.1 From 6dcffd3b4215bb242f7a051e52c076d4edf11ef7 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Tue, 16 Mar 2010 18:01:38 +0000 Subject: Removed dependencies in qpid/messaging on qpid/client. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@923908 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Address.h | 2 +- qpid/cpp/include/qpid/messaging/Codec.h | 2 +- qpid/cpp/include/qpid/messaging/Connection.h | 15 ++---- qpid/cpp/include/qpid/messaging/Handle.h | 71 ++++++++++++++++++++++++++ qpid/cpp/include/qpid/messaging/ImportExport.h | 33 ++++++++++++ qpid/cpp/include/qpid/messaging/ListContent.h | 2 +- qpid/cpp/include/qpid/messaging/ListView.h | 2 +- qpid/cpp/include/qpid/messaging/MapContent.h | 2 +- qpid/cpp/include/qpid/messaging/MapView.h | 2 +- qpid/cpp/include/qpid/messaging/Message.h | 6 +-- qpid/cpp/include/qpid/messaging/Receiver.h | 27 +++++----- qpid/cpp/include/qpid/messaging/Sender.h | 15 ++---- qpid/cpp/include/qpid/messaging/Session.h | 34 ++++++------ qpid/cpp/include/qpid/messaging/Uuid.h | 2 +- qpid/cpp/include/qpid/messaging/Variant.h | 2 +- 15 files changed, 153 insertions(+), 64 deletions(-) create mode 100644 qpid/cpp/include/qpid/messaging/Handle.h create mode 100644 qpid/cpp/include/qpid/messaging/ImportExport.h (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Address.h b/qpid/cpp/include/qpid/messaging/Address.h index f3ca30bcd4..55befd2d6d 100644 --- a/qpid/cpp/include/qpid/messaging/Address.h +++ b/qpid/cpp/include/qpid/messaging/Address.h @@ -24,7 +24,7 @@ #include #include "qpid/Exception.h" #include "qpid/messaging/Variant.h" -#include "qpid/client/ClientImportExport.h" +#include "qpid/messaging/ImportExport.h" #include namespace qpid { diff --git a/qpid/cpp/include/qpid/messaging/Codec.h b/qpid/cpp/include/qpid/messaging/Codec.h index bacec5c786..b9b1cc862a 100644 --- a/qpid/cpp/include/qpid/messaging/Codec.h +++ b/qpid/cpp/include/qpid/messaging/Codec.h @@ -22,7 +22,7 @@ * */ #include -#include "qpid/client/ClientImportExport.h" +#include "qpid/messaging/ImportExport.h" namespace qpid { namespace messaging { diff --git a/qpid/cpp/include/qpid/messaging/Connection.h b/qpid/cpp/include/qpid/messaging/Connection.h index e2d1cc2ed4..7f324cea1e 100644 --- a/qpid/cpp/include/qpid/messaging/Connection.h +++ b/qpid/cpp/include/qpid/messaging/Connection.h @@ -22,19 +22,14 @@ * */ #include -#include "qpid/client/ClientImportExport.h" -#include "qpid/client/Handle.h" +#include "qpid/messaging/ImportExport.h" +#include "qpid/messaging/Handle.h" #include "qpid/messaging/Variant.h" namespace qpid { -namespace client { - -template class PrivateImplRef; - -} - namespace messaging { +template class PrivateImplRef; class ConnectionImpl; class Session; @@ -43,7 +38,7 @@ struct InvalidOptionString : public qpid::Exception InvalidOptionString(const std::string& msg); }; -class Connection : public qpid::client::Handle +class Connection : public qpid::messaging::Handle { public: QPID_CLIENT_EXTERN Connection(ConnectionImpl* impl); @@ -92,7 +87,7 @@ class Connection : public qpid::client::Handle QPID_CLIENT_EXTERN Session getSession(const std::string& name) const; private: - friend class qpid::client::PrivateImplRef; + friend class qpid::messaging::PrivateImplRef; }; diff --git a/qpid/cpp/include/qpid/messaging/Handle.h b/qpid/cpp/include/qpid/messaging/Handle.h new file mode 100644 index 0000000000..c528c39e19 --- /dev/null +++ b/qpid/cpp/include/qpid/messaging/Handle.h @@ -0,0 +1,71 @@ +#ifndef QPID_MESSAGING_HANDLE_H +#define QPID_MESSAGING_HANDLE_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/messaging/ImportExport.h" + +namespace qpid { +namespace messaging { + +template class PrivateImplRef; + +/** + * A handle is like a pointer: refers to an underlying implementation object. + * Copying the handle does not copy the object. + * + * Handles can be null, like a 0 pointer. Use isValid(), isNull() or the + * conversion to bool to test for a null handle. + */ +template class Handle { + public: + + /**@return true if handle is valid, i.e. not null. */ + QPID_CLIENT_EXTERN bool isValid() const { return impl; } + + /**@return true if handle is null. It is an error to call any function on a null handle. */ + QPID_CLIENT_EXTERN bool isNull() const { return !impl; } + + /** Conversion to bool supports idiom if (handle) { handle->... } */ + QPID_CLIENT_EXTERN operator bool() const { return impl; } + + /** Operator ! supports idiom if (!handle) { do_if_handle_is_null(); } */ + QPID_CLIENT_EXTERN bool operator !() const { return !impl; } + + void swap(Handle& h) { T* t = h.impl; h.impl = impl; impl = t; } + + protected: + typedef T Impl; + QPID_CLIENT_EXTERN Handle() :impl() {} + + // Not implemented,subclasses must implement. + QPID_CLIENT_EXTERN Handle(const Handle&); + QPID_CLIENT_EXTERN Handle& operator=(const Handle&); + + Impl* impl; + + friend class PrivateImplRef; +}; + +}} // namespace qpid::messaging + +#endif /*!QPID_MESSAGING_HANDLE_H*/ diff --git a/qpid/cpp/include/qpid/messaging/ImportExport.h b/qpid/cpp/include/qpid/messaging/ImportExport.h new file mode 100644 index 0000000000..7113b437be --- /dev/null +++ b/qpid/cpp/include/qpid/messaging/ImportExport.h @@ -0,0 +1,33 @@ +#ifndef QPID_MESSAGING_IMPORTEXPORT_H +#define QPID_MESSAGING_IMPORTEXPORT_H + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#if defined(WIN32) && !defined(QPID_DECLARE_STATIC) +#if defined(CLIENT_EXPORT) || defined (qpidclient_EXPORTS) +#define QPID_CLIENT_EXTERN __declspec(dllexport) +#else +#define QPID_CLIENT_EXTERN __declspec(dllimport) +#endif +#else +#define QPID_CLIENT_EXTERN +#endif + +#endif /*!QPID_MESSAGING_IMPORTEXPORT_H*/ diff --git a/qpid/cpp/include/qpid/messaging/ListContent.h b/qpid/cpp/include/qpid/messaging/ListContent.h index f57a920a88..3db8a8eac6 100644 --- a/qpid/cpp/include/qpid/messaging/ListContent.h +++ b/qpid/cpp/include/qpid/messaging/ListContent.h @@ -21,7 +21,7 @@ * under the License. * */ -#include "qpid/client/ClientImportExport.h" +#include "qpid/messaging/ImportExport.h" #include "Variant.h" namespace qpid { diff --git a/qpid/cpp/include/qpid/messaging/ListView.h b/qpid/cpp/include/qpid/messaging/ListView.h index 4970a20072..d7c3536a9c 100644 --- a/qpid/cpp/include/qpid/messaging/ListView.h +++ b/qpid/cpp/include/qpid/messaging/ListView.h @@ -22,7 +22,7 @@ * */ -#include "qpid/client/ClientImportExport.h" +#include "qpid/messaging/ImportExport.h" #include "Variant.h" namespace qpid { diff --git a/qpid/cpp/include/qpid/messaging/MapContent.h b/qpid/cpp/include/qpid/messaging/MapContent.h index 3a80a38732..78ef51e593 100644 --- a/qpid/cpp/include/qpid/messaging/MapContent.h +++ b/qpid/cpp/include/qpid/messaging/MapContent.h @@ -22,7 +22,7 @@ * */ -#include "qpid/client/ClientImportExport.h" +#include "qpid/messaging/ImportExport.h" #include "Variant.h" #include #include diff --git a/qpid/cpp/include/qpid/messaging/MapView.h b/qpid/cpp/include/qpid/messaging/MapView.h index 910dfca5c2..baa999b4ad 100644 --- a/qpid/cpp/include/qpid/messaging/MapView.h +++ b/qpid/cpp/include/qpid/messaging/MapView.h @@ -21,7 +21,7 @@ * under the License. * */ -#include "qpid/client/ClientImportExport.h" +#include "qpid/messaging/ImportExport.h" #include "Variant.h" #include #include diff --git a/qpid/cpp/include/qpid/messaging/Message.h b/qpid/cpp/include/qpid/messaging/Message.h index 30e15d79a3..21404d482b 100644 --- a/qpid/cpp/include/qpid/messaging/Message.h +++ b/qpid/cpp/include/qpid/messaging/Message.h @@ -25,12 +25,9 @@ #include #include "qpid/messaging/Duration.h" #include "qpid/messaging/Variant.h" -#include "qpid/client/ClientImportExport.h" +#include "qpid/messaging/ImportExport.h" namespace qpid { -namespace client { -} - namespace messaging { class Address; @@ -87,6 +84,7 @@ class Message QPID_CLIENT_EXTERN const std::string& getContent() const; QPID_CLIENT_EXTERN std::string& getContent(); + QPID_CLIENT_EXTERN void setContent(const std::string&); QPID_CLIENT_EXTERN void setContent(const char* chars, size_t count); QPID_CLIENT_EXTERN void getContent(std::pair& content) const; diff --git a/qpid/cpp/include/qpid/messaging/Receiver.h b/qpid/cpp/include/qpid/messaging/Receiver.h index bc1f39bfc1..80b58106d7 100644 --- a/qpid/cpp/include/qpid/messaging/Receiver.h +++ b/qpid/cpp/include/qpid/messaging/Receiver.h @@ -22,19 +22,15 @@ * */ #include "qpid/Exception.h" -#include "qpid/client/ClientImportExport.h" -#include "qpid/client/Handle.h" +#include "qpid/messaging/ImportExport.h" +#include "qpid/messaging/Handle.h" #include "qpid/messaging/Duration.h" namespace qpid { -namespace client { +namespace messaging { template class PrivateImplRef; -} - -namespace messaging { - class Message; class ReceiverImpl; class Session; @@ -42,7 +38,7 @@ class Session; /** * Interface through which messages are received. */ -class Receiver : public qpid::client::Handle +class Receiver : public qpid::messaging::Handle { public: struct NoMessageAvailable : qpid::Exception {}; @@ -60,14 +56,16 @@ class Receiver : public qpid::client::Handle QPID_CLIENT_EXTERN bool get(Message& message, Duration timeout=INFINITE_DURATION); /** * Retrieves a message from this receivers local queue, or waits - * for upto the specified timeout for a message to become - * available. Throws NoMessageAvailable if there is no - * message to give after waiting for the specified timeout. + * for up to the specified timeout for a message to become + * available. + * + *@exception NoMessageAvailable if there is no message to give + * after waiting for the specified timeout. */ QPID_CLIENT_EXTERN Message get(Duration timeout=INFINITE_DURATION); /** * Retrieves a message for this receivers subscription or waits - * for upto the specified timeout for one to become + * for up to the specified timeout for one to become * available. Unlike get() this method will check with the server * that there is no message for the subscription this receiver is * serving before returning false. @@ -79,6 +77,9 @@ class Receiver : public qpid::client::Handle * available. Unlike get() this method will check with the server * that there is no message for the subscription this receiver is * serving before throwing an exception. + * + *@exception NoMessageAvailable if there is no message to give + * after waiting for the specified timeout. */ QPID_CLIENT_EXTERN Message fetch(Duration timeout=INFINITE_DURATION); /** @@ -123,7 +124,7 @@ class Receiver : public qpid::client::Handle QPID_CLIENT_EXTERN Session getSession() const; private: - friend class qpid::client::PrivateImplRef; + friend class qpid::messaging::PrivateImplRef; }; }} // namespace qpid::messaging diff --git a/qpid/cpp/include/qpid/messaging/Sender.h b/qpid/cpp/include/qpid/messaging/Sender.h index eb8ccc2f84..b7dd015a55 100644 --- a/qpid/cpp/include/qpid/messaging/Sender.h +++ b/qpid/cpp/include/qpid/messaging/Sender.h @@ -21,27 +21,22 @@ * under the License. * */ -#include "qpid/client/ClientImportExport.h" -#include "qpid/client/Handle.h" +#include "qpid/messaging/ImportExport.h" +#include "qpid/messaging/Handle.h" #include "qpid/sys/IntegerTypes.h" #include namespace qpid { -namespace client { - -template class PrivateImplRef; - -} - namespace messaging { +template class PrivateImplRef; class Message; class SenderImpl; class Session; /** * Interface through which messages are sent. */ -class Sender : public qpid::client::Handle +class Sender : public qpid::messaging::Handle { public: QPID_CLIENT_EXTERN Sender(SenderImpl* impl = 0); @@ -79,7 +74,7 @@ class Sender : public qpid::client::Handle */ QPID_CLIENT_EXTERN Session getSession() const; private: - friend class qpid::client::PrivateImplRef; + friend class qpid::messaging::PrivateImplRef; }; }} // namespace qpid::messaging diff --git a/qpid/cpp/include/qpid/messaging/Session.h b/qpid/cpp/include/qpid/messaging/Session.h index 87f69f268a..5375b4d346 100644 --- a/qpid/cpp/include/qpid/messaging/Session.h +++ b/qpid/cpp/include/qpid/messaging/Session.h @@ -23,20 +23,15 @@ */ #include "qpid/Exception.h" #include "qpid/messaging/Duration.h" -#include "qpid/client/ClientImportExport.h" -#include "qpid/client/Handle.h" +#include "qpid/messaging/ImportExport.h" +#include "qpid/messaging/Handle.h" #include "qpid/sys/Time.h" #include namespace qpid { -namespace client { - -template class PrivateImplRef; - -} - namespace messaging { +template class PrivateImplRef; class Address; class Connection; class Message; @@ -55,7 +50,7 @@ struct KeyError : qpid::Exception * A session represents a distinct 'conversation' which can involve * sending and receiving messages to and from different addresses. */ -class Session : public qpid::client::Handle +class Session : public qpid::messaging::Handle { public: QPID_CLIENT_EXTERN Session(SessionImpl* impl = 0); @@ -83,8 +78,8 @@ class Session : public qpid::client::Handle QPID_CLIENT_EXTERN void flush(); /** - * Returns the number of messages received and waiting to be - * fetched. + * Returns the total number of messages received and waiting to be + * fetched by all Receivers belonging to this session. */ QPID_CLIENT_EXTERN uint32_t available(); /** @@ -99,14 +94,15 @@ class Session : public qpid::client::Handle * to the specified timeout waiting for one to arrive. Returns * true if a message was available at the point of return, in * which case the passed in receiver reference will be set to the - * receiver for that message or fals if no message was available. + * receiver for that message or false if no message was available. */ QPID_CLIENT_EXTERN bool nextReceiver(Receiver&, Duration timeout=INFINITE_DURATION); /** * Returns the receiver for the next available message. If there * are no available messages at present the call will block for up - * to the specified timeout waiting for one to arrive. Will throw - * Receiver::NoMessageAvailable if no message became available in + * to the specified timeout waiting for one to arrive. + * + *@exception Receiver::NoMessageAvailable if no message became available in * time. */ QPID_CLIENT_EXTERN Receiver nextReceiver(Duration timeout=INFINITE_DURATION); @@ -126,13 +122,13 @@ class Session : public qpid::client::Handle QPID_CLIENT_EXTERN Receiver createReceiver(const std::string& address); /** - * Returns the sender with the specified name or throws KeyError - * if there is none for that name. + * Returns the sender with the specified name. + *@exception KeyError if there is none for that name. */ QPID_CLIENT_EXTERN Sender getSender(const std::string& name) const; /** - * Returns the receiver with the specified name or throws KeyError - * if there is none for that name. + * Returns the receiver with the specified name. + *@exception KeyError if there is none for that name. */ QPID_CLIENT_EXTERN Receiver getReceiver(const std::string& name) const; /** @@ -142,7 +138,7 @@ class Session : public qpid::client::Handle QPID_CLIENT_EXTERN Connection getConnection() const; private: - friend class qpid::client::PrivateImplRef; + friend class qpid::messaging::PrivateImplRef; }; }} // namespace qpid::messaging diff --git a/qpid/cpp/include/qpid/messaging/Uuid.h b/qpid/cpp/include/qpid/messaging/Uuid.h index bbc9bd7a97..d83f8495b7 100644 --- a/qpid/cpp/include/qpid/messaging/Uuid.h +++ b/qpid/cpp/include/qpid/messaging/Uuid.h @@ -22,7 +22,7 @@ * */ -#include "qpid/client/ClientImportExport.h" +#include "qpid/messaging/ImportExport.h" #include #include diff --git a/qpid/cpp/include/qpid/messaging/Variant.h b/qpid/cpp/include/qpid/messaging/Variant.h index 0bf62a9909..51c6bd98fe 100644 --- a/qpid/cpp/include/qpid/messaging/Variant.h +++ b/qpid/cpp/include/qpid/messaging/Variant.h @@ -28,7 +28,7 @@ #include "Uuid.h" #include "qpid/Exception.h" #include "qpid/sys/IntegerTypes.h" -#include "qpid/client/ClientImportExport.h" +#include "qpid/messaging/ImportExport.h" namespace qpid { namespace messaging { -- cgit v1.2.1 From d0c0c11e83798904672f4bb88cd0fdcc93d4570b Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Thu, 18 Mar 2010 18:37:28 +0000 Subject: QPID-2452: Fixed control over the encoding used when sending a string valued variant. The user is currently responsible for correctly setting any encoding (e.g. utf8). If none is specified it will be transfered as an amqp0-10 vbin. Fixed bug preventing correct assignment of encoding in variants. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@924939 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/framing/FieldValue.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/framing/FieldValue.h b/qpid/cpp/include/qpid/framing/FieldValue.h index f413d5a552..8af1f8dedd 100644 --- a/qpid/cpp/include/qpid/framing/FieldValue.h +++ b/qpid/cpp/include/qpid/framing/FieldValue.h @@ -335,6 +335,16 @@ class Str16Value : public FieldValue { QPID_COMMON_EXTERN Str16Value(const std::string& v); }; +class Var16Value : public FieldValue { + public: + QPID_COMMON_EXTERN Var16Value(const std::string& v, uint8_t code); +}; + +class Var32Value : public FieldValue { + public: + QPID_COMMON_EXTERN Var32Value(const std::string& v, uint8_t code); +}; + class Struct32Value : public FieldValue { public: QPID_COMMON_EXTERN Struct32Value(const std::string& v); -- cgit v1.2.1 From ed9e0f6f6685439791d3af2985ff36a9707ce5e1 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Fri, 19 Mar 2010 17:04:18 +0000 Subject: QPID-664: Prevent dangling pointers when receiver/sender handles stay in scope after connection/session handles goes out of scope. This change require connections to be closed explicitly to avoid leaking memory. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@925332 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Connection.h | 5 +++++ qpid/cpp/include/qpid/messaging/Session.h | 6 ++++++ 2 files changed, 11 insertions(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Connection.h b/qpid/cpp/include/qpid/messaging/Connection.h index 7f324cea1e..b5eeeb2980 100644 --- a/qpid/cpp/include/qpid/messaging/Connection.h +++ b/qpid/cpp/include/qpid/messaging/Connection.h @@ -80,6 +80,11 @@ class Connection : public qpid::messaging::Handle QPID_CLIENT_EXTERN Connection& operator=(const Connection&); QPID_CLIENT_EXTERN void setOption(const std::string& name, const Variant& value); QPID_CLIENT_EXTERN void open(const std::string& url); + /** + * Closes a connection and all sessions associated with it. An + * opened connection must be closed before the last handle is + * allowed to go out of scope. + */ QPID_CLIENT_EXTERN void close(); QPID_CLIENT_EXTERN Session newSession(bool transactional, const std::string& name = std::string()); QPID_CLIENT_EXTERN Session newSession(const std::string& name = std::string()); diff --git a/qpid/cpp/include/qpid/messaging/Session.h b/qpid/cpp/include/qpid/messaging/Session.h index 5375b4d346..032b678c5c 100644 --- a/qpid/cpp/include/qpid/messaging/Session.h +++ b/qpid/cpp/include/qpid/messaging/Session.h @@ -58,6 +58,12 @@ class Session : public qpid::messaging::Handle QPID_CLIENT_EXTERN ~Session(); QPID_CLIENT_EXTERN Session& operator=(const Session&); + /** + * Closes a session and all associated senders and receivers. An + * opened session should be closed before the last handle to it + * goes out of scope. All a connections sessions can be closed by + * a call to Connection::close(). + */ QPID_CLIENT_EXTERN void close(); QPID_CLIENT_EXTERN void commit(); -- cgit v1.2.1 From e7adde6d95152f78a48963539141ddf0999a6827 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Wed, 24 Mar 2010 18:35:11 +0000 Subject: QPID-664: Updates to address options to stay in-line with python client changes in r926604 git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@927144 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Address.h | 111 ++++++++++++------------------ 1 file changed, 43 insertions(+), 68 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Address.h b/qpid/cpp/include/qpid/messaging/Address.h index 55befd2d6d..fd790a613c 100644 --- a/qpid/cpp/include/qpid/messaging/Address.h +++ b/qpid/cpp/include/qpid/messaging/Address.h @@ -65,82 +65,57 @@ class AddressImpl; * * * - * - * - * - * - * + * + * + * + * + * + * + * + * + * + * + * + * + * + * * - * - * - * - * - *
    createIndicate whether the address should be - * automatically created or not. Can be one of always, - * never, sender or receiver. The properties of - * the node to be created can be specified via the node-properties - * option (see below).
    assertIndicate whether or not to assert any specified - * node-properties match the address. Can be one of always, - * never, sender or receiver.
    deleteIndicate whether or not to delete the addressed - * nide when a sender or receiver is cancelled. Can be one of always, - * never, sender or receiver.
    createIndicate whether the address should be automatically created + * or not. Can be one of always, never, + * sender or receiver. The properties of the node + * to be created can be specified via the node options (see + * below). + *
    assertIndicate whether or not to assert any specified node + * properties(see below) match the address. Can be one of + * always, never, sender or + * receiver. + *
    deleteIndicate whether or not to delete the addressed node when a + * sender or receiver is cancelled. Can be one of always, + * never, sender or receiver. + *
    reliabilityindicates the level of - * reliability expected. Can be one of unreliable, at-most-once, - * at-least-once or exactly-once (the latter is not yet correctly - * supported).
    node-propertiesA nested map of properties of the addressed - * entity or 'node'. These can be used when automatically creating it, - * or to assert certain properties. - * - * The valid node-properties are: - *
      - *
    • type - queue or topic
    • - * - *
    • durable - true or false
    • - * - *
    • x-properties - a nested map that can contain implementation or - * protocol specifiec extedned properties. For the amqp 0-10 mapping, - * the fields in queue- or exchange- declare can be specified in here; - * a bindings entry may also be specified, whose value should be an - * array of strings of the form exchange/key; anything else will be - * passed through in the arguments field. - *
    • - *
    - *
    + * + * node + * A nested map describing properties of the addressed + * node. Current properties supported are type (topic or queue), + * durable (boolean), x-declare and x-bindings. + * + * + * + * + * link + * A nested map through which properties of the 'link' from + * sender/receiver to node can be configured. Current propeties + * are name, durable, realiability, x-declare, x-subscribe and + * x-bindings. + * + * * - * For receivers there are some further options of interest: + * For receivers there is one other option of interest: * * - * - * - * * - * - * - * - * - * - * *
    no-local(only relevant for topics at present) specifies that the - * receiver does not want to receiver messages published to the topic - * that originate from a sender on the same connection
    mode(only relevant for queues) * indicates whether the subscribe should consume (the default) or * merely browse the messages. Valid values are 'consume' and * 'browse'
    durable(only relevant for topics at present) specifies that a - * durable subscription is required
    filter(only relevant for topics at present) allows bindings to - * be created for the queue that match the given criteria (or list of - * criteria).
    x-propertiesallows protocol or implementation specific options - * to be specified for a receiver; this is a nested map and currently - * the implementation only recognises two specific nested properties - * within it (all others are passed through in the arguments of the - * message-subscribe command): - * - *
      - *
    • exclusive, which requests an exclusive subscription and - * is only relevant for queues
    • - * - *
    • x-queue-arguments, which is only relevant for topics and - * allows arguments to the queue-declare for the subscription - * queue to be specified
    • - *
    - *
    */ class Address -- cgit v1.2.1 From ade3e9aee3d6b69c5c9f5e250c1c625dc117abf6 Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Fri, 26 Mar 2010 20:49:46 +0000 Subject: Move ManagementAgent class statics to be file static to avoid exposing their types in the header file git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@928054 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/agent/ManagementAgent.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/agent/ManagementAgent.h b/qpid/cpp/include/qpid/agent/ManagementAgent.h index 41b6423624..b6ec82862c 100644 --- a/qpid/cpp/include/qpid/agent/ManagementAgent.h +++ b/qpid/cpp/include/qpid/agent/ManagementAgent.h @@ -24,7 +24,6 @@ #include "qpid/management/ManagementObject.h" #include "qpid/management/ManagementEvent.h" #include "qpid/management/Manageable.h" -#include "qpid/sys/Mutex.h" #include "qpid/client/ConnectionSettings.h" namespace qpid { @@ -45,11 +44,6 @@ class ManagementAgent QMF_AGENT_EXTERN Singleton(bool disableManagement = false); QMF_AGENT_EXTERN ~Singleton(); QMF_AGENT_EXTERN static ManagementAgent* getInstance(); - private: - static sys::Mutex lock; - static bool disabled; - static int refCount; - static ManagementAgent* agent; }; typedef enum { -- cgit v1.2.1 From 7e92a02008a01cc824bc34dd7296791b4d8912e5 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Mon, 29 Mar 2010 16:00:24 +0000 Subject: QPID-664: move Variant and Uuid from messaging to types namespace git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@928814 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/client/amqp0_10/Codecs.h | 8 +- qpid/cpp/include/qpid/messaging/Address.h | 12 +- qpid/cpp/include/qpid/messaging/Codec.h | 8 +- qpid/cpp/include/qpid/messaging/Connection.h | 6 +- qpid/cpp/include/qpid/messaging/ListContent.h | 32 ++--- qpid/cpp/include/qpid/messaging/ListView.h | 12 +- qpid/cpp/include/qpid/messaging/MapContent.h | 22 ++-- qpid/cpp/include/qpid/messaging/MapView.h | 12 +- qpid/cpp/include/qpid/messaging/Message.h | 6 +- qpid/cpp/include/qpid/messaging/Uuid.h | 94 ------------- qpid/cpp/include/qpid/messaging/Variant.h | 174 ------------------------- qpid/cpp/include/qpid/types/Uuid.h | 94 +++++++++++++ qpid/cpp/include/qpid/types/Variant.h | 174 +++++++++++++++++++++++++ 13 files changed, 328 insertions(+), 326 deletions(-) delete mode 100644 qpid/cpp/include/qpid/messaging/Uuid.h delete mode 100644 qpid/cpp/include/qpid/messaging/Variant.h create mode 100644 qpid/cpp/include/qpid/types/Uuid.h create mode 100644 qpid/cpp/include/qpid/types/Variant.h (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/client/amqp0_10/Codecs.h b/qpid/cpp/include/qpid/client/amqp0_10/Codecs.h index 5ef0b9fffe..097cf5877f 100644 --- a/qpid/cpp/include/qpid/client/amqp0_10/Codecs.h +++ b/qpid/cpp/include/qpid/client/amqp0_10/Codecs.h @@ -35,8 +35,8 @@ namespace amqp0_10 { class MapCodec : public qpid::messaging::Codec { public: - void encode(const qpid::messaging::Variant&, std::string&); - void decode(const std::string&, qpid::messaging::Variant&); + void encode(const qpid::types::Variant&, std::string&); + void decode(const std::string&, qpid::types::Variant&); static const std::string contentType; private: @@ -49,8 +49,8 @@ class MapCodec : public qpid::messaging::Codec class ListCodec : public qpid::messaging::Codec { public: - void encode(const qpid::messaging::Variant&, std::string&); - void decode(const std::string&, qpid::messaging::Variant&); + void encode(const qpid::types::Variant&, std::string&); + void decode(const std::string&, qpid::types::Variant&); static const std::string contentType; private: diff --git a/qpid/cpp/include/qpid/messaging/Address.h b/qpid/cpp/include/qpid/messaging/Address.h index fd790a613c..307e0cfa8d 100644 --- a/qpid/cpp/include/qpid/messaging/Address.h +++ b/qpid/cpp/include/qpid/messaging/Address.h @@ -23,7 +23,7 @@ */ #include #include "qpid/Exception.h" -#include "qpid/messaging/Variant.h" +#include "qpid/types/Variant.h" #include "qpid/messaging/ImportExport.h" #include @@ -124,7 +124,7 @@ class Address QPID_CLIENT_EXTERN Address(); QPID_CLIENT_EXTERN Address(const std::string& address); QPID_CLIENT_EXTERN Address(const std::string& name, const std::string& subject, - const Variant::Map& options, const std::string& type = ""); + const qpid::types::Variant::Map& options, const std::string& type = ""); QPID_CLIENT_EXTERN Address(const Address& address); QPID_CLIENT_EXTERN ~Address(); QPID_CLIENT_EXTERN Address& operator=(const Address&); @@ -133,14 +133,14 @@ class Address QPID_CLIENT_EXTERN const std::string& getSubject() const; QPID_CLIENT_EXTERN void setSubject(const std::string&); QPID_CLIENT_EXTERN bool hasSubject() const; - QPID_CLIENT_EXTERN const Variant::Map& getOptions() const; - QPID_CLIENT_EXTERN Variant::Map& getOptions(); - QPID_CLIENT_EXTERN void setOptions(const Variant::Map&); + QPID_CLIENT_EXTERN const qpid::types::Variant::Map& getOptions() const; + QPID_CLIENT_EXTERN qpid::types::Variant::Map& getOptions(); + QPID_CLIENT_EXTERN void setOptions(const qpid::types::Variant::Map&); QPID_CLIENT_EXTERN std::string getType() const; QPID_CLIENT_EXTERN void setType(const std::string&); - QPID_CLIENT_EXTERN const Variant& getOption(const std::string& key) const; + QPID_CLIENT_EXTERN const qpid::types::Variant& getOption(const std::string& key) const; QPID_CLIENT_EXTERN std::string toStr() const; QPID_CLIENT_EXTERN operator bool() const; diff --git a/qpid/cpp/include/qpid/messaging/Codec.h b/qpid/cpp/include/qpid/messaging/Codec.h index b9b1cc862a..a69baa5af1 100644 --- a/qpid/cpp/include/qpid/messaging/Codec.h +++ b/qpid/cpp/include/qpid/messaging/Codec.h @@ -25,9 +25,11 @@ #include "qpid/messaging/ImportExport.h" namespace qpid { +namespace types{ +class Variant; +} namespace messaging { -class Variant; /** * */ @@ -35,8 +37,8 @@ class Codec { public: QPID_CLIENT_EXTERN virtual ~Codec() {} - virtual void encode(const Variant&, std::string&) = 0; - virtual void decode(const std::string&, Variant&) = 0; + virtual void encode(const qpid::types::Variant&, std::string&) = 0; + virtual void decode(const std::string&, qpid::types::Variant&) = 0; private: }; }} // namespace qpid::messaging diff --git a/qpid/cpp/include/qpid/messaging/Connection.h b/qpid/cpp/include/qpid/messaging/Connection.h index b5eeeb2980..24fb9650d8 100644 --- a/qpid/cpp/include/qpid/messaging/Connection.h +++ b/qpid/cpp/include/qpid/messaging/Connection.h @@ -24,7 +24,7 @@ #include #include "qpid/messaging/ImportExport.h" #include "qpid/messaging/Handle.h" -#include "qpid/messaging/Variant.h" +#include "qpid/types/Variant.h" namespace qpid { namespace messaging { @@ -74,11 +74,11 @@ class Connection : public qpid::messaging::Handle * doubled every failure until the value of max-retry-interval * is reached. */ - QPID_CLIENT_EXTERN Connection(const Variant::Map& options = Variant::Map()); + QPID_CLIENT_EXTERN Connection(const qpid::types::Variant::Map& options = qpid::types::Variant::Map()); QPID_CLIENT_EXTERN Connection(const std::string& options); QPID_CLIENT_EXTERN ~Connection(); QPID_CLIENT_EXTERN Connection& operator=(const Connection&); - QPID_CLIENT_EXTERN void setOption(const std::string& name, const Variant& value); + QPID_CLIENT_EXTERN void setOption(const std::string& name, const qpid::types::Variant& value); QPID_CLIENT_EXTERN void open(const std::string& url); /** * Closes a connection and all sessions associated with it. An diff --git a/qpid/cpp/include/qpid/messaging/ListContent.h b/qpid/cpp/include/qpid/messaging/ListContent.h index 3db8a8eac6..1e7d34af54 100644 --- a/qpid/cpp/include/qpid/messaging/ListContent.h +++ b/qpid/cpp/include/qpid/messaging/ListContent.h @@ -22,7 +22,7 @@ * */ #include "qpid/messaging/ImportExport.h" -#include "Variant.h" +#include "qpid/types/Variant.h" namespace qpid { namespace messaging { @@ -36,13 +36,13 @@ class Message; class ListContent { public: - typedef Variant::List::iterator iterator; - typedef Variant::List::reverse_iterator reverse_iterator; - typedef Variant::List::const_iterator const_iterator; - typedef Variant::List::const_reverse_iterator const_reverse_iterator; + typedef qpid::types::Variant::List::iterator iterator; + typedef qpid::types::Variant::List::reverse_iterator reverse_iterator; + typedef qpid::types::Variant::List::const_iterator const_iterator; + typedef qpid::types::Variant::List::const_reverse_iterator const_reverse_iterator; QPID_CLIENT_EXTERN ListContent(Message&); - QPID_CLIENT_EXTERN ListContent(Message&, const Variant::List&); + QPID_CLIENT_EXTERN ListContent(Message&, const qpid::types::Variant::List&); QPID_CLIENT_EXTERN ~ListContent(); QPID_CLIENT_EXTERN const_iterator begin() const; @@ -57,27 +57,27 @@ class ListContent QPID_CLIENT_EXTERN bool empty() const; QPID_CLIENT_EXTERN size_t size() const; - QPID_CLIENT_EXTERN const Variant& front() const; - QPID_CLIENT_EXTERN Variant& front(); - QPID_CLIENT_EXTERN const Variant& back() const; - QPID_CLIENT_EXTERN Variant& back(); + QPID_CLIENT_EXTERN const qpid::types::Variant& front() const; + QPID_CLIENT_EXTERN qpid::types::Variant& front(); + QPID_CLIENT_EXTERN const qpid::types::Variant& back() const; + QPID_CLIENT_EXTERN qpid::types::Variant& back(); - QPID_CLIENT_EXTERN void push_front(const Variant&); - QPID_CLIENT_EXTERN void push_back(const Variant&); + QPID_CLIENT_EXTERN void push_front(const qpid::types::Variant&); + QPID_CLIENT_EXTERN void push_back(const qpid::types::Variant&); QPID_CLIENT_EXTERN void pop_front(); QPID_CLIENT_EXTERN void pop_back(); - QPID_CLIENT_EXTERN iterator insert(iterator position, const Variant&); - QPID_CLIENT_EXTERN void insert(iterator position, size_t n, const Variant&); + QPID_CLIENT_EXTERN iterator insert(iterator position, const qpid::types::Variant&); + QPID_CLIENT_EXTERN void insert(iterator position, size_t n, const qpid::types::Variant&); QPID_CLIENT_EXTERN iterator erase(iterator position); QPID_CLIENT_EXTERN iterator erase(iterator first, iterator last); QPID_CLIENT_EXTERN void clear(); QPID_CLIENT_EXTERN void encode(); - QPID_CLIENT_EXTERN const Variant::List& asList() const; - QPID_CLIENT_EXTERN Variant::List& asList(); + QPID_CLIENT_EXTERN const qpid::types::Variant::List& asList() const; + QPID_CLIENT_EXTERN qpid::types::Variant::List& asList(); private: ListContentImpl* impl; diff --git a/qpid/cpp/include/qpid/messaging/ListView.h b/qpid/cpp/include/qpid/messaging/ListView.h index d7c3536a9c..dce82a657c 100644 --- a/qpid/cpp/include/qpid/messaging/ListView.h +++ b/qpid/cpp/include/qpid/messaging/ListView.h @@ -23,7 +23,7 @@ */ #include "qpid/messaging/ImportExport.h" -#include "Variant.h" +#include "qpid/types/Variant.h" namespace qpid { namespace messaging { @@ -37,8 +37,8 @@ class Message; class ListView { public: - typedef Variant::List::const_iterator const_iterator; - typedef Variant::List::const_reverse_iterator const_reverse_iterator; + typedef qpid::types::Variant::List::const_iterator const_iterator; + typedef qpid::types::Variant::List::const_reverse_iterator const_reverse_iterator; QPID_CLIENT_EXTERN ListView(const Message&); QPID_CLIENT_EXTERN ~ListView(); @@ -52,10 +52,10 @@ class ListView QPID_CLIENT_EXTERN bool empty() const; QPID_CLIENT_EXTERN size_t size() const; - QPID_CLIENT_EXTERN const Variant& front() const; - QPID_CLIENT_EXTERN const Variant& back() const; + QPID_CLIENT_EXTERN const qpid::types::Variant& front() const; + QPID_CLIENT_EXTERN const qpid::types::Variant& back() const; - QPID_CLIENT_EXTERN const Variant::List& asList() const; + QPID_CLIENT_EXTERN const qpid::types::Variant::List& asList() const; private: ListViewImpl* impl; }; diff --git a/qpid/cpp/include/qpid/messaging/MapContent.h b/qpid/cpp/include/qpid/messaging/MapContent.h index 78ef51e593..863eaed786 100644 --- a/qpid/cpp/include/qpid/messaging/MapContent.h +++ b/qpid/cpp/include/qpid/messaging/MapContent.h @@ -23,7 +23,7 @@ */ #include "qpid/messaging/ImportExport.h" -#include "Variant.h" +#include "qpid/types/Variant.h" #include #include @@ -40,14 +40,14 @@ class MapContent { public: typedef std::string key_type; - typedef std::pair value_type; - typedef std::map::const_iterator const_iterator; - typedef std::map::iterator iterator; - typedef std::map::const_reverse_iterator const_reverse_iterator; - typedef std::map::reverse_iterator reverse_iterator; + typedef std::pair value_type; + typedef std::map::const_iterator const_iterator; + typedef std::map::iterator iterator; + typedef std::map::const_reverse_iterator const_reverse_iterator; + typedef std::map::reverse_iterator reverse_iterator; QPID_CLIENT_EXTERN MapContent(Message&); - QPID_CLIENT_EXTERN MapContent(Message&, const Variant::Map&); + QPID_CLIENT_EXTERN MapContent(Message&, const qpid::types::Variant::Map&); QPID_CLIENT_EXTERN ~MapContent(); QPID_CLIENT_EXTERN const_iterator begin() const; @@ -64,8 +64,8 @@ class MapContent QPID_CLIENT_EXTERN const_iterator find(const key_type&) const; QPID_CLIENT_EXTERN iterator find(const key_type&); - QPID_CLIENT_EXTERN const Variant& operator[](const key_type&) const; - QPID_CLIENT_EXTERN Variant& operator[](const key_type&); + QPID_CLIENT_EXTERN const qpid::types::Variant& operator[](const key_type&) const; + QPID_CLIENT_EXTERN qpid::types::Variant& operator[](const key_type&); QPID_CLIENT_EXTERN std::pair insert(const value_type&); QPID_CLIENT_EXTERN iterator insert(iterator position, const value_type&); @@ -76,8 +76,8 @@ class MapContent QPID_CLIENT_EXTERN void encode(); - QPID_CLIENT_EXTERN const std::map& asMap() const; - QPID_CLIENT_EXTERN std::map& asMap(); + QPID_CLIENT_EXTERN const std::map& asMap() const; + QPID_CLIENT_EXTERN std::map& asMap(); private: MapContentImpl* impl; diff --git a/qpid/cpp/include/qpid/messaging/MapView.h b/qpid/cpp/include/qpid/messaging/MapView.h index baa999b4ad..e359a9d929 100644 --- a/qpid/cpp/include/qpid/messaging/MapView.h +++ b/qpid/cpp/include/qpid/messaging/MapView.h @@ -22,7 +22,7 @@ * */ #include "qpid/messaging/ImportExport.h" -#include "Variant.h" +#include "qpid/types/Variant.h" #include #include @@ -39,9 +39,9 @@ class MapView { public: typedef std::string key_type; - typedef std::pair value_type; - typedef std::map::const_iterator const_iterator; - typedef std::map::const_reverse_iterator const_reverse_iterator; + typedef std::pair value_type; + typedef std::map::const_iterator const_iterator; + typedef std::map::const_reverse_iterator const_reverse_iterator; QPID_CLIENT_EXTERN MapView(const Message&); QPID_CLIENT_EXTERN ~MapView(); @@ -56,9 +56,9 @@ class MapView QPID_CLIENT_EXTERN size_t size() const; QPID_CLIENT_EXTERN const_iterator find(const key_type&) const; - QPID_CLIENT_EXTERN const Variant& operator[](const key_type&) const; + QPID_CLIENT_EXTERN const qpid::types::Variant& operator[](const key_type&) const; - QPID_CLIENT_EXTERN const std::map& asMap() const; + QPID_CLIENT_EXTERN const std::map& asMap() const; private: MapViewImpl* impl; }; diff --git a/qpid/cpp/include/qpid/messaging/Message.h b/qpid/cpp/include/qpid/messaging/Message.h index 21404d482b..04923ee03b 100644 --- a/qpid/cpp/include/qpid/messaging/Message.h +++ b/qpid/cpp/include/qpid/messaging/Message.h @@ -24,7 +24,7 @@ #include #include "qpid/messaging/Duration.h" -#include "qpid/messaging/Variant.h" +#include "qpid/types/Variant.h" #include "qpid/messaging/ImportExport.h" namespace qpid { @@ -79,8 +79,8 @@ class Message QPID_CLIENT_EXTERN bool isRedelivered() const; - QPID_CLIENT_EXTERN const Variant::Map& getHeaders() const; - QPID_CLIENT_EXTERN Variant::Map& getHeaders(); + QPID_CLIENT_EXTERN const qpid::types::Variant::Map& getHeaders() const; + QPID_CLIENT_EXTERN qpid::types::Variant::Map& getHeaders(); QPID_CLIENT_EXTERN const std::string& getContent() const; QPID_CLIENT_EXTERN std::string& getContent(); diff --git a/qpid/cpp/include/qpid/messaging/Uuid.h b/qpid/cpp/include/qpid/messaging/Uuid.h deleted file mode 100644 index d83f8495b7..0000000000 --- a/qpid/cpp/include/qpid/messaging/Uuid.h +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef QPID_MESSAGING_UUID_H -#define QPID_MESSAGING_UUID_H - -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -#include "qpid/messaging/ImportExport.h" -#include -#include - -namespace qpid { -namespace messaging { - -class Uuid -{ - public: - static const size_t SIZE; - /** - * If unique is true, this will generate a new unique uuid, if not - * it will construct a null uuid. - */ - QPID_CLIENT_EXTERN Uuid(bool unique=false); - QPID_CLIENT_EXTERN Uuid(const Uuid&); - QPID_CLIENT_EXTERN Uuid& operator=(const Uuid&); - /** Copy the UUID from data16, which must point to a 16-byte UUID */ - QPID_CLIENT_EXTERN Uuid(const unsigned char* data16); - - /** Set to a new unique identifier. */ - QPID_CLIENT_EXTERN void generate(); - - /** Set to all zeros. */ - QPID_CLIENT_EXTERN void clear(); - - /** Test for null (all zeros). */ - QPID_CLIENT_EXTERN bool isNull() const; - QPID_CLIENT_EXTERN operator bool() const; - QPID_CLIENT_EXTERN bool operator!() const; - - /** String value in format 1b4e28ba-2fa1-11d2-883f-b9a761bde3fb. */ - QPID_CLIENT_EXTERN std::string str() const; - - QPID_CLIENT_EXTERN size_t size() const; - QPID_CLIENT_EXTERN const unsigned char* data() const; - - friend QPID_CLIENT_EXTERN bool operator==(const Uuid&, const Uuid&); - friend QPID_CLIENT_EXTERN bool operator!=(const Uuid&, const Uuid&); - friend QPID_CLIENT_EXTERN bool operator<(const Uuid&, const Uuid&); - friend QPID_CLIENT_EXTERN bool operator>(const Uuid&, const Uuid&); - friend QPID_CLIENT_EXTERN bool operator<=(const Uuid&, const Uuid&); - friend QPID_CLIENT_EXTERN bool operator>=(const Uuid&, const Uuid&); - friend QPID_CLIENT_EXTERN std::ostream& operator<<(std::ostream&, Uuid); - friend QPID_CLIENT_EXTERN std::istream& operator>>(std::istream&, Uuid&); - - private: - unsigned char bytes[16]; -}; - -/** Returns true if the uuids are equal, false otherwise. **/ -QPID_CLIENT_EXTERN bool operator==(const Uuid&, const Uuid&); -/** Returns true if the uuids are NOT equal, false if they are. **/ -QPID_CLIENT_EXTERN bool operator!=(const Uuid&, const Uuid&); - -QPID_CLIENT_EXTERN bool operator<(const Uuid&, const Uuid&); -QPID_CLIENT_EXTERN bool operator>(const Uuid&, const Uuid&); -QPID_CLIENT_EXTERN bool operator<=(const Uuid&, const Uuid&); -QPID_CLIENT_EXTERN bool operator>=(const Uuid&, const Uuid&); - -/** Print in format 1b4e28ba-2fa1-11d2-883f-b9a761bde3fb. */ -QPID_CLIENT_EXTERN std::ostream& operator<<(std::ostream&, Uuid); - -/** Read from format 1b4e28ba-2fa1-11d2-883f-b9a761bde3fb. */ -QPID_CLIENT_EXTERN std::istream& operator>>(std::istream&, Uuid&); - -}} // namespace qpid::messaging - -#endif /*!QPID_MESSAGING_UUID_H*/ diff --git a/qpid/cpp/include/qpid/messaging/Variant.h b/qpid/cpp/include/qpid/messaging/Variant.h deleted file mode 100644 index 51c6bd98fe..0000000000 --- a/qpid/cpp/include/qpid/messaging/Variant.h +++ /dev/null @@ -1,174 +0,0 @@ -#ifndef QPID_MESSAGING_VARIANT_H -#define QPID_MESSAGING_VARIANT_H - -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -#include -#include -#include -#include -#include "Uuid.h" -#include "qpid/Exception.h" -#include "qpid/sys/IntegerTypes.h" -#include "qpid/messaging/ImportExport.h" - -namespace qpid { -namespace messaging { - -/** - * Thrown when an illegal conversion of a variant is attempted. - */ -struct InvalidConversion : public qpid::Exception -{ - InvalidConversion(const std::string& msg); -}; - -enum VariantType { - VAR_VOID = 0, - VAR_BOOL, - VAR_UINT8, - VAR_UINT16, - VAR_UINT32, - VAR_UINT64, - VAR_INT8, - VAR_INT16, - VAR_INT32, - VAR_INT64, - VAR_FLOAT, - VAR_DOUBLE, - VAR_STRING, - VAR_MAP, - VAR_LIST, - VAR_UUID -}; - -class VariantImpl; - -/** - * Represents a value of variable type. - */ -class Variant -{ - public: - typedef std::map Map; - typedef std::list List; - - QPID_CLIENT_EXTERN Variant(); - QPID_CLIENT_EXTERN Variant(bool); - QPID_CLIENT_EXTERN Variant(uint8_t); - QPID_CLIENT_EXTERN Variant(uint16_t); - QPID_CLIENT_EXTERN Variant(uint32_t); - QPID_CLIENT_EXTERN Variant(uint64_t); - QPID_CLIENT_EXTERN Variant(int8_t); - QPID_CLIENT_EXTERN Variant(int16_t); - QPID_CLIENT_EXTERN Variant(int32_t); - QPID_CLIENT_EXTERN Variant(int64_t); - QPID_CLIENT_EXTERN Variant(float); - QPID_CLIENT_EXTERN Variant(double); - QPID_CLIENT_EXTERN Variant(const std::string&); - QPID_CLIENT_EXTERN Variant(const char*); - QPID_CLIENT_EXTERN Variant(const Map&); - QPID_CLIENT_EXTERN Variant(const List&); - QPID_CLIENT_EXTERN Variant(const Variant&); - QPID_CLIENT_EXTERN Variant(const Uuid&); - - QPID_CLIENT_EXTERN ~Variant(); - - QPID_CLIENT_EXTERN VariantType getType() const; - QPID_CLIENT_EXTERN bool isVoid() const; - - QPID_CLIENT_EXTERN Variant& operator=(bool); - QPID_CLIENT_EXTERN Variant& operator=(uint8_t); - QPID_CLIENT_EXTERN Variant& operator=(uint16_t); - QPID_CLIENT_EXTERN Variant& operator=(uint32_t); - QPID_CLIENT_EXTERN Variant& operator=(uint64_t); - QPID_CLIENT_EXTERN Variant& operator=(int8_t); - QPID_CLIENT_EXTERN Variant& operator=(int16_t); - QPID_CLIENT_EXTERN Variant& operator=(int32_t); - QPID_CLIENT_EXTERN Variant& operator=(int64_t); - QPID_CLIENT_EXTERN Variant& operator=(float); - QPID_CLIENT_EXTERN Variant& operator=(double); - QPID_CLIENT_EXTERN Variant& operator=(const std::string&); - QPID_CLIENT_EXTERN Variant& operator=(const char*); - QPID_CLIENT_EXTERN Variant& operator=(const Map&); - QPID_CLIENT_EXTERN Variant& operator=(const List&); - QPID_CLIENT_EXTERN Variant& operator=(const Variant&); - QPID_CLIENT_EXTERN Variant& operator=(const Uuid&); - - QPID_CLIENT_EXTERN bool asBool() const; - QPID_CLIENT_EXTERN uint8_t asUint8() const; - QPID_CLIENT_EXTERN uint16_t asUint16() const; - QPID_CLIENT_EXTERN uint32_t asUint32() const; - QPID_CLIENT_EXTERN uint64_t asUint64() const; - QPID_CLIENT_EXTERN int8_t asInt8() const; - QPID_CLIENT_EXTERN int16_t asInt16() const; - QPID_CLIENT_EXTERN int32_t asInt32() const; - QPID_CLIENT_EXTERN int64_t asInt64() const; - QPID_CLIENT_EXTERN float asFloat() const; - QPID_CLIENT_EXTERN double asDouble() const; - QPID_CLIENT_EXTERN std::string asString() const; - QPID_CLIENT_EXTERN Uuid asUuid() const; - - QPID_CLIENT_EXTERN operator bool() const; - QPID_CLIENT_EXTERN operator uint8_t() const; - QPID_CLIENT_EXTERN operator uint16_t() const; - QPID_CLIENT_EXTERN operator uint32_t() const; - QPID_CLIENT_EXTERN operator uint64_t() const; - QPID_CLIENT_EXTERN operator int8_t() const; - QPID_CLIENT_EXTERN operator int16_t() const; - QPID_CLIENT_EXTERN operator int32_t() const; - QPID_CLIENT_EXTERN operator int64_t() const; - QPID_CLIENT_EXTERN operator float() const; - QPID_CLIENT_EXTERN operator double() const; - QPID_CLIENT_EXTERN operator const char*() const; - QPID_CLIENT_EXTERN operator Uuid() const; - - QPID_CLIENT_EXTERN const Map& asMap() const; - QPID_CLIENT_EXTERN Map& asMap(); - QPID_CLIENT_EXTERN const List& asList() const; - QPID_CLIENT_EXTERN List& asList(); - /** - * Unlike asString(), getString() will not do any conversions and - * will throw InvalidConversion if the type is not STRING. - */ - QPID_CLIENT_EXTERN const std::string& getString() const; - QPID_CLIENT_EXTERN std::string& getString(); - - QPID_CLIENT_EXTERN void setEncoding(const std::string&); - QPID_CLIENT_EXTERN const std::string& getEncoding() const; - - QPID_CLIENT_EXTERN bool isEqualTo(const Variant& a) const; - - QPID_CLIENT_EXTERN void reset(); - private: - VariantImpl* impl; -}; - -QPID_CLIENT_EXTERN std::ostream& operator<<(std::ostream& out, const Variant& value); -QPID_CLIENT_EXTERN std::ostream& operator<<(std::ostream& out, const Variant::Map& map); -QPID_CLIENT_EXTERN std::ostream& operator<<(std::ostream& out, const Variant::List& list); -QPID_CLIENT_EXTERN bool operator==(const Variant& a, const Variant& b); - -typedef Variant::Map VariantMap; - -}} // namespace qpid::messaging - -#endif /*!QPID_MESSAGING_VARIANT_H*/ diff --git a/qpid/cpp/include/qpid/types/Uuid.h b/qpid/cpp/include/qpid/types/Uuid.h new file mode 100644 index 0000000000..41042a0731 --- /dev/null +++ b/qpid/cpp/include/qpid/types/Uuid.h @@ -0,0 +1,94 @@ +#ifndef QPID_TYPES_UUID_H +#define QPID_TYPES_UUID_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/CommonImportExport.h" +#include +#include + +namespace qpid { +namespace types { + +class Uuid +{ + public: + static const size_t SIZE; + /** + * If unique is true, this will generate a new unique uuid, if not + * it will construct a null uuid. + */ + QPID_COMMON_EXTERN Uuid(bool unique=false); + QPID_COMMON_EXTERN Uuid(const Uuid&); + QPID_COMMON_EXTERN Uuid& operator=(const Uuid&); + /** Copy the UUID from data16, which must point to a 16-byte UUID */ + QPID_COMMON_EXTERN Uuid(const unsigned char* data16); + + /** Set to a new unique identifier. */ + QPID_COMMON_EXTERN void generate(); + + /** Set to all zeros. */ + QPID_COMMON_EXTERN void clear(); + + /** Test for null (all zeros). */ + QPID_COMMON_EXTERN bool isNull() const; + QPID_COMMON_EXTERN operator bool() const; + QPID_COMMON_EXTERN bool operator!() const; + + /** String value in format 1b4e28ba-2fa1-11d2-883f-b9a761bde3fb. */ + QPID_COMMON_EXTERN std::string str() const; + + QPID_COMMON_EXTERN size_t size() const; + QPID_COMMON_EXTERN const unsigned char* data() const; + + friend QPID_COMMON_EXTERN bool operator==(const Uuid&, const Uuid&); + friend QPID_COMMON_EXTERN bool operator!=(const Uuid&, const Uuid&); + friend QPID_COMMON_EXTERN bool operator<(const Uuid&, const Uuid&); + friend QPID_COMMON_EXTERN bool operator>(const Uuid&, const Uuid&); + friend QPID_COMMON_EXTERN bool operator<=(const Uuid&, const Uuid&); + friend QPID_COMMON_EXTERN bool operator>=(const Uuid&, const Uuid&); + friend QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream&, Uuid); + friend QPID_COMMON_EXTERN std::istream& operator>>(std::istream&, Uuid&); + + private: + unsigned char bytes[16]; +}; + +/** Returns true if the uuids are equal, false otherwise. **/ +QPID_COMMON_EXTERN bool operator==(const Uuid&, const Uuid&); +/** Returns true if the uuids are NOT equal, false if they are. **/ +QPID_COMMON_EXTERN bool operator!=(const Uuid&, const Uuid&); + +QPID_COMMON_EXTERN bool operator<(const Uuid&, const Uuid&); +QPID_COMMON_EXTERN bool operator>(const Uuid&, const Uuid&); +QPID_COMMON_EXTERN bool operator<=(const Uuid&, const Uuid&); +QPID_COMMON_EXTERN bool operator>=(const Uuid&, const Uuid&); + +/** Print in format 1b4e28ba-2fa1-11d2-883f-b9a761bde3fb. */ +QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream&, Uuid); + +/** Read from format 1b4e28ba-2fa1-11d2-883f-b9a761bde3fb. */ +QPID_COMMON_EXTERN std::istream& operator>>(std::istream&, Uuid&); + +}} // namespace qpid::types + +#endif /*!QPID_TYPES_UUID_H*/ diff --git a/qpid/cpp/include/qpid/types/Variant.h b/qpid/cpp/include/qpid/types/Variant.h new file mode 100644 index 0000000000..f57adcd31e --- /dev/null +++ b/qpid/cpp/include/qpid/types/Variant.h @@ -0,0 +1,174 @@ +#ifndef QPID_TYPES_VARIANT_H +#define QPID_TYPES_VARIANT_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#include +#include +#include +#include +#include "Uuid.h" +#include "qpid/Exception.h" +#include "qpid/sys/IntegerTypes.h" +#include "qpid/CommonImportExport.h" + +namespace qpid { +namespace types { + +/** + * Thrown when an illegal conversion of a variant is attempted. + */ +struct InvalidConversion : public qpid::Exception +{ + InvalidConversion(const std::string& msg); +}; + +enum VariantType { + VAR_VOID = 0, + VAR_BOOL, + VAR_UINT8, + VAR_UINT16, + VAR_UINT32, + VAR_UINT64, + VAR_INT8, + VAR_INT16, + VAR_INT32, + VAR_INT64, + VAR_FLOAT, + VAR_DOUBLE, + VAR_STRING, + VAR_MAP, + VAR_LIST, + VAR_UUID +}; + +class VariantImpl; + +/** + * Represents a value of variable type. + */ +class Variant +{ + public: + typedef std::map Map; + typedef std::list List; + + QPID_COMMON_EXTERN Variant(); + QPID_COMMON_EXTERN Variant(bool); + QPID_COMMON_EXTERN Variant(uint8_t); + QPID_COMMON_EXTERN Variant(uint16_t); + QPID_COMMON_EXTERN Variant(uint32_t); + QPID_COMMON_EXTERN Variant(uint64_t); + QPID_COMMON_EXTERN Variant(int8_t); + QPID_COMMON_EXTERN Variant(int16_t); + QPID_COMMON_EXTERN Variant(int32_t); + QPID_COMMON_EXTERN Variant(int64_t); + QPID_COMMON_EXTERN Variant(float); + QPID_COMMON_EXTERN Variant(double); + QPID_COMMON_EXTERN Variant(const std::string&); + QPID_COMMON_EXTERN Variant(const char*); + QPID_COMMON_EXTERN Variant(const Map&); + QPID_COMMON_EXTERN Variant(const List&); + QPID_COMMON_EXTERN Variant(const Variant&); + QPID_COMMON_EXTERN Variant(const Uuid&); + + QPID_COMMON_EXTERN ~Variant(); + + QPID_COMMON_EXTERN VariantType getType() const; + QPID_COMMON_EXTERN bool isVoid() const; + + QPID_COMMON_EXTERN Variant& operator=(bool); + QPID_COMMON_EXTERN Variant& operator=(uint8_t); + QPID_COMMON_EXTERN Variant& operator=(uint16_t); + QPID_COMMON_EXTERN Variant& operator=(uint32_t); + QPID_COMMON_EXTERN Variant& operator=(uint64_t); + QPID_COMMON_EXTERN Variant& operator=(int8_t); + QPID_COMMON_EXTERN Variant& operator=(int16_t); + QPID_COMMON_EXTERN Variant& operator=(int32_t); + QPID_COMMON_EXTERN Variant& operator=(int64_t); + QPID_COMMON_EXTERN Variant& operator=(float); + QPID_COMMON_EXTERN Variant& operator=(double); + QPID_COMMON_EXTERN Variant& operator=(const std::string&); + QPID_COMMON_EXTERN Variant& operator=(const char*); + QPID_COMMON_EXTERN Variant& operator=(const Map&); + QPID_COMMON_EXTERN Variant& operator=(const List&); + QPID_COMMON_EXTERN Variant& operator=(const Variant&); + QPID_COMMON_EXTERN Variant& operator=(const Uuid&); + + QPID_COMMON_EXTERN bool asBool() const; + QPID_COMMON_EXTERN uint8_t asUint8() const; + QPID_COMMON_EXTERN uint16_t asUint16() const; + QPID_COMMON_EXTERN uint32_t asUint32() const; + QPID_COMMON_EXTERN uint64_t asUint64() const; + QPID_COMMON_EXTERN int8_t asInt8() const; + QPID_COMMON_EXTERN int16_t asInt16() const; + QPID_COMMON_EXTERN int32_t asInt32() const; + QPID_COMMON_EXTERN int64_t asInt64() const; + QPID_COMMON_EXTERN float asFloat() const; + QPID_COMMON_EXTERN double asDouble() const; + QPID_COMMON_EXTERN std::string asString() const; + QPID_COMMON_EXTERN Uuid asUuid() const; + + QPID_COMMON_EXTERN operator bool() const; + QPID_COMMON_EXTERN operator uint8_t() const; + QPID_COMMON_EXTERN operator uint16_t() const; + QPID_COMMON_EXTERN operator uint32_t() const; + QPID_COMMON_EXTERN operator uint64_t() const; + QPID_COMMON_EXTERN operator int8_t() const; + QPID_COMMON_EXTERN operator int16_t() const; + QPID_COMMON_EXTERN operator int32_t() const; + QPID_COMMON_EXTERN operator int64_t() const; + QPID_COMMON_EXTERN operator float() const; + QPID_COMMON_EXTERN operator double() const; + QPID_COMMON_EXTERN operator const char*() const; + QPID_COMMON_EXTERN operator Uuid() const; + + QPID_COMMON_EXTERN const Map& asMap() const; + QPID_COMMON_EXTERN Map& asMap(); + QPID_COMMON_EXTERN const List& asList() const; + QPID_COMMON_EXTERN List& asList(); + /** + * Unlike asString(), getString() will not do any conversions and + * will throw InvalidConversion if the type is not STRING. + */ + QPID_COMMON_EXTERN const std::string& getString() const; + QPID_COMMON_EXTERN std::string& getString(); + + QPID_COMMON_EXTERN void setEncoding(const std::string&); + QPID_COMMON_EXTERN const std::string& getEncoding() const; + + QPID_COMMON_EXTERN bool isEqualTo(const Variant& a) const; + + QPID_COMMON_EXTERN void reset(); + private: + VariantImpl* impl; +}; + +QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& out, const Variant& value); +QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& out, const Variant::Map& map); +QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& out, const Variant::List& list); +QPID_COMMON_EXTERN bool operator==(const Variant& a, const Variant& b); + +typedef Variant::Map VariantMap; + +}} // namespace qpid::types + +#endif /*!QPID_TYPES_VARIANT_H*/ -- cgit v1.2.1 From 3d990371a345d1760cebd7dc0e47365034cfe2d4 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Mon, 29 Mar 2010 18:15:42 +0000 Subject: QPID-2406: a more explicit solution for durations in the messaging api git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@928855 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Duration.h | 19 +++++++++++++++---- qpid/cpp/include/qpid/messaging/Receiver.h | 8 ++++---- qpid/cpp/include/qpid/messaging/Session.h | 4 ++-- 3 files changed, 21 insertions(+), 10 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Duration.h b/qpid/cpp/include/qpid/messaging/Duration.h index 5f95acf04d..a127e86f29 100644 --- a/qpid/cpp/include/qpid/messaging/Duration.h +++ b/qpid/cpp/include/qpid/messaging/Duration.h @@ -22,7 +22,6 @@ * */ #include "qpid/sys/IntegerTypes.h" -#include namespace qpid { namespace messaging { @@ -30,9 +29,21 @@ namespace messaging { /** * A duration is a time in milliseconds. */ -typedef uint64_t Duration; -const Duration INFINITE_DURATION = std::numeric_limits::max(); -const Duration DURATION_SEC = 1000; +class Duration +{ + public: + explicit Duration(uint64_t milliseconds); + uint64_t getMilliseconds() const; + static const Duration INFINITE; + static const Duration IMMEDIATE; + static const Duration SECOND; + static const Duration MINUTE; + private: + uint64_t milliseconds; +}; + +Duration operator*(const Duration& duration, uint64_t multiplier); +Duration operator*(uint64_t multiplier, const Duration& duration); }} // namespace qpid::messaging diff --git a/qpid/cpp/include/qpid/messaging/Receiver.h b/qpid/cpp/include/qpid/messaging/Receiver.h index 80b58106d7..f0b9a7d66e 100644 --- a/qpid/cpp/include/qpid/messaging/Receiver.h +++ b/qpid/cpp/include/qpid/messaging/Receiver.h @@ -53,7 +53,7 @@ class Receiver : public qpid::messaging::Handle * available. Returns false if there is no message to give after * waiting for the specified timeout. */ - QPID_CLIENT_EXTERN bool get(Message& message, Duration timeout=INFINITE_DURATION); + QPID_CLIENT_EXTERN bool get(Message& message, Duration timeout=Duration::INFINITE); /** * Retrieves a message from this receivers local queue, or waits * for up to the specified timeout for a message to become @@ -62,7 +62,7 @@ class Receiver : public qpid::messaging::Handle *@exception NoMessageAvailable if there is no message to give * after waiting for the specified timeout. */ - QPID_CLIENT_EXTERN Message get(Duration timeout=INFINITE_DURATION); + QPID_CLIENT_EXTERN Message get(Duration timeout=Duration::INFINITE); /** * Retrieves a message for this receivers subscription or waits * for up to the specified timeout for one to become @@ -70,7 +70,7 @@ class Receiver : public qpid::messaging::Handle * that there is no message for the subscription this receiver is * serving before returning false. */ - QPID_CLIENT_EXTERN bool fetch(Message& message, Duration timeout=INFINITE_DURATION); + QPID_CLIENT_EXTERN bool fetch(Message& message, Duration timeout=Duration::INFINITE); /** * Retrieves a message for this receivers subscription or waits * for up to the specified timeout for one to become @@ -81,7 +81,7 @@ class Receiver : public qpid::messaging::Handle *@exception NoMessageAvailable if there is no message to give * after waiting for the specified timeout. */ - QPID_CLIENT_EXTERN Message fetch(Duration timeout=INFINITE_DURATION); + QPID_CLIENT_EXTERN Message fetch(Duration timeout=Duration::INFINITE); /** * Sets the capacity for the receiver. The capacity determines how * many incoming messages can be held in the receiver before being diff --git a/qpid/cpp/include/qpid/messaging/Session.h b/qpid/cpp/include/qpid/messaging/Session.h index 032b678c5c..bc5aaed6ba 100644 --- a/qpid/cpp/include/qpid/messaging/Session.h +++ b/qpid/cpp/include/qpid/messaging/Session.h @@ -102,7 +102,7 @@ class Session : public qpid::messaging::Handle * which case the passed in receiver reference will be set to the * receiver for that message or false if no message was available. */ - QPID_CLIENT_EXTERN bool nextReceiver(Receiver&, Duration timeout=INFINITE_DURATION); + QPID_CLIENT_EXTERN bool nextReceiver(Receiver&, Duration timeout=Duration::INFINITE); /** * Returns the receiver for the next available message. If there * are no available messages at present the call will block for up @@ -111,7 +111,7 @@ class Session : public qpid::messaging::Handle *@exception Receiver::NoMessageAvailable if no message became available in * time. */ - QPID_CLIENT_EXTERN Receiver nextReceiver(Duration timeout=INFINITE_DURATION); + QPID_CLIENT_EXTERN Receiver nextReceiver(Duration timeout=Duration::INFINITE); /** * Create a new sender through which messages can be sent to the -- cgit v1.2.1 From beb68a5d1b8d74f4c53299c81911a3ad85011f17 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Mon, 29 Mar 2010 19:21:26 +0000 Subject: QPID-664: renamed headers as properties (to match python); added priority git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@928878 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Message.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Message.h b/qpid/cpp/include/qpid/messaging/Message.h index 04923ee03b..d7b2622d08 100644 --- a/qpid/cpp/include/qpid/messaging/Message.h +++ b/qpid/cpp/include/qpid/messaging/Message.h @@ -65,6 +65,9 @@ class Message QPID_CLIENT_EXTERN void setCorrelationId(const std::string&); QPID_CLIENT_EXTERN const std::string& getCorrelationId() const; + QPID_CLIENT_EXTERN void setPriority(uint8_t); + QPID_CLIENT_EXTERN uint8_t getPriority() const; + /** * Set the time to live for this message in milliseconds. */ @@ -77,10 +80,11 @@ class Message QPID_CLIENT_EXTERN void setDurable(bool durable); QPID_CLIENT_EXTERN bool getDurable() const; - QPID_CLIENT_EXTERN bool isRedelivered() const; + QPID_CLIENT_EXTERN bool getRedelivered() const; + QPID_CLIENT_EXTERN void setRedelivered(bool); - QPID_CLIENT_EXTERN const qpid::types::Variant::Map& getHeaders() const; - QPID_CLIENT_EXTERN qpid::types::Variant::Map& getHeaders(); + QPID_CLIENT_EXTERN const qpid::types::Variant::Map& getProperties() const; + QPID_CLIENT_EXTERN qpid::types::Variant::Map& getProperties(); QPID_CLIENT_EXTERN const std::string& getContent() const; QPID_CLIENT_EXTERN std::string& getContent(); -- cgit v1.2.1 From 7b39205d3938dcdf87e78d99caa7d69f02212bf8 Mon Sep 17 00:00:00 2001 From: "Stephen D. Huston" Date: Tue, 30 Mar 2010 20:02:35 +0000 Subject: Rename Duration::INFINITE to Duration::FOREVER; resolves QPID-2475. Added missing QPID_CLIENT_EXTERN where needed in Duration class to build on Windows. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@929240 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Duration.h | 20 ++++++++++++-------- qpid/cpp/include/qpid/messaging/Receiver.h | 8 ++++---- qpid/cpp/include/qpid/messaging/Session.h | 4 ++-- 3 files changed, 18 insertions(+), 14 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Duration.h b/qpid/cpp/include/qpid/messaging/Duration.h index a127e86f29..fdd1cf4a50 100644 --- a/qpid/cpp/include/qpid/messaging/Duration.h +++ b/qpid/cpp/include/qpid/messaging/Duration.h @@ -21,6 +21,8 @@ * under the License. * */ + +#include "qpid/client/ClientImportExport.h" #include "qpid/sys/IntegerTypes.h" namespace qpid { @@ -32,18 +34,20 @@ namespace messaging { class Duration { public: - explicit Duration(uint64_t milliseconds); - uint64_t getMilliseconds() const; - static const Duration INFINITE; - static const Duration IMMEDIATE; - static const Duration SECOND; - static const Duration MINUTE; + QPID_CLIENT_EXTERN explicit Duration(uint64_t milliseconds); + QPID_CLIENT_EXTERN uint64_t getMilliseconds() const; + QPID_CLIENT_EXTERN static const Duration FOREVER; + QPID_CLIENT_EXTERN static const Duration IMMEDIATE; + QPID_CLIENT_EXTERN static const Duration SECOND; + QPID_CLIENT_EXTERN static const Duration MINUTE; private: uint64_t milliseconds; }; -Duration operator*(const Duration& duration, uint64_t multiplier); -Duration operator*(uint64_t multiplier, const Duration& duration); +QPID_CLIENT_EXTERN Duration operator*(const Duration& duration, + uint64_t multiplier); +QPID_CLIENT_EXTERN Duration operator*(uint64_t multiplier, + const Duration& duration); }} // namespace qpid::messaging diff --git a/qpid/cpp/include/qpid/messaging/Receiver.h b/qpid/cpp/include/qpid/messaging/Receiver.h index f0b9a7d66e..48b0b78754 100644 --- a/qpid/cpp/include/qpid/messaging/Receiver.h +++ b/qpid/cpp/include/qpid/messaging/Receiver.h @@ -53,7 +53,7 @@ class Receiver : public qpid::messaging::Handle * available. Returns false if there is no message to give after * waiting for the specified timeout. */ - QPID_CLIENT_EXTERN bool get(Message& message, Duration timeout=Duration::INFINITE); + QPID_CLIENT_EXTERN bool get(Message& message, Duration timeout=Duration::FOREVER); /** * Retrieves a message from this receivers local queue, or waits * for up to the specified timeout for a message to become @@ -62,7 +62,7 @@ class Receiver : public qpid::messaging::Handle *@exception NoMessageAvailable if there is no message to give * after waiting for the specified timeout. */ - QPID_CLIENT_EXTERN Message get(Duration timeout=Duration::INFINITE); + QPID_CLIENT_EXTERN Message get(Duration timeout=Duration::FOREVER); /** * Retrieves a message for this receivers subscription or waits * for up to the specified timeout for one to become @@ -70,7 +70,7 @@ class Receiver : public qpid::messaging::Handle * that there is no message for the subscription this receiver is * serving before returning false. */ - QPID_CLIENT_EXTERN bool fetch(Message& message, Duration timeout=Duration::INFINITE); + QPID_CLIENT_EXTERN bool fetch(Message& message, Duration timeout=Duration::FOREVER); /** * Retrieves a message for this receivers subscription or waits * for up to the specified timeout for one to become @@ -81,7 +81,7 @@ class Receiver : public qpid::messaging::Handle *@exception NoMessageAvailable if there is no message to give * after waiting for the specified timeout. */ - QPID_CLIENT_EXTERN Message fetch(Duration timeout=Duration::INFINITE); + QPID_CLIENT_EXTERN Message fetch(Duration timeout=Duration::FOREVER); /** * Sets the capacity for the receiver. The capacity determines how * many incoming messages can be held in the receiver before being diff --git a/qpid/cpp/include/qpid/messaging/Session.h b/qpid/cpp/include/qpid/messaging/Session.h index bc5aaed6ba..eaecb69260 100644 --- a/qpid/cpp/include/qpid/messaging/Session.h +++ b/qpid/cpp/include/qpid/messaging/Session.h @@ -102,7 +102,7 @@ class Session : public qpid::messaging::Handle * which case the passed in receiver reference will be set to the * receiver for that message or false if no message was available. */ - QPID_CLIENT_EXTERN bool nextReceiver(Receiver&, Duration timeout=Duration::INFINITE); + QPID_CLIENT_EXTERN bool nextReceiver(Receiver&, Duration timeout=Duration::FOREVER); /** * Returns the receiver for the next available message. If there * are no available messages at present the call will block for up @@ -111,7 +111,7 @@ class Session : public qpid::messaging::Handle *@exception Receiver::NoMessageAvailable if no message became available in * time. */ - QPID_CLIENT_EXTERN Receiver nextReceiver(Duration timeout=Duration::INFINITE); + QPID_CLIENT_EXTERN Receiver nextReceiver(Duration timeout=Duration::FOREVER); /** * Create a new sender through which messages can be sent to the -- cgit v1.2.1 From e148043f68f2f71b057d191177dcdf83156f642a Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Wed, 31 Mar 2010 16:17:17 +0000 Subject: QPID-664: made changes suggested by Alan Conway, also moved 0-10 map/list codecs to common lib git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@929606 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/amqp_0_10/Codecs.h | 70 ++++++++++++++++++++ qpid/cpp/include/qpid/client/amqp0_10/Codecs.h | 61 ----------------- qpid/cpp/include/qpid/messaging/Address.h | 22 +++++-- qpid/cpp/include/qpid/messaging/Codec.h | 46 ------------- qpid/cpp/include/qpid/messaging/Connection.h | 11 +++- qpid/cpp/include/qpid/messaging/ListContent.h | 91 -------------------------- qpid/cpp/include/qpid/messaging/ListView.h | 67 ------------------- qpid/cpp/include/qpid/messaging/MapContent.h | 91 -------------------------- qpid/cpp/include/qpid/messaging/MapView.h | 70 -------------------- qpid/cpp/include/qpid/messaging/Message.h | 61 +++++++++++++++-- qpid/cpp/include/qpid/messaging/Receiver.h | 8 +-- qpid/cpp/include/qpid/messaging/Sender.h | 5 +- qpid/cpp/include/qpid/messaging/Session.h | 8 +-- qpid/cpp/include/qpid/types/Variant.h | 5 +- 14 files changed, 166 insertions(+), 450 deletions(-) create mode 100644 qpid/cpp/include/qpid/amqp_0_10/Codecs.h delete mode 100644 qpid/cpp/include/qpid/client/amqp0_10/Codecs.h delete mode 100644 qpid/cpp/include/qpid/messaging/Codec.h delete mode 100644 qpid/cpp/include/qpid/messaging/ListContent.h delete mode 100644 qpid/cpp/include/qpid/messaging/ListView.h delete mode 100644 qpid/cpp/include/qpid/messaging/MapContent.h delete mode 100644 qpid/cpp/include/qpid/messaging/MapView.h (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/amqp_0_10/Codecs.h b/qpid/cpp/include/qpid/amqp_0_10/Codecs.h new file mode 100644 index 0000000000..669b485807 --- /dev/null +++ b/qpid/cpp/include/qpid/amqp_0_10/Codecs.h @@ -0,0 +1,70 @@ +#ifndef QPID_AMQP_0_10_CODECS_H +#define QPID_AMQP_0_10_CODECS_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/types/Variant.h" + +namespace qpid { +namespace framing { +class FieldTable; +} +namespace amqp_0_10 { +/** + * Codec for encoding/decoding a map of Variants using the AMQP 0-10 + * map encoding. + */ +class MapCodec +{ + public: + static void encode(const qpid::types::Variant::Map&, std::string&); + static void decode(const std::string&, qpid::types::Variant::Map&); + static const std::string contentType; + private: +}; + +/** + * Codec for encoding/decoding a list of Variants using the AMQP 0-10 + * list encoding. + */ +class ListCodec +{ + public: + static void encode(const qpid::types::Variant::List&, std::string&); + static void decode(const std::string&, qpid::types::Variant::List&); + static const std::string contentType; + private: +}; + +/** + * @internal + * + * Conversion functions between qpid::types:Variant::Map and the + * deprecated qpid::framing::FieldTable. + * + */ +void translate(const qpid::types::Variant::Map& from, qpid::framing::FieldTable& to); +void translate(const qpid::framing::FieldTable& from, qpid::types::Variant::Map& to); + +}} // namespace qpid::amqp_0_10 + +#endif /*!QPID_AMQP_0_10_CODECS_H*/ diff --git a/qpid/cpp/include/qpid/client/amqp0_10/Codecs.h b/qpid/cpp/include/qpid/client/amqp0_10/Codecs.h deleted file mode 100644 index 097cf5877f..0000000000 --- a/qpid/cpp/include/qpid/client/amqp0_10/Codecs.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef QPID_CLIENT_AMQP0_10_CODECS_H -#define QPID_CLIENT_AMQP0_10_CODECS_H - -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -#include "qpid/messaging/Codec.h" - -namespace qpid { -namespace client { -namespace amqp0_10 { - - -/** - * Codec for encoding/decoding a map of Variants using the AMQP 0-10 - * map encoding. - */ -class MapCodec : public qpid::messaging::Codec -{ - public: - void encode(const qpid::types::Variant&, std::string&); - void decode(const std::string&, qpid::types::Variant&); - - static const std::string contentType; - private: -}; - -/** - * Codec for encoding/decoding a list of Variants using the AMQP 0-10 - * list encoding. - */ -class ListCodec : public qpid::messaging::Codec -{ - public: - void encode(const qpid::types::Variant&, std::string&); - void decode(const std::string&, qpid::types::Variant&); - - static const std::string contentType; - private: -}; - -}}} // namespace qpid::client::amqp0_10 - -#endif /*!QPID_CLIENT_AMQP0_10_CODECS_H*/ diff --git a/qpid/cpp/include/qpid/messaging/Address.h b/qpid/cpp/include/qpid/messaging/Address.h index 307e0cfa8d..34a186c9ce 100644 --- a/qpid/cpp/include/qpid/messaging/Address.h +++ b/qpid/cpp/include/qpid/messaging/Address.h @@ -30,11 +30,18 @@ namespace qpid { namespace messaging { +/** + * Thrown when a syntactically correct address cannot be resolved or + * used. + */ struct InvalidAddress : public qpid::Exception { InvalidAddress(const std::string& msg); }; +/** + * Thrown when an address string with inalid sytanx is used. + */ struct MalformedAddress : public qpid::Exception { MalformedAddress(const std::string& msg); @@ -117,6 +124,8 @@ class AddressImpl; * merely browse the messages. Valid values are 'consume' and * 'browse' * + * + * An address has value semantics. */ class Address { @@ -132,17 +141,22 @@ class Address QPID_CLIENT_EXTERN void setName(const std::string&); QPID_CLIENT_EXTERN const std::string& getSubject() const; QPID_CLIENT_EXTERN void setSubject(const std::string&); - QPID_CLIENT_EXTERN bool hasSubject() const; QPID_CLIENT_EXTERN const qpid::types::Variant::Map& getOptions() const; QPID_CLIENT_EXTERN qpid::types::Variant::Map& getOptions(); QPID_CLIENT_EXTERN void setOptions(const qpid::types::Variant::Map&); QPID_CLIENT_EXTERN std::string getType() const; + /** + * The type of and addressed node influences how receivers and + * senders are constructed for it. It also affects how a reply-to + * address is encoded. If the type is not specified in the address + * itself, it will be automatically determined by querying the + * broker. The type can be explicitly set to prevent this if + * needed. + */ QPID_CLIENT_EXTERN void setType(const std::string&); - QPID_CLIENT_EXTERN const qpid::types::Variant& getOption(const std::string& key) const; - - QPID_CLIENT_EXTERN std::string toStr() const; + QPID_CLIENT_EXTERN std::string str() const; QPID_CLIENT_EXTERN operator bool() const; QPID_CLIENT_EXTERN bool operator !() const; private: diff --git a/qpid/cpp/include/qpid/messaging/Codec.h b/qpid/cpp/include/qpid/messaging/Codec.h deleted file mode 100644 index a69baa5af1..0000000000 --- a/qpid/cpp/include/qpid/messaging/Codec.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef QPID_MESSAGING_CODEC_H -#define QPID_MESSAGING_CODEC_H - -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -#include -#include "qpid/messaging/ImportExport.h" - -namespace qpid { -namespace types{ -class Variant; -} -namespace messaging { - -/** - * - */ -class Codec -{ - public: - QPID_CLIENT_EXTERN virtual ~Codec() {} - virtual void encode(const qpid::types::Variant&, std::string&) = 0; - virtual void decode(const std::string&, qpid::types::Variant&) = 0; - private: -}; -}} // namespace qpid::messaging - -#endif /*!QPID_MESSAGING_CODEC_H*/ diff --git a/qpid/cpp/include/qpid/messaging/Connection.h b/qpid/cpp/include/qpid/messaging/Connection.h index 24fb9650d8..8b0f9e98e3 100644 --- a/qpid/cpp/include/qpid/messaging/Connection.h +++ b/qpid/cpp/include/qpid/messaging/Connection.h @@ -75,6 +75,12 @@ class Connection : public qpid::messaging::Handle * is reached. */ QPID_CLIENT_EXTERN Connection(const qpid::types::Variant::Map& options = qpid::types::Variant::Map()); + /** + * Creates a connection using an option string of the form + * {name=value,name2=value2...}, see above for options supported. + * + * @exception InvalidOptionString if the string does not match the correct syntax + */ QPID_CLIENT_EXTERN Connection(const std::string& options); QPID_CLIENT_EXTERN ~Connection(); QPID_CLIENT_EXTERN Connection& operator=(const Connection&); @@ -86,9 +92,8 @@ class Connection : public qpid::messaging::Handle * allowed to go out of scope. */ QPID_CLIENT_EXTERN void close(); - QPID_CLIENT_EXTERN Session newSession(bool transactional, const std::string& name = std::string()); - QPID_CLIENT_EXTERN Session newSession(const std::string& name = std::string()); - QPID_CLIENT_EXTERN Session newSession(const char* name); + QPID_CLIENT_EXTERN Session createTransactionalSession(const std::string& name = std::string()); + QPID_CLIENT_EXTERN Session createSession(const std::string& name = std::string()); QPID_CLIENT_EXTERN Session getSession(const std::string& name) const; private: diff --git a/qpid/cpp/include/qpid/messaging/ListContent.h b/qpid/cpp/include/qpid/messaging/ListContent.h deleted file mode 100644 index 1e7d34af54..0000000000 --- a/qpid/cpp/include/qpid/messaging/ListContent.h +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef QPID_MESSAGING_LISTCONTENT_H -#define QPID_MESSAGING_LISTCONTENT_H - -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -#include "qpid/messaging/ImportExport.h" -#include "qpid/types/Variant.h" - -namespace qpid { -namespace messaging { - -class ListContentImpl; -class Message; - -/** - * Allows message content to be manipulated as a list. - */ -class ListContent -{ - public: - typedef qpid::types::Variant::List::iterator iterator; - typedef qpid::types::Variant::List::reverse_iterator reverse_iterator; - typedef qpid::types::Variant::List::const_iterator const_iterator; - typedef qpid::types::Variant::List::const_reverse_iterator const_reverse_iterator; - - QPID_CLIENT_EXTERN ListContent(Message&); - QPID_CLIENT_EXTERN ListContent(Message&, const qpid::types::Variant::List&); - QPID_CLIENT_EXTERN ~ListContent(); - - QPID_CLIENT_EXTERN const_iterator begin() const; - QPID_CLIENT_EXTERN iterator begin(); - QPID_CLIENT_EXTERN const_iterator end() const; - QPID_CLIENT_EXTERN iterator end(); - QPID_CLIENT_EXTERN const_reverse_iterator rbegin() const; - QPID_CLIENT_EXTERN reverse_iterator rbegin(); - QPID_CLIENT_EXTERN const_reverse_iterator rend() const; - QPID_CLIENT_EXTERN reverse_iterator rend(); - - QPID_CLIENT_EXTERN bool empty() const; - QPID_CLIENT_EXTERN size_t size() const; - - QPID_CLIENT_EXTERN const qpid::types::Variant& front() const; - QPID_CLIENT_EXTERN qpid::types::Variant& front(); - QPID_CLIENT_EXTERN const qpid::types::Variant& back() const; - QPID_CLIENT_EXTERN qpid::types::Variant& back(); - - QPID_CLIENT_EXTERN void push_front(const qpid::types::Variant&); - QPID_CLIENT_EXTERN void push_back(const qpid::types::Variant&); - - QPID_CLIENT_EXTERN void pop_front(); - QPID_CLIENT_EXTERN void pop_back(); - - QPID_CLIENT_EXTERN iterator insert(iterator position, const qpid::types::Variant&); - QPID_CLIENT_EXTERN void insert(iterator position, size_t n, const qpid::types::Variant&); - QPID_CLIENT_EXTERN iterator erase(iterator position); - QPID_CLIENT_EXTERN iterator erase(iterator first, iterator last); - QPID_CLIENT_EXTERN void clear(); - - QPID_CLIENT_EXTERN void encode(); - - QPID_CLIENT_EXTERN const qpid::types::Variant::List& asList() const; - QPID_CLIENT_EXTERN qpid::types::Variant::List& asList(); - private: - ListContentImpl* impl; - - QPID_CLIENT_EXTERN ListContent& operator=(const ListContent&); -}; - -QPID_CLIENT_EXTERN std::ostream& operator<<(std::ostream& out, const ListContent& m); - -}} // namespace qpid::messaging - -#endif /*!QPID_MESSAGING_LISTCONTENT_H*/ diff --git a/qpid/cpp/include/qpid/messaging/ListView.h b/qpid/cpp/include/qpid/messaging/ListView.h deleted file mode 100644 index dce82a657c..0000000000 --- a/qpid/cpp/include/qpid/messaging/ListView.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef QPID_MESSAGING_LISTVIEW_H -#define QPID_MESSAGING_LISTVIEW_H - -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -#include "qpid/messaging/ImportExport.h" -#include "qpid/types/Variant.h" - -namespace qpid { -namespace messaging { - -class ListViewImpl; -class Message; - -/** - * Provides a view of message content as a list - */ -class ListView -{ - public: - typedef qpid::types::Variant::List::const_iterator const_iterator; - typedef qpid::types::Variant::List::const_reverse_iterator const_reverse_iterator; - - QPID_CLIENT_EXTERN ListView(const Message&); - QPID_CLIENT_EXTERN ~ListView(); - QPID_CLIENT_EXTERN ListView& operator=(const ListView&); - - QPID_CLIENT_EXTERN const_iterator begin() const; - QPID_CLIENT_EXTERN const_iterator end() const; - QPID_CLIENT_EXTERN const_reverse_iterator rbegin() const; - QPID_CLIENT_EXTERN const_reverse_iterator rend() const; - - QPID_CLIENT_EXTERN bool empty() const; - QPID_CLIENT_EXTERN size_t size() const; - - QPID_CLIENT_EXTERN const qpid::types::Variant& front() const; - QPID_CLIENT_EXTERN const qpid::types::Variant& back() const; - - QPID_CLIENT_EXTERN const qpid::types::Variant::List& asList() const; - private: - ListViewImpl* impl; -}; - -QPID_CLIENT_EXTERN std::ostream& operator<<(std::ostream& out, const ListView& m); - -}} // namespace qpid::messaging - -#endif /*!QPID_MESSAGING_LISTVIEW_H*/ diff --git a/qpid/cpp/include/qpid/messaging/MapContent.h b/qpid/cpp/include/qpid/messaging/MapContent.h deleted file mode 100644 index 863eaed786..0000000000 --- a/qpid/cpp/include/qpid/messaging/MapContent.h +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef QPID_MESSAGING_MAPCONTENT_H -#define QPID_MESSAGING_MAPCONTENT_H - -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -#include "qpid/messaging/ImportExport.h" -#include "qpid/types/Variant.h" -#include -#include - -namespace qpid { -namespace messaging { - -class MapContentImpl; -class Message; - -/** - * Allows message content to be manipulated as a map - */ -class MapContent -{ - public: - typedef std::string key_type; - typedef std::pair value_type; - typedef std::map::const_iterator const_iterator; - typedef std::map::iterator iterator; - typedef std::map::const_reverse_iterator const_reverse_iterator; - typedef std::map::reverse_iterator reverse_iterator; - - QPID_CLIENT_EXTERN MapContent(Message&); - QPID_CLIENT_EXTERN MapContent(Message&, const qpid::types::Variant::Map&); - QPID_CLIENT_EXTERN ~MapContent(); - - QPID_CLIENT_EXTERN const_iterator begin() const; - QPID_CLIENT_EXTERN const_iterator end() const; - QPID_CLIENT_EXTERN const_reverse_iterator rbegin() const; - QPID_CLIENT_EXTERN const_reverse_iterator rend() const; - QPID_CLIENT_EXTERN iterator begin(); - QPID_CLIENT_EXTERN iterator end(); - QPID_CLIENT_EXTERN reverse_iterator rbegin(); - QPID_CLIENT_EXTERN reverse_iterator rend(); - - QPID_CLIENT_EXTERN bool empty() const; - QPID_CLIENT_EXTERN size_t size() const; - - QPID_CLIENT_EXTERN const_iterator find(const key_type&) const; - QPID_CLIENT_EXTERN iterator find(const key_type&); - QPID_CLIENT_EXTERN const qpid::types::Variant& operator[](const key_type&) const; - QPID_CLIENT_EXTERN qpid::types::Variant& operator[](const key_type&); - - QPID_CLIENT_EXTERN std::pair insert(const value_type&); - QPID_CLIENT_EXTERN iterator insert(iterator position, const value_type&); - QPID_CLIENT_EXTERN void erase(iterator position); - QPID_CLIENT_EXTERN void erase(iterator first, iterator last); - QPID_CLIENT_EXTERN size_t erase(const key_type&); - QPID_CLIENT_EXTERN void clear(); - - QPID_CLIENT_EXTERN void encode(); - - QPID_CLIENT_EXTERN const std::map& asMap() const; - QPID_CLIENT_EXTERN std::map& asMap(); - private: - MapContentImpl* impl; - - QPID_CLIENT_EXTERN MapContent& operator=(const MapContent&); -}; - -QPID_CLIENT_EXTERN std::ostream& operator<<(std::ostream& out, const MapContent& m); - -}} // namespace qpid::messaging - -#endif /*!QPID_MESSAGING_MAPCONTENT_H*/ diff --git a/qpid/cpp/include/qpid/messaging/MapView.h b/qpid/cpp/include/qpid/messaging/MapView.h deleted file mode 100644 index e359a9d929..0000000000 --- a/qpid/cpp/include/qpid/messaging/MapView.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef QPID_MESSAGING_MAPVIEW_H -#define QPID_MESSAGING_MAPVIEW_H - -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -#include "qpid/messaging/ImportExport.h" -#include "qpid/types/Variant.h" -#include -#include - -namespace qpid { -namespace messaging { - -class MapViewImpl; -class Message; - -/** - * Provides a view of message content as a list - */ -class MapView -{ - public: - typedef std::string key_type; - typedef std::pair value_type; - typedef std::map::const_iterator const_iterator; - typedef std::map::const_reverse_iterator const_reverse_iterator; - - QPID_CLIENT_EXTERN MapView(const Message&); - QPID_CLIENT_EXTERN ~MapView(); - QPID_CLIENT_EXTERN MapView& operator=(const MapView&); - - QPID_CLIENT_EXTERN const_iterator begin() const; - QPID_CLIENT_EXTERN const_iterator end() const; - QPID_CLIENT_EXTERN const_reverse_iterator rbegin() const; - QPID_CLIENT_EXTERN const_reverse_iterator rend() const; - - QPID_CLIENT_EXTERN bool empty() const; - QPID_CLIENT_EXTERN size_t size() const; - - QPID_CLIENT_EXTERN const_iterator find(const key_type&) const; - QPID_CLIENT_EXTERN const qpid::types::Variant& operator[](const key_type&) const; - - QPID_CLIENT_EXTERN const std::map& asMap() const; - private: - MapViewImpl* impl; -}; - -QPID_CLIENT_EXTERN std::ostream& operator<<(std::ostream& out, const MapView& m); - -}} // namespace qpid::messaging - -#endif /*!QPID_MESSAGING_MAPVIEW_H*/ diff --git a/qpid/cpp/include/qpid/messaging/Message.h b/qpid/cpp/include/qpid/messaging/Message.h index d7b2622d08..ce7691edc1 100644 --- a/qpid/cpp/include/qpid/messaging/Message.h +++ b/qpid/cpp/include/qpid/messaging/Message.h @@ -23,6 +23,7 @@ */ #include +#include "qpid/Exception.h" #include "qpid/messaging/Duration.h" #include "qpid/types/Variant.h" #include "qpid/messaging/ImportExport.h" @@ -86,17 +87,69 @@ class Message QPID_CLIENT_EXTERN const qpid::types::Variant::Map& getProperties() const; QPID_CLIENT_EXTERN qpid::types::Variant::Map& getProperties(); - QPID_CLIENT_EXTERN const std::string& getContent() const; - QPID_CLIENT_EXTERN std::string& getContent(); - QPID_CLIENT_EXTERN void setContent(const std::string&); + /** + * Note that chars are copied. + */ QPID_CLIENT_EXTERN void setContent(const char* chars, size_t count); - QPID_CLIENT_EXTERN void getContent(std::pair& content) const; + /** Get the content as a std::string */ + QPID_CLIENT_EXTERN std::string getContent() const; + /** Get a const pointer to the start of the content data. */ + QPID_CLIENT_EXTERN const char* getContentPtr() const; + /** Get the size of content in bytes. */ + QPID_CLIENT_EXTERN size_t getContentSize() const; private: MessageImpl* impl; friend struct MessageImplAccess; }; + +struct EncodingException : qpid::Exception +{ + EncodingException(const std::string& msg); +}; + +/** + * Decodes message content into a Variant::Map. + * + * @param message the message whose content should be decoded + * @param map the map into which the message contents will be decoded + * @param encoding if specified, the encoding to use - this overrides + * any encoding specified by the content-type of the message + * @exception EncodingException + */ +void decode(const Message& message, qpid::types::Variant::Map& map, const std::string& encoding = std::string()); +/** + * Decodes message content into a Variant::List. + * + * @param message the message whose content should be decoded + * @param list the list into which the message contents will be decoded + * @param encoding if specified, the encoding to use - this overrides + * any encoding specified by the content-type of the message + * @exception EncodingException + */ +void decode(const Message& message, qpid::types::Variant::List& list, const std::string& encoding = std::string()); +/** + * Encodes a Variant::Map into a message. + * + * @param map the map to be encoded + * @param message the message whose content should be set to the encoded map + * @param encoding if specified, the encoding to use - this overrides + * any encoding specified by the content-type of the message + * @exception EncodingException + */ +void encode(const qpid::types::Variant::Map& map, Message& message, const std::string& encoding = std::string()); +/** + * Encodes a Variant::List into a message. + * + * @param list the list to be encoded + * @param message the message whose content should be set to the encoded list + * @param encoding if specified, the encoding to use - this overrides + * any encoding specified by the content-type of the message + * @exception EncodingException + */ +void encode(const qpid::types::Variant::List& list, Message& message, const std::string& encoding = std::string()); + }} // namespace qpid::messaging #endif /*!QPID_MESSAGING_MESSAGE_H*/ diff --git a/qpid/cpp/include/qpid/messaging/Receiver.h b/qpid/cpp/include/qpid/messaging/Receiver.h index 48b0b78754..d89813acfc 100644 --- a/qpid/cpp/include/qpid/messaging/Receiver.h +++ b/qpid/cpp/include/qpid/messaging/Receiver.h @@ -59,7 +59,7 @@ class Receiver : public qpid::messaging::Handle * for up to the specified timeout for a message to become * available. * - *@exception NoMessageAvailable if there is no message to give + * @exception NoMessageAvailable if there is no message to give * after waiting for the specified timeout. */ QPID_CLIENT_EXTERN Message get(Duration timeout=Duration::FOREVER); @@ -78,7 +78,7 @@ class Receiver : public qpid::messaging::Handle * that there is no message for the subscription this receiver is * serving before throwing an exception. * - *@exception NoMessageAvailable if there is no message to give + * @exception NoMessageAvailable if there is no message to give * after waiting for the specified timeout. */ QPID_CLIENT_EXTERN Message fetch(Duration timeout=Duration::FOREVER); @@ -99,14 +99,14 @@ class Receiver : public qpid::messaging::Handle * Returns the number of messages received and waiting to be * fetched. */ - QPID_CLIENT_EXTERN uint32_t available(); + QPID_CLIENT_EXTERN uint32_t getAvailable(); /** * Returns a count of the number of messages received on this * receiver that have been acknowledged, but for which that * acknowledgement has not yet been confirmed as processed by the * server. */ - QPID_CLIENT_EXTERN uint32_t pendingAck(); + QPID_CLIENT_EXTERN uint32_t getPendingAck(); /** * Cancels this receiver. diff --git a/qpid/cpp/include/qpid/messaging/Sender.h b/qpid/cpp/include/qpid/messaging/Sender.h index b7dd015a55..66a7b1fe37 100644 --- a/qpid/cpp/include/qpid/messaging/Sender.h +++ b/qpid/cpp/include/qpid/messaging/Sender.h @@ -44,6 +44,9 @@ class Sender : public qpid::messaging::Handle QPID_CLIENT_EXTERN ~Sender(); QPID_CLIENT_EXTERN Sender& operator=(const Sender&); + /** + * Sends a message; will block if the pending == capacity + */ QPID_CLIENT_EXTERN void send(const Message& message); QPID_CLIENT_EXTERN void close(); @@ -62,7 +65,7 @@ class Sender : public qpid::messaging::Handle * Returns the number of sent messages pending confirmation of * receipt by the broker. (These are the 'in-doubt' messages). */ - QPID_CLIENT_EXTERN uint32_t pending(); + QPID_CLIENT_EXTERN uint32_t getPending(); /** * Returns the name of this sender. diff --git a/qpid/cpp/include/qpid/messaging/Session.h b/qpid/cpp/include/qpid/messaging/Session.h index eaecb69260..75bbe409ff 100644 --- a/qpid/cpp/include/qpid/messaging/Session.h +++ b/qpid/cpp/include/qpid/messaging/Session.h @@ -87,13 +87,13 @@ class Session : public qpid::messaging::Handle * Returns the total number of messages received and waiting to be * fetched by all Receivers belonging to this session. */ - QPID_CLIENT_EXTERN uint32_t available(); + QPID_CLIENT_EXTERN uint32_t getAvailable(); /** * Returns a count of the number of messages received this session * that have been acknowledged, but for which that acknowledgement * has not yet been confirmed as processed by the server. */ - QPID_CLIENT_EXTERN uint32_t pendingAck(); + QPID_CLIENT_EXTERN uint32_t getPendingAck(); /** * Retrieves the receiver for the next available message. If there * are no available messages at present the call will block for up @@ -108,8 +108,8 @@ class Session : public qpid::messaging::Handle * are no available messages at present the call will block for up * to the specified timeout waiting for one to arrive. * - *@exception Receiver::NoMessageAvailable if no message became available in - * time. + * @exception Receiver::NoMessageAvailable if no message became + * available in time. */ QPID_CLIENT_EXTERN Receiver nextReceiver(Duration timeout=Duration::FOREVER); diff --git a/qpid/cpp/include/qpid/types/Variant.h b/qpid/cpp/include/qpid/types/Variant.h index f57adcd31e..91e37242d0 100644 --- a/qpid/cpp/include/qpid/types/Variant.h +++ b/qpid/cpp/include/qpid/types/Variant.h @@ -138,7 +138,7 @@ class Variant QPID_COMMON_EXTERN operator int64_t() const; QPID_COMMON_EXTERN operator float() const; QPID_COMMON_EXTERN operator double() const; - QPID_COMMON_EXTERN operator const char*() const; + QPID_COMMON_EXTERN operator std::string() const; QPID_COMMON_EXTERN operator Uuid() const; QPID_COMMON_EXTERN const Map& asMap() const; @@ -166,9 +166,6 @@ QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& out, const Variant& va QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& out, const Variant::Map& map); QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& out, const Variant::List& list); QPID_COMMON_EXTERN bool operator==(const Variant& a, const Variant& b); - -typedef Variant::Map VariantMap; - }} // namespace qpid::types #endif /*!QPID_TYPES_VARIANT_H*/ -- cgit v1.2.1 From c53c4cc94e121c0fc3df6010cffa1bbb49a779db Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Wed, 31 Mar 2010 21:13:12 +0000 Subject: Merged the changes from the qmf-devel0.7a branch back to the trunk. This is a checkpoint along the QMFv2 development path. This update introduces portions of QMFv2 into the code: - The C++ agent (qpid/agent) uses QMFv2 for data and method transfer o The APIs no longer use qpid::framing::* o Consequently, boost is no longer referenced from the API headers. o Agents and Objects are now referenced by strings, not numbers. o Schema transfer still uses the QMFv1 format. - The broker-resident agent can use QMFv1 or QMFv2 based on the command line options. It defaults to QMFv1 for compatibility. - The pure-python QMF console (qmf.console) can concurrently interact with both QMFv1 and QMFv2 agents. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@929716 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/agent/ManagementAgent.h | 14 ++++ qpid/cpp/include/qpid/framing/FieldTable.h | 1 + qpid/cpp/include/qpid/management/ManagementEvent.h | 12 ++-- .../cpp/include/qpid/management/ManagementObject.h | 83 +++++++++++++++------- 4 files changed, 82 insertions(+), 28 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/agent/ManagementAgent.h b/qpid/cpp/include/qpid/agent/ManagementAgent.h index b6ec82862c..aeb5585e61 100644 --- a/qpid/cpp/include/qpid/agent/ManagementAgent.h +++ b/qpid/cpp/include/qpid/agent/ManagementAgent.h @@ -63,6 +63,17 @@ class ManagementAgent virtual int getMaxThreads() = 0; + // Set the name of the agent + // + // vendor - Vendor name or domain (i.e. "apache.org") + // product - Product name (i.e. "qpid") + // instance - A unique identifier for this instance of the agent. + // If empty, the agent will create a GUID for the instance. + // + virtual void setName(const std::string& vendor, + const std::string& product, + const std::string& instance="") = 0; + // Connect to a management broker // // brokerHost - Hostname or IP address (dotted-quad) of broker. @@ -128,6 +139,9 @@ class ManagementAgent // in an orderly way. // virtual ObjectId addObject(ManagementObject* objectPtr, uint64_t persistId = 0) = 0; + virtual ObjectId addObject(ManagementObject* objectPtr, + const std::string& key, + bool persistent = true) = 0; // // diff --git a/qpid/cpp/include/qpid/framing/FieldTable.h b/qpid/cpp/include/qpid/framing/FieldTable.h index 085f7ed110..fdb1a28b9d 100644 --- a/qpid/cpp/include/qpid/framing/FieldTable.h +++ b/qpid/cpp/include/qpid/framing/FieldTable.h @@ -51,6 +51,7 @@ class FieldTable typedef boost::shared_ptr ValuePtr; typedef std::map ValueMap; typedef ValueMap::iterator iterator; + typedef ValueMap::const_iterator const_iterator; typedef ValueMap::const_reference const_reference; typedef ValueMap::reference reference; typedef ValueMap::value_type value_type; diff --git a/qpid/cpp/include/qpid/management/ManagementEvent.h b/qpid/cpp/include/qpid/management/ManagementEvent.h index 01b9ae49ec..e80175096f 100644 --- a/qpid/cpp/include/qpid/management/ManagementEvent.h +++ b/qpid/cpp/include/qpid/management/ManagementEvent.h @@ -23,7 +23,7 @@ */ #include "qpid/management/ManagementObject.h" -#include +#include "qpid/types/Variant.h" #include namespace qpid { @@ -32,16 +32,20 @@ namespace management { class ManagementAgent; class ManagementEvent : public ManagementItem { -public: - typedef void (*writeSchemaCall_t)(qpid::framing::Buffer&); + public: + static const uint8_t MD5_LEN = 16; + //typedef void (*writeSchemaCall_t)(qpid::framing::Buffer&); + typedef void (*writeSchemaCall_t)(std::string&); virtual ~ManagementEvent() {} virtual writeSchemaCall_t getWriteSchemaCall(void) = 0; + //virtual mapEncodeSchemaCall_t getMapEncodeSchemaCall(void) = 0; virtual std::string& getEventName() const = 0; virtual std::string& getPackageName() const = 0; virtual uint8_t* getMd5Sum() const = 0; virtual uint8_t getSeverity() const = 0; - virtual void encode(qpid::framing::Buffer&) const = 0; + virtual void encode(std::string&) const = 0; + virtual void mapEncode(qpid::types::Variant::Map&) const = 0; }; }} diff --git a/qpid/cpp/include/qpid/management/ManagementObject.h b/qpid/cpp/include/qpid/management/ManagementObject.h index b1c70f64d6..0e9c7f0a0b 100644 --- a/qpid/cpp/include/qpid/management/ManagementObject.h +++ b/qpid/cpp/include/qpid/management/ManagementObject.h @@ -24,8 +24,8 @@ #include "qpid/sys/Time.h" #include "qpid/sys/Mutex.h" -#include #include "qpid/CommonImportExport.h" +#include "qpid/types/Variant.h" #include #include @@ -53,23 +53,33 @@ protected: const AgentAttachment* agent; uint64_t first; uint64_t second; + uint64_t agentEpoch; std::string v2Key; + std::string agentName; void fromString(const std::string&); public: - QPID_COMMON_EXTERN ObjectId() : agent(0), first(0), second(0) {} - QPID_COMMON_EXTERN ObjectId(framing::Buffer& buf) : agent(0) { decode(buf); } - QPID_COMMON_EXTERN ObjectId(uint8_t flags, uint16_t seq, uint32_t broker, uint32_t bank, uint64_t object); - QPID_COMMON_EXTERN ObjectId(AgentAttachment* _agent, uint8_t flags, uint16_t seq, uint64_t object); + QPID_COMMON_EXTERN ObjectId() : agent(0), first(0), second(0), agentEpoch(0) {} + QPID_COMMON_EXTERN ObjectId(const types::Variant& map) : + agent(0), first(0), second(0), agentEpoch(0) { mapDecode(map.asMap()); } + QPID_COMMON_EXTERN ObjectId(uint8_t flags, uint16_t seq, uint32_t broker); + QPID_COMMON_EXTERN ObjectId(AgentAttachment* _agent, uint8_t flags, uint16_t seq); QPID_COMMON_EXTERN ObjectId(std::istream&); QPID_COMMON_EXTERN ObjectId(const std::string&); + // Deprecated: + QPID_COMMON_EXTERN ObjectId(uint8_t flags, uint16_t seq, uint32_t broker, uint64_t object); QPID_COMMON_EXTERN bool operator==(const ObjectId &other) const; QPID_COMMON_EXTERN bool operator<(const ObjectId &other) const; + QPID_COMMON_EXTERN void mapEncode(types::Variant::Map& map) const; + QPID_COMMON_EXTERN void mapDecode(const types::Variant::Map& map); + QPID_COMMON_EXTERN operator types::Variant::Map() const; QPID_COMMON_EXTERN uint32_t encodedSize() const { return 16; }; - QPID_COMMON_EXTERN void encode(framing::Buffer& buffer) const; - QPID_COMMON_EXTERN void decode(framing::Buffer& buffer); + QPID_COMMON_EXTERN void encode(std::string& buffer) const; + QPID_COMMON_EXTERN void decode(const std::string& buffer); + QPID_COMMON_EXTERN bool equalV1(const ObjectId &other) const; QPID_COMMON_EXTERN void setV2Key(const std::string& _key) { v2Key = _key; } QPID_COMMON_EXTERN void setV2Key(const ManagementObject& object); - QPID_COMMON_EXTERN bool equalV1(const ObjectId &other) const; + QPID_COMMON_EXTERN void setAgentName(const std::string& _name) { agentName = _name; } + QPID_COMMON_EXTERN const std::string& getAgentName() const { return agentName; } QPID_COMMON_EXTERN const std::string& getV2Key() const { return v2Key; } friend QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream&, const ObjectId&); }; @@ -94,6 +104,7 @@ public: static const uint8_t TYPE_S16 = 17; static const uint8_t TYPE_S32 = 18; static const uint8_t TYPE_S64 = 19; + static const uint8_t TYPE_LIST = 21; static const uint8_t ACCESS_RC = 1; static const uint8_t ACCESS_RW = 2; @@ -125,7 +136,7 @@ protected: uint64_t updateTime; ObjectId objectId; mutable bool configChanged; - bool instChanged; + mutable bool instChanged; bool deleted; Manageable* coreObject; mutable sys::Mutex accessLock; @@ -135,13 +146,17 @@ protected: bool forcePublish; QPID_COMMON_EXTERN int getThreadIndex(); - QPID_COMMON_EXTERN void writeTimestamps(qpid::framing::Buffer& buf) const; - QPID_COMMON_EXTERN void readTimestamps(qpid::framing::Buffer& buf); + QPID_COMMON_EXTERN void writeTimestamps(std::string& buf) const; + QPID_COMMON_EXTERN void writeTimestamps(types::Variant::Map& map) const; + QPID_COMMON_EXTERN void readTimestamps(const std::string& buf); + QPID_COMMON_EXTERN void readTimestamps(const types::Variant::Map& buf); QPID_COMMON_EXTERN uint32_t writeTimestampsSize() const; public: + QPID_COMMON_EXTERN static const uint8_t MD5_LEN = 16; QPID_COMMON_EXTERN static int maxThreads; - typedef void (*writeSchemaCall_t) (qpid::framing::Buffer&); + //typedef void (*writeSchemaCall_t) (qpid::framing::Buffer&); + typedef void (*writeSchemaCall_t) (std::string&); ManagementObject(Manageable* _core) : createTime(uint64_t(qpid::sys::Duration(qpid::sys::now()))), @@ -151,15 +166,28 @@ protected: virtual ~ManagementObject() {} virtual writeSchemaCall_t getWriteSchemaCall() = 0; - virtual void readProperties(qpid::framing::Buffer& buf) = 0; - virtual uint32_t writePropertiesSize() const = 0; - virtual void writeProperties(qpid::framing::Buffer& buf) const = 0; - virtual void writeStatistics(qpid::framing::Buffer& buf, - bool skipHeaders = false) = 0; - virtual void doMethod(std::string& methodName, - qpid::framing::Buffer& inBuf, - qpid::framing::Buffer& outBuf) = 0; virtual std::string getKey() const = 0; + + // Encode & Decode the property and statistics values + // for this object. + virtual void mapEncodeValues(types::Variant::Map& map, + bool includeProperties, + bool includeStatistics) = 0; + virtual void mapDecodeValues(const types::Variant::Map& map) = 0; + virtual void doMethod(std::string& methodName, + const types::Variant::Map& inMap, + types::Variant::Map& outMap) = 0; + + /** + * The following five methods are not pure-virtual because they will only + * be overridden in cases where QMFv1 is to be supported. + */ + virtual uint32_t writePropertiesSize() const { return 0; } + virtual void readProperties(const std::string&) {} + virtual void writeProperties(std::string&) const {} + virtual void writeStatistics(std::string&, bool = false) {} + virtual void doMethod(std::string&, const std::string&, std::string&) {} + QPID_COMMON_EXTERN virtual void setReference(ObjectId objectId); virtual std::string& getClassName() const = 0; @@ -183,16 +211,23 @@ protected: inline void setFlags(uint32_t f) { flags = f; } inline uint32_t getFlags() { return flags; } bool isSameClass(ManagementObject& other) { - for (int idx = 0; idx < 16; idx++) + for (int idx = 0; idx < MD5_LEN; idx++) if (other.getMd5Sum()[idx] != getMd5Sum()[idx]) return false; return other.getClassName() == getClassName() && other.getPackageName() == getPackageName(); } - QPID_COMMON_EXTERN void encode(qpid::framing::Buffer& buf) const { writeProperties(buf); } - QPID_COMMON_EXTERN void decode(qpid::framing::Buffer& buf) { readProperties(buf); } - QPID_COMMON_EXTERN uint32_t encodedSize() const { return writePropertiesSize(); } + // QPID_COMMON_EXTERN void encode(qpid::framing::Buffer& buf) const { writeProperties(buf); } + // QPID_COMMON_EXTERN void decode(qpid::framing::Buffer& buf) { readProperties(buf); } + //QPID_COMMON_EXTERN uint32_t encodedSize() const { return writePropertiesSize(); } + + // Encode/Decode the entire object as a map + QPID_COMMON_EXTERN void mapEncode(types::Variant::Map& map, + bool includeProperties=true, + bool includeStatistics=true); + + QPID_COMMON_EXTERN void mapDecode(const types::Variant::Map& map); }; typedef std::map ManagementObjectMap; -- cgit v1.2.1 From b16d99f1de42e7e02cb0c09d83201a9c87275c83 Mon Sep 17 00:00:00 2001 From: "Stephen D. Huston" Date: Thu, 1 Apr 2010 16:28:38 +0000 Subject: Add missing QPID_COMMON_EXTERNs to fix build on Windows. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@930031 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/amqp_0_10/Codecs.h | 11 +++++++---- qpid/cpp/include/qpid/framing/Uuid.h | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/amqp_0_10/Codecs.h b/qpid/cpp/include/qpid/amqp_0_10/Codecs.h index 669b485807..78b0aa671b 100644 --- a/qpid/cpp/include/qpid/amqp_0_10/Codecs.h +++ b/qpid/cpp/include/qpid/amqp_0_10/Codecs.h @@ -22,6 +22,7 @@ * */ +#include "qpid/CommonImportExport.h" #include "qpid/types/Variant.h" namespace qpid { @@ -33,7 +34,7 @@ namespace amqp_0_10 { * Codec for encoding/decoding a map of Variants using the AMQP 0-10 * map encoding. */ -class MapCodec +class QPID_COMMON_EXTERN MapCodec { public: static void encode(const qpid::types::Variant::Map&, std::string&); @@ -46,7 +47,7 @@ class MapCodec * Codec for encoding/decoding a list of Variants using the AMQP 0-10 * list encoding. */ -class ListCodec +class QPID_COMMON_EXTERN ListCodec { public: static void encode(const qpid::types::Variant::List&, std::string&); @@ -62,8 +63,10 @@ class ListCodec * deprecated qpid::framing::FieldTable. * */ -void translate(const qpid::types::Variant::Map& from, qpid::framing::FieldTable& to); -void translate(const qpid::framing::FieldTable& from, qpid::types::Variant::Map& to); +QPID_COMMON_EXTERN void translate(const qpid::types::Variant::Map& from, + qpid::framing::FieldTable& to); +QPID_COMMON_EXTERN void translate(const qpid::framing::FieldTable& from, + qpid::types::Variant::Map& to); }} // namespace qpid::amqp_0_10 diff --git a/qpid/cpp/include/qpid/framing/Uuid.h b/qpid/cpp/include/qpid/framing/Uuid.h index 2cca6e9dfe..d357538b4d 100644 --- a/qpid/cpp/include/qpid/framing/Uuid.h +++ b/qpid/cpp/include/qpid/framing/Uuid.h @@ -61,7 +61,7 @@ struct Uuid : public boost::array { void clear(); /** Test for null (all zeros). */ - bool isNull() const; + QPID_COMMON_EXTERN bool isNull() const; operator bool() const { return !isNull(); } bool operator!() const { return isNull(); } -- cgit v1.2.1 From 4d3714d33c6e779f26d27b18eaaae53c69f7de87 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Thu, 1 Apr 2010 18:41:37 +0000 Subject: QPID-664: minor adjustment to connection option names git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@930061 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Connection.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Connection.h b/qpid/cpp/include/qpid/messaging/Connection.h index 8b0f9e98e3..34a37ab776 100644 --- a/qpid/cpp/include/qpid/messaging/Connection.h +++ b/qpid/cpp/include/qpid/messaging/Connection.h @@ -54,7 +54,6 @@ class Connection : public qpid::messaging::Handle * sasl-min-ssf * sasl-max-ssf * protocol - * urls * * (note also bounds, locale, max-channels and max-framesize, but * not sure whether those should be documented here) @@ -67,6 +66,7 @@ class Connection : public qpid::messaging::Handle * reconnect-interval-min: number of seconds (initial delay between failed reconnection attempts) * reconnect-interval-max: number of seconds (maximum delay between failed reconnection attempts) * reconnect-interval: shorthand for setting the same reconnect_interval_min/max + * reconnect-urls: list of alternate urls to try when connecting * * The reconnect-interval is the time that the client waits * for after a failed attempt to reconnect before retrying. It -- cgit v1.2.1 From 979cdd9b4520c9aede4c225bb24989311f029551 Mon Sep 17 00:00:00 2001 From: "Stephen D. Huston" Date: Thu, 1 Apr 2010 23:39:52 +0000 Subject: Add missing QPID_CLIENT_EXTERNs to fix build on Windows. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@930140 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Message.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Message.h b/qpid/cpp/include/qpid/messaging/Message.h index ce7691edc1..c4b031046a 100644 --- a/qpid/cpp/include/qpid/messaging/Message.h +++ b/qpid/cpp/include/qpid/messaging/Message.h @@ -118,7 +118,9 @@ struct EncodingException : qpid::Exception * any encoding specified by the content-type of the message * @exception EncodingException */ -void decode(const Message& message, qpid::types::Variant::Map& map, const std::string& encoding = std::string()); +QPID_CLIENT_EXTERN void decode(const Message& message, + qpid::types::Variant::Map& map, + const std::string& encoding = std::string()); /** * Decodes message content into a Variant::List. * @@ -128,7 +130,9 @@ void decode(const Message& message, qpid::types::Variant::Map& map, const std::s * any encoding specified by the content-type of the message * @exception EncodingException */ -void decode(const Message& message, qpid::types::Variant::List& list, const std::string& encoding = std::string()); +QPID_CLIENT_EXTERN void decode(const Message& message, + qpid::types::Variant::List& list, + const std::string& encoding = std::string()); /** * Encodes a Variant::Map into a message. * @@ -138,7 +142,9 @@ void decode(const Message& message, qpid::types::Variant::List& list, const std: * any encoding specified by the content-type of the message * @exception EncodingException */ -void encode(const qpid::types::Variant::Map& map, Message& message, const std::string& encoding = std::string()); +QPID_CLIENT_EXTERN void encode(const qpid::types::Variant::Map& map, + Message& message, + const std::string& encoding = std::string()); /** * Encodes a Variant::List into a message. * @@ -148,7 +154,9 @@ void encode(const qpid::types::Variant::Map& map, Message& message, const std::s * any encoding specified by the content-type of the message * @exception EncodingException */ -void encode(const qpid::types::Variant::List& list, Message& message, const std::string& encoding = std::string()); +QPID_CLIENT_EXTERN void encode(const qpid::types::Variant::List& list, + Message& message, + const std::string& encoding = std::string()); }} // namespace qpid::messaging -- cgit v1.2.1 From dd9a35c0bf36bb63a2e584ec28d482a7c5c16ce0 Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Fri, 2 Apr 2010 20:00:06 +0000 Subject: Remove unnecessary reference to qpid/sys/Time.h to avoid pulling in boost on Windows. Stop Duration.h referring to qpid/client include files. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@930362 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Duration.h | 2 +- qpid/cpp/include/qpid/messaging/Session.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Duration.h b/qpid/cpp/include/qpid/messaging/Duration.h index fdd1cf4a50..f38a1c33bc 100644 --- a/qpid/cpp/include/qpid/messaging/Duration.h +++ b/qpid/cpp/include/qpid/messaging/Duration.h @@ -22,7 +22,7 @@ * */ -#include "qpid/client/ClientImportExport.h" +#include "qpid/messaging/ImportExport.h" #include "qpid/sys/IntegerTypes.h" namespace qpid { diff --git a/qpid/cpp/include/qpid/messaging/Session.h b/qpid/cpp/include/qpid/messaging/Session.h index 75bbe409ff..66a4937e6b 100644 --- a/qpid/cpp/include/qpid/messaging/Session.h +++ b/qpid/cpp/include/qpid/messaging/Session.h @@ -25,7 +25,6 @@ #include "qpid/messaging/Duration.h" #include "qpid/messaging/ImportExport.h" #include "qpid/messaging/Handle.h" -#include "qpid/sys/Time.h" #include namespace qpid { -- cgit v1.2.1 From 331a2bea4eb38cbba44c82e7286c13b147b5519b Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Tue, 6 Apr 2010 14:52:47 +0000 Subject: QPID-664: added param to control synchronous send and acknowledge git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@931170 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Sender.h | 9 +++++++-- qpid/cpp/include/qpid/messaging/Session.h | 5 ++++- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Sender.h b/qpid/cpp/include/qpid/messaging/Sender.h index 66a7b1fe37..7c4b68731e 100644 --- a/qpid/cpp/include/qpid/messaging/Sender.h +++ b/qpid/cpp/include/qpid/messaging/Sender.h @@ -45,9 +45,14 @@ class Sender : public qpid::messaging::Handle QPID_CLIENT_EXTERN Sender& operator=(const Sender&); /** - * Sends a message; will block if the pending == capacity + * Sends a message + * + * @param message the message to send + * @param sync if true the call will block until the server + * confirms receipt of the messages; if false will only block for + * available capacity (i.e. pending == capacity) */ - QPID_CLIENT_EXTERN void send(const Message& message); + QPID_CLIENT_EXTERN void send(const Message& message, bool sync=false); QPID_CLIENT_EXTERN void close(); /** diff --git a/qpid/cpp/include/qpid/messaging/Session.h b/qpid/cpp/include/qpid/messaging/Session.h index 66a4937e6b..9b373e2d8b 100644 --- a/qpid/cpp/include/qpid/messaging/Session.h +++ b/qpid/cpp/include/qpid/messaging/Session.h @@ -71,8 +71,11 @@ class Session : public qpid::messaging::Handle /** * Acknowledges all outstanding messages that have been received * by the application on this session. + * + * @param sync if true, blocks until the acknowledgement has been + * processed by the server */ - QPID_CLIENT_EXTERN void acknowledge(); + QPID_CLIENT_EXTERN void acknowledge(bool sync=false); /** * Rejects the specified message. This will prevent the message * being redelivered. -- cgit v1.2.1 From 24816ab849015f212eb49963c3e08b99dfa700fe Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Tue, 6 Apr 2010 19:08:28 +0000 Subject: QPID-664: added method to release messages git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@931275 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Session.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Session.h b/qpid/cpp/include/qpid/messaging/Session.h index 9b373e2d8b..c20de9079b 100644 --- a/qpid/cpp/include/qpid/messaging/Session.h +++ b/qpid/cpp/include/qpid/messaging/Session.h @@ -78,9 +78,16 @@ class Session : public qpid::messaging::Handle QPID_CLIENT_EXTERN void acknowledge(bool sync=false); /** * Rejects the specified message. This will prevent the message - * being redelivered. + * being redelivered. This must be called before the message is + * acknowledged. */ QPID_CLIENT_EXTERN void reject(Message&); + /** + * Releases the specified message. This will allow the broker to + * redeliver the message. This must be called before the message + * is acknowledged. + */ + QPID_CLIENT_EXTERN void release(Message&); QPID_CLIENT_EXTERN void sync(); QPID_CLIENT_EXTERN void flush(); -- cgit v1.2.1 From 728d92b0ddddc8f9a04ae535fd0c09f1479c0b75 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Wed, 7 Apr 2010 19:41:44 +0000 Subject: QPID-664: removed flush, added option to make sync non-blocking if so desired git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@931651 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/client/SessionBase_0_10.h | 2 ++ qpid/cpp/include/qpid/messaging/Connection.h | 3 --- qpid/cpp/include/qpid/messaging/Session.h | 11 +++++++++-- 3 files changed, 11 insertions(+), 5 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/client/SessionBase_0_10.h b/qpid/cpp/include/qpid/client/SessionBase_0_10.h index e76019dd4d..6b7ed97df4 100644 --- a/qpid/cpp/include/qpid/client/SessionBase_0_10.h +++ b/qpid/cpp/include/qpid/client/SessionBase_0_10.h @@ -101,6 +101,8 @@ class SessionBase_0_10 { QPID_CLIENT_EXTERN Connection getConnection(); + /** Send sync request without actually blocking for it**/ + QPID_CLIENT_EXTERN void sendSyncRequest(); protected: boost::shared_ptr impl; friend class SessionBase_0_10Access; diff --git a/qpid/cpp/include/qpid/messaging/Connection.h b/qpid/cpp/include/qpid/messaging/Connection.h index 34a37ab776..933c503635 100644 --- a/qpid/cpp/include/qpid/messaging/Connection.h +++ b/qpid/cpp/include/qpid/messaging/Connection.h @@ -55,9 +55,6 @@ class Connection : public qpid::messaging::Handle * sasl-max-ssf * protocol * - * (note also bounds, locale, max-channels and max-framesize, but - * not sure whether those should be documented here) - * * Reconnect behaviour can be controlled through the following options: * * reconnect: true/false (enables/disables reconnect entirely) diff --git a/qpid/cpp/include/qpid/messaging/Session.h b/qpid/cpp/include/qpid/messaging/Session.h index c20de9079b..95f9832576 100644 --- a/qpid/cpp/include/qpid/messaging/Session.h +++ b/qpid/cpp/include/qpid/messaging/Session.h @@ -89,8 +89,15 @@ class Session : public qpid::messaging::Handle */ QPID_CLIENT_EXTERN void release(Message&); - QPID_CLIENT_EXTERN void sync(); - QPID_CLIENT_EXTERN void flush(); + /** + * Request synchronisation with the server. + * + * @param block if true, this call will block until the server + * confirms completion of all pending operations; if false the + * call will request notifcation from the server but will return + * before receiving it. + */ + QPID_CLIENT_EXTERN void sync(bool block=true); /** * Returns the total number of messages received and waiting to be -- cgit v1.2.1 From 4376b9e814b7b43bace03158f4dac04f6e6ffd4c Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Wed, 7 Apr 2010 19:51:09 +0000 Subject: Added AbsTime::epoch()) constant to Time.h to provide a portable reference time point. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@931656 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/sys/Time.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/sys/Time.h b/qpid/cpp/include/qpid/sys/Time.h index ad05b0d1c7..bd6fe87ec8 100644 --- a/qpid/cpp/include/qpid/sys/Time.h +++ b/qpid/cpp/include/qpid/sys/Time.h @@ -88,13 +88,16 @@ class AbsTime { TimePrivate timepoint; public: - QPID_COMMON_EXTERN inline AbsTime() {} + + QPID_COMMON_EXTERN inline AbsTime() : timepoint() {} QPID_COMMON_EXTERN AbsTime(const AbsTime& time0, const Duration& duration); // Default assignment operation fine // Default copy constructor fine QPID_COMMON_EXTERN static AbsTime now(); QPID_COMMON_EXTERN static AbsTime FarFuture(); + QPID_COMMON_EXTERN static AbsTime epoch(); // The Unix epoch: 1970-01-01T00:00:00 + const TimePrivate& getPrivate(void) const { return timepoint; } bool operator==(const AbsTime& t) const { return t.timepoint == timepoint; } template void serialize(S& s) { s(timepoint); } -- cgit v1.2.1 From 2763bd77f14f04757fc70b006d0fba893e2cee9b Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Wed, 7 Apr 2010 20:51:14 +0000 Subject: Use read-write lock to imporve Logger concurrency. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@931682 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/log/Logger.h | 1 + 1 file changed, 1 insertion(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/log/Logger.h b/qpid/cpp/include/qpid/log/Logger.h index d7da1f077a..80622365b1 100644 --- a/qpid/cpp/include/qpid/log/Logger.h +++ b/qpid/cpp/include/qpid/log/Logger.h @@ -98,6 +98,7 @@ class Logger : private boost::noncopyable { typedef std::set Statements; sys::Mutex lock; + sys::RWlock outputsLock; inline void enable_unlocked(Statement* s); Statements statements; -- cgit v1.2.1 From bb69ac2090b9afb719ce4e4b9130226c34e591d9 Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Thu, 8 Apr 2010 04:53:33 +0000 Subject: Changed the recent AbsTime::Epoch code to conform better to the previously existing code. Fixed AbsTime to compile on Windows again. Removed unused and seemingly extraneous serialize() code from AbsTime. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@931782 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/sys/Time.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/sys/Time.h b/qpid/cpp/include/qpid/sys/Time.h index bd6fe87ec8..7c4bf75b8b 100644 --- a/qpid/cpp/include/qpid/sys/Time.h +++ b/qpid/cpp/include/qpid/sys/Time.h @@ -96,11 +96,10 @@ public: QPID_COMMON_EXTERN static AbsTime now(); QPID_COMMON_EXTERN static AbsTime FarFuture(); - QPID_COMMON_EXTERN static AbsTime epoch(); // The Unix epoch: 1970-01-01T00:00:00 + QPID_COMMON_EXTERN static AbsTime Epoch(); const TimePrivate& getPrivate(void) const { return timepoint; } bool operator==(const AbsTime& t) const { return t.timepoint == timepoint; } - template void serialize(S& s) { s(timepoint); } friend bool operator<(const AbsTime& a, const AbsTime& b); friend bool operator>(const AbsTime& a, const AbsTime& b); @@ -159,6 +158,9 @@ const Duration TIME_NSEC = 1; /** Value to represent an infinite timeout */ const Duration TIME_INFINITE = std::numeric_limits::max(); +/** Absolute time point for the Unix epoch: 1970-01-01T00:00:00 */ +const AbsTime EPOCH = AbsTime::Epoch(); + /** Time greater than any other time */ const AbsTime FAR_FUTURE = AbsTime::FarFuture(); -- cgit v1.2.1 From 6c91609a8b9e6bf768a698afb1ea5ca380dcf361 Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Thu, 8 Apr 2010 05:07:08 +0000 Subject: Remove some clunky accessors for AbsTime on Windows and replace by making Condition a friend class of AbsTime. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@931783 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/sys/Time.h | 2 +- qpid/cpp/include/qpid/sys/windows/Condition.h | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/sys/Time.h b/qpid/cpp/include/qpid/sys/Time.h index 7c4bf75b8b..f21a0d8c75 100644 --- a/qpid/cpp/include/qpid/sys/Time.h +++ b/qpid/cpp/include/qpid/sys/Time.h @@ -84,6 +84,7 @@ class Duration; */ class AbsTime { friend class Duration; + friend class Condition; TimePrivate timepoint; @@ -98,7 +99,6 @@ public: QPID_COMMON_EXTERN static AbsTime FarFuture(); QPID_COMMON_EXTERN static AbsTime Epoch(); - const TimePrivate& getPrivate(void) const { return timepoint; } bool operator==(const AbsTime& t) const { return t.timepoint == timepoint; } friend bool operator<(const AbsTime& a, const AbsTime& b); diff --git a/qpid/cpp/include/qpid/sys/windows/Condition.h b/qpid/cpp/include/qpid/sys/windows/Condition.h index 979fae9b0a..cd5aebbf09 100755 --- a/qpid/cpp/include/qpid/sys/windows/Condition.h +++ b/qpid/cpp/include/qpid/sys/windows/Condition.h @@ -34,9 +34,6 @@ namespace qpid { namespace sys { -// Private Time related implementation details -void toPtime(boost::posix_time::ptime& pt, const AbsTime& t); - /** * A condition variable for thread synchronization. */ @@ -65,7 +62,7 @@ void Condition::wait(Mutex& mutex) { } bool Condition::wait(Mutex& mutex, const AbsTime& absoluteTime){ - return condition.timed_wait(mutex.mutex, absoluteTime.getPrivate()); + return condition.timed_wait(mutex.mutex, absoluteTime.timepoint); } void Condition::notify(){ -- cgit v1.2.1 From 1102cd63f46516cd5b8c46d17567dcd4669adf0a Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Thu, 8 Apr 2010 09:47:21 +0000 Subject: QPID-664: set content-type on encoded messages, removed some duplication and added in a typedef to codecs that may be useful git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@931851 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/amqp_0_10/Codecs.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/amqp_0_10/Codecs.h b/qpid/cpp/include/qpid/amqp_0_10/Codecs.h index 78b0aa671b..62370a0e5e 100644 --- a/qpid/cpp/include/qpid/amqp_0_10/Codecs.h +++ b/qpid/cpp/include/qpid/amqp_0_10/Codecs.h @@ -37,8 +37,9 @@ namespace amqp_0_10 { class QPID_COMMON_EXTERN MapCodec { public: - static void encode(const qpid::types::Variant::Map&, std::string&); - static void decode(const std::string&, qpid::types::Variant::Map&); + typedef qpid::types::Variant::Map ObjectType; + static void encode(const ObjectType&, std::string&); + static void decode(const std::string&, ObjectType&); static const std::string contentType; private: }; @@ -50,8 +51,9 @@ class QPID_COMMON_EXTERN MapCodec class QPID_COMMON_EXTERN ListCodec { public: - static void encode(const qpid::types::Variant::List&, std::string&); - static void decode(const std::string&, qpid::types::Variant::List&); + typedef qpid::types::Variant::List ObjectType; + static void encode(const ObjectType&, std::string&); + static void decode(const std::string&, ObjectType&); static const std::string contentType; private: }; -- cgit v1.2.1 From 13d4a7f61d6b4b9935d88e97d14eda29c9ad0950 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Thu, 8 Apr 2010 09:49:04 +0000 Subject: QPID-664: changed open() to connect(), moved url parameter to constructor, added detach() and isConnected() git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@931852 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Connection.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Connection.h b/qpid/cpp/include/qpid/messaging/Connection.h index 933c503635..e58abc1986 100644 --- a/qpid/cpp/include/qpid/messaging/Connection.h +++ b/qpid/cpp/include/qpid/messaging/Connection.h @@ -53,7 +53,7 @@ class Connection : public qpid::messaging::Handle * sasl-mechanism * sasl-min-ssf * sasl-max-ssf - * protocol + * transport * * Reconnect behaviour can be controlled through the following options: * @@ -71,18 +71,20 @@ class Connection : public qpid::messaging::Handle * doubled every failure until the value of max-retry-interval * is reached. */ - QPID_CLIENT_EXTERN Connection(const qpid::types::Variant::Map& options = qpid::types::Variant::Map()); + QPID_CLIENT_EXTERN Connection(const std::string& url, const qpid::types::Variant::Map& options = qpid::types::Variant::Map()); /** * Creates a connection using an option string of the form * {name=value,name2=value2...}, see above for options supported. * * @exception InvalidOptionString if the string does not match the correct syntax */ - QPID_CLIENT_EXTERN Connection(const std::string& options); + QPID_CLIENT_EXTERN Connection(const std::string& url, const std::string& options); QPID_CLIENT_EXTERN ~Connection(); QPID_CLIENT_EXTERN Connection& operator=(const Connection&); QPID_CLIENT_EXTERN void setOption(const std::string& name, const qpid::types::Variant& value); - QPID_CLIENT_EXTERN void open(const std::string& url); + QPID_CLIENT_EXTERN void connect(); + QPID_CLIENT_EXTERN bool isConnected(); + QPID_CLIENT_EXTERN void detach(); /** * Closes a connection and all sessions associated with it. An * opened connection must be closed before the last handle is -- cgit v1.2.1 From bc855954bb7c6195ff2ba0dc9451e30c8c128bdc Mon Sep 17 00:00:00 2001 From: "Stephen D. Huston" Date: Thu, 8 Apr 2010 16:35:29 +0000 Subject: Removed QPID_COMMON_EXTERN from inlined constructor. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@931995 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/sys/Time.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/sys/Time.h b/qpid/cpp/include/qpid/sys/Time.h index f21a0d8c75..f798baadfe 100644 --- a/qpid/cpp/include/qpid/sys/Time.h +++ b/qpid/cpp/include/qpid/sys/Time.h @@ -90,7 +90,7 @@ class AbsTime { public: - QPID_COMMON_EXTERN inline AbsTime() : timepoint() {} + inline AbsTime() : timepoint() {} QPID_COMMON_EXTERN AbsTime(const AbsTime& time0, const Duration& duration); // Default assignment operation fine // Default copy constructor fine -- cgit v1.2.1 From 5f4ccf5da76ae6ebfdd3252ed6f865e0a72fd745 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Fri, 9 Apr 2010 03:53:30 +0000 Subject: QPID-2489 - Remove references to boost:: and qpid::framing:: from QMF-generated cpp files Added a wrapper class for framing::Buffer in the qpid::management namespace. This wrapper class has no reference to framing or boost and is now used in the generated C++ code to encode QMFv1 content. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@932236 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/amqp_0_10/Codecs.h | 2 + qpid/cpp/include/qpid/framing/Buffer.h | 1 + qpid/cpp/include/qpid/management/Buffer.h | 106 ++++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+) create mode 100644 qpid/cpp/include/qpid/management/Buffer.h (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/amqp_0_10/Codecs.h b/qpid/cpp/include/qpid/amqp_0_10/Codecs.h index 62370a0e5e..08275402fc 100644 --- a/qpid/cpp/include/qpid/amqp_0_10/Codecs.h +++ b/qpid/cpp/include/qpid/amqp_0_10/Codecs.h @@ -40,6 +40,7 @@ class QPID_COMMON_EXTERN MapCodec typedef qpid::types::Variant::Map ObjectType; static void encode(const ObjectType&, std::string&); static void decode(const std::string&, ObjectType&); + static size_t encodedSize(const ObjectType&); static const std::string contentType; private: }; @@ -54,6 +55,7 @@ class QPID_COMMON_EXTERN ListCodec typedef qpid::types::Variant::List ObjectType; static void encode(const ObjectType&, std::string&); static void decode(const std::string&, ObjectType&); + static size_t encodedSize(const ObjectType&); static const std::string contentType; private: }; diff --git a/qpid/cpp/include/qpid/framing/Buffer.h b/qpid/cpp/include/qpid/framing/Buffer.h index 50cc6fefe4..04583433c5 100644 --- a/qpid/cpp/include/qpid/framing/Buffer.h +++ b/qpid/cpp/include/qpid/framing/Buffer.h @@ -75,6 +75,7 @@ class Buffer QPID_COMMON_EXTERN uint32_t available() { return size - position; } QPID_COMMON_EXTERN uint32_t getSize() { return size; } QPID_COMMON_EXTERN uint32_t getPosition() { return position; } + QPID_COMMON_EXTERN void setPosition(uint32_t p) { position = p; } QPID_COMMON_EXTERN Iterator getIterator() { return Iterator(*this); } QPID_COMMON_EXTERN char* getPointer() { return data; } diff --git a/qpid/cpp/include/qpid/management/Buffer.h b/qpid/cpp/include/qpid/management/Buffer.h new file mode 100644 index 0000000000..81710171f5 --- /dev/null +++ b/qpid/cpp/include/qpid/management/Buffer.h @@ -0,0 +1,106 @@ +#ifndef _Management_Buffer_ +#define _Management_Buffer_ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#include "qpid/Exception.h" +#include "qpid/CommonImportExport.h" +#include "qpid/types/Variant.h" +#include + +namespace qpid { +namespace framing { + class Buffer; +} + +namespace management { + +struct OutOfBounds : qpid::Exception { + OutOfBounds() : qpid::Exception(std::string("Out of Bounds")) {} +}; + + +/** + * This class is a wrapper around qpid::framing::Buffer that does not include any dependencies + * from boost or from qpid::framing. + */ +class Buffer +{ +public: + QPID_COMMON_EXTERN Buffer(char* data=0, uint32_t size=0); + QPID_COMMON_EXTERN ~Buffer(); + + QPID_COMMON_EXTERN void record(); + QPID_COMMON_EXTERN void restore(bool reRecord = false); + QPID_COMMON_EXTERN void reset(); + + QPID_COMMON_EXTERN uint32_t available(); + QPID_COMMON_EXTERN uint32_t getSize(); + QPID_COMMON_EXTERN uint32_t getPosition(); + QPID_COMMON_EXTERN char* getPointer(); + + QPID_COMMON_EXTERN void putOctet(uint8_t i); + QPID_COMMON_EXTERN void putShort(uint16_t i); + QPID_COMMON_EXTERN void putLong(uint32_t i); + QPID_COMMON_EXTERN void putLongLong(uint64_t i); + QPID_COMMON_EXTERN void putInt8(int8_t i); + QPID_COMMON_EXTERN void putInt16(int16_t i); + QPID_COMMON_EXTERN void putInt32(int32_t i); + QPID_COMMON_EXTERN void putInt64(int64_t i); + QPID_COMMON_EXTERN void putFloat(float f); + QPID_COMMON_EXTERN void putDouble(double f); + QPID_COMMON_EXTERN void putBin128(const uint8_t* b); + + QPID_COMMON_EXTERN uint8_t getOctet(); + QPID_COMMON_EXTERN uint16_t getShort(); + QPID_COMMON_EXTERN uint32_t getLong(); + QPID_COMMON_EXTERN uint64_t getLongLong(); + QPID_COMMON_EXTERN int8_t getInt8(); + QPID_COMMON_EXTERN int16_t getInt16(); + QPID_COMMON_EXTERN int32_t getInt32(); + QPID_COMMON_EXTERN int64_t getInt64(); + QPID_COMMON_EXTERN float getFloat(); + QPID_COMMON_EXTERN double getDouble(); + + QPID_COMMON_EXTERN void putShortString(const std::string& s); + QPID_COMMON_EXTERN void putMediumString(const std::string& s); + QPID_COMMON_EXTERN void putLongString(const std::string& s); + QPID_COMMON_EXTERN void getShortString(std::string& s); + QPID_COMMON_EXTERN void getMediumString(std::string& s); + QPID_COMMON_EXTERN void getLongString(std::string& s); + QPID_COMMON_EXTERN void getBin128(uint8_t* b); + + QPID_COMMON_EXTERN void putMap(const types::Variant::Map& map); + QPID_COMMON_EXTERN void putList(const types::Variant::List& list); + QPID_COMMON_EXTERN void getMap(types::Variant::Map& map); + QPID_COMMON_EXTERN void getList(types::Variant::List& list); + + QPID_COMMON_EXTERN void putRawData(const std::string& s); + QPID_COMMON_EXTERN void getRawData(std::string& s, uint32_t size); + + QPID_COMMON_EXTERN void putRawData(const uint8_t* data, size_t size); + QPID_COMMON_EXTERN void getRawData(uint8_t* data, size_t size); + +private: + framing::Buffer* impl; +}; + +}} // namespace qpid::management + +#endif -- cgit v1.2.1 From 0aaa340fa8c3b994790b355950d358af3b0979e2 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Fri, 9 Apr 2010 15:08:47 +0000 Subject: QPID-664: changed connect() back to open(),removed detach(),defined new exception hierarchy, added ability to re-use reconnect/replay logic for resource-limit-exceeded errors git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@932451 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/client/SessionBase_0_10.h | 3 - qpid/cpp/include/qpid/messaging/Address.h | 19 +-- qpid/cpp/include/qpid/messaging/Connection.h | 14 +-- qpid/cpp/include/qpid/messaging/Receiver.h | 4 +- qpid/cpp/include/qpid/messaging/Session.h | 10 +- qpid/cpp/include/qpid/messaging/exceptions.h | 150 ++++++++++++++++++++++++ qpid/cpp/include/qpid/types/Exception.h | 44 +++++++ qpid/cpp/include/qpid/types/Variant.h | 4 +- 8 files changed, 207 insertions(+), 41 deletions(-) create mode 100644 qpid/cpp/include/qpid/messaging/exceptions.h create mode 100644 qpid/cpp/include/qpid/types/Exception.h (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/client/SessionBase_0_10.h b/qpid/cpp/include/qpid/client/SessionBase_0_10.h index 6b7ed97df4..3b5c84e74b 100644 --- a/qpid/cpp/include/qpid/client/SessionBase_0_10.h +++ b/qpid/cpp/include/qpid/client/SessionBase_0_10.h @@ -100,9 +100,6 @@ class SessionBase_0_10 { QPID_CLIENT_EXTERN bool isValid() const; QPID_CLIENT_EXTERN Connection getConnection(); - - /** Send sync request without actually blocking for it**/ - QPID_CLIENT_EXTERN void sendSyncRequest(); protected: boost::shared_ptr impl; friend class SessionBase_0_10Access; diff --git a/qpid/cpp/include/qpid/messaging/Address.h b/qpid/cpp/include/qpid/messaging/Address.h index 34a186c9ce..3722db94e8 100644 --- a/qpid/cpp/include/qpid/messaging/Address.h +++ b/qpid/cpp/include/qpid/messaging/Address.h @@ -22,7 +22,7 @@ * */ #include -#include "qpid/Exception.h" +#include "qpid/messaging/exceptions.h" #include "qpid/types/Variant.h" #include "qpid/messaging/ImportExport.h" #include @@ -30,23 +30,6 @@ namespace qpid { namespace messaging { -/** - * Thrown when a syntactically correct address cannot be resolved or - * used. - */ -struct InvalidAddress : public qpid::Exception -{ - InvalidAddress(const std::string& msg); -}; - -/** - * Thrown when an address string with inalid sytanx is used. - */ -struct MalformedAddress : public qpid::Exception -{ - MalformedAddress(const std::string& msg); -}; - class AddressImpl; /** diff --git a/qpid/cpp/include/qpid/messaging/Connection.h b/qpid/cpp/include/qpid/messaging/Connection.h index e58abc1986..23711034d6 100644 --- a/qpid/cpp/include/qpid/messaging/Connection.h +++ b/qpid/cpp/include/qpid/messaging/Connection.h @@ -24,6 +24,7 @@ #include #include "qpid/messaging/ImportExport.h" #include "qpid/messaging/Handle.h" +#include "qpid/messaging/exceptions.h" #include "qpid/types/Variant.h" namespace qpid { @@ -33,11 +34,6 @@ template class PrivateImplRef; class ConnectionImpl; class Session; -struct InvalidOptionString : public qpid::Exception -{ - InvalidOptionString(const std::string& msg); -}; - class Connection : public qpid::messaging::Handle { public: @@ -51,6 +47,7 @@ class Connection : public qpid::messaging::Handle * heartbeat * tcp-nodelay * sasl-mechanism + * sasl-service * sasl-min-ssf * sasl-max-ssf * transport @@ -78,13 +75,12 @@ class Connection : public qpid::messaging::Handle * * @exception InvalidOptionString if the string does not match the correct syntax */ - QPID_CLIENT_EXTERN Connection(const std::string& url, const std::string& options); + QPID_CLIENT_EXTERN Connection(const std::string& url, const std::string& options) throw(InvalidOptionString); QPID_CLIENT_EXTERN ~Connection(); QPID_CLIENT_EXTERN Connection& operator=(const Connection&); QPID_CLIENT_EXTERN void setOption(const std::string& name, const qpid::types::Variant& value); - QPID_CLIENT_EXTERN void connect(); - QPID_CLIENT_EXTERN bool isConnected(); - QPID_CLIENT_EXTERN void detach(); + QPID_CLIENT_EXTERN void open(); + QPID_CLIENT_EXTERN bool isOpen(); /** * Closes a connection and all sessions associated with it. An * opened connection must be closed before the last handle is diff --git a/qpid/cpp/include/qpid/messaging/Receiver.h b/qpid/cpp/include/qpid/messaging/Receiver.h index d89813acfc..6926d3401a 100644 --- a/qpid/cpp/include/qpid/messaging/Receiver.h +++ b/qpid/cpp/include/qpid/messaging/Receiver.h @@ -21,7 +21,7 @@ * under the License. * */ -#include "qpid/Exception.h" +#include "qpid/messaging/exceptions.h" #include "qpid/messaging/ImportExport.h" #include "qpid/messaging/Handle.h" #include "qpid/messaging/Duration.h" @@ -41,8 +41,6 @@ class Session; class Receiver : public qpid::messaging::Handle { public: - struct NoMessageAvailable : qpid::Exception {}; - QPID_CLIENT_EXTERN Receiver(ReceiverImpl* impl = 0); QPID_CLIENT_EXTERN Receiver(const Receiver&); QPID_CLIENT_EXTERN ~Receiver(); diff --git a/qpid/cpp/include/qpid/messaging/Session.h b/qpid/cpp/include/qpid/messaging/Session.h index 95f9832576..b3bc527329 100644 --- a/qpid/cpp/include/qpid/messaging/Session.h +++ b/qpid/cpp/include/qpid/messaging/Session.h @@ -21,7 +21,7 @@ * under the License. * */ -#include "qpid/Exception.h" +#include "qpid/messaging/exceptions.h" #include "qpid/messaging/Duration.h" #include "qpid/messaging/ImportExport.h" #include "qpid/messaging/Handle.h" @@ -40,11 +40,6 @@ class Receiver; class SessionImpl; class Subscription; -struct KeyError : qpid::Exception -{ - QPID_CLIENT_EXTERN KeyError(const std::string&); -}; - /** * A session represents a distinct 'conversation' which can involve * sending and receiving messages to and from different addresses. @@ -159,6 +154,9 @@ class Session : public qpid::messaging::Handle */ QPID_CLIENT_EXTERN Connection getConnection() const; + QPID_CLIENT_EXTERN bool hasError(); + QPID_CLIENT_EXTERN void checkError(); + private: friend class qpid::messaging::PrivateImplRef; }; diff --git a/qpid/cpp/include/qpid/messaging/exceptions.h b/qpid/cpp/include/qpid/messaging/exceptions.h new file mode 100644 index 0000000000..af7959fe13 --- /dev/null +++ b/qpid/cpp/include/qpid/messaging/exceptions.h @@ -0,0 +1,150 @@ +#ifndef QPID_MESSAGING_EXCEPTIONS_H +#define QPID_MESSAGING_EXCEPTIONS_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/types/Exception.h" +#include "qpid/types/Variant.h" +#include "qpid/messaging/ImportExport.h" + +namespace qpid { +namespace messaging { + +struct MessagingException : public qpid::types::Exception +{ + QPID_CLIENT_EXTERN MessagingException(const std::string& msg); + QPID_CLIENT_EXTERN virtual ~MessagingException() throw(); + + qpid::types::Variant::Map detail; + //TODO: override what() to include detail if present +}; + +struct InvalidOptionString : public MessagingException +{ + QPID_CLIENT_EXTERN InvalidOptionString(const std::string& msg); +}; + +struct KeyError : MessagingException +{ + QPID_CLIENT_EXTERN KeyError(const std::string&); +}; + +struct LinkError : MessagingException +{ + QPID_CLIENT_EXTERN LinkError(const std::string&); +}; + +struct AddressError : LinkError +{ + QPID_CLIENT_EXTERN AddressError(const std::string&); +}; + +/** + * Thrown when a syntactically correct address cannot be resolved or + * used. + */ +struct ResolutionError : public AddressError +{ + QPID_CLIENT_EXTERN ResolutionError(const std::string& msg); +}; + +struct AssertionFailed : public ResolutionError +{ + QPID_CLIENT_EXTERN AssertionFailed(const std::string& msg); +}; + +struct NotFound : public ResolutionError +{ + QPID_CLIENT_EXTERN NotFound(const std::string& msg); +}; + +/** + * Thrown when an address string with inalid sytanx is used. + */ +struct MalformedAddress : public AddressError +{ + QPID_CLIENT_EXTERN MalformedAddress(const std::string& msg); +}; + +struct ReceiverError : LinkError +{ + QPID_CLIENT_EXTERN ReceiverError(const std::string&); +}; + +struct FetchError : ReceiverError +{ + QPID_CLIENT_EXTERN FetchError(const std::string&); +}; + +struct NoMessageAvailable : FetchError +{ + QPID_CLIENT_EXTERN NoMessageAvailable(); +}; + +struct SenderError : LinkError +{ + QPID_CLIENT_EXTERN SenderError(const std::string&); +}; + +struct SendError : SenderError +{ + QPID_CLIENT_EXTERN SendError(const std::string&); +}; + +struct TargetCapacityExceeded : SendError +{ + QPID_CLIENT_EXTERN TargetCapacityExceeded(const std::string&); +}; + +struct SessionError : MessagingException +{ + QPID_CLIENT_EXTERN SessionError(const std::string&); +}; + +struct TransactionError : SessionError +{ + QPID_CLIENT_EXTERN TransactionError(const std::string&); +}; + +struct TransactionAborted : TransactionError +{ + QPID_CLIENT_EXTERN TransactionAborted(const std::string&); +}; + +struct UnauthorizedAccess : SessionError +{ + QPID_CLIENT_EXTERN UnauthorizedAccess(const std::string&); +}; + +struct ConnectionError : MessagingException +{ + QPID_CLIENT_EXTERN ConnectionError(const std::string&); +}; + +struct TransportFailure : MessagingException +{ + QPID_CLIENT_EXTERN TransportFailure(const std::string&); +}; + +}} // namespace qpid::messaging + +#endif /*!QPID_MESSAGING_EXCEPTIONS_H*/ diff --git a/qpid/cpp/include/qpid/types/Exception.h b/qpid/cpp/include/qpid/types/Exception.h new file mode 100644 index 0000000000..a8b7d128af --- /dev/null +++ b/qpid/cpp/include/qpid/types/Exception.h @@ -0,0 +1,44 @@ +#ifndef QPID_TYPES_EXCEPTION_H +#define QPID_TYPES_EXCEPTION_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include +#include "qpid/CommonImportExport.h" + +namespace qpid { +namespace types { + +class Exception : public std::exception +{ + public: + QPID_COMMON_EXTERN explicit Exception(const std::string& message=std::string()) throw(); + QPID_COMMON_EXTERN virtual ~Exception() throw(); + QPID_COMMON_EXTERN virtual const char* what() const throw(); + + private: + const std::string message; +}; + +}} // namespace qpid::types + +#endif /*!QPID_TYPES_EXCEPTION_H*/ diff --git a/qpid/cpp/include/qpid/types/Variant.h b/qpid/cpp/include/qpid/types/Variant.h index 91e37242d0..059550bc9c 100644 --- a/qpid/cpp/include/qpid/types/Variant.h +++ b/qpid/cpp/include/qpid/types/Variant.h @@ -26,7 +26,7 @@ #include #include #include "Uuid.h" -#include "qpid/Exception.h" +#include "qpid/types/Exception.h" #include "qpid/sys/IntegerTypes.h" #include "qpid/CommonImportExport.h" @@ -36,7 +36,7 @@ namespace types { /** * Thrown when an illegal conversion of a variant is attempted. */ -struct InvalidConversion : public qpid::Exception +struct InvalidConversion : public Exception { InvalidConversion(const std::string& msg); }; -- cgit v1.2.1 From 07f4175206b402e7745f58b831b0cf6ec1e26c2d Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Fri, 9 Apr 2010 16:27:35 +0000 Subject: QPID-664: changed pending to unsettled; added available to sender; minor update to address doc git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@932490 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Address.h | 9 ++++++++- qpid/cpp/include/qpid/messaging/Receiver.h | 2 +- qpid/cpp/include/qpid/messaging/Sender.h | 8 ++++++-- qpid/cpp/include/qpid/messaging/Session.h | 8 +++++--- 4 files changed, 20 insertions(+), 7 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Address.h b/qpid/cpp/include/qpid/messaging/Address.h index 3722db94e8..99e41bb253 100644 --- a/qpid/cpp/include/qpid/messaging/Address.h +++ b/qpid/cpp/include/qpid/messaging/Address.h @@ -84,9 +84,16 @@ class AddressImpl; * * * node + * A nested map describing properties of the addressed * node. Current properties supported are type (topic or queue), - * durable (boolean), x-declare and x-bindings. + * durable (boolean), x-declare and x-bindings. The x-declare + * option is a nested map in whcih protocol amqp 0-10 specific + * options for queue or exchange declare can be specified. The + * x-bindings option is a nested list, each element of which can + * specify a queue, an exchange, a binding-key and arguments, + * which are used to establish a binding on create. The node + * will be used if queue or exchange values are not specified. * * * diff --git a/qpid/cpp/include/qpid/messaging/Receiver.h b/qpid/cpp/include/qpid/messaging/Receiver.h index 6926d3401a..738ff82507 100644 --- a/qpid/cpp/include/qpid/messaging/Receiver.h +++ b/qpid/cpp/include/qpid/messaging/Receiver.h @@ -104,7 +104,7 @@ class Receiver : public qpid::messaging::Handle * acknowledgement has not yet been confirmed as processed by the * server. */ - QPID_CLIENT_EXTERN uint32_t getPendingAck(); + QPID_CLIENT_EXTERN uint32_t getUnsettled(); /** * Cancels this receiver. diff --git a/qpid/cpp/include/qpid/messaging/Sender.h b/qpid/cpp/include/qpid/messaging/Sender.h index 7c4b68731e..80fa174d80 100644 --- a/qpid/cpp/include/qpid/messaging/Sender.h +++ b/qpid/cpp/include/qpid/messaging/Sender.h @@ -70,8 +70,12 @@ class Sender : public qpid::messaging::Handle * Returns the number of sent messages pending confirmation of * receipt by the broker. (These are the 'in-doubt' messages). */ - QPID_CLIENT_EXTERN uint32_t getPending(); - + QPID_CLIENT_EXTERN uint32_t getUnsettled(); + /** + * Returns the number of messages for which there is available + * capacity. + */ + QPID_CLIENT_EXTERN uint32_t getAvailable(); /** * Returns the name of this sender. */ diff --git a/qpid/cpp/include/qpid/messaging/Session.h b/qpid/cpp/include/qpid/messaging/Session.h index b3bc527329..ac0ea425f6 100644 --- a/qpid/cpp/include/qpid/messaging/Session.h +++ b/qpid/cpp/include/qpid/messaging/Session.h @@ -96,15 +96,17 @@ class Session : public qpid::messaging::Handle /** * Returns the total number of messages received and waiting to be - * fetched by all Receivers belonging to this session. + * fetched by all Receivers belonging to this session. This is the + * total number of available messages across all receivers on this + * session. */ - QPID_CLIENT_EXTERN uint32_t getAvailable(); + QPID_CLIENT_EXTERN uint32_t getReceivable(); /** * Returns a count of the number of messages received this session * that have been acknowledged, but for which that acknowledgement * has not yet been confirmed as processed by the server. */ - QPID_CLIENT_EXTERN uint32_t getPendingAck(); + QPID_CLIENT_EXTERN uint32_t getUnsettledAcks(); /** * Retrieves the receiver for the next available message. If there * are no available messages at present the call will block for up -- cgit v1.2.1 From e3c5ebca4152d1753f714c6b2d62485a2ef4d288 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Fri, 9 Apr 2010 17:19:32 +0000 Subject: QPID-2489 - Added wrapped version of Mutex to isolate QMF-generated source from boost. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@932517 13f79535-47bb-0310-9956-ffa450edef68 --- .../cpp/include/qpid/management/ManagementObject.h | 4 +- qpid/cpp/include/qpid/management/Mutex.h | 66 ++++++++++++++++++++++ 2 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 qpid/cpp/include/qpid/management/Mutex.h (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/management/ManagementObject.h b/qpid/cpp/include/qpid/management/ManagementObject.h index 0e9c7f0a0b..9538a3e831 100644 --- a/qpid/cpp/include/qpid/management/ManagementObject.h +++ b/qpid/cpp/include/qpid/management/ManagementObject.h @@ -23,7 +23,7 @@ */ #include "qpid/sys/Time.h" -#include "qpid/sys/Mutex.h" +#include "qpid/management/Mutex.h" #include "qpid/CommonImportExport.h" #include "qpid/types/Variant.h" #include @@ -139,7 +139,7 @@ protected: mutable bool instChanged; bool deleted; Manageable* coreObject; - mutable sys::Mutex accessLock; + mutable Mutex accessLock; uint32_t flags; static int nextThreadIndex; diff --git a/qpid/cpp/include/qpid/management/Mutex.h b/qpid/cpp/include/qpid/management/Mutex.h new file mode 100644 index 0000000000..ec1ff35402 --- /dev/null +++ b/qpid/cpp/include/qpid/management/Mutex.h @@ -0,0 +1,66 @@ +#ifndef _management_Mutex_h +#define _management_Mutex_h + +/* + * + * Copyright (c) 2008 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. + * + */ + + +namespace qpid { + namespace sys { + class Mutex; + } + + namespace management { + + /** + * Scoped lock template: calls lock() in ctor, unlock() in dtor. + * L can be any class with lock() and unlock() functions. + */ + template class ScopedLockTemplate { + public: + ScopedLockTemplate(L& l) : mutex(l) { mutex.lock(); } + ~ScopedLockTemplate() { mutex.unlock(); } + private: + L& mutex; + }; + + template class ScopedUnlockTemplate { + public: + ScopedUnlockTemplate(L& l) : mutex(l) { mutex.unlock(); } + ~ScopedUnlockTemplate() { mutex.lock(); } + private: + L& mutex; + }; + + class Mutex { + public: + typedef ScopedLockTemplate ScopedLock; + typedef ScopedUnlockTemplate ScopedUnlock; + + Mutex(); + ~Mutex(); + void lock(); + void unlock(); + private: + sys::Mutex* impl; + }; + } +} + +#endif + -- cgit v1.2.1 From dea0572f4b7af8020492ae192daeab078d524c5f Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Fri, 9 Apr 2010 21:46:19 +0000 Subject: Make qmf generated code use new qpid::types::Exception as base for buffer exception. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@932631 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/management/Buffer.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/management/Buffer.h b/qpid/cpp/include/qpid/management/Buffer.h index 81710171f5..c32494b8c0 100644 --- a/qpid/cpp/include/qpid/management/Buffer.h +++ b/qpid/cpp/include/qpid/management/Buffer.h @@ -19,8 +19,8 @@ * under the License. * */ -#include "qpid/Exception.h" #include "qpid/CommonImportExport.h" +#include "qpid/types/Exception.h" #include "qpid/types/Variant.h" #include @@ -31,8 +31,8 @@ namespace framing { namespace management { -struct OutOfBounds : qpid::Exception { - OutOfBounds() : qpid::Exception(std::string("Out of Bounds")) {} +struct OutOfBounds : qpid::types::Exception { + OutOfBounds() : qpid::types::Exception(std::string("Out of Bounds")) {} }; -- cgit v1.2.1 From e94bc23df7b9d7a1612c27d8d4f3e2739fd151c8 Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Fri, 9 Apr 2010 22:41:07 +0000 Subject: Small fixes to get recent management changes to compile under Visual Studio/Windows git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@932641 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/management/Mutex.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/management/Mutex.h b/qpid/cpp/include/qpid/management/Mutex.h index ec1ff35402..67ae04bae9 100644 --- a/qpid/cpp/include/qpid/management/Mutex.h +++ b/qpid/cpp/include/qpid/management/Mutex.h @@ -19,6 +19,7 @@ * */ +#include "qpid/CommonImportExport.h" namespace qpid { namespace sys { @@ -52,10 +53,10 @@ namespace qpid { typedef ScopedLockTemplate ScopedLock; typedef ScopedUnlockTemplate ScopedUnlock; - Mutex(); - ~Mutex(); - void lock(); - void unlock(); + QPID_COMMON_EXTERN Mutex(); + QPID_COMMON_EXTERN ~Mutex(); + QPID_COMMON_EXTERN void lock(); + QPID_COMMON_EXTERN void unlock(); private: sys::Mutex* impl; }; -- cgit v1.2.1 From 9d700685c817f1a6b90d2493360f2ae57a396777 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Mon, 12 Apr 2010 10:24:30 +0000 Subject: QPID-664: removed explicit throw() clause git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@933176 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Connection.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Connection.h b/qpid/cpp/include/qpid/messaging/Connection.h index 23711034d6..59fc471fe7 100644 --- a/qpid/cpp/include/qpid/messaging/Connection.h +++ b/qpid/cpp/include/qpid/messaging/Connection.h @@ -75,7 +75,7 @@ class Connection : public qpid::messaging::Handle * * @exception InvalidOptionString if the string does not match the correct syntax */ - QPID_CLIENT_EXTERN Connection(const std::string& url, const std::string& options) throw(InvalidOptionString); + QPID_CLIENT_EXTERN Connection(const std::string& url, const std::string& options); QPID_CLIENT_EXTERN ~Connection(); QPID_CLIENT_EXTERN Connection& operator=(const Connection&); QPID_CLIENT_EXTERN void setOption(const std::string& name, const qpid::types::Variant& value); -- cgit v1.2.1 From 88604cf22118085d8a1dc6cfcb17b74e1fb59044 Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Wed, 14 Apr 2010 02:13:08 +0000 Subject: Remove final vestiges of old client API references from messaging and agent header files git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@933842 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/agent/ManagementAgent.h | 6 ------ qpid/cpp/include/qpid/management/ManagementObject.h | 18 +++++------------- qpid/cpp/include/qpid/messaging/Address.h | 6 ++++-- qpid/cpp/include/qpid/messaging/Connection.h | 4 +++- qpid/cpp/include/qpid/messaging/Duration.h | 1 + qpid/cpp/include/qpid/messaging/Message.h | 9 +++++---- qpid/cpp/include/qpid/messaging/Receiver.h | 3 ++- qpid/cpp/include/qpid/messaging/Sender.h | 2 ++ qpid/cpp/include/qpid/messaging/Session.h | 4 +++- 9 files changed, 25 insertions(+), 28 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/agent/ManagementAgent.h b/qpid/cpp/include/qpid/agent/ManagementAgent.h index aeb5585e61..456b657dc2 100644 --- a/qpid/cpp/include/qpid/agent/ManagementAgent.h +++ b/qpid/cpp/include/qpid/agent/ManagementAgent.h @@ -24,7 +24,6 @@ #include "qpid/management/ManagementObject.h" #include "qpid/management/ManagementEvent.h" #include "qpid/management/Manageable.h" -#include "qpid/client/ConnectionSettings.h" namespace qpid { namespace management { @@ -104,11 +103,6 @@ class ManagementAgent const std::string& mech = "PLAIN", const std::string& proto = "tcp") = 0; - virtual void init(const client::ConnectionSettings& settings, - uint16_t intervalSeconds = 10, - bool useExternalThread = false, - const std::string& storeFile = "") = 0; - // Register a schema with the management agent. This is normally called by the // package initializer generated by the management code generator. // diff --git a/qpid/cpp/include/qpid/management/ManagementObject.h b/qpid/cpp/include/qpid/management/ManagementObject.h index 9538a3e831..da255d7879 100644 --- a/qpid/cpp/include/qpid/management/ManagementObject.h +++ b/qpid/cpp/include/qpid/management/ManagementObject.h @@ -21,11 +21,11 @@ * under the License. * */ +#include "qpid/CommonImportExport.h" -#include "qpid/sys/Time.h" #include "qpid/management/Mutex.h" -#include "qpid/CommonImportExport.h" #include "qpid/types/Variant.h" + #include #include @@ -158,11 +158,7 @@ protected: //typedef void (*writeSchemaCall_t) (qpid::framing::Buffer&); typedef void (*writeSchemaCall_t) (std::string&); - ManagementObject(Manageable* _core) : - createTime(uint64_t(qpid::sys::Duration(qpid::sys::now()))), - destroyTime(0), updateTime(createTime), configChanged(true), - instChanged(true), deleted(false), - coreObject(_core), forcePublish(false) {} + QPID_COMMON_EXTERN ManagementObject(Manageable* _core); virtual ~ManagementObject() {} virtual writeSchemaCall_t getWriteSchemaCall() = 0; @@ -201,12 +197,8 @@ protected: virtual bool hasInst() { return true; } inline void setForcePublish(bool f) { forcePublish = f; } inline bool getForcePublish() { return forcePublish; } - inline void setUpdateTime() { updateTime = (uint64_t(sys::Duration(sys::now()))); } - - inline void resourceDestroy() { - destroyTime = uint64_t (qpid::sys::Duration(qpid::sys::now())); - deleted = true; - } + QPID_COMMON_EXTERN void setUpdateTime(); + QPID_COMMON_EXTERN void resourceDestroy(); inline bool isDeleted() { return deleted; } inline void setFlags(uint32_t f) { flags = f; } inline uint32_t getFlags() { return flags; } diff --git a/qpid/cpp/include/qpid/messaging/Address.h b/qpid/cpp/include/qpid/messaging/Address.h index 99e41bb253..10d00ba18e 100644 --- a/qpid/cpp/include/qpid/messaging/Address.h +++ b/qpid/cpp/include/qpid/messaging/Address.h @@ -21,10 +21,12 @@ * under the License. * */ -#include +#include "qpid/messaging/ImportExport.h" + #include "qpid/messaging/exceptions.h" #include "qpid/types/Variant.h" -#include "qpid/messaging/ImportExport.h" + +#include #include namespace qpid { diff --git a/qpid/cpp/include/qpid/messaging/Connection.h b/qpid/cpp/include/qpid/messaging/Connection.h index 59fc471fe7..ae5ed4c12e 100644 --- a/qpid/cpp/include/qpid/messaging/Connection.h +++ b/qpid/cpp/include/qpid/messaging/Connection.h @@ -21,12 +21,14 @@ * under the License. * */ -#include #include "qpid/messaging/ImportExport.h" + #include "qpid/messaging/Handle.h" #include "qpid/messaging/exceptions.h" #include "qpid/types/Variant.h" +#include + namespace qpid { namespace messaging { diff --git a/qpid/cpp/include/qpid/messaging/Duration.h b/qpid/cpp/include/qpid/messaging/Duration.h index f38a1c33bc..2791e188d7 100644 --- a/qpid/cpp/include/qpid/messaging/Duration.h +++ b/qpid/cpp/include/qpid/messaging/Duration.h @@ -23,6 +23,7 @@ */ #include "qpid/messaging/ImportExport.h" + #include "qpid/sys/IntegerTypes.h" namespace qpid { diff --git a/qpid/cpp/include/qpid/messaging/Message.h b/qpid/cpp/include/qpid/messaging/Message.h index c4b031046a..9ab98ae0ce 100644 --- a/qpid/cpp/include/qpid/messaging/Message.h +++ b/qpid/cpp/include/qpid/messaging/Message.h @@ -21,12 +21,13 @@ * under the License. * */ +#include "qpid/messaging/ImportExport.h" -#include -#include "qpid/Exception.h" #include "qpid/messaging/Duration.h" +#include "qpid/types/Exception.h" #include "qpid/types/Variant.h" -#include "qpid/messaging/ImportExport.h" + +#include namespace qpid { namespace messaging { @@ -104,7 +105,7 @@ class Message friend struct MessageImplAccess; }; -struct EncodingException : qpid::Exception +struct EncodingException : qpid::types::Exception { EncodingException(const std::string& msg); }; diff --git a/qpid/cpp/include/qpid/messaging/Receiver.h b/qpid/cpp/include/qpid/messaging/Receiver.h index 738ff82507..65581d06c5 100644 --- a/qpid/cpp/include/qpid/messaging/Receiver.h +++ b/qpid/cpp/include/qpid/messaging/Receiver.h @@ -21,8 +21,9 @@ * under the License. * */ -#include "qpid/messaging/exceptions.h" #include "qpid/messaging/ImportExport.h" + +#include "qpid/messaging/exceptions.h" #include "qpid/messaging/Handle.h" #include "qpid/messaging/Duration.h" diff --git a/qpid/cpp/include/qpid/messaging/Sender.h b/qpid/cpp/include/qpid/messaging/Sender.h index 80fa174d80..4b64224596 100644 --- a/qpid/cpp/include/qpid/messaging/Sender.h +++ b/qpid/cpp/include/qpid/messaging/Sender.h @@ -22,8 +22,10 @@ * */ #include "qpid/messaging/ImportExport.h" + #include "qpid/messaging/Handle.h" #include "qpid/sys/IntegerTypes.h" + #include namespace qpid { diff --git a/qpid/cpp/include/qpid/messaging/Session.h b/qpid/cpp/include/qpid/messaging/Session.h index ac0ea425f6..7413417058 100644 --- a/qpid/cpp/include/qpid/messaging/Session.h +++ b/qpid/cpp/include/qpid/messaging/Session.h @@ -21,10 +21,12 @@ * under the License. * */ +#include "qpid/messaging/ImportExport.h" + #include "qpid/messaging/exceptions.h" #include "qpid/messaging/Duration.h" -#include "qpid/messaging/ImportExport.h" #include "qpid/messaging/Handle.h" + #include namespace qpid { -- cgit v1.2.1 From a7f0c4d48ded9eb951a837716db8cf82e4561d24 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Wed, 14 Apr 2010 14:40:08 +0000 Subject: Tidy up unnecessary includes in ConnectionSettings and fix consequences git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@933971 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/client/Connection.h | 2 ++ qpid/cpp/include/qpid/client/ConnectionSettings.h | 14 +++++--------- 2 files changed, 7 insertions(+), 9 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/client/Connection.h b/qpid/cpp/include/qpid/client/Connection.h index 4d92d4b804..6ed0d98bc0 100644 --- a/qpid/cpp/include/qpid/client/Connection.h +++ b/qpid/cpp/include/qpid/client/Connection.h @@ -28,6 +28,8 @@ #include "qpid/client/ConnectionSettings.h" #include "qpid/framing/ProtocolVersion.h" +#include "boost/function.hpp" + namespace qpid { struct Url; diff --git a/qpid/cpp/include/qpid/client/ConnectionSettings.h b/qpid/cpp/include/qpid/client/ConnectionSettings.h index 46053e1fa8..bf060e73bb 100644 --- a/qpid/cpp/include/qpid/client/ConnectionSettings.h +++ b/qpid/cpp/include/qpid/client/ConnectionSettings.h @@ -22,13 +22,9 @@ * */ -#include "qpid/Options.h" -#include "qpid/log/Options.h" -#include "qpid/Url.h" #include "qpid/client/ClientImportExport.h" - -#include -#include +#include "qpid/sys/IntegerTypes.h" +#include namespace qpid { @@ -107,7 +103,7 @@ struct ConnectionSettings { * Limit the size of the connections send buffer . The buffer * is limited to bounds * maxFrameSize. */ - uint bounds; + unsigned int bounds; /** * If true, TCP_NODELAY will be set for the connection. */ @@ -120,12 +116,12 @@ struct ConnectionSettings { * Minimum acceptable strength of any SASL negotiated security * layer. 0 means no security layer required. */ - uint minSsf; + unsigned int minSsf; /** * Maximum acceptable strength of any SASL negotiated security * layer. 0 means no security layer allowed. */ - uint maxSsf; + unsigned int maxSsf; }; }} // namespace qpid::client -- cgit v1.2.1 From f5cc88101cd67ad288811e96f334e71201e69db0 Mon Sep 17 00:00:00 2001 From: Kenneth Anthony Giusti Date: Mon, 19 Apr 2010 18:56:53 +0000 Subject: QMF: Add timestamps to generated V2 objects git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@935704 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/management/ManagementObject.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/management/ManagementObject.h b/qpid/cpp/include/qpid/management/ManagementObject.h index da255d7879..9c2d14fa94 100644 --- a/qpid/cpp/include/qpid/management/ManagementObject.h +++ b/qpid/cpp/include/qpid/management/ManagementObject.h @@ -147,9 +147,7 @@ protected: QPID_COMMON_EXTERN int getThreadIndex(); QPID_COMMON_EXTERN void writeTimestamps(std::string& buf) const; - QPID_COMMON_EXTERN void writeTimestamps(types::Variant::Map& map) const; QPID_COMMON_EXTERN void readTimestamps(const std::string& buf); - QPID_COMMON_EXTERN void readTimestamps(const types::Variant::Map& buf); QPID_COMMON_EXTERN uint32_t writeTimestampsSize() const; public: @@ -173,6 +171,8 @@ protected: virtual void doMethod(std::string& methodName, const types::Variant::Map& inMap, types::Variant::Map& outMap) = 0; + QPID_COMMON_EXTERN void writeTimestamps(types::Variant::Map& map) const; + QPID_COMMON_EXTERN void readTimestamps(const types::Variant::Map& buf); /** * The following five methods are not pure-virtual because they will only @@ -215,11 +215,11 @@ protected: //QPID_COMMON_EXTERN uint32_t encodedSize() const { return writePropertiesSize(); } // Encode/Decode the entire object as a map - QPID_COMMON_EXTERN void mapEncode(types::Variant::Map& map, - bool includeProperties=true, - bool includeStatistics=true); + //QPID_COMMON_EXTERN void mapEncode(types::Variant::Map& map, + //bool includeProperties=true, + //bool includeStatistics=true); - QPID_COMMON_EXTERN void mapDecode(const types::Variant::Map& map); + //QPID_COMMON_EXTERN void mapDecode(const types::Variant::Map& map); }; typedef std::map ManagementObjectMap; -- cgit v1.2.1 From e20869eb4e1ed97f00c3f3e9843b14a00267d25b Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Wed, 21 Apr 2010 22:07:04 +0000 Subject: QPID-2527: Remove Thread::id member as its uses are better implemented by comparison operators. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@936537 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/sys/Thread.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/sys/Thread.h b/qpid/cpp/include/qpid/sys/Thread.h index bfea4b4944..45a39e796f 100644 --- a/qpid/cpp/include/qpid/sys/Thread.h +++ b/qpid/cpp/include/qpid/sys/Thread.h @@ -49,16 +49,18 @@ class Thread QPID_COMMON_EXTERN explicit Thread(qpid::sys::Runnable*); QPID_COMMON_EXTERN explicit Thread(qpid::sys::Runnable&); - QPID_COMMON_EXTERN void join(); + QPID_COMMON_EXTERN operator bool(); + QPID_COMMON_EXTERN bool operator==(const Thread&) const; + QPID_COMMON_EXTERN bool operator!=(const Thread&) const; - QPID_COMMON_EXTERN unsigned long id(); + QPID_COMMON_EXTERN void join(); QPID_COMMON_EXTERN static Thread current(); /** ID of current thread for logging. * Workaround for broken Thread::current() in APR */ - static unsigned long logId() { return current().id(); } + QPID_COMMON_EXTERN static unsigned long logId(); }; }} -- cgit v1.2.1 From b4738c5e99ee9e751f45deb177270bc0bb0a775e Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Fri, 23 Apr 2010 03:59:52 +0000 Subject: QPID-1904: Ensure that all timestamp uses are correctly relative to 1/1/1970 epoch. - Removed the hacky way to access the internal time value in AbsTime now that there is a defined AbsTime value EPOCH. - Changed all the code to use Duration(EPOCH, abtime) git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@937147 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/sys/Time.h | 16 +++++----------- qpid/cpp/include/qpid/sys/posix/Condition.h | 2 +- 2 files changed, 6 insertions(+), 12 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/sys/Time.h b/qpid/cpp/include/qpid/sys/Time.h index f798baadfe..d3ab832229 100644 --- a/qpid/cpp/include/qpid/sys/Time.h +++ b/qpid/cpp/include/qpid/sys/Time.h @@ -58,20 +58,15 @@ class Duration; * accessors to its internal state. If you think you want to replace its value, * you need to construct a new AbsTime and assign it, viz: * - * AbsTime when = AbsTime::now(); + * AbsTime when = now(); * ... * when = AbsTime(when, 2*TIME_SEC); // Advance timer 2 secs * - * If for some reason you need access to the internal nanosec value you need - * to convert the AbsTime to a Duration and use its conversion to int64_t, viz: + * AbsTime is not intended to be used to represent calendar dates/times + * but you can construct a Duration since the Unix Epoch, 1970-1-1-00:00, + * so that you can convert to a date/time if needed: * - * AbsTime now = AbsTime::now(); - * - * int64_t ns = Duration(now); - * - * However note that the nanosecond value that is returned here is not - * defined to be anything in particular and could vary from platform to - * platform. + * int64_t nanosec_since_epoch = Duration(EPOCH, now()); * * There are some sensible operations that are currently missing from * AbsTime, but nearly all that's needed can be done with a mixture of @@ -125,7 +120,6 @@ class Duration { public: QPID_COMMON_EXTERN inline Duration(int64_t time0 = 0); - QPID_COMMON_EXTERN explicit Duration(const AbsTime& time0); QPID_COMMON_EXTERN explicit Duration(const AbsTime& start, const AbsTime& finish); inline operator int64_t() const; }; diff --git a/qpid/cpp/include/qpid/sys/posix/Condition.h b/qpid/cpp/include/qpid/sys/posix/Condition.h index 279039735a..36e7557ffd 100644 --- a/qpid/cpp/include/qpid/sys/posix/Condition.h +++ b/qpid/cpp/include/qpid/sys/posix/Condition.h @@ -65,7 +65,7 @@ void Condition::wait(Mutex& mutex) { bool Condition::wait(Mutex& mutex, const AbsTime& absoluteTime){ struct timespec ts; - toTimespec(ts, Duration(absoluteTime)); + toTimespec(ts, Duration(EPOCH, absoluteTime)); int status = pthread_cond_timedwait(&condition, &mutex.mutex, &ts); if (status != 0) { if (status == ETIMEDOUT) return false; -- cgit v1.2.1 From 46ebf5fb57eda5044f57486a53bf822efc21f3a0 Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Wed, 28 Apr 2010 20:02:18 +0000 Subject: Replaced some unnecessary streaming operators ("<<") with preprocessor string concatenation git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@939068 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/Msg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/Msg.h b/qpid/cpp/include/qpid/Msg.h index 6e08a89571..a4450eb34c 100644 --- a/qpid/cpp/include/qpid/Msg.h +++ b/qpid/cpp/include/qpid/Msg.h @@ -69,7 +69,7 @@ inline std::ostream& operator<<(std::ostream& o, const Msg& m) { } /** Construct a message using operator << and append (file:line) */ -#define QPID_MSG(message) ::qpid::Msg() << message << " (" << __FILE__ << ":" << __LINE__ << ")" +#define QPID_MSG(message) (::qpid::Msg() << message << " (" __FILE__ ":" "##__LINE__##" ")") } // namespace qpid -- cgit v1.2.1 From 28970fdd83d8514964cd79e1ef57d4d7db0c0c3d Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Thu, 29 Apr 2010 02:44:06 +0000 Subject: Fix previous checkin and correctly quote __LINE__ in QPID_MSG git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@939184 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/Msg.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/Msg.h b/qpid/cpp/include/qpid/Msg.h index a4450eb34c..e1837c29e5 100644 --- a/qpid/cpp/include/qpid/Msg.h +++ b/qpid/cpp/include/qpid/Msg.h @@ -69,7 +69,9 @@ inline std::ostream& operator<<(std::ostream& o, const Msg& m) { } /** Construct a message using operator << and append (file:line) */ -#define QPID_MSG(message) (::qpid::Msg() << message << " (" __FILE__ ":" "##__LINE__##" ")") +#define QUOTE_(x) #x +#define QUOTE(x) QUOTE_(x) +#define QPID_MSG(message) (::qpid::Msg() << message << " (" __FILE__ ":" QUOTE(__LINE__) ")") } // namespace qpid -- cgit v1.2.1 From 671f79a045c5ca31cab8db699292e6020b749088 Mon Sep 17 00:00:00 2001 From: Jonathan Robie Date: Thu, 29 Apr 2010 16:36:29 +0000 Subject: Added doxygen group directives. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@939373 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Address.h | 2 +- qpid/cpp/include/qpid/messaging/Connection.h | 6 +++++- qpid/cpp/include/qpid/messaging/Duration.h | 2 +- qpid/cpp/include/qpid/messaging/Handle.h | 2 +- qpid/cpp/include/qpid/messaging/Message.h | 2 +- qpid/cpp/include/qpid/messaging/Receiver.h | 2 +- qpid/cpp/include/qpid/messaging/Sender.h | 2 +- qpid/cpp/include/qpid/messaging/Session.h | 2 +- qpid/cpp/include/qpid/messaging/exceptions.h | 3 +++ 9 files changed, 15 insertions(+), 8 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Address.h b/qpid/cpp/include/qpid/messaging/Address.h index 10d00ba18e..7bb821e644 100644 --- a/qpid/cpp/include/qpid/messaging/Address.h +++ b/qpid/cpp/include/qpid/messaging/Address.h @@ -34,7 +34,7 @@ namespace messaging { class AddressImpl; -/** +/** \ingroup messaging * Represents an address to which messages can be sent and from which * messages can be received. Often a simple name is sufficient for * this, however this can be augmented with a subject pattern and diff --git a/qpid/cpp/include/qpid/messaging/Connection.h b/qpid/cpp/include/qpid/messaging/Connection.h index ae5ed4c12e..d3db50592b 100644 --- a/qpid/cpp/include/qpid/messaging/Connection.h +++ b/qpid/cpp/include/qpid/messaging/Connection.h @@ -36,12 +36,16 @@ template class PrivateImplRef; class ConnectionImpl; class Session; +/** \ingroup messaging + * A connection represents a network connection to a remote endpoint. + */ + class Connection : public qpid::messaging::Handle { public: QPID_CLIENT_EXTERN Connection(ConnectionImpl* impl); QPID_CLIENT_EXTERN Connection(const Connection&); - /** + /** * Current implementation supports the following options: * * username diff --git a/qpid/cpp/include/qpid/messaging/Duration.h b/qpid/cpp/include/qpid/messaging/Duration.h index 2791e188d7..3198ebe6a2 100644 --- a/qpid/cpp/include/qpid/messaging/Duration.h +++ b/qpid/cpp/include/qpid/messaging/Duration.h @@ -29,7 +29,7 @@ namespace qpid { namespace messaging { -/** +/** \ingroup messaging * A duration is a time in milliseconds. */ class Duration diff --git a/qpid/cpp/include/qpid/messaging/Handle.h b/qpid/cpp/include/qpid/messaging/Handle.h index c528c39e19..cfc6e8ebfc 100644 --- a/qpid/cpp/include/qpid/messaging/Handle.h +++ b/qpid/cpp/include/qpid/messaging/Handle.h @@ -29,7 +29,7 @@ namespace messaging { template class PrivateImplRef; -/** +/** \ingroup messaging * A handle is like a pointer: refers to an underlying implementation object. * Copying the handle does not copy the object. * diff --git a/qpid/cpp/include/qpid/messaging/Message.h b/qpid/cpp/include/qpid/messaging/Message.h index 9ab98ae0ce..8e4c274734 100644 --- a/qpid/cpp/include/qpid/messaging/Message.h +++ b/qpid/cpp/include/qpid/messaging/Message.h @@ -36,7 +36,7 @@ class Address; class Codec; struct MessageImpl; -/** +/** \ingroup messaging * Representation of a message. */ class Message diff --git a/qpid/cpp/include/qpid/messaging/Receiver.h b/qpid/cpp/include/qpid/messaging/Receiver.h index 65581d06c5..a368b113c1 100644 --- a/qpid/cpp/include/qpid/messaging/Receiver.h +++ b/qpid/cpp/include/qpid/messaging/Receiver.h @@ -36,7 +36,7 @@ class Message; class ReceiverImpl; class Session; -/** +/** \ingroup messaging * Interface through which messages are received. */ class Receiver : public qpid::messaging::Handle diff --git a/qpid/cpp/include/qpid/messaging/Sender.h b/qpid/cpp/include/qpid/messaging/Sender.h index 4b64224596..9b5d0452e8 100644 --- a/qpid/cpp/include/qpid/messaging/Sender.h +++ b/qpid/cpp/include/qpid/messaging/Sender.h @@ -35,7 +35,7 @@ template class PrivateImplRef; class Message; class SenderImpl; class Session; -/** +/** \ingroup messaging * Interface through which messages are sent. */ class Sender : public qpid::messaging::Handle diff --git a/qpid/cpp/include/qpid/messaging/Session.h b/qpid/cpp/include/qpid/messaging/Session.h index 7413417058..9fa9fe48d1 100644 --- a/qpid/cpp/include/qpid/messaging/Session.h +++ b/qpid/cpp/include/qpid/messaging/Session.h @@ -42,7 +42,7 @@ class Receiver; class SessionImpl; class Subscription; -/** +/** \ingroup messaging * A session represents a distinct 'conversation' which can involve * sending and receiving messages to and from different addresses. */ diff --git a/qpid/cpp/include/qpid/messaging/exceptions.h b/qpid/cpp/include/qpid/messaging/exceptions.h index af7959fe13..e20c1742c1 100644 --- a/qpid/cpp/include/qpid/messaging/exceptions.h +++ b/qpid/cpp/include/qpid/messaging/exceptions.h @@ -29,6 +29,9 @@ namespace qpid { namespace messaging { +/** \ingroup messaging + */ + struct MessagingException : public qpid::types::Exception { QPID_CLIENT_EXTERN MessagingException(const std::string& msg); -- cgit v1.2.1 From 2b02dfc5293b55a3644d0d241ec1a7c6774f0dd5 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Tue, 11 May 2010 10:06:30 +0000 Subject: QPID-664: Add default constructor for Connection; add option to set url on existing connection. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@943071 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Connection.h | 1 + 1 file changed, 1 insertion(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Connection.h b/qpid/cpp/include/qpid/messaging/Connection.h index d3db50592b..bd13700e0e 100644 --- a/qpid/cpp/include/qpid/messaging/Connection.h +++ b/qpid/cpp/include/qpid/messaging/Connection.h @@ -45,6 +45,7 @@ class Connection : public qpid::messaging::Handle public: QPID_CLIENT_EXTERN Connection(ConnectionImpl* impl); QPID_CLIENT_EXTERN Connection(const Connection&); + QPID_CLIENT_EXTERN Connection(); /** * Current implementation supports the following options: * -- cgit v1.2.1 From f3e8a605653ebb9ff310d0982e58721168a72fc5 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Tue, 11 May 2010 14:39:58 +0000 Subject: Support for multiple protocols in qpid::Url. - simplified qpid::Address to hold (protocol,host,port) triples. - protocol plugins call Url:addProtocol to add tags to Url parser. - use Address::protocol when establishing connections. - ssl_test: tests using URL to connect. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@943130 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/Address.h | 62 +++++++++------------------------- qpid/cpp/include/qpid/Url.h | 19 ++++++----- qpid/cpp/include/qpid/sys/SystemInfo.h | 5 +-- 3 files changed, 29 insertions(+), 57 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/Address.h b/qpid/cpp/include/qpid/Address.h index fe82b21b9e..71da7b25db 100755 --- a/qpid/cpp/include/qpid/Address.h +++ b/qpid/cpp/include/qpid/Address.h @@ -21,64 +21,34 @@ #include "qpid/sys/IntegerTypes.h" #include "qpid/CommonImportExport.h" -#include #include #include -#include namespace qpid { +namespace client { class ConnectionSettings; } -/** TCP address of a broker - host:port */ -struct TcpAddress { - static const uint16_t DEFAULT_PORT=5672; - QPID_COMMON_EXTERN explicit TcpAddress(const std::string& host_=std::string(),uint16_t port_=DEFAULT_PORT); - std::string host; - uint16_t port; -}; -bool operator==(const TcpAddress& x, const TcpAddress& y); -QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& os, const TcpAddress& a); - -/**@internal Not a real address type, this is a placeholder to - * demonstrate and validate multi-protocol Urls for unit tests and - * developer education only. An example address holds just a char. - */ -struct ExampleAddress { - explicit ExampleAddress(char data); - char data; -}; -bool operator==(const ExampleAddress& x, const ExampleAddress& y); -std::ostream& operator<<(std::ostream& os, const ExampleAddress& a); /** - * Contains the address of an AMQP broker. Can any supported type of - * broker address. Currently only TcpAddress is supported. + * Contains the protocol address of an AMQP broker. */ struct Address { public: - Address(const Address& a) : value(a.value) {} - Address(const TcpAddress& tcp) : value(tcp) {} - Address(const ExampleAddress& eg) : value(eg) {} ///<@internal - - template Address& operator=(const AddressType& t) { value=t; return *this; } - - /** Get the address of type AddressType. - *@return AddressType* pointing to the contained address or 0 if - *contained address is not of type AddressType. - */ - template AddressType* get() { return boost::get(&value); } - - /** Get the address of type AddressType. - *@return AddressType* pointing to the contained address or 0 if - *contained address is not of type AddressType. - */ - template const AddressType* get() const { return boost::get(&value); } - -private: - boost::variant value; - friend std::ostream& operator<<(std::ostream& os, const Address& addr); + static const std::string TCP; // Default TCP protocol tag. + static const uint16_t AMQP_PORT=5672; // Default AMQP port. + + QPID_COMMON_EXTERN explicit Address( + const std::string& protocol_=std::string(), + const std::string& host_=std::string(), + uint16_t port_=0 + ) : protocol(protocol_), host(host_), port(port_) {} + + std::string protocol; + std::string host; + uint16_t port; }; - +QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& os, const Address& addr); +QPID_COMMON_EXTERN bool operator==(const Address& x, const Address& y); } // namespace qpid diff --git a/qpid/cpp/include/qpid/Url.h b/qpid/cpp/include/qpid/Url.h index d0f4bb0c22..44b13b0c2a 100644 --- a/qpid/cpp/include/qpid/Url.h +++ b/qpid/cpp/include/qpid/Url.h @@ -29,13 +29,11 @@ namespace qpid { -QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& os, const TcpAddress& a); - /** An AMQP URL contains a list of addresses */ struct Url : public std::vector
    { /** Url with the hostname as returned by gethostname(2) */ - static Url getHostNameUrl(uint16_t port); + QPID_COMMON_EXTERN static Url getHostNameUrl(uint16_t port); /** Url with local IP address(es), may be more than one address * on a multi-homed host. */ @@ -65,21 +63,24 @@ struct Url : public std::vector
    { /** Throw Invalid if the URL does not contain any addresses. */ QPID_COMMON_EXTERN void throwIfEmpty() const; - /** Replace contents with parsed URL as defined in - * https://wiki.108.redhat.com/jira/browse/AMQP-95 + /** Replace contents with parsed url *@exception Invalid if the url is invalid. */ QPID_COMMON_EXTERN void parse(const char* url); QPID_COMMON_EXTERN void parse(const std::string& url) { parse(url.c_str()); } - /** Replace contesnts with parsed URL as defined in - * https://wiki.108.redhat.com/jira/browse/AMQP-95 - * url.empty() will be true if url is invalid. - */ + /** Replace contesnts with parsed URL. Replace with empty URL if invalid. */ void parseNoThrow(const char* url); + /** Add a protocol tag to be recognzed in URLs. + * Only for use by protcol plug-in initializers. + */ + static void addProtocol(const std::string& tag); + private: mutable std::string cache; // cache string form for efficiency. + static std::vector protocols; + friend class UrlParser; }; inline bool operator==(const Url& a, const Url& b) { return a.str()==b.str(); } diff --git a/qpid/cpp/include/qpid/sys/SystemInfo.h b/qpid/cpp/include/qpid/sys/SystemInfo.h index 09f9980173..23594cf650 100644 --- a/qpid/cpp/include/qpid/sys/SystemInfo.h +++ b/qpid/cpp/include/qpid/sys/SystemInfo.h @@ -24,6 +24,7 @@ #include "qpid/sys/IntegerTypes.h" #include "qpid/Address.h" #include "qpid/CommonImportExport.h" +#include namespace qpid { namespace sys { @@ -40,10 +41,10 @@ namespace SystemInfo { QPID_COMMON_EXTERN long concurrency(); /** - * Get the local host name and set it in the specified TcpAddress. + * Get the local host name and set it in the specified. * Returns false if it can't be obtained and sets errno to any error value. */ - QPID_COMMON_EXTERN bool getLocalHostname (TcpAddress &address); + QPID_COMMON_EXTERN bool getLocalHostname (Address &address); QPID_COMMON_EXTERN void getLocalIpAddresses (uint16_t port, std::vector
    &addrList); -- cgit v1.2.1 From 228be4e020ebc5cdc9a7d04b9980d666ac99d9b4 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Tue, 11 May 2010 16:23:36 +0000 Subject: Added missing EXTERNs for Windows git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@943164 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/Url.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/Url.h b/qpid/cpp/include/qpid/Url.h index 44b13b0c2a..5f6ff990ac 100644 --- a/qpid/cpp/include/qpid/Url.h +++ b/qpid/cpp/include/qpid/Url.h @@ -70,12 +70,12 @@ struct Url : public std::vector
    { QPID_COMMON_EXTERN void parse(const std::string& url) { parse(url.c_str()); } /** Replace contesnts with parsed URL. Replace with empty URL if invalid. */ - void parseNoThrow(const char* url); + QPID_COMMON_EXTERN void parseNoThrow(const char* url); /** Add a protocol tag to be recognzed in URLs. * Only for use by protcol plug-in initializers. */ - static void addProtocol(const std::string& tag); + QPID_COMMON_EXTERN static void addProtocol(const std::string& tag); private: mutable std::string cache; // cache string form for efficiency. -- cgit v1.2.1 From 71f061dafa318a9c7bf58571487b433546a4ac2a Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Wed, 12 May 2010 19:20:41 +0000 Subject: Remove incorrect optimization in Logger. Use of read-write lock causes a race in log. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@943641 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/log/Logger.h | 1 - 1 file changed, 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/log/Logger.h b/qpid/cpp/include/qpid/log/Logger.h index 80622365b1..d7da1f077a 100644 --- a/qpid/cpp/include/qpid/log/Logger.h +++ b/qpid/cpp/include/qpid/log/Logger.h @@ -98,7 +98,6 @@ class Logger : private boost::noncopyable { typedef std::set Statements; sys::Mutex lock; - sys::RWlock outputsLock; inline void enable_unlocked(Statement* s); Statements statements; -- cgit v1.2.1 From 3bf89b21d7692a031cfc118f7520e7dfec06483d Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Thu, 13 May 2010 18:55:06 +0000 Subject: Moved FailoverUpdates to qpid::messaging namespace. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@943975 13f79535-47bb-0310-9956-ffa450edef68 --- .../include/qpid/client/amqp0_10/FailoverUpdates.h | 55 ---------------------- qpid/cpp/include/qpid/messaging/FailoverUpdates.h | 49 +++++++++++++++++++ 2 files changed, 49 insertions(+), 55 deletions(-) delete mode 100644 qpid/cpp/include/qpid/client/amqp0_10/FailoverUpdates.h create mode 100644 qpid/cpp/include/qpid/messaging/FailoverUpdates.h (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/client/amqp0_10/FailoverUpdates.h b/qpid/cpp/include/qpid/client/amqp0_10/FailoverUpdates.h deleted file mode 100644 index 159745e67c..0000000000 --- a/qpid/cpp/include/qpid/client/amqp0_10/FailoverUpdates.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef QPID_CLIENT_AMQP0_10_FAILOVERUPDATES_H -#define QPID_CLIENT_AMQP0_10_FAILOVERUPDATES_H - -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -#include "qpid/client/ClientImportExport.h" - -namespace qpid { - -namespace messaging { -class Connection; -} - -namespace client { -namespace amqp0_10 { - -struct FailoverUpdatesImpl; -/** - * A utility to listen for updates on cluster membership - published - * via the amq.failover exchange - and update the list of known urls - * for a connection accordingly. - */ -class FailoverUpdates -{ - public: - QPID_CLIENT_EXTERN FailoverUpdates(qpid::messaging::Connection& connection); - QPID_CLIENT_EXTERN ~FailoverUpdates(); - private: - FailoverUpdatesImpl* impl; - - //no need to copy instances of this class - FailoverUpdates(const FailoverUpdates&); - FailoverUpdates& operator=(const FailoverUpdates&); -}; -}}} // namespace qpid::client::amqp0_10 - -#endif /*!QPID_CLIENT_AMQP0_10_FAILOVERUPDATES_H*/ diff --git a/qpid/cpp/include/qpid/messaging/FailoverUpdates.h b/qpid/cpp/include/qpid/messaging/FailoverUpdates.h new file mode 100644 index 0000000000..1d4cfaa10d --- /dev/null +++ b/qpid/cpp/include/qpid/messaging/FailoverUpdates.h @@ -0,0 +1,49 @@ +#ifndef QPID_CLIENT_AMQP0_10_FAILOVERUPDATES_H +#define QPID_CLIENT_AMQP0_10_FAILOVERUPDATES_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#include "qpid/client/ClientImportExport.h" + +namespace qpid { +namespace messaging { +class Connection; +class FailoverUpdatesImpl; + +/** + * A utility to listen for updates on cluster membership and update + * the list of known urls for a connection accordingly. + */ +class FailoverUpdates +{ + public: + QPID_CLIENT_EXTERN FailoverUpdates(Connection& connection); + QPID_CLIENT_EXTERN ~FailoverUpdates(); + private: + FailoverUpdatesImpl* impl; + + //no need to copy instances of this class + FailoverUpdates(const FailoverUpdates&); + FailoverUpdates& operator=(const FailoverUpdates&); +}; +}} // namespace qpid::messaging + +#endif /*!QPID_CLIENT_AMQP0_10_FAILOVERUPDATES_H*/ -- cgit v1.2.1 From e45595ccb655166dc9387f26b8fd9f2e018bdbd8 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Fri, 14 May 2010 13:54:56 +0000 Subject: Add missing "public" qualifier to exception inheritance. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@944259 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/exceptions.h | 30 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/exceptions.h b/qpid/cpp/include/qpid/messaging/exceptions.h index e20c1742c1..74393e2463 100644 --- a/qpid/cpp/include/qpid/messaging/exceptions.h +++ b/qpid/cpp/include/qpid/messaging/exceptions.h @@ -46,17 +46,17 @@ struct InvalidOptionString : public MessagingException QPID_CLIENT_EXTERN InvalidOptionString(const std::string& msg); }; -struct KeyError : MessagingException +struct KeyError : public MessagingException { QPID_CLIENT_EXTERN KeyError(const std::string&); }; -struct LinkError : MessagingException +struct LinkError : public MessagingException { QPID_CLIENT_EXTERN LinkError(const std::string&); }; -struct AddressError : LinkError +struct AddressError : public LinkError { QPID_CLIENT_EXTERN AddressError(const std::string&); }; @@ -88,62 +88,62 @@ struct MalformedAddress : public AddressError QPID_CLIENT_EXTERN MalformedAddress(const std::string& msg); }; -struct ReceiverError : LinkError +struct ReceiverError : public LinkError { QPID_CLIENT_EXTERN ReceiverError(const std::string&); }; -struct FetchError : ReceiverError +struct FetchError : public ReceiverError { QPID_CLIENT_EXTERN FetchError(const std::string&); }; -struct NoMessageAvailable : FetchError +struct NoMessageAvailable : public FetchError { QPID_CLIENT_EXTERN NoMessageAvailable(); }; -struct SenderError : LinkError +struct SenderError : public LinkError { QPID_CLIENT_EXTERN SenderError(const std::string&); }; -struct SendError : SenderError +struct SendError : public SenderError { QPID_CLIENT_EXTERN SendError(const std::string&); }; -struct TargetCapacityExceeded : SendError +struct TargetCapacityExceeded : public SendError { QPID_CLIENT_EXTERN TargetCapacityExceeded(const std::string&); }; -struct SessionError : MessagingException +struct SessionError : public MessagingException { QPID_CLIENT_EXTERN SessionError(const std::string&); }; -struct TransactionError : SessionError +struct TransactionError : public SessionError { QPID_CLIENT_EXTERN TransactionError(const std::string&); }; -struct TransactionAborted : TransactionError +struct TransactionAborted : public TransactionError { QPID_CLIENT_EXTERN TransactionAborted(const std::string&); }; -struct UnauthorizedAccess : SessionError +struct UnauthorizedAccess : public SessionError { QPID_CLIENT_EXTERN UnauthorizedAccess(const std::string&); }; -struct ConnectionError : MessagingException +struct ConnectionError : public MessagingException { QPID_CLIENT_EXTERN ConnectionError(const std::string&); }; -struct TransportFailure : MessagingException +struct TransportFailure : public MessagingException { QPID_CLIENT_EXTERN TransportFailure(const std::string&); }; -- cgit v1.2.1 From 71975bc9bca46868053cc683105f74efd550f2b0 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Fri, 14 May 2010 13:55:18 +0000 Subject: Initial multi-thread unit test for messaging API. - added Receiver::isClosed() to test for local close. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@944261 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Receiver.h | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Receiver.h b/qpid/cpp/include/qpid/messaging/Receiver.h index a368b113c1..2cd024f26f 100644 --- a/qpid/cpp/include/qpid/messaging/Receiver.h +++ b/qpid/cpp/include/qpid/messaging/Receiver.h @@ -49,8 +49,7 @@ class Receiver : public qpid::messaging::Handle /** * Retrieves a message from this receivers local queue, or waits * for upto the specified timeout for a message to become - * available. Returns false if there is no message to give after - * waiting for the specified timeout. + * available. */ QPID_CLIENT_EXTERN bool get(Message& message, Duration timeout=Duration::FOREVER); /** @@ -59,7 +58,8 @@ class Receiver : public qpid::messaging::Handle * available. * * @exception NoMessageAvailable if there is no message to give - * after waiting for the specified timeout. + * after waiting for the specified timeout, or if the Receiver is + * closed, in which case isClose() will be true. */ QPID_CLIENT_EXTERN Message get(Duration timeout=Duration::FOREVER); /** @@ -68,6 +68,10 @@ class Receiver : public qpid::messaging::Handle * available. Unlike get() this method will check with the server * that there is no message for the subscription this receiver is * serving before returning false. + * + * @return false if there is no message to give after + * waiting for the specified timeout, or if the Receiver is + * closed, in which case isClose() will be true. */ QPID_CLIENT_EXTERN bool fetch(Message& message, Duration timeout=Duration::FOREVER); /** @@ -78,7 +82,8 @@ class Receiver : public qpid::messaging::Handle * serving before throwing an exception. * * @exception NoMessageAvailable if there is no message to give - * after waiting for the specified timeout. + * after waiting for the specified timeout, or if the Receiver is + * closed, in which case isClose() will be true. */ QPID_CLIENT_EXTERN Message fetch(Duration timeout=Duration::FOREVER); /** @@ -88,19 +93,19 @@ class Receiver : public qpid::messaging::Handle */ QPID_CLIENT_EXTERN void setCapacity(uint32_t); /** - * Returns the capacity of the receiver. The capacity determines + * @return the capacity of the receiver. The capacity determines * how many incoming messages can be held in the receiver before * being requested by a client via fetch() (or pushed to a * listener). */ QPID_CLIENT_EXTERN uint32_t getCapacity(); /** - * Returns the number of messages received and waiting to be + * @return the number of messages received and waiting to be * fetched. */ QPID_CLIENT_EXTERN uint32_t getAvailable(); /** - * Returns a count of the number of messages received on this + * @return a count of the number of messages received on this * receiver that have been acknowledged, but for which that * acknowledgement has not yet been confirmed as processed by the * server. @@ -112,6 +117,11 @@ class Receiver : public qpid::messaging::Handle */ QPID_CLIENT_EXTERN void close(); + /** + * Return true if the receiver was closed by a call to close() + */ + QPID_CLIENT_EXTERN bool isClosed() const; + /** * Returns the name of this receiver. */ -- cgit v1.2.1 From 19aa087d2ffca61fd76592983f91618940686fd6 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Mon, 17 May 2010 15:34:14 +0000 Subject: Added support for user/pass@ syntax in Url. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@945211 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/Url.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/Url.h b/qpid/cpp/include/qpid/Url.h index 5f6ff990ac..80931618ed 100644 --- a/qpid/cpp/include/qpid/Url.h +++ b/qpid/cpp/include/qpid/Url.h @@ -56,7 +56,6 @@ struct Url : public std::vector
    { /** Parse url, throw Invalid if invalid. */ explicit Url(const char* url) { parse(url); } - Url& operator=(const Url& u) { this->std::vector
    ::operator=(u); cache=u.cache; return *this; } Url& operator=(const char* s) { parse(s); return *this; } Url& operator=(const std::string& s) { parse(s); return *this; } @@ -77,9 +76,17 @@ struct Url : public std::vector
    { */ QPID_COMMON_EXTERN static void addProtocol(const std::string& tag); + QPID_COMMON_EXTERN void setUser(const std::string&); + QPID_COMMON_EXTERN void setPass(const std::string&); + QPID_COMMON_EXTERN std::string getUser() const; + QPID_COMMON_EXTERN std::string getPass() const; + private: - mutable std::string cache; // cache string form for efficiency. static std::vector protocols; + + mutable std::string cache; // cache string form for efficiency. + std::string user, pass; + friend class UrlParser; }; -- cgit v1.2.1 From abfe789b522301b1a28228c4a1553e325287224f Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Tue, 18 May 2010 17:26:58 +0000 Subject: QPID-2612: Fix to windows build from Chuck Rolke git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@945778 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Address.h | 38 ++++++------ qpid/cpp/include/qpid/messaging/Connection.h | 28 ++++----- qpid/cpp/include/qpid/messaging/Duration.h | 16 ++--- qpid/cpp/include/qpid/messaging/FailoverUpdates.h | 6 +- qpid/cpp/include/qpid/messaging/Handle.h | 14 ++--- qpid/cpp/include/qpid/messaging/ImportExport.h | 8 +-- qpid/cpp/include/qpid/messaging/Message.h | 72 +++++++++++------------ qpid/cpp/include/qpid/messaging/Receiver.h | 32 +++++----- qpid/cpp/include/qpid/messaging/Sender.h | 24 ++++---- qpid/cpp/include/qpid/messaging/Session.h | 48 +++++++-------- qpid/cpp/include/qpid/messaging/exceptions.h | 46 +++++++-------- 11 files changed, 166 insertions(+), 166 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Address.h b/qpid/cpp/include/qpid/messaging/Address.h index 7bb821e644..2e36d0ae22 100644 --- a/qpid/cpp/include/qpid/messaging/Address.h +++ b/qpid/cpp/include/qpid/messaging/Address.h @@ -122,22 +122,22 @@ class AddressImpl; class Address { public: - QPID_CLIENT_EXTERN Address(); - QPID_CLIENT_EXTERN Address(const std::string& address); - QPID_CLIENT_EXTERN Address(const std::string& name, const std::string& subject, + QPID_MESSAGING_EXTERN Address(); + QPID_MESSAGING_EXTERN Address(const std::string& address); + QPID_MESSAGING_EXTERN Address(const std::string& name, const std::string& subject, const qpid::types::Variant::Map& options, const std::string& type = ""); - QPID_CLIENT_EXTERN Address(const Address& address); - QPID_CLIENT_EXTERN ~Address(); - QPID_CLIENT_EXTERN Address& operator=(const Address&); - QPID_CLIENT_EXTERN const std::string& getName() const; - QPID_CLIENT_EXTERN void setName(const std::string&); - QPID_CLIENT_EXTERN const std::string& getSubject() const; - QPID_CLIENT_EXTERN void setSubject(const std::string&); - QPID_CLIENT_EXTERN const qpid::types::Variant::Map& getOptions() const; - QPID_CLIENT_EXTERN qpid::types::Variant::Map& getOptions(); - QPID_CLIENT_EXTERN void setOptions(const qpid::types::Variant::Map&); + QPID_MESSAGING_EXTERN Address(const Address& address); + QPID_MESSAGING_EXTERN ~Address(); + QPID_MESSAGING_EXTERN Address& operator=(const Address&); + QPID_MESSAGING_EXTERN const std::string& getName() const; + QPID_MESSAGING_EXTERN void setName(const std::string&); + QPID_MESSAGING_EXTERN const std::string& getSubject() const; + QPID_MESSAGING_EXTERN void setSubject(const std::string&); + QPID_MESSAGING_EXTERN const qpid::types::Variant::Map& getOptions() const; + QPID_MESSAGING_EXTERN qpid::types::Variant::Map& getOptions(); + QPID_MESSAGING_EXTERN void setOptions(const qpid::types::Variant::Map&); - QPID_CLIENT_EXTERN std::string getType() const; + QPID_MESSAGING_EXTERN std::string getType() const; /** * The type of and addressed node influences how receivers and * senders are constructed for it. It also affects how a reply-to @@ -146,16 +146,16 @@ class Address * broker. The type can be explicitly set to prevent this if * needed. */ - QPID_CLIENT_EXTERN void setType(const std::string&); + QPID_MESSAGING_EXTERN void setType(const std::string&); - QPID_CLIENT_EXTERN std::string str() const; - QPID_CLIENT_EXTERN operator bool() const; - QPID_CLIENT_EXTERN bool operator !() const; + QPID_MESSAGING_EXTERN std::string str() const; + QPID_MESSAGING_EXTERN operator bool() const; + QPID_MESSAGING_EXTERN bool operator !() const; private: AddressImpl* impl; }; -QPID_CLIENT_EXTERN std::ostream& operator<<(std::ostream& out, const Address& address); +QPID_MESSAGING_EXTERN std::ostream& operator<<(std::ostream& out, const Address& address); }} // namespace qpid::messaging diff --git a/qpid/cpp/include/qpid/messaging/Connection.h b/qpid/cpp/include/qpid/messaging/Connection.h index bd13700e0e..a7f67cef8e 100644 --- a/qpid/cpp/include/qpid/messaging/Connection.h +++ b/qpid/cpp/include/qpid/messaging/Connection.h @@ -43,9 +43,9 @@ class Session; class Connection : public qpid::messaging::Handle { public: - QPID_CLIENT_EXTERN Connection(ConnectionImpl* impl); - QPID_CLIENT_EXTERN Connection(const Connection&); - QPID_CLIENT_EXTERN Connection(); + QPID_MESSAGING_EXTERN Connection(ConnectionImpl* impl); + QPID_MESSAGING_EXTERN Connection(const Connection&); + QPID_MESSAGING_EXTERN Connection(); /** * Current implementation supports the following options: * @@ -75,29 +75,29 @@ class Connection : public qpid::messaging::Handle * doubled every failure until the value of max-retry-interval * is reached. */ - QPID_CLIENT_EXTERN Connection(const std::string& url, const qpid::types::Variant::Map& options = qpid::types::Variant::Map()); + QPID_MESSAGING_EXTERN Connection(const std::string& url, const qpid::types::Variant::Map& options = qpid::types::Variant::Map()); /** * Creates a connection using an option string of the form * {name=value,name2=value2...}, see above for options supported. * * @exception InvalidOptionString if the string does not match the correct syntax */ - QPID_CLIENT_EXTERN Connection(const std::string& url, const std::string& options); - QPID_CLIENT_EXTERN ~Connection(); - QPID_CLIENT_EXTERN Connection& operator=(const Connection&); - QPID_CLIENT_EXTERN void setOption(const std::string& name, const qpid::types::Variant& value); - QPID_CLIENT_EXTERN void open(); - QPID_CLIENT_EXTERN bool isOpen(); + QPID_MESSAGING_EXTERN Connection(const std::string& url, const std::string& options); + QPID_MESSAGING_EXTERN ~Connection(); + QPID_MESSAGING_EXTERN Connection& operator=(const Connection&); + QPID_MESSAGING_EXTERN void setOption(const std::string& name, const qpid::types::Variant& value); + QPID_MESSAGING_EXTERN void open(); + QPID_MESSAGING_EXTERN bool isOpen(); /** * Closes a connection and all sessions associated with it. An * opened connection must be closed before the last handle is * allowed to go out of scope. */ - QPID_CLIENT_EXTERN void close(); - QPID_CLIENT_EXTERN Session createTransactionalSession(const std::string& name = std::string()); - QPID_CLIENT_EXTERN Session createSession(const std::string& name = std::string()); + QPID_MESSAGING_EXTERN void close(); + QPID_MESSAGING_EXTERN Session createTransactionalSession(const std::string& name = std::string()); + QPID_MESSAGING_EXTERN Session createSession(const std::string& name = std::string()); - QPID_CLIENT_EXTERN Session getSession(const std::string& name) const; + QPID_MESSAGING_EXTERN Session getSession(const std::string& name) const; private: friend class qpid::messaging::PrivateImplRef; diff --git a/qpid/cpp/include/qpid/messaging/Duration.h b/qpid/cpp/include/qpid/messaging/Duration.h index 3198ebe6a2..abcf169090 100644 --- a/qpid/cpp/include/qpid/messaging/Duration.h +++ b/qpid/cpp/include/qpid/messaging/Duration.h @@ -35,19 +35,19 @@ namespace messaging { class Duration { public: - QPID_CLIENT_EXTERN explicit Duration(uint64_t milliseconds); - QPID_CLIENT_EXTERN uint64_t getMilliseconds() const; - QPID_CLIENT_EXTERN static const Duration FOREVER; - QPID_CLIENT_EXTERN static const Duration IMMEDIATE; - QPID_CLIENT_EXTERN static const Duration SECOND; - QPID_CLIENT_EXTERN static const Duration MINUTE; + QPID_MESSAGING_EXTERN explicit Duration(uint64_t milliseconds); + QPID_MESSAGING_EXTERN uint64_t getMilliseconds() const; + QPID_MESSAGING_EXTERN static const Duration FOREVER; + QPID_MESSAGING_EXTERN static const Duration IMMEDIATE; + QPID_MESSAGING_EXTERN static const Duration SECOND; + QPID_MESSAGING_EXTERN static const Duration MINUTE; private: uint64_t milliseconds; }; -QPID_CLIENT_EXTERN Duration operator*(const Duration& duration, +QPID_MESSAGING_EXTERN Duration operator*(const Duration& duration, uint64_t multiplier); -QPID_CLIENT_EXTERN Duration operator*(uint64_t multiplier, +QPID_MESSAGING_EXTERN Duration operator*(uint64_t multiplier, const Duration& duration); }} // namespace qpid::messaging diff --git a/qpid/cpp/include/qpid/messaging/FailoverUpdates.h b/qpid/cpp/include/qpid/messaging/FailoverUpdates.h index 1d4cfaa10d..fb9d106557 100644 --- a/qpid/cpp/include/qpid/messaging/FailoverUpdates.h +++ b/qpid/cpp/include/qpid/messaging/FailoverUpdates.h @@ -21,7 +21,7 @@ * under the License. * */ -#include "qpid/client/ClientImportExport.h" +#include "qpid/messaging/ImportExport.h" namespace qpid { namespace messaging { @@ -35,8 +35,8 @@ class FailoverUpdatesImpl; class FailoverUpdates { public: - QPID_CLIENT_EXTERN FailoverUpdates(Connection& connection); - QPID_CLIENT_EXTERN ~FailoverUpdates(); + QPID_MESSAGING_EXTERN FailoverUpdates(Connection& connection); + QPID_MESSAGING_EXTERN ~FailoverUpdates(); private: FailoverUpdatesImpl* impl; diff --git a/qpid/cpp/include/qpid/messaging/Handle.h b/qpid/cpp/include/qpid/messaging/Handle.h index cfc6e8ebfc..1e634ef888 100644 --- a/qpid/cpp/include/qpid/messaging/Handle.h +++ b/qpid/cpp/include/qpid/messaging/Handle.h @@ -40,26 +40,26 @@ template class Handle { public: /**@return true if handle is valid, i.e. not null. */ - QPID_CLIENT_EXTERN bool isValid() const { return impl; } + QPID_MESSAGING_EXTERN bool isValid() const { return impl; } /**@return true if handle is null. It is an error to call any function on a null handle. */ - QPID_CLIENT_EXTERN bool isNull() const { return !impl; } + QPID_MESSAGING_EXTERN bool isNull() const { return !impl; } /** Conversion to bool supports idiom if (handle) { handle->... } */ - QPID_CLIENT_EXTERN operator bool() const { return impl; } + QPID_MESSAGING_EXTERN operator bool() const { return impl; } /** Operator ! supports idiom if (!handle) { do_if_handle_is_null(); } */ - QPID_CLIENT_EXTERN bool operator !() const { return !impl; } + QPID_MESSAGING_EXTERN bool operator !() const { return !impl; } void swap(Handle& h) { T* t = h.impl; h.impl = impl; impl = t; } protected: typedef T Impl; - QPID_CLIENT_EXTERN Handle() :impl() {} + QPID_MESSAGING_EXTERN Handle() :impl() {} // Not implemented,subclasses must implement. - QPID_CLIENT_EXTERN Handle(const Handle&); - QPID_CLIENT_EXTERN Handle& operator=(const Handle&); + QPID_MESSAGING_EXTERN Handle(const Handle&); + QPID_MESSAGING_EXTERN Handle& operator=(const Handle&); Impl* impl; diff --git a/qpid/cpp/include/qpid/messaging/ImportExport.h b/qpid/cpp/include/qpid/messaging/ImportExport.h index 7113b437be..52f3eb8568 100644 --- a/qpid/cpp/include/qpid/messaging/ImportExport.h +++ b/qpid/cpp/include/qpid/messaging/ImportExport.h @@ -21,13 +21,13 @@ */ #if defined(WIN32) && !defined(QPID_DECLARE_STATIC) -#if defined(CLIENT_EXPORT) || defined (qpidclient_EXPORTS) -#define QPID_CLIENT_EXTERN __declspec(dllexport) +#if defined(CLIENT_EXPORT) || defined (qpidmessaging_EXPORTS) +#define QPID_MESSAGING_EXTERN __declspec(dllexport) #else -#define QPID_CLIENT_EXTERN __declspec(dllimport) +#define QPID_MESSAGING_EXTERN __declspec(dllimport) #endif #else -#define QPID_CLIENT_EXTERN +#define QPID_MESSAGING_EXTERN #endif #endif /*!QPID_MESSAGING_IMPORTEXPORT_H*/ diff --git a/qpid/cpp/include/qpid/messaging/Message.h b/qpid/cpp/include/qpid/messaging/Message.h index 8e4c274734..ba58b5887c 100644 --- a/qpid/cpp/include/qpid/messaging/Message.h +++ b/qpid/cpp/include/qpid/messaging/Message.h @@ -42,64 +42,64 @@ struct MessageImpl; class Message { public: - QPID_CLIENT_EXTERN Message(const std::string& bytes = std::string()); - QPID_CLIENT_EXTERN Message(const char*, size_t); - QPID_CLIENT_EXTERN Message(const Message&); - QPID_CLIENT_EXTERN ~Message(); + QPID_MESSAGING_EXTERN Message(const std::string& bytes = std::string()); + QPID_MESSAGING_EXTERN Message(const char*, size_t); + QPID_MESSAGING_EXTERN Message(const Message&); + QPID_MESSAGING_EXTERN ~Message(); - QPID_CLIENT_EXTERN Message& operator=(const Message&); + QPID_MESSAGING_EXTERN Message& operator=(const Message&); - QPID_CLIENT_EXTERN void setReplyTo(const Address&); - QPID_CLIENT_EXTERN const Address& getReplyTo() const; + QPID_MESSAGING_EXTERN void setReplyTo(const Address&); + QPID_MESSAGING_EXTERN const Address& getReplyTo() const; - QPID_CLIENT_EXTERN void setSubject(const std::string&); - QPID_CLIENT_EXTERN const std::string& getSubject() const; + QPID_MESSAGING_EXTERN void setSubject(const std::string&); + QPID_MESSAGING_EXTERN const std::string& getSubject() const; - QPID_CLIENT_EXTERN void setContentType(const std::string&); - QPID_CLIENT_EXTERN const std::string& getContentType() const; + QPID_MESSAGING_EXTERN void setContentType(const std::string&); + QPID_MESSAGING_EXTERN const std::string& getContentType() const; - QPID_CLIENT_EXTERN void setMessageId(const std::string&); - QPID_CLIENT_EXTERN const std::string& getMessageId() const; + QPID_MESSAGING_EXTERN void setMessageId(const std::string&); + QPID_MESSAGING_EXTERN const std::string& getMessageId() const; - QPID_CLIENT_EXTERN void setUserId(const std::string&); - QPID_CLIENT_EXTERN const std::string& getUserId() const; + QPID_MESSAGING_EXTERN void setUserId(const std::string&); + QPID_MESSAGING_EXTERN const std::string& getUserId() const; - QPID_CLIENT_EXTERN void setCorrelationId(const std::string&); - QPID_CLIENT_EXTERN const std::string& getCorrelationId() const; + QPID_MESSAGING_EXTERN void setCorrelationId(const std::string&); + QPID_MESSAGING_EXTERN const std::string& getCorrelationId() const; - QPID_CLIENT_EXTERN void setPriority(uint8_t); - QPID_CLIENT_EXTERN uint8_t getPriority() const; + QPID_MESSAGING_EXTERN void setPriority(uint8_t); + QPID_MESSAGING_EXTERN uint8_t getPriority() const; /** * Set the time to live for this message in milliseconds. */ - QPID_CLIENT_EXTERN void setTtl(Duration ttl); + QPID_MESSAGING_EXTERN void setTtl(Duration ttl); /** *Get the time to live for this message in milliseconds. */ - QPID_CLIENT_EXTERN Duration getTtl() const; + QPID_MESSAGING_EXTERN Duration getTtl() const; - QPID_CLIENT_EXTERN void setDurable(bool durable); - QPID_CLIENT_EXTERN bool getDurable() const; + QPID_MESSAGING_EXTERN void setDurable(bool durable); + QPID_MESSAGING_EXTERN bool getDurable() const; - QPID_CLIENT_EXTERN bool getRedelivered() const; - QPID_CLIENT_EXTERN void setRedelivered(bool); + QPID_MESSAGING_EXTERN bool getRedelivered() const; + QPID_MESSAGING_EXTERN void setRedelivered(bool); - QPID_CLIENT_EXTERN const qpid::types::Variant::Map& getProperties() const; - QPID_CLIENT_EXTERN qpid::types::Variant::Map& getProperties(); + QPID_MESSAGING_EXTERN const qpid::types::Variant::Map& getProperties() const; + QPID_MESSAGING_EXTERN qpid::types::Variant::Map& getProperties(); - QPID_CLIENT_EXTERN void setContent(const std::string&); + QPID_MESSAGING_EXTERN void setContent(const std::string&); /** * Note that chars are copied. */ - QPID_CLIENT_EXTERN void setContent(const char* chars, size_t count); + QPID_MESSAGING_EXTERN void setContent(const char* chars, size_t count); /** Get the content as a std::string */ - QPID_CLIENT_EXTERN std::string getContent() const; + QPID_MESSAGING_EXTERN std::string getContent() const; /** Get a const pointer to the start of the content data. */ - QPID_CLIENT_EXTERN const char* getContentPtr() const; + QPID_MESSAGING_EXTERN const char* getContentPtr() const; /** Get the size of content in bytes. */ - QPID_CLIENT_EXTERN size_t getContentSize() const; + QPID_MESSAGING_EXTERN size_t getContentSize() const; private: MessageImpl* impl; friend struct MessageImplAccess; @@ -119,7 +119,7 @@ struct EncodingException : qpid::types::Exception * any encoding specified by the content-type of the message * @exception EncodingException */ -QPID_CLIENT_EXTERN void decode(const Message& message, +QPID_MESSAGING_EXTERN void decode(const Message& message, qpid::types::Variant::Map& map, const std::string& encoding = std::string()); /** @@ -131,7 +131,7 @@ QPID_CLIENT_EXTERN void decode(const Message& message, * any encoding specified by the content-type of the message * @exception EncodingException */ -QPID_CLIENT_EXTERN void decode(const Message& message, +QPID_MESSAGING_EXTERN void decode(const Message& message, qpid::types::Variant::List& list, const std::string& encoding = std::string()); /** @@ -143,7 +143,7 @@ QPID_CLIENT_EXTERN void decode(const Message& message, * any encoding specified by the content-type of the message * @exception EncodingException */ -QPID_CLIENT_EXTERN void encode(const qpid::types::Variant::Map& map, +QPID_MESSAGING_EXTERN void encode(const qpid::types::Variant::Map& map, Message& message, const std::string& encoding = std::string()); /** @@ -155,7 +155,7 @@ QPID_CLIENT_EXTERN void encode(const qpid::types::Variant::Map& map, * any encoding specified by the content-type of the message * @exception EncodingException */ -QPID_CLIENT_EXTERN void encode(const qpid::types::Variant::List& list, +QPID_MESSAGING_EXTERN void encode(const qpid::types::Variant::List& list, Message& message, const std::string& encoding = std::string()); diff --git a/qpid/cpp/include/qpid/messaging/Receiver.h b/qpid/cpp/include/qpid/messaging/Receiver.h index 2cd024f26f..a1129975cf 100644 --- a/qpid/cpp/include/qpid/messaging/Receiver.h +++ b/qpid/cpp/include/qpid/messaging/Receiver.h @@ -42,16 +42,16 @@ class Session; class Receiver : public qpid::messaging::Handle { public: - QPID_CLIENT_EXTERN Receiver(ReceiverImpl* impl = 0); - QPID_CLIENT_EXTERN Receiver(const Receiver&); - QPID_CLIENT_EXTERN ~Receiver(); - QPID_CLIENT_EXTERN Receiver& operator=(const Receiver&); + QPID_MESSAGING_EXTERN Receiver(ReceiverImpl* impl = 0); + QPID_MESSAGING_EXTERN Receiver(const Receiver&); + QPID_MESSAGING_EXTERN ~Receiver(); + QPID_MESSAGING_EXTERN Receiver& operator=(const Receiver&); /** * Retrieves a message from this receivers local queue, or waits * for upto the specified timeout for a message to become * available. */ - QPID_CLIENT_EXTERN bool get(Message& message, Duration timeout=Duration::FOREVER); + QPID_MESSAGING_EXTERN bool get(Message& message, Duration timeout=Duration::FOREVER); /** * Retrieves a message from this receivers local queue, or waits * for up to the specified timeout for a message to become @@ -61,7 +61,7 @@ class Receiver : public qpid::messaging::Handle * after waiting for the specified timeout, or if the Receiver is * closed, in which case isClose() will be true. */ - QPID_CLIENT_EXTERN Message get(Duration timeout=Duration::FOREVER); + QPID_MESSAGING_EXTERN Message get(Duration timeout=Duration::FOREVER); /** * Retrieves a message for this receivers subscription or waits * for up to the specified timeout for one to become @@ -73,7 +73,7 @@ class Receiver : public qpid::messaging::Handle * waiting for the specified timeout, or if the Receiver is * closed, in which case isClose() will be true. */ - QPID_CLIENT_EXTERN bool fetch(Message& message, Duration timeout=Duration::FOREVER); + QPID_MESSAGING_EXTERN bool fetch(Message& message, Duration timeout=Duration::FOREVER); /** * Retrieves a message for this receivers subscription or waits * for up to the specified timeout for one to become @@ -85,52 +85,52 @@ class Receiver : public qpid::messaging::Handle * after waiting for the specified timeout, or if the Receiver is * closed, in which case isClose() will be true. */ - QPID_CLIENT_EXTERN Message fetch(Duration timeout=Duration::FOREVER); + QPID_MESSAGING_EXTERN Message fetch(Duration timeout=Duration::FOREVER); /** * Sets the capacity for the receiver. The capacity determines how * many incoming messages can be held in the receiver before being * requested by a client via fetch() (or pushed to a listener). */ - QPID_CLIENT_EXTERN void setCapacity(uint32_t); + QPID_MESSAGING_EXTERN void setCapacity(uint32_t); /** * @return the capacity of the receiver. The capacity determines * how many incoming messages can be held in the receiver before * being requested by a client via fetch() (or pushed to a * listener). */ - QPID_CLIENT_EXTERN uint32_t getCapacity(); + QPID_MESSAGING_EXTERN uint32_t getCapacity(); /** * @return the number of messages received and waiting to be * fetched. */ - QPID_CLIENT_EXTERN uint32_t getAvailable(); + QPID_MESSAGING_EXTERN uint32_t getAvailable(); /** * @return a count of the number of messages received on this * receiver that have been acknowledged, but for which that * acknowledgement has not yet been confirmed as processed by the * server. */ - QPID_CLIENT_EXTERN uint32_t getUnsettled(); + QPID_MESSAGING_EXTERN uint32_t getUnsettled(); /** * Cancels this receiver. */ - QPID_CLIENT_EXTERN void close(); + QPID_MESSAGING_EXTERN void close(); /** * Return true if the receiver was closed by a call to close() */ - QPID_CLIENT_EXTERN bool isClosed() const; + QPID_MESSAGING_EXTERN bool isClosed() const; /** * Returns the name of this receiver. */ - QPID_CLIENT_EXTERN const std::string& getName() const; + QPID_MESSAGING_EXTERN const std::string& getName() const; /** * Returns a handle to the session associated with this receiver. */ - QPID_CLIENT_EXTERN Session getSession() const; + QPID_MESSAGING_EXTERN Session getSession() const; private: friend class qpid::messaging::PrivateImplRef; diff --git a/qpid/cpp/include/qpid/messaging/Sender.h b/qpid/cpp/include/qpid/messaging/Sender.h index 9b5d0452e8..80ebf517a4 100644 --- a/qpid/cpp/include/qpid/messaging/Sender.h +++ b/qpid/cpp/include/qpid/messaging/Sender.h @@ -41,10 +41,10 @@ class Session; class Sender : public qpid::messaging::Handle { public: - QPID_CLIENT_EXTERN Sender(SenderImpl* impl = 0); - QPID_CLIENT_EXTERN Sender(const Sender&); - QPID_CLIENT_EXTERN ~Sender(); - QPID_CLIENT_EXTERN Sender& operator=(const Sender&); + QPID_MESSAGING_EXTERN Sender(SenderImpl* impl = 0); + QPID_MESSAGING_EXTERN Sender(const Sender&); + QPID_MESSAGING_EXTERN ~Sender(); + QPID_MESSAGING_EXTERN Sender& operator=(const Sender&); /** * Sends a message @@ -54,39 +54,39 @@ class Sender : public qpid::messaging::Handle * confirms receipt of the messages; if false will only block for * available capacity (i.e. pending == capacity) */ - QPID_CLIENT_EXTERN void send(const Message& message, bool sync=false); - QPID_CLIENT_EXTERN void close(); + QPID_MESSAGING_EXTERN void send(const Message& message, bool sync=false); + QPID_MESSAGING_EXTERN void close(); /** * Sets the capacity for the sender. The capacity determines how * many outgoing messages can be held pending confirmation of * receipt by the broker. */ - QPID_CLIENT_EXTERN void setCapacity(uint32_t); + QPID_MESSAGING_EXTERN void setCapacity(uint32_t); /** * Returns the capacity of the sender. * @see setCapacity */ - QPID_CLIENT_EXTERN uint32_t getCapacity(); + QPID_MESSAGING_EXTERN uint32_t getCapacity(); /** * Returns the number of sent messages pending confirmation of * receipt by the broker. (These are the 'in-doubt' messages). */ - QPID_CLIENT_EXTERN uint32_t getUnsettled(); + QPID_MESSAGING_EXTERN uint32_t getUnsettled(); /** * Returns the number of messages for which there is available * capacity. */ - QPID_CLIENT_EXTERN uint32_t getAvailable(); + QPID_MESSAGING_EXTERN uint32_t getAvailable(); /** * Returns the name of this sender. */ - QPID_CLIENT_EXTERN const std::string& getName() const; + QPID_MESSAGING_EXTERN const std::string& getName() const; /** * Returns a handle to the session associated with this sender. */ - QPID_CLIENT_EXTERN Session getSession() const; + QPID_MESSAGING_EXTERN Session getSession() const; private: friend class qpid::messaging::PrivateImplRef; }; diff --git a/qpid/cpp/include/qpid/messaging/Session.h b/qpid/cpp/include/qpid/messaging/Session.h index 9fa9fe48d1..34fccdb868 100644 --- a/qpid/cpp/include/qpid/messaging/Session.h +++ b/qpid/cpp/include/qpid/messaging/Session.h @@ -49,10 +49,10 @@ class Subscription; class Session : public qpid::messaging::Handle { public: - QPID_CLIENT_EXTERN Session(SessionImpl* impl = 0); - QPID_CLIENT_EXTERN Session(const Session&); - QPID_CLIENT_EXTERN ~Session(); - QPID_CLIENT_EXTERN Session& operator=(const Session&); + QPID_MESSAGING_EXTERN Session(SessionImpl* impl = 0); + QPID_MESSAGING_EXTERN Session(const Session&); + QPID_MESSAGING_EXTERN ~Session(); + QPID_MESSAGING_EXTERN Session& operator=(const Session&); /** * Closes a session and all associated senders and receivers. An @@ -60,10 +60,10 @@ class Session : public qpid::messaging::Handle * goes out of scope. All a connections sessions can be closed by * a call to Connection::close(). */ - QPID_CLIENT_EXTERN void close(); + QPID_MESSAGING_EXTERN void close(); - QPID_CLIENT_EXTERN void commit(); - QPID_CLIENT_EXTERN void rollback(); + QPID_MESSAGING_EXTERN void commit(); + QPID_MESSAGING_EXTERN void rollback(); /** * Acknowledges all outstanding messages that have been received @@ -72,19 +72,19 @@ class Session : public qpid::messaging::Handle * @param sync if true, blocks until the acknowledgement has been * processed by the server */ - QPID_CLIENT_EXTERN void acknowledge(bool sync=false); + QPID_MESSAGING_EXTERN void acknowledge(bool sync=false); /** * Rejects the specified message. This will prevent the message * being redelivered. This must be called before the message is * acknowledged. */ - QPID_CLIENT_EXTERN void reject(Message&); + QPID_MESSAGING_EXTERN void reject(Message&); /** * Releases the specified message. This will allow the broker to * redeliver the message. This must be called before the message * is acknowledged. */ - QPID_CLIENT_EXTERN void release(Message&); + QPID_MESSAGING_EXTERN void release(Message&); /** * Request synchronisation with the server. @@ -94,7 +94,7 @@ class Session : public qpid::messaging::Handle * call will request notifcation from the server but will return * before receiving it. */ - QPID_CLIENT_EXTERN void sync(bool block=true); + QPID_MESSAGING_EXTERN void sync(bool block=true); /** * Returns the total number of messages received and waiting to be @@ -102,13 +102,13 @@ class Session : public qpid::messaging::Handle * total number of available messages across all receivers on this * session. */ - QPID_CLIENT_EXTERN uint32_t getReceivable(); + QPID_MESSAGING_EXTERN uint32_t getReceivable(); /** * Returns a count of the number of messages received this session * that have been acknowledged, but for which that acknowledgement * has not yet been confirmed as processed by the server. */ - QPID_CLIENT_EXTERN uint32_t getUnsettledAcks(); + QPID_MESSAGING_EXTERN uint32_t getUnsettledAcks(); /** * Retrieves the receiver for the next available message. If there * are no available messages at present the call will block for up @@ -117,7 +117,7 @@ class Session : public qpid::messaging::Handle * which case the passed in receiver reference will be set to the * receiver for that message or false if no message was available. */ - QPID_CLIENT_EXTERN bool nextReceiver(Receiver&, Duration timeout=Duration::FOREVER); + QPID_MESSAGING_EXTERN bool nextReceiver(Receiver&, Duration timeout=Duration::FOREVER); /** * Returns the receiver for the next available message. If there * are no available messages at present the call will block for up @@ -126,40 +126,40 @@ class Session : public qpid::messaging::Handle * @exception Receiver::NoMessageAvailable if no message became * available in time. */ - QPID_CLIENT_EXTERN Receiver nextReceiver(Duration timeout=Duration::FOREVER); + QPID_MESSAGING_EXTERN Receiver nextReceiver(Duration timeout=Duration::FOREVER); /** * Create a new sender through which messages can be sent to the * specified address. */ - QPID_CLIENT_EXTERN Sender createSender(const Address& address); - QPID_CLIENT_EXTERN Sender createSender(const std::string& address); + QPID_MESSAGING_EXTERN Sender createSender(const Address& address); + QPID_MESSAGING_EXTERN Sender createSender(const std::string& address); /** * Create a new receiver through which messages can be received * from the specified address. */ - QPID_CLIENT_EXTERN Receiver createReceiver(const Address& address); - QPID_CLIENT_EXTERN Receiver createReceiver(const std::string& address); + QPID_MESSAGING_EXTERN Receiver createReceiver(const Address& address); + QPID_MESSAGING_EXTERN Receiver createReceiver(const std::string& address); /** * Returns the sender with the specified name. *@exception KeyError if there is none for that name. */ - QPID_CLIENT_EXTERN Sender getSender(const std::string& name) const; + QPID_MESSAGING_EXTERN Sender getSender(const std::string& name) const; /** * Returns the receiver with the specified name. *@exception KeyError if there is none for that name. */ - QPID_CLIENT_EXTERN Receiver getReceiver(const std::string& name) const; + QPID_MESSAGING_EXTERN Receiver getReceiver(const std::string& name) const; /** * Returns a handle to the connection this session is associated * with. */ - QPID_CLIENT_EXTERN Connection getConnection() const; + QPID_MESSAGING_EXTERN Connection getConnection() const; - QPID_CLIENT_EXTERN bool hasError(); - QPID_CLIENT_EXTERN void checkError(); + QPID_MESSAGING_EXTERN bool hasError(); + QPID_MESSAGING_EXTERN void checkError(); private: friend class qpid::messaging::PrivateImplRef; diff --git a/qpid/cpp/include/qpid/messaging/exceptions.h b/qpid/cpp/include/qpid/messaging/exceptions.h index 74393e2463..0ff608b343 100644 --- a/qpid/cpp/include/qpid/messaging/exceptions.h +++ b/qpid/cpp/include/qpid/messaging/exceptions.h @@ -22,9 +22,9 @@ * */ +#include "qpid/messaging/ImportExport.h" #include "qpid/types/Exception.h" #include "qpid/types/Variant.h" -#include "qpid/messaging/ImportExport.h" namespace qpid { namespace messaging { @@ -34,8 +34,8 @@ namespace messaging { struct MessagingException : public qpid::types::Exception { - QPID_CLIENT_EXTERN MessagingException(const std::string& msg); - QPID_CLIENT_EXTERN virtual ~MessagingException() throw(); + QPID_MESSAGING_EXTERN MessagingException(const std::string& msg); + QPID_MESSAGING_EXTERN virtual ~MessagingException() throw(); qpid::types::Variant::Map detail; //TODO: override what() to include detail if present @@ -43,22 +43,22 @@ struct MessagingException : public qpid::types::Exception struct InvalidOptionString : public MessagingException { - QPID_CLIENT_EXTERN InvalidOptionString(const std::string& msg); + QPID_MESSAGING_EXTERN InvalidOptionString(const std::string& msg); }; struct KeyError : public MessagingException { - QPID_CLIENT_EXTERN KeyError(const std::string&); + QPID_MESSAGING_EXTERN KeyError(const std::string&); }; struct LinkError : public MessagingException { - QPID_CLIENT_EXTERN LinkError(const std::string&); + QPID_MESSAGING_EXTERN LinkError(const std::string&); }; struct AddressError : public LinkError { - QPID_CLIENT_EXTERN AddressError(const std::string&); + QPID_MESSAGING_EXTERN AddressError(const std::string&); }; /** @@ -67,17 +67,17 @@ struct AddressError : public LinkError */ struct ResolutionError : public AddressError { - QPID_CLIENT_EXTERN ResolutionError(const std::string& msg); + QPID_MESSAGING_EXTERN ResolutionError(const std::string& msg); }; struct AssertionFailed : public ResolutionError { - QPID_CLIENT_EXTERN AssertionFailed(const std::string& msg); + QPID_MESSAGING_EXTERN AssertionFailed(const std::string& msg); }; struct NotFound : public ResolutionError { - QPID_CLIENT_EXTERN NotFound(const std::string& msg); + QPID_MESSAGING_EXTERN NotFound(const std::string& msg); }; /** @@ -85,67 +85,67 @@ struct NotFound : public ResolutionError */ struct MalformedAddress : public AddressError { - QPID_CLIENT_EXTERN MalformedAddress(const std::string& msg); + QPID_MESSAGING_EXTERN MalformedAddress(const std::string& msg); }; struct ReceiverError : public LinkError { - QPID_CLIENT_EXTERN ReceiverError(const std::string&); + QPID_MESSAGING_EXTERN ReceiverError(const std::string&); }; struct FetchError : public ReceiverError { - QPID_CLIENT_EXTERN FetchError(const std::string&); + QPID_MESSAGING_EXTERN FetchError(const std::string&); }; struct NoMessageAvailable : public FetchError { - QPID_CLIENT_EXTERN NoMessageAvailable(); + QPID_MESSAGING_EXTERN NoMessageAvailable(); }; struct SenderError : public LinkError { - QPID_CLIENT_EXTERN SenderError(const std::string&); + QPID_MESSAGING_EXTERN SenderError(const std::string&); }; struct SendError : public SenderError { - QPID_CLIENT_EXTERN SendError(const std::string&); + QPID_MESSAGING_EXTERN SendError(const std::string&); }; struct TargetCapacityExceeded : public SendError { - QPID_CLIENT_EXTERN TargetCapacityExceeded(const std::string&); + QPID_MESSAGING_EXTERN TargetCapacityExceeded(const std::string&); }; struct SessionError : public MessagingException { - QPID_CLIENT_EXTERN SessionError(const std::string&); + QPID_MESSAGING_EXTERN SessionError(const std::string&); }; struct TransactionError : public SessionError { - QPID_CLIENT_EXTERN TransactionError(const std::string&); + QPID_MESSAGING_EXTERN TransactionError(const std::string&); }; struct TransactionAborted : public TransactionError { - QPID_CLIENT_EXTERN TransactionAborted(const std::string&); + QPID_MESSAGING_EXTERN TransactionAborted(const std::string&); }; struct UnauthorizedAccess : public SessionError { - QPID_CLIENT_EXTERN UnauthorizedAccess(const std::string&); + QPID_MESSAGING_EXTERN UnauthorizedAccess(const std::string&); }; struct ConnectionError : public MessagingException { - QPID_CLIENT_EXTERN ConnectionError(const std::string&); + QPID_MESSAGING_EXTERN ConnectionError(const std::string&); }; struct TransportFailure : public MessagingException { - QPID_CLIENT_EXTERN TransportFailure(const std::string&); + QPID_MESSAGING_EXTERN TransportFailure(const std::string&); }; }} // namespace qpid::messaging -- cgit v1.2.1 From 0f5cd165647af0c5d0791bad309c249bc0996af1 Mon Sep 17 00:00:00 2001 From: "Stephen D. Huston" Date: Wed, 19 May 2010 21:28:38 +0000 Subject: Correct class/struct reference; resolves compile warning on Windows. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@946407 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/Address.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/Address.h b/qpid/cpp/include/qpid/Address.h index 71da7b25db..57c9139f87 100755 --- a/qpid/cpp/include/qpid/Address.h +++ b/qpid/cpp/include/qpid/Address.h @@ -25,7 +25,7 @@ #include namespace qpid { -namespace client { class ConnectionSettings; } +namespace client { struct ConnectionSettings; } /** -- cgit v1.2.1 From f50e4c2871bbebc89fa2796ff850911f082778c3 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Thu, 20 May 2010 19:52:55 +0000 Subject: Removed the logic in the broker's management agent that detected name collisions. The new logic will disambiguate colliding names by adding an underscore to the one being inserted. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@946773 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/management/ManagementObject.h | 1 + 1 file changed, 1 insertion(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/management/ManagementObject.h b/qpid/cpp/include/qpid/management/ManagementObject.h index 9c2d14fa94..6bbd7ec407 100644 --- a/qpid/cpp/include/qpid/management/ManagementObject.h +++ b/qpid/cpp/include/qpid/management/ManagementObject.h @@ -78,6 +78,7 @@ public: QPID_COMMON_EXTERN bool equalV1(const ObjectId &other) const; QPID_COMMON_EXTERN void setV2Key(const std::string& _key) { v2Key = _key; } QPID_COMMON_EXTERN void setV2Key(const ManagementObject& object); + QPID_COMMON_EXTERN void disambiguate(); QPID_COMMON_EXTERN void setAgentName(const std::string& _name) { agentName = _name; } QPID_COMMON_EXTERN const std::string& getAgentName() const { return agentName; } QPID_COMMON_EXTERN const std::string& getV2Key() const { return v2Key; } -- cgit v1.2.1 From 5afdc67935d07852c7c166741401ec4a77604d9b Mon Sep 17 00:00:00 2001 From: Kenneth Anthony Giusti Date: Fri, 21 May 2010 17:39:51 +0000 Subject: QMF: add bindEvent api to allow filtering of unsolicted events. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@947084 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/engine/Console.h | 3 +++ qpid/cpp/include/qpid/console/SessionManager.h | 14 ++++++++++++++ 2 files changed, 17 insertions(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qmf/engine/Console.h b/qpid/cpp/include/qmf/engine/Console.h index 03b3993395..bd40c63c6c 100644 --- a/qpid/cpp/include/qmf/engine/Console.h +++ b/qpid/cpp/include/qmf/engine/Console.h @@ -217,6 +217,9 @@ namespace engine { void bindClass(const SchemaClassKey* key); void bindClass(const char* packageName, const char* className); + void bindEvent(const SchemaClassKey *key); + void bindEvent(const char* packageName, const char* eventName); + /* void startSync(const Query& query, void* context, SyncQuery& sync); void touchSync(SyncQuery& sync); diff --git a/qpid/cpp/include/qpid/console/SessionManager.h b/qpid/cpp/include/qpid/console/SessionManager.h index f27037a559..b46af549ff 100644 --- a/qpid/cpp/include/qpid/console/SessionManager.h +++ b/qpid/cpp/include/qpid/console/SessionManager.h @@ -138,6 +138,20 @@ class SessionManager QPID_CONSOLE_EXTERN void bindClass(const std::string& packageName, const std::string& className); + /** Request events from a particular package. + * + * Note that this method is only meaningful if a ConsoleListener was provided at session + * creation and if the 'userBindings' flag was set to true. + * + * @param classKey Class key of event of interest + * @param packageName Name of package of event of interest. + * @param eventName Name of event of interest. Default=All events defined by package. + */ + QPID_CONSOLE_EXTERN void bindEvent(const ClassKey& classKey); + QPID_CONSOLE_EXTERN void bindEvent(const std::string& packageName, + const std::string& eventName=""); + + /** Get a list of qmf agents known to the session manager. * *@param agents Vector of Agent objects returned by the session manager. -- cgit v1.2.1 From ead2334ee878db9098cb4c03b2921089dc66c477 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Tue, 25 May 2010 14:02:49 +0000 Subject: Replaced the earlier-removed init function (in ManagementAgent.h) that uses ConnectionSettings. Created a ConnectionSettings in the qpid::management name space that mirrors that from the qpid::client namespace. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@948046 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/agent/ManagementAgent.h | 9 +- .../include/qpid/management/ConnectionSettings.h | 118 +++++++++++++++++++++ 2 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 qpid/cpp/include/qpid/management/ConnectionSettings.h (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/agent/ManagementAgent.h b/qpid/cpp/include/qpid/agent/ManagementAgent.h index 456b657dc2..d534416da2 100644 --- a/qpid/cpp/include/qpid/agent/ManagementAgent.h +++ b/qpid/cpp/include/qpid/agent/ManagementAgent.h @@ -24,6 +24,7 @@ #include "qpid/management/ManagementObject.h" #include "qpid/management/ManagementEvent.h" #include "qpid/management/Manageable.h" +#include "qpid/management/ConnectionSettings.h" namespace qpid { namespace management { @@ -103,6 +104,12 @@ class ManagementAgent const std::string& mech = "PLAIN", const std::string& proto = "tcp") = 0; + virtual void init(const management::ConnectionSettings& settings, + uint16_t intervalSeconds = 10, + bool useExternalThread = false, + const std::string& storeFile = "") = 0; + + // Register a schema with the management agent. This is normally called by the // package initializer generated by the management code generator. // @@ -117,7 +124,7 @@ class ManagementAgent const std::string& eventName, uint8_t* md5Sum, management::ManagementEvent::writeSchemaCall_t schemaCall) = 0; - + // Add a management object to the agent. Once added, this object shall be visible // in the greater management context. // diff --git a/qpid/cpp/include/qpid/management/ConnectionSettings.h b/qpid/cpp/include/qpid/management/ConnectionSettings.h new file mode 100644 index 0000000000..b631ffa658 --- /dev/null +++ b/qpid/cpp/include/qpid/management/ConnectionSettings.h @@ -0,0 +1,118 @@ +#ifndef _management_ConnectionSettings_h +#define _management_ConnectionSettings_h +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/CommonImportExport.h" +#include "qpid/types/Variant.h" +#include + +namespace qpid { +namespace management { + +/** + * Settings for a Connection. + */ +struct ConnectionSettings { + + QPID_COMMON_EXTERN ConnectionSettings(); + QPID_COMMON_EXTERN virtual ~ConnectionSettings(); + + /** + * The protocol used for the connection (defaults to 'tcp') + */ + std::string protocol; + + /** + * The host (or ip address) to connect to (defaults to 'localhost'). + */ + std::string host; + /** + * The port to connect to (defaults to 5672). + */ + uint16_t port; + /** + * Allows an AMQP 'virtual host' to be specified for the + * connection. + */ + std::string virtualhost; + + /** + * The username to use when authenticating the connection. If not + * specified the current users login is used if available. + */ + std::string username; + /** + * The password to use when authenticating the connection. + */ + std::string password; + /** + * The SASL mechanism to use when authenticating the connection; + * the options are currently PLAIN or ANONYMOUS. + */ + std::string mechanism; + /** + * Allows a locale to be specified for the connection. + */ + std::string locale; + /** + * Allows a heartbeat frequency to be specified + */ + uint16_t heartbeat; + /** + * The maximum number of channels that the client will request for + * use on this connection. + */ + uint16_t maxChannels; + /** + * The maximum frame size that the client will request for this + * connection. + */ + uint16_t maxFrameSize; + /** + * Limit the size of the connections send buffer . The buffer + * is limited to bounds * maxFrameSize. + */ + unsigned int bounds; + /** + * If true, TCP_NODELAY will be set for the connection. + */ + bool tcpNoDelay; + /** + * SASL service name + */ + std::string service; + /** + * Minimum acceptable strength of any SASL negotiated security + * layer. 0 means no security layer required. + */ + unsigned int minSsf; + /** + * Maximum acceptable strength of any SASL negotiated security + * layer. 0 means no security layer allowed. + */ + unsigned int maxSsf; +}; + +}} + +#endif + -- cgit v1.2.1 From 095fb80c67258ab00a2654bdd4a094f4d37ed4b8 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Thu, 3 Jun 2010 20:23:30 +0000 Subject: QPID-2644 - Console examples sometimes fail due to not waiting for the broker connection to complete Moved 'Broker::waitForStable' from private to public, used this function in the examples to hold off until the broker is fully connected. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@951141 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/console/Broker.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/console/Broker.h b/qpid/cpp/include/qpid/console/Broker.h index af163b8bfd..0b2d1bcb61 100644 --- a/qpid/cpp/include/qpid/console/Broker.h +++ b/qpid/cpp/include/qpid/console/Broker.h @@ -55,15 +55,16 @@ namespace console { client::ConnectionSettings& settings); QPID_CONSOLE_EXTERN ~Broker(); - bool isConnected() const { return connected; } - const std::string& getError() const { return error; } - const std::string& getSessionId() const { return amqpSessionId; } - const framing::Uuid& getBrokerId() const { return brokerId; } - uint32_t getBrokerBank() const { return 1; } - void addBinding(const std::string& key) { + QPID_CONSOLE_EXTERN bool isConnected() const { return connected; } + QPID_CONSOLE_EXTERN const std::string& getError() const { return error; } + QPID_CONSOLE_EXTERN const std::string& getSessionId() const { return amqpSessionId; } + QPID_CONSOLE_EXTERN const framing::Uuid& getBrokerId() const { return brokerId; } + QPID_CONSOLE_EXTERN uint32_t getBrokerBank() const { return 1; } + QPID_CONSOLE_EXTERN void addBinding(const std::string& key) { connThreadBody.bindExchange("qpid.management", key); } QPID_CONSOLE_EXTERN std::string getUrl() const; + QPID_CONSOLE_EXTERN void waitForStable(); private: friend class SessionManager; @@ -117,7 +118,6 @@ namespace console { void received(client::Message& msg); void resetAgents(); void updateAgent(const Object& object); - void waitForStable(); void incOutstanding(); void decOutstanding(); void setBrokerId(const framing::Uuid& id) { brokerId = id; } -- cgit v1.2.1 From 4424bc7676367fef809d0de1fb720c1c50c6bd08 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Fri, 4 Jun 2010 15:23:32 +0000 Subject: Fix initialization-order problem with URL protocol tags. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@951441 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/Url.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/Url.h b/qpid/cpp/include/qpid/Url.h index 80931618ed..353e9d5599 100644 --- a/qpid/cpp/include/qpid/Url.h +++ b/qpid/cpp/include/qpid/Url.h @@ -82,8 +82,6 @@ struct Url : public std::vector
    { QPID_COMMON_EXTERN std::string getPass() const; private: - static std::vector protocols; - mutable std::string cache; // cache string form for efficiency. std::string user, pass; -- cgit v1.2.1 From dfacc80897fe0d8889fab5758b75e6b600925ff3 Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Fri, 4 Jun 2010 17:41:38 +0000 Subject: Eliminate windows warning git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@951502 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/framing/FieldValue.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/framing/FieldValue.h b/qpid/cpp/include/qpid/framing/FieldValue.h index 8af1f8dedd..19220e74d5 100644 --- a/qpid/cpp/include/qpid/framing/FieldValue.h +++ b/qpid/cpp/include/qpid/framing/FieldValue.h @@ -123,7 +123,7 @@ template <> inline bool FieldValue::convertsTo() const { return data->convertsToString(); } template <> -inline int FieldValue::get() const { return data->getInt(); } +inline int FieldValue::get() const { return static_cast(data->getInt()); } template <> inline int64_t FieldValue::get() const { return data->getInt(); } -- cgit v1.2.1 From df8ed89d564f506eb1515bd61199d6dd493d1066 Mon Sep 17 00:00:00 2001 From: "Stephen D. Huston" Date: Thu, 17 Jun 2010 21:13:55 +0000 Subject: Refer to FailoverUpdatesImpl as the struct it is, not a class. Removes compile warning on Windows. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@955750 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/FailoverUpdates.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/FailoverUpdates.h b/qpid/cpp/include/qpid/messaging/FailoverUpdates.h index fb9d106557..14a1a31b63 100644 --- a/qpid/cpp/include/qpid/messaging/FailoverUpdates.h +++ b/qpid/cpp/include/qpid/messaging/FailoverUpdates.h @@ -26,7 +26,7 @@ namespace qpid { namespace messaging { class Connection; -class FailoverUpdatesImpl; +struct FailoverUpdatesImpl; /** * A utility to listen for updates on cluster membership and update -- cgit v1.2.1 From 770c53c8c07fc36a20d687e2da9963c1831f80df Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Wed, 30 Jun 2010 14:05:51 +0000 Subject: Fixed incorrect syntax for connection options in the comments. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@959317 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Connection.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Connection.h b/qpid/cpp/include/qpid/messaging/Connection.h index a7f67cef8e..5af4628fa8 100644 --- a/qpid/cpp/include/qpid/messaging/Connection.h +++ b/qpid/cpp/include/qpid/messaging/Connection.h @@ -78,7 +78,7 @@ class Connection : public qpid::messaging::Handle QPID_MESSAGING_EXTERN Connection(const std::string& url, const qpid::types::Variant::Map& options = qpid::types::Variant::Map()); /** * Creates a connection using an option string of the form - * {name=value,name2=value2...}, see above for options supported. + * {name:value,name2:value2...}, see above for options supported. * * @exception InvalidOptionString if the string does not match the correct syntax */ -- cgit v1.2.1 From d991ec04ca246220148a1efff7eb6995d80cd676 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Wed, 30 Jun 2010 19:54:00 +0000 Subject: QPID-2708: Create a separate qpidtypes library for the types namespace. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@959419 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/types/Exception.h | 8 +- qpid/cpp/include/qpid/types/ImportExport.h | 33 ++++++ qpid/cpp/include/qpid/types/Uuid.h | 58 +++++----- qpid/cpp/include/qpid/types/Variant.h | 168 ++++++++++++++--------------- 4 files changed, 150 insertions(+), 117 deletions(-) create mode 100644 qpid/cpp/include/qpid/types/ImportExport.h (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/types/Exception.h b/qpid/cpp/include/qpid/types/Exception.h index a8b7d128af..d061a7df0e 100644 --- a/qpid/cpp/include/qpid/types/Exception.h +++ b/qpid/cpp/include/qpid/types/Exception.h @@ -23,7 +23,7 @@ */ #include -#include "qpid/CommonImportExport.h" +#include "qpid/types/ImportExport.h" namespace qpid { namespace types { @@ -31,9 +31,9 @@ namespace types { class Exception : public std::exception { public: - QPID_COMMON_EXTERN explicit Exception(const std::string& message=std::string()) throw(); - QPID_COMMON_EXTERN virtual ~Exception() throw(); - QPID_COMMON_EXTERN virtual const char* what() const throw(); + QPID_TYPES_EXTERN explicit Exception(const std::string& message=std::string()) throw(); + QPID_TYPES_EXTERN virtual ~Exception() throw(); + QPID_TYPES_EXTERN virtual const char* what() const throw(); private: const std::string message; diff --git a/qpid/cpp/include/qpid/types/ImportExport.h b/qpid/cpp/include/qpid/types/ImportExport.h new file mode 100644 index 0000000000..bb10575fcd --- /dev/null +++ b/qpid/cpp/include/qpid/types/ImportExport.h @@ -0,0 +1,33 @@ +#ifndef QPID_TYPES_IMPORTEXPORT_H +#define QPID_TYPES_IMPORTEXPORT_H + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#if defined(WIN32) && !defined(QPID_DECLARE_STATIC) +#if defined(TYPES_EXPORT) || defined (qpidtypes_EXPORTS) +#define QPID_TYPES_EXTERN __declspec(dllexport) +#else +#define QPID_TYPES_EXTERN __declspec(dllimport) +#endif +#else +#define QPID_TYPES_EXTERN +#endif + +#endif /*!QPID_TYPES_IMPORTEXPORT_H*/ diff --git a/qpid/cpp/include/qpid/types/Uuid.h b/qpid/cpp/include/qpid/types/Uuid.h index 41042a0731..467a895184 100644 --- a/qpid/cpp/include/qpid/types/Uuid.h +++ b/qpid/cpp/include/qpid/types/Uuid.h @@ -22,7 +22,7 @@ * */ -#include "qpid/CommonImportExport.h" +#include "qpid/types/ImportExport.h" #include #include @@ -37,57 +37,57 @@ class Uuid * If unique is true, this will generate a new unique uuid, if not * it will construct a null uuid. */ - QPID_COMMON_EXTERN Uuid(bool unique=false); - QPID_COMMON_EXTERN Uuid(const Uuid&); - QPID_COMMON_EXTERN Uuid& operator=(const Uuid&); + QPID_TYPES_EXTERN Uuid(bool unique=false); + QPID_TYPES_EXTERN Uuid(const Uuid&); + QPID_TYPES_EXTERN Uuid& operator=(const Uuid&); /** Copy the UUID from data16, which must point to a 16-byte UUID */ - QPID_COMMON_EXTERN Uuid(const unsigned char* data16); + QPID_TYPES_EXTERN Uuid(const unsigned char* data16); /** Set to a new unique identifier. */ - QPID_COMMON_EXTERN void generate(); + QPID_TYPES_EXTERN void generate(); /** Set to all zeros. */ - QPID_COMMON_EXTERN void clear(); + QPID_TYPES_EXTERN void clear(); /** Test for null (all zeros). */ - QPID_COMMON_EXTERN bool isNull() const; - QPID_COMMON_EXTERN operator bool() const; - QPID_COMMON_EXTERN bool operator!() const; + QPID_TYPES_EXTERN bool isNull() const; + QPID_TYPES_EXTERN operator bool() const; + QPID_TYPES_EXTERN bool operator!() const; /** String value in format 1b4e28ba-2fa1-11d2-883f-b9a761bde3fb. */ - QPID_COMMON_EXTERN std::string str() const; + QPID_TYPES_EXTERN std::string str() const; - QPID_COMMON_EXTERN size_t size() const; - QPID_COMMON_EXTERN const unsigned char* data() const; + QPID_TYPES_EXTERN size_t size() const; + QPID_TYPES_EXTERN const unsigned char* data() const; - friend QPID_COMMON_EXTERN bool operator==(const Uuid&, const Uuid&); - friend QPID_COMMON_EXTERN bool operator!=(const Uuid&, const Uuid&); - friend QPID_COMMON_EXTERN bool operator<(const Uuid&, const Uuid&); - friend QPID_COMMON_EXTERN bool operator>(const Uuid&, const Uuid&); - friend QPID_COMMON_EXTERN bool operator<=(const Uuid&, const Uuid&); - friend QPID_COMMON_EXTERN bool operator>=(const Uuid&, const Uuid&); - friend QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream&, Uuid); - friend QPID_COMMON_EXTERN std::istream& operator>>(std::istream&, Uuid&); + friend QPID_TYPES_EXTERN bool operator==(const Uuid&, const Uuid&); + friend QPID_TYPES_EXTERN bool operator!=(const Uuid&, const Uuid&); + friend QPID_TYPES_EXTERN bool operator<(const Uuid&, const Uuid&); + friend QPID_TYPES_EXTERN bool operator>(const Uuid&, const Uuid&); + friend QPID_TYPES_EXTERN bool operator<=(const Uuid&, const Uuid&); + friend QPID_TYPES_EXTERN bool operator>=(const Uuid&, const Uuid&); + friend QPID_TYPES_EXTERN std::ostream& operator<<(std::ostream&, Uuid); + friend QPID_TYPES_EXTERN std::istream& operator>>(std::istream&, Uuid&); private: unsigned char bytes[16]; }; /** Returns true if the uuids are equal, false otherwise. **/ -QPID_COMMON_EXTERN bool operator==(const Uuid&, const Uuid&); +QPID_TYPES_EXTERN bool operator==(const Uuid&, const Uuid&); /** Returns true if the uuids are NOT equal, false if they are. **/ -QPID_COMMON_EXTERN bool operator!=(const Uuid&, const Uuid&); +QPID_TYPES_EXTERN bool operator!=(const Uuid&, const Uuid&); -QPID_COMMON_EXTERN bool operator<(const Uuid&, const Uuid&); -QPID_COMMON_EXTERN bool operator>(const Uuid&, const Uuid&); -QPID_COMMON_EXTERN bool operator<=(const Uuid&, const Uuid&); -QPID_COMMON_EXTERN bool operator>=(const Uuid&, const Uuid&); +QPID_TYPES_EXTERN bool operator<(const Uuid&, const Uuid&); +QPID_TYPES_EXTERN bool operator>(const Uuid&, const Uuid&); +QPID_TYPES_EXTERN bool operator<=(const Uuid&, const Uuid&); +QPID_TYPES_EXTERN bool operator>=(const Uuid&, const Uuid&); /** Print in format 1b4e28ba-2fa1-11d2-883f-b9a761bde3fb. */ -QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream&, Uuid); +QPID_TYPES_EXTERN std::ostream& operator<<(std::ostream&, Uuid); /** Read from format 1b4e28ba-2fa1-11d2-883f-b9a761bde3fb. */ -QPID_COMMON_EXTERN std::istream& operator>>(std::istream&, Uuid&); +QPID_TYPES_EXTERN std::istream& operator>>(std::istream&, Uuid&); }} // namespace qpid::types diff --git a/qpid/cpp/include/qpid/types/Variant.h b/qpid/cpp/include/qpid/types/Variant.h index 059550bc9c..7b43422261 100644 --- a/qpid/cpp/include/qpid/types/Variant.h +++ b/qpid/cpp/include/qpid/types/Variant.h @@ -28,7 +28,7 @@ #include "Uuid.h" #include "qpid/types/Exception.h" #include "qpid/sys/IntegerTypes.h" -#include "qpid/CommonImportExport.h" +#include "qpid/types/ImportExport.h" namespace qpid { namespace types { @@ -71,101 +71,101 @@ class Variant typedef std::map Map; typedef std::list List; - QPID_COMMON_EXTERN Variant(); - QPID_COMMON_EXTERN Variant(bool); - QPID_COMMON_EXTERN Variant(uint8_t); - QPID_COMMON_EXTERN Variant(uint16_t); - QPID_COMMON_EXTERN Variant(uint32_t); - QPID_COMMON_EXTERN Variant(uint64_t); - QPID_COMMON_EXTERN Variant(int8_t); - QPID_COMMON_EXTERN Variant(int16_t); - QPID_COMMON_EXTERN Variant(int32_t); - QPID_COMMON_EXTERN Variant(int64_t); - QPID_COMMON_EXTERN Variant(float); - QPID_COMMON_EXTERN Variant(double); - QPID_COMMON_EXTERN Variant(const std::string&); - QPID_COMMON_EXTERN Variant(const char*); - QPID_COMMON_EXTERN Variant(const Map&); - QPID_COMMON_EXTERN Variant(const List&); - QPID_COMMON_EXTERN Variant(const Variant&); - QPID_COMMON_EXTERN Variant(const Uuid&); - - QPID_COMMON_EXTERN ~Variant(); - - QPID_COMMON_EXTERN VariantType getType() const; - QPID_COMMON_EXTERN bool isVoid() const; + QPID_TYPES_EXTERN Variant(); + QPID_TYPES_EXTERN Variant(bool); + QPID_TYPES_EXTERN Variant(uint8_t); + QPID_TYPES_EXTERN Variant(uint16_t); + QPID_TYPES_EXTERN Variant(uint32_t); + QPID_TYPES_EXTERN Variant(uint64_t); + QPID_TYPES_EXTERN Variant(int8_t); + QPID_TYPES_EXTERN Variant(int16_t); + QPID_TYPES_EXTERN Variant(int32_t); + QPID_TYPES_EXTERN Variant(int64_t); + QPID_TYPES_EXTERN Variant(float); + QPID_TYPES_EXTERN Variant(double); + QPID_TYPES_EXTERN Variant(const std::string&); + QPID_TYPES_EXTERN Variant(const char*); + QPID_TYPES_EXTERN Variant(const Map&); + QPID_TYPES_EXTERN Variant(const List&); + QPID_TYPES_EXTERN Variant(const Variant&); + QPID_TYPES_EXTERN Variant(const Uuid&); + + QPID_TYPES_EXTERN ~Variant(); + + QPID_TYPES_EXTERN VariantType getType() const; + QPID_TYPES_EXTERN bool isVoid() const; - QPID_COMMON_EXTERN Variant& operator=(bool); - QPID_COMMON_EXTERN Variant& operator=(uint8_t); - QPID_COMMON_EXTERN Variant& operator=(uint16_t); - QPID_COMMON_EXTERN Variant& operator=(uint32_t); - QPID_COMMON_EXTERN Variant& operator=(uint64_t); - QPID_COMMON_EXTERN Variant& operator=(int8_t); - QPID_COMMON_EXTERN Variant& operator=(int16_t); - QPID_COMMON_EXTERN Variant& operator=(int32_t); - QPID_COMMON_EXTERN Variant& operator=(int64_t); - QPID_COMMON_EXTERN Variant& operator=(float); - QPID_COMMON_EXTERN Variant& operator=(double); - QPID_COMMON_EXTERN Variant& operator=(const std::string&); - QPID_COMMON_EXTERN Variant& operator=(const char*); - QPID_COMMON_EXTERN Variant& operator=(const Map&); - QPID_COMMON_EXTERN Variant& operator=(const List&); - QPID_COMMON_EXTERN Variant& operator=(const Variant&); - QPID_COMMON_EXTERN Variant& operator=(const Uuid&); - - QPID_COMMON_EXTERN bool asBool() const; - QPID_COMMON_EXTERN uint8_t asUint8() const; - QPID_COMMON_EXTERN uint16_t asUint16() const; - QPID_COMMON_EXTERN uint32_t asUint32() const; - QPID_COMMON_EXTERN uint64_t asUint64() const; - QPID_COMMON_EXTERN int8_t asInt8() const; - QPID_COMMON_EXTERN int16_t asInt16() const; - QPID_COMMON_EXTERN int32_t asInt32() const; - QPID_COMMON_EXTERN int64_t asInt64() const; - QPID_COMMON_EXTERN float asFloat() const; - QPID_COMMON_EXTERN double asDouble() const; - QPID_COMMON_EXTERN std::string asString() const; - QPID_COMMON_EXTERN Uuid asUuid() const; - - QPID_COMMON_EXTERN operator bool() const; - QPID_COMMON_EXTERN operator uint8_t() const; - QPID_COMMON_EXTERN operator uint16_t() const; - QPID_COMMON_EXTERN operator uint32_t() const; - QPID_COMMON_EXTERN operator uint64_t() const; - QPID_COMMON_EXTERN operator int8_t() const; - QPID_COMMON_EXTERN operator int16_t() const; - QPID_COMMON_EXTERN operator int32_t() const; - QPID_COMMON_EXTERN operator int64_t() const; - QPID_COMMON_EXTERN operator float() const; - QPID_COMMON_EXTERN operator double() const; - QPID_COMMON_EXTERN operator std::string() const; - QPID_COMMON_EXTERN operator Uuid() const; - - QPID_COMMON_EXTERN const Map& asMap() const; - QPID_COMMON_EXTERN Map& asMap(); - QPID_COMMON_EXTERN const List& asList() const; - QPID_COMMON_EXTERN List& asList(); + QPID_TYPES_EXTERN Variant& operator=(bool); + QPID_TYPES_EXTERN Variant& operator=(uint8_t); + QPID_TYPES_EXTERN Variant& operator=(uint16_t); + QPID_TYPES_EXTERN Variant& operator=(uint32_t); + QPID_TYPES_EXTERN Variant& operator=(uint64_t); + QPID_TYPES_EXTERN Variant& operator=(int8_t); + QPID_TYPES_EXTERN Variant& operator=(int16_t); + QPID_TYPES_EXTERN Variant& operator=(int32_t); + QPID_TYPES_EXTERN Variant& operator=(int64_t); + QPID_TYPES_EXTERN Variant& operator=(float); + QPID_TYPES_EXTERN Variant& operator=(double); + QPID_TYPES_EXTERN Variant& operator=(const std::string&); + QPID_TYPES_EXTERN Variant& operator=(const char*); + QPID_TYPES_EXTERN Variant& operator=(const Map&); + QPID_TYPES_EXTERN Variant& operator=(const List&); + QPID_TYPES_EXTERN Variant& operator=(const Variant&); + QPID_TYPES_EXTERN Variant& operator=(const Uuid&); + + QPID_TYPES_EXTERN bool asBool() const; + QPID_TYPES_EXTERN uint8_t asUint8() const; + QPID_TYPES_EXTERN uint16_t asUint16() const; + QPID_TYPES_EXTERN uint32_t asUint32() const; + QPID_TYPES_EXTERN uint64_t asUint64() const; + QPID_TYPES_EXTERN int8_t asInt8() const; + QPID_TYPES_EXTERN int16_t asInt16() const; + QPID_TYPES_EXTERN int32_t asInt32() const; + QPID_TYPES_EXTERN int64_t asInt64() const; + QPID_TYPES_EXTERN float asFloat() const; + QPID_TYPES_EXTERN double asDouble() const; + QPID_TYPES_EXTERN std::string asString() const; + QPID_TYPES_EXTERN Uuid asUuid() const; + + QPID_TYPES_EXTERN operator bool() const; + QPID_TYPES_EXTERN operator uint8_t() const; + QPID_TYPES_EXTERN operator uint16_t() const; + QPID_TYPES_EXTERN operator uint32_t() const; + QPID_TYPES_EXTERN operator uint64_t() const; + QPID_TYPES_EXTERN operator int8_t() const; + QPID_TYPES_EXTERN operator int16_t() const; + QPID_TYPES_EXTERN operator int32_t() const; + QPID_TYPES_EXTERN operator int64_t() const; + QPID_TYPES_EXTERN operator float() const; + QPID_TYPES_EXTERN operator double() const; + QPID_TYPES_EXTERN operator std::string() const; + QPID_TYPES_EXTERN operator Uuid() const; + + QPID_TYPES_EXTERN const Map& asMap() const; + QPID_TYPES_EXTERN Map& asMap(); + QPID_TYPES_EXTERN const List& asList() const; + QPID_TYPES_EXTERN List& asList(); /** * Unlike asString(), getString() will not do any conversions and * will throw InvalidConversion if the type is not STRING. */ - QPID_COMMON_EXTERN const std::string& getString() const; - QPID_COMMON_EXTERN std::string& getString(); + QPID_TYPES_EXTERN const std::string& getString() const; + QPID_TYPES_EXTERN std::string& getString(); - QPID_COMMON_EXTERN void setEncoding(const std::string&); - QPID_COMMON_EXTERN const std::string& getEncoding() const; + QPID_TYPES_EXTERN void setEncoding(const std::string&); + QPID_TYPES_EXTERN const std::string& getEncoding() const; - QPID_COMMON_EXTERN bool isEqualTo(const Variant& a) const; + QPID_TYPES_EXTERN bool isEqualTo(const Variant& a) const; - QPID_COMMON_EXTERN void reset(); + QPID_TYPES_EXTERN void reset(); private: VariantImpl* impl; }; -QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& out, const Variant& value); -QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& out, const Variant::Map& map); -QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& out, const Variant::List& list); -QPID_COMMON_EXTERN bool operator==(const Variant& a, const Variant& b); +QPID_TYPES_EXTERN std::ostream& operator<<(std::ostream& out, const Variant& value); +QPID_TYPES_EXTERN std::ostream& operator<<(std::ostream& out, const Variant::Map& map); +QPID_TYPES_EXTERN std::ostream& operator<<(std::ostream& out, const Variant::List& list); +QPID_TYPES_EXTERN bool operator==(const Variant& a, const Variant& b); }} // namespace qpid::types #endif /*!QPID_TYPES_VARIANT_H*/ -- cgit v1.2.1 From 62a1dcddbc7f087df2d8cd1ee19f8f4b5c50bc3d Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Wed, 30 Jun 2010 22:22:50 +0000 Subject: QPID-664: expose authenticated username for connection git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@959461 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Connection.h | 1 + 1 file changed, 1 insertion(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Connection.h b/qpid/cpp/include/qpid/messaging/Connection.h index 5af4628fa8..6f2cd54b4b 100644 --- a/qpid/cpp/include/qpid/messaging/Connection.h +++ b/qpid/cpp/include/qpid/messaging/Connection.h @@ -98,6 +98,7 @@ class Connection : public qpid::messaging::Handle QPID_MESSAGING_EXTERN Session createSession(const std::string& name = std::string()); QPID_MESSAGING_EXTERN Session getSession(const std::string& name) const; + QPID_MESSAGING_EXTERN std::string getAuthenticatedUsername(); private: friend class qpid::messaging::PrivateImplRef; -- cgit v1.2.1 From 61847068238af35543de06e54bc757dbfb3da776 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Thu, 1 Jul 2010 19:19:48 +0000 Subject: Fix spordic failure in cluster_test testConnectionKnownHosts. Very occasional failure of the form: cluster_test.cpp(547): error in "testConnectionKnownHosts": check kb0 == kb2 failed [42179 57640 != 44199 57640 ] ]) Fix is to avoid using possibly out-of-date initial-brokers data from the connection. Only rely on updates received from the amq.failover exchange. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@959751 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/client/FailoverListener.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/client/FailoverListener.h b/qpid/cpp/include/qpid/client/FailoverListener.h index 8414b80f2b..59108eb7cb 100644 --- a/qpid/cpp/include/qpid/client/FailoverListener.h +++ b/qpid/cpp/include/qpid/client/FailoverListener.h @@ -60,6 +60,12 @@ class FailoverListener : private MessageListener, private qpid::sys::Runnable /** Subscribe to amq.failover exchange. */ QPID_CLIENT_EXTERN FailoverListener(Connection); + /** Subscribe to amq.failover exchange. + *@param useInitial If true use the connection's initial brokers as + * the initial value of getKnownBrokers + */ + QPID_CLIENT_EXTERN FailoverListener(Connection, bool useInitial); + QPID_CLIENT_EXTERN ~FailoverListener(); /** Returns the latest list of known broker URLs. */ @@ -68,7 +74,8 @@ class FailoverListener : private MessageListener, private qpid::sys::Runnable private: void received(Message& msg); void run(); - + void init(bool); + mutable sys::Mutex lock; Connection connection; Session session; -- cgit v1.2.1 From 809ec3077dbe82d0b77f46c9a7c6ec90ce0cb555 Mon Sep 17 00:00:00 2001 From: Kenneth Anthony Giusti Date: Fri, 2 Jul 2010 14:46:30 +0000 Subject: QPID-2716: QMF bugfix - set agent name in object id git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@960012 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/agent/ManagementAgent.h | 1 + 1 file changed, 1 insertion(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/agent/ManagementAgent.h b/qpid/cpp/include/qpid/agent/ManagementAgent.h index d534416da2..aa0a974c35 100644 --- a/qpid/cpp/include/qpid/agent/ManagementAgent.h +++ b/qpid/cpp/include/qpid/agent/ManagementAgent.h @@ -69,6 +69,7 @@ class ManagementAgent // product - Product name (i.e. "qpid") // instance - A unique identifier for this instance of the agent. // If empty, the agent will create a GUID for the instance. + // Note: the ":" character is reserved - do no use it in the vendor or product name. // virtual void setName(const std::string& vendor, const std::string& product, -- cgit v1.2.1 From f67dc9fc3989a350af068ff5d80a8d325ef78f2a Mon Sep 17 00:00:00 2001 From: Kenneth Anthony Giusti Date: Thu, 8 Jul 2010 20:29:52 +0000 Subject: QMF: add api to get agent id, and new object id constructor that uses agent id. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@961919 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/agent/ManagementAgent.h | 10 ++++++++++ qpid/cpp/include/qpid/management/ManagementObject.h | 4 ++++ 2 files changed, 14 insertions(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/agent/ManagementAgent.h b/qpid/cpp/include/qpid/agent/ManagementAgent.h index aa0a974c35..e2451244c1 100644 --- a/qpid/cpp/include/qpid/agent/ManagementAgent.h +++ b/qpid/cpp/include/qpid/agent/ManagementAgent.h @@ -75,6 +75,16 @@ class ManagementAgent const std::string& product, const std::string& instance="") = 0; + // Retrieve the name of the agent as assigned by setName() + // + virtual void getName(std::string& vendor, + std::string& product, + std::string& instance) = 0; + + // Obtain the fully qualified name of the agent + // + virtual const std::string& getAddress() = 0; + // Connect to a management broker // // brokerHost - Hostname or IP address (dotted-quad) of broker. diff --git a/qpid/cpp/include/qpid/management/ManagementObject.h b/qpid/cpp/include/qpid/management/ManagementObject.h index 6bbd7ec407..59a7f00603 100644 --- a/qpid/cpp/include/qpid/management/ManagementObject.h +++ b/qpid/cpp/include/qpid/management/ManagementObject.h @@ -65,6 +65,10 @@ public: QPID_COMMON_EXTERN ObjectId(AgentAttachment* _agent, uint8_t flags, uint16_t seq); QPID_COMMON_EXTERN ObjectId(std::istream&); QPID_COMMON_EXTERN ObjectId(const std::string&); + QPID_COMMON_EXTERN ObjectId(const std::string& agentAddress, const std::string& key, + uint64_t epoch=0) : agent(0), first(0), second(0), + agentEpoch(epoch), v2Key(key), agentName(agentAddress) {} + // Deprecated: QPID_COMMON_EXTERN ObjectId(uint8_t flags, uint16_t seq, uint32_t broker, uint64_t object); QPID_COMMON_EXTERN bool operator==(const ObjectId &other) const; -- cgit v1.2.1 From 642860379c66cb08dcca723da10e2749ac44e3b8 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Tue, 27 Jul 2010 20:33:42 +0000 Subject: Removed unused header files. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@979857 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/Agent.h | 287 ------------------------------ qpid/cpp/include/qmf/AgentObject.h | 95 ---------- qpid/cpp/include/qmf/Connection.h | 125 ------------- qpid/cpp/include/qmf/ConnectionSettings.h | 32 ---- qpid/cpp/include/qmf/ConsoleObject.h | 94 ---------- qpid/cpp/include/qmf/QmfImportExport.h | 33 ---- 6 files changed, 666 deletions(-) delete mode 100644 qpid/cpp/include/qmf/Agent.h delete mode 100644 qpid/cpp/include/qmf/AgentObject.h delete mode 100644 qpid/cpp/include/qmf/Connection.h delete mode 100644 qpid/cpp/include/qmf/ConnectionSettings.h delete mode 100644 qpid/cpp/include/qmf/ConsoleObject.h delete mode 100644 qpid/cpp/include/qmf/QmfImportExport.h (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qmf/Agent.h b/qpid/cpp/include/qmf/Agent.h deleted file mode 100644 index e61cd737d0..0000000000 --- a/qpid/cpp/include/qmf/Agent.h +++ /dev/null @@ -1,287 +0,0 @@ -#ifndef _QmfAgent_ -#define _QmfAgent_ - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include "qmf/QmfImportExport.h" - -namespace qmf { - - class AgentImpl; - class Connection; - class ObjectId; - class AgentObject; - class Value; - class Event; - class SchemaObjectClass; - - /** - * AgentListener is used by agents that select the internalStore=false option (see Agent - * constructor) or by agents that wish to provide access control for queries and methods. - * - * \ingroup qmfapi - */ - class AgentListener { - QMF_EXTERN virtual ~AgentListener(); - - /** - * allowQuery is called before a query operation is executed. If true is returned - * by this function, the query will proceed. If false is returned, the query will - * be forbidden. - * - * @param q The query being requested. - * @param userId The authenticated identity of the user requesting the query. - */ - virtual bool allowQuery(const Query& q, const char* userId); - - /** - * allowMethod is called before a method call is executed. If true is returned - * by this function, the method call will proceed. If false is returned, the method - * call will be forbidden. - * - * @param name The name of the method being called. - * @param args A value object (of type "map") that contains both input and output arguments. - * @param oid The objectId that identifies the instance of the object being called. - * @param cls The Schema describing the object being called. - * @param userId The authenticated identity of the requesting user. - */ - virtual bool allowMethod(const char* name, const Value& args, const ObjectId& oid, - const SchemaObjectClass& cls, const char* userId); - - /** - * query is called when the agent receives a query request. The handler must invoke - * Agent::queryResponse zero or more times (using the supplied context) followed by - * a single invocation of Agent::queryComplete. These calls do not need to be made - * synchronously in the context of this function. They may occur before or after this - * function returns. - * - * This function will only be invoked if internalStore=false in the Agent's constructor. - * - * @param context A context value to use in resulting calls to queryResponse and quertComplete. - * @param q The query requested by the console. - * @param userId the authenticated identity of the user requesting the query. - */ - virtual void query(uint32_t context, const Query& q, const char* userId); - - /** - * syncStart is called when a console requests a standing query. This function must - * behave exactly like AgentListener::query (i.e. send zero or more responses followed - * by a queryComplete) except it then remembers the context and the query and makes - * subsequent queryResponse calls whenever appropriate according the the query. - * - * The standing query shall stay in effect until syncStop is called with the same context - * value or until a specified period of time elapses without receiving a syncTouch for the - * context. - * - * This function will only be invoked if internalStore=false in the Agent's constructor. - * - * @param context A context value to use in resulting calls to queryResponse and queryComplete. - * @param q The query requested by the console. - * @param userId the authenticated identity of the user requesting the query. - */ - virtual void syncStart(uint32_t context, const Query& q, const char* userId); - - /** - * syncTouch is called when the console that requested a standing query refreshes its - * interest in the query. The console must periodically "touch" a standing query to keep - * it alive. This prevents standing queries from accumulating when the console disconnects - * before it can stop the query. - * - * This function will only be invoked if internalStore=false in the Agent's constructor. - * - * @param context The context supplied in a previous call to syncStart. - * @param userId The authenticated identity of the requesting user. - */ - virtual void syncTouch(uint32_t context, const char* userId); - - /** - * syncStop is called when the console that requested a standing query no longer wishes to - * receive data associated with that query. The application shall stop processing this - * query and shall remove its record of the context value. - * - * This function will only be invoked if internalStore=false in the Agent's constructor. - * - * @param context The context supplied in a previous call to syncStart. - * @param userId The authenticated identity of the requesting user. - */ - virtual void syncStop(uint32_t context, const char* userId); - - /** - * methodCall is called when a console invokes a method on a QMF object. The application - * must call Agent::methodResponse once in response to this function. The response does - * not need to be called synchronously in the context of this function. It may be called - * before or after this function returns. - * - * This function will only be invoked if internalStore=false in the Agent's constructor. - * - * @param context A context value to use in resulting call to methodResponse. - * @param name The name of the method being called. - * @param args A value object (of type "map") that contains both input and output arguments. - * @param oid The objectId that identifies the instance of the object being called. - * @param cls The Schema describing the object being called. - * @param userId The authenticated identity of the requesting user. - */ - virtual void methodCall(uint32_t context, const char* name, Value& args, - const ObjectId& oid, const SchemaObjectClass& cls, const char* userId); - }; - - /** - * The Agent class is the QMF Agent portal. It should be instantiated once and associated with a - * Connection (setConnection) to connect an agent to the QMF infrastructure. - * - * \ingroup qmfapi - */ - class Agent { - public: - /** - * Create an instance of the Agent class. - * - * @param label An optional string label that can be used to identify the agent. - * - * @param internalStore If true, objects shall be tracked internally by the agent. - * If false, the user of the agent must track the objects. - * If the agent is tracking the objects, queries and syncs are handled by - * the agent. The only involvement the user has is to optionally authorize - * individual operations. If the user is tracking the objects, the user code - * must implement queries and syncs (standing queries). - * - * @param listener A pointer to a class that implements the AgentListener interface. - * This must be supplied if any of the following conditions are true: - * - The agent model contains methods - * - The user wishes to individually authorize query and sync operations. - * - internalStore = false - */ - QMF_EXTERN Agent(char* label="qmfa", bool internalStore=true, AgentListener* listener=0); - - /** - * Destroy an instance of the Agent class. - */ - QMF_EXTERN ~Agent(); - - /** - * Set the persistent store file. This file, if specified, is used to store state information - * about the Agent. For example, if object-ids must be persistent across restarts of the Agent - * program, this file path must be supplied. - * - * @param path Full path to a file that is both writable and readable by the Agent program. - */ - QMF_EXTERN void setStoreDir(const char* path); - - /** - * Provide a connection (to a Qpid broker) over which the agent can communicate. - * - * @param conn Pointer to a Connection object. - */ - QMF_EXTERN void setConnection(Connection* conn); - - /** - * Register a class schema (object or event) with the agent. The agent must have a registered - * schema for an object class or an event class before it can handle objects or events of that - * class. - * - * @param cls Pointer to the schema structure describing the class. - */ - QMF_EXTERN void registerClass(SchemaObjectClass* cls); - QMF_EXTERN void registerClass(SchemaEventClass* cls); - - /** - * Add an object to the agent (for internal storage mode only). - * - * @param obj Reference to the object to be managed by the agent. - * - * @param persistent Iff true, the object ID assigned to the object shall indicate persistence - * (i.e. the object ID shall be the same across restarts of the agent program). - * - * @param oid 64-bit value for the oid (if zero, the agent will assign the value). - * - * @param oidLo 32-bit value for the lower 32-bits of the oid. - * - * @param oidHi 32-bit value for the upper 32-bits of the oid. - */ - QMF_EXTERN const ObjectId* addObject(AgentObject& obj, bool persistent=false, uint64_t oid=0); - QMF_EXTERN const ObjectId* addObject(AgentObject& obj, bool persistent, uint32_t oidLo, uint32_t oidHi); - - /** - * Allocate an object ID for an object (for external storage mode only). - * - * @param persistent Iff true, the object ID allocated shall indicate persistence - * (i.e. the object ID shall be the same across restarts of the agent program). - * - * @param oid 64-bit value for the oid (if zero, the agent will assign the value). - * - * @param oidLo 32-bit value for the lower 32-bits of the oid. - * - * @param oidHi 32-bit value for the upper 32-bits of the oid. - */ - QMF_EXTERN const ObjectId* allocObjectId(bool persistent=false, uint64_t oid=0); - QMF_EXTERN const ObjectId* allocObjectId(bool persistent, uint32_t oidLo, uint32_t oidHi); - - /** - * Raise a QMF event. - * - * @param event Reference to an event object to be raised to the QMF infrastructure. - */ - QMF_EXTERN void raiseEvent(Event& event); - - /** - * Provide a response to a query (for external storage mode only). - * - * @param context The context value supplied in the query (via the AgentListener interface). - * - * @param object A reference to the agent that matched the query criteria. - * - * @param prop If true, transmit the property attributes of this object. - * - * @param stat If true, transmit the statistic attributes of this object. - */ - QMF_EXTERN void queryResponse(uint32_t context, AgentObject& object, bool prop = true, bool stat = true); - - /** - * Indicate that a query (or the initial dump of a sync) is complete (for external storage mode only). - * - * @param context The context value supplied in the query/sync (via the AgentListener interface). - */ - QMF_EXTERN void queryComplete(uint32_t context); - - /** - * Provide the response to a method call. - * - * @param context The context value supplied in the method request (via the AgentListener interface). - * - * @param args The argument list from the method call. Must include the output arguments (may include - * the input arguments). - * - * @param status Numerical return status: zero indicates no error, non-zero indicates error. - * - * @param exception Pointer to an exception value. If status is non-zero, the exception value is - * sent to the caller. It is optional (i.e. leave the pointer as 0), or may be - * set to any legal value. A string may be supplied, but an unmanaged object of - * any schema may also be passed. - */ - QMF_EXTERN void methodResponse(uint32_t context, const Value& args, uint32_t status=0, - const Value* exception=0); - - private: - AgentImpl* impl; - }; - -} - -#endif diff --git a/qpid/cpp/include/qmf/AgentObject.h b/qpid/cpp/include/qmf/AgentObject.h deleted file mode 100644 index a1878605eb..0000000000 --- a/qpid/cpp/include/qmf/AgentObject.h +++ /dev/null @@ -1,95 +0,0 @@ -#ifndef _QmfAgentObject_ -#define _QmfAgentObject_ - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include "qmf/QmfImportExport.h" - -namespace qmf { - - class AgentObjectImpl; - class SchemaObjectClass; - class ObjectId; - class Value; - class Agent; - - /** - * AgentObject is an extension of Object with agent-specific methods added. - * - * \ingroup qmfapi - */ - class AgentObject : public Object { - public: - /** - * Create a new Object of a specific type. - * - * @param type Pointer to the schema class to use as a type for this object. - */ - QMF_EXTERN AgentObject(const SchemaObjectClass* type); - - /** - * Schedule this object for deletion. Agent objects should never be directly - * destroyed, rather this method should be called and all pointers to this - * object dropped. The agent will clean up and properly delete the object at - * the appropraite time. - */ - QMF_EXTERN void destroy(); - - /** - * Set the object ID for this object if it is to be managed by the agent. - * - * @param oid The new object ID for the managed object. - */ - QMF_EXTERN void setObjectId(ObjectId& oid); - - /** - * Handler for invoked method calls. This will only be called for objects that - * are being managed and stored by an agent (see internalStore argument in Agent::Agent). - * If this function is not overridden in a child class, the default implementation will - * cause AgentListener::methodCall to be invoked in the application program. - * - * If this function is overridden in a sub-class, the implementation must perform - * the actions associated with the method call (i.e. implement the method). Once the - * method execution is complete, it must call Agent::methodResponse with the result - * of the method execution. Agent::methodResponse does not need to be called - * synchronously in the context of this function call. It may be called at a later - * time from a different thread. - * - * @param context Context supplied by the agent and required to be passed in the - * call to Agent::methodResponse - * - * @param name The name of the method. - * - * @param args A Value (of type map) that contains the input and output arguments. - * - * @param userId The authenticated identity of the user who invoked the method. - */ - QMF_EXTERN virtual void methodInvoked(uint32_t context, const char* name, Value& args, - const char* userId); - private: - friend class Agent; - virtual ~AgentObject(); - void setAgent(Agent* agent); - AgentObjectImpl* impl; - }; - -} - -#endif diff --git a/qpid/cpp/include/qmf/Connection.h b/qpid/cpp/include/qmf/Connection.h deleted file mode 100644 index f648b1427f..0000000000 --- a/qpid/cpp/include/qmf/Connection.h +++ /dev/null @@ -1,125 +0,0 @@ -#ifndef _QmfConnection_ -#define _QmfConnection_ - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include "qmf/QmfImportExport.h" -#include "qmf/ConnectionSettings.h" - -namespace qmf { - - /** - * Operational states for Connections. - * - * \ingroup qmfapi - */ - enum ConnectionState { - CONNECTION_UP = 1, - CONNECTION_DOWN = 2 - }; - - /** - * Implement a subclass of ConnectionListener and provide it with the - * Connection constructor to receive notification of changes in the - * connection state. - * - * \ingroup qmfapi - */ - class ConnectionListener { - QMF_EXTERN virtual ~ConnectionListener(); - - /** - * Called each time the state of the connection changes. - * - * @param state the new state - */ - virtual void newState(ConnectionState state); - - /** - * Called if the connection requires input from an interactive client. - * - * @param prompt Text of the prompt - describes what information is required. - * @param answer The interactive user input. - * @param answerLen on Input - the maximum number of bytes that can be copied to answer. - * on Output - the number of bytes copied to answer. - */ - virtual void interactivePrompt(const char* prompt, char* answer, uint32_t answerLen); - }; - - class ConnectionImpl; - - /** - * The Connection class represents a connection to a QPID broker that can - * be used by agents and consoles, possibly multiple at the same time. - * - * \ingroup qmfapi - */ - class Connection { - public: - - /** - * Creates a connection object and begins the process of attempting to - * connect to the QPID broker. - * - * @param settings The settings that control how the connection is set - * up. - * - * @param listener An optional pointer to a subclass of - * ConnectionListener to receive notifications of events related to - * this connection. - */ - QMF_EXTERN Connection(const ConnectionSettings& settings, - const ConnectionListener* listener = 0); - - /** - * Destroys a connection, causing the connection to be closed. - */ - QMF_EXTERN ~Connection(); - - /** - * Set the administrative state of the connection (enabled or disabled). - * - * @param enabled True => enable connection, False => disable connection - */ - QMF_EXTERN void setAdminState(bool enabled); - - /** - * Return the current operational state of the connection (up or down). - * - * @return the current connection state. - */ - QMF_EXTERN ConnectionState getOperState() const; - - /** - * Get the error message from the last failure to connect. - * - * @return Null-terminated string containing the error message. - */ - QMF_EXTERN const char* getLastError() const; - - private: - friend class AgentImpl; - friend class ConsoleImpl; - ConnectionImpl* impl; - }; - -} - -#endif diff --git a/qpid/cpp/include/qmf/ConnectionSettings.h b/qpid/cpp/include/qmf/ConnectionSettings.h deleted file mode 100644 index 11af73d797..0000000000 --- a/qpid/cpp/include/qmf/ConnectionSettings.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef _QmfConnectionSettings_ -#define _QmfConnectionSettings_ - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -namespace qmf { - namespace engine { - class ConnectionSettings; - } - - typedef class engine::ConnectionSettings ConnectionSettings; -} - -#endif - diff --git a/qpid/cpp/include/qmf/ConsoleObject.h b/qpid/cpp/include/qmf/ConsoleObject.h deleted file mode 100644 index acbc285e05..0000000000 --- a/qpid/cpp/include/qmf/ConsoleObject.h +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef _QmfConsoleObject_ -#define _QmfConsoleObject_ - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include "qmf/QmfImportExport.h" - -namespace qmf { - - class ConsoleObjectImpl; - class SchemaObjectClass; - class ObjectId; - class Value; - - /** - * ConsoleObject is an extension of Object with console-specific methods added. - * - * \ingroup qmfapi - */ - class ConsoleObject : public Object { - public: - /** - * Create a new Object of a specific type. - * - * @param type Pointer to the schema class to use as a type for this object. - */ - QMF_EXTERN ConsoleObject(const SchemaObjectClass* type); - - /** - * Destroy the object. - */ - QMF_EXTERN virtual ~ConsoleObject(); - - /** - * - */ - QMF_EXTERN const SchemaObjectClass* getSchema() const; - - /** - * - */ - QMF_EXTERN ObjectId* getObjectId() const; - - /** - * - */ - QMF_EXTERN uint64_t getCurrentTime() const; - QMF_EXTERN uint64_t getCreateTime() const; - QMF_EXTERN uint64_t getDeleteTime() const; - - /** - * - */ - QMF_EXTERN bool isDeleted() const; - - /** - * - */ - QMF_EXTERN void update(); - - /** - * - */ - QMF_EXTERN void invokeMethod(const char* name, const Value* arguments, MethodResult& result); - - /** - * - */ - QMF_EXTERN uint32_t invokeMethodAsync(const char* name, const Value* arguments = 0); - - private: - ConsoleObjectImpl* impl; - }; - -} - -#endif diff --git a/qpid/cpp/include/qmf/QmfImportExport.h b/qpid/cpp/include/qmf/QmfImportExport.h deleted file mode 100644 index f5e1d9127c..0000000000 --- a/qpid/cpp/include/qmf/QmfImportExport.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef QMF_IMPORT_EXPORT_H -#define QMF_IMPORT_EXPORT_H - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#if defined(WIN32) && !defined(QPID_DECLARE_STATIC) -# if defined(QMF_EXPORT) || defined (qmfcommon_EXPORTS) -# define QMF_EXTERN __declspec(dllexport) -# else -# define QMF_EXTERN __declspec(dllimport) -# endif -#else -# define QMF_EXTERN -#endif - -#endif -- cgit v1.2.1 From f2d8997be0a6c78ea40dc5d54babc19487a66de5 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Wed, 28 Jul 2010 18:35:15 +0000 Subject: Made the new C++ API more friendly for swig-wrapping. - Added Message::setProperty() as an alternative to using getProperties() to obtain a writable reference to a Variant::Map. - Added unit testing for this new method. - Added #ifndef SWIG conditions around the declarations of non-member operator<< methods. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@980147 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Address.h | 2 ++ qpid/cpp/include/qpid/messaging/Message.h | 2 ++ qpid/cpp/include/qpid/types/Variant.h | 2 ++ 3 files changed, 6 insertions(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Address.h b/qpid/cpp/include/qpid/messaging/Address.h index 2e36d0ae22..bebbfc72f6 100644 --- a/qpid/cpp/include/qpid/messaging/Address.h +++ b/qpid/cpp/include/qpid/messaging/Address.h @@ -155,7 +155,9 @@ class Address AddressImpl* impl; }; +#ifndef SWIG QPID_MESSAGING_EXTERN std::ostream& operator<<(std::ostream& out, const Address& address); +#endif }} // namespace qpid::messaging diff --git a/qpid/cpp/include/qpid/messaging/Message.h b/qpid/cpp/include/qpid/messaging/Message.h index ba58b5887c..d48af35cc0 100644 --- a/qpid/cpp/include/qpid/messaging/Message.h +++ b/qpid/cpp/include/qpid/messaging/Message.h @@ -100,6 +100,8 @@ class Message QPID_MESSAGING_EXTERN const char* getContentPtr() const; /** Get the size of content in bytes. */ QPID_MESSAGING_EXTERN size_t getContentSize() const; + + QPID_MESSAGING_EXTERN void setProperty(const std::string&, const qpid::types::Variant&); private: MessageImpl* impl; friend struct MessageImplAccess; diff --git a/qpid/cpp/include/qpid/types/Variant.h b/qpid/cpp/include/qpid/types/Variant.h index 7b43422261..3ed1db4452 100644 --- a/qpid/cpp/include/qpid/types/Variant.h +++ b/qpid/cpp/include/qpid/types/Variant.h @@ -162,10 +162,12 @@ class Variant VariantImpl* impl; }; +#ifndef SWIG QPID_TYPES_EXTERN std::ostream& operator<<(std::ostream& out, const Variant& value); QPID_TYPES_EXTERN std::ostream& operator<<(std::ostream& out, const Variant::Map& map); QPID_TYPES_EXTERN std::ostream& operator<<(std::ostream& out, const Variant::List& list); QPID_TYPES_EXTERN bool operator==(const Variant& a, const Variant& b); +#endif }} // namespace qpid::types #endif /*!QPID_TYPES_VARIANT_H*/ -- cgit v1.2.1 From 21c329d508ba90d3925a61f96a3359acfbe9d5d5 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Wed, 4 Aug 2010 13:22:00 +0000 Subject: Added conditional-compilation directives to hide the PrivateImplRef template from Swig. It seems that earlier versions of Swig (like that in RHEL5) don't like the template syntax. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@982243 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Connection.h | 6 +++++- qpid/cpp/include/qpid/messaging/Receiver.h | 4 ++++ qpid/cpp/include/qpid/messaging/Sender.h | 4 ++++ qpid/cpp/include/qpid/messaging/Session.h | 4 ++++ 4 files changed, 17 insertions(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Connection.h b/qpid/cpp/include/qpid/messaging/Connection.h index 6f2cd54b4b..59f5616a2f 100644 --- a/qpid/cpp/include/qpid/messaging/Connection.h +++ b/qpid/cpp/include/qpid/messaging/Connection.h @@ -32,7 +32,9 @@ namespace qpid { namespace messaging { +#ifndef SWIG template class PrivateImplRef; +#endif class ConnectionImpl; class Session; @@ -99,9 +101,11 @@ class Connection : public qpid::messaging::Handle QPID_MESSAGING_EXTERN Session getSession(const std::string& name) const; QPID_MESSAGING_EXTERN std::string getAuthenticatedUsername(); + +#ifndef SWIG private: friend class qpid::messaging::PrivateImplRef; - +#endif }; }} // namespace qpid::messaging diff --git a/qpid/cpp/include/qpid/messaging/Receiver.h b/qpid/cpp/include/qpid/messaging/Receiver.h index a1129975cf..6f3ae961db 100644 --- a/qpid/cpp/include/qpid/messaging/Receiver.h +++ b/qpid/cpp/include/qpid/messaging/Receiver.h @@ -30,7 +30,9 @@ namespace qpid { namespace messaging { +#ifndef SWIG template class PrivateImplRef; +#endif class Message; class ReceiverImpl; @@ -132,8 +134,10 @@ class Receiver : public qpid::messaging::Handle */ QPID_MESSAGING_EXTERN Session getSession() const; +#ifndef SWIG private: friend class qpid::messaging::PrivateImplRef; +#endif }; }} // namespace qpid::messaging diff --git a/qpid/cpp/include/qpid/messaging/Sender.h b/qpid/cpp/include/qpid/messaging/Sender.h index 80ebf517a4..85658f37cc 100644 --- a/qpid/cpp/include/qpid/messaging/Sender.h +++ b/qpid/cpp/include/qpid/messaging/Sender.h @@ -31,7 +31,9 @@ namespace qpid { namespace messaging { +#ifndef SWIG template class PrivateImplRef; +#endif class Message; class SenderImpl; class Session; @@ -87,8 +89,10 @@ class Sender : public qpid::messaging::Handle * Returns a handle to the session associated with this sender. */ QPID_MESSAGING_EXTERN Session getSession() const; +#ifndef SWIG private: friend class qpid::messaging::PrivateImplRef; +#endif }; }} // namespace qpid::messaging diff --git a/qpid/cpp/include/qpid/messaging/Session.h b/qpid/cpp/include/qpid/messaging/Session.h index 34fccdb868..688a4dd102 100644 --- a/qpid/cpp/include/qpid/messaging/Session.h +++ b/qpid/cpp/include/qpid/messaging/Session.h @@ -32,7 +32,9 @@ namespace qpid { namespace messaging { +#ifndef SWIG template class PrivateImplRef; +#endif class Address; class Connection; class Message; @@ -161,8 +163,10 @@ class Session : public qpid::messaging::Handle QPID_MESSAGING_EXTERN bool hasError(); QPID_MESSAGING_EXTERN void checkError(); +#ifndef SWIG private: friend class qpid::messaging::PrivateImplRef; +#endif }; }} // namespace qpid::messaging -- cgit v1.2.1 From 03b589ce68fd45bdf2634c211b02bdc5f3cbdba5 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Thu, 12 Aug 2010 22:28:09 +0000 Subject: QPID-2792 - QMF Clients in C++ following the ABI-stable pattern of the new messaging API git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@985016 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/Agent.h | 84 +++++++++++++++++++++++++++++++ qpid/cpp/include/qmf/AgentEvent.h | 74 ++++++++++++++++++++++++++++ qpid/cpp/include/qmf/AgentSession.h | 93 +++++++++++++++++++++++++++++++++++ qpid/cpp/include/qmf/ConsoleEvent.h | 73 +++++++++++++++++++++++++++ qpid/cpp/include/qmf/ConsoleSession.h | 65 ++++++++++++++++++++++++ qpid/cpp/include/qmf/Data.h | 71 ++++++++++++++++++++++++++ qpid/cpp/include/qmf/DataAddr.h | 62 +++++++++++++++++++++++ qpid/cpp/include/qmf/Handle.h | 70 ++++++++++++++++++++++++++ qpid/cpp/include/qmf/ImportExport.h | 33 +++++++++++++ qpid/cpp/include/qmf/Query.h | 65 ++++++++++++++++++++++++ qpid/cpp/include/qmf/Schema.h | 76 ++++++++++++++++++++++++++++ qpid/cpp/include/qmf/SchemaId.h | 61 +++++++++++++++++++++++ qpid/cpp/include/qmf/SchemaMethod.h | 65 ++++++++++++++++++++++++ qpid/cpp/include/qmf/SchemaProperty.h | 74 ++++++++++++++++++++++++++++ qpid/cpp/include/qmf/SchemaTypes.h | 56 +++++++++++++++++++++ qpid/cpp/include/qmf/exceptions.h | 59 ++++++++++++++++++++++ 16 files changed, 1081 insertions(+) create mode 100644 qpid/cpp/include/qmf/Agent.h create mode 100644 qpid/cpp/include/qmf/AgentEvent.h create mode 100644 qpid/cpp/include/qmf/AgentSession.h create mode 100644 qpid/cpp/include/qmf/ConsoleEvent.h create mode 100644 qpid/cpp/include/qmf/ConsoleSession.h create mode 100644 qpid/cpp/include/qmf/Data.h create mode 100644 qpid/cpp/include/qmf/DataAddr.h create mode 100644 qpid/cpp/include/qmf/Handle.h create mode 100644 qpid/cpp/include/qmf/ImportExport.h create mode 100644 qpid/cpp/include/qmf/Query.h create mode 100644 qpid/cpp/include/qmf/Schema.h create mode 100644 qpid/cpp/include/qmf/SchemaId.h create mode 100644 qpid/cpp/include/qmf/SchemaMethod.h create mode 100644 qpid/cpp/include/qmf/SchemaProperty.h create mode 100644 qpid/cpp/include/qmf/SchemaTypes.h create mode 100644 qpid/cpp/include/qmf/exceptions.h (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qmf/Agent.h b/qpid/cpp/include/qmf/Agent.h new file mode 100644 index 0000000000..8ddea0fae9 --- /dev/null +++ b/qpid/cpp/include/qmf/Agent.h @@ -0,0 +1,84 @@ +#ifndef QMF_AGENT_H +#define QMF_AGENT_H +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include +#include "qmf/Handle.h" +#include "qmf/exceptions.h" +#include "qpid/messaging/Duration.h" +#include "qpid/types/Variant.h" +#include + +namespace qmf { + +#ifndef SWIG + template class PrivateImplRef; +#endif + + class AgentImpl; + class ConsoleEvent; + class Query; + class DataAddr; + class SchemaId; + class Schema; + + class Agent : public qmf::Handle { + public: + QMF_EXTERN Agent(AgentImpl* impl = 0); + QMF_EXTERN Agent(const Agent&); + QMF_EXTERN Agent& operator=(const Agent&); + QMF_EXTERN ~Agent(); + + QMF_EXTERN std::string getName() const; + QMF_EXTERN uint32_t getEpoch() const; + QMF_EXTERN std::string getVendor() const; + QMF_EXTERN std::string getProduct() const; + QMF_EXTERN std::string getInstance() const; + QMF_EXTERN const qpid::types::Variant& getAttribute(const std::string&) const; + QMF_EXTERN const qpid::types::Variant::Map& getAttributes() const; + + QMF_EXTERN ConsoleEvent query(const Query&, qpid::messaging::Duration timeout=qpid::messaging::Duration::MINUTE); + QMF_EXTERN ConsoleEvent query(const std::string&, qpid::messaging::Duration timeout=qpid::messaging::Duration::MINUTE); + QMF_EXTERN uint32_t queryAsync(const Query&); + QMF_EXTERN uint32_t queryAsync(const std::string&); + + QMF_EXTERN ConsoleEvent callMethod(const std::string&, const qpid::types::Variant::Map&, const DataAddr&, + qpid::messaging::Duration timeout=qpid::messaging::Duration::MINUTE); + QMF_EXTERN uint32_t callMethodAsync(const std::string&, const qpid::types::Variant::Map&, const DataAddr&); + + QMF_EXTERN uint32_t getPackageCount() const; + QMF_EXTERN const std::string& getPackage(uint32_t) const; + QMF_EXTERN uint32_t getSchemaIdCount(const std::string&) const; + QMF_EXTERN SchemaId getSchemaId(const std::string&, uint32_t) const; + QMF_EXTERN Schema getSchema(const SchemaId&, qpid::messaging::Duration timeout=qpid::messaging::Duration::MINUTE); + + +#ifndef SWIG + private: + friend class qmf::PrivateImplRef; + friend struct AgentImplAccess; +#endif + }; + +} + +#endif diff --git a/qpid/cpp/include/qmf/AgentEvent.h b/qpid/cpp/include/qmf/AgentEvent.h new file mode 100644 index 0000000000..59a41c3267 --- /dev/null +++ b/qpid/cpp/include/qmf/AgentEvent.h @@ -0,0 +1,74 @@ +#ifndef QMF_AGENT_EVENT_H +#define QMF_AGENT_EVENT_H +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include +#include "qmf/Handle.h" +#include "qpid/types/Variant.h" + +namespace qmf { + +#ifndef SWIG + template class PrivateImplRef; +#endif + + class AgentEventImpl; + class Query; + class DataAddr; + + enum AgentEventCode { + AGENT_AUTH_QUERY = 1, + AGENT_AUTH_SUBSCRIBE = 2, + AGENT_QUERY = 3, + AGENT_METHOD = 4, + AGENT_SUBSCRIBE_BEGIN = 5, + AGENT_SUBSCRIBE_TOUCH = 6, + AGENT_SUBSCRIBE_END = 7, + AGENT_THREAD_FAILED = 8 + }; + + class AgentEvent : public qmf::Handle { + public: + QMF_EXTERN AgentEvent(AgentEventImpl* impl = 0); + QMF_EXTERN AgentEvent(const AgentEvent&); + QMF_EXTERN AgentEvent& operator=(const AgentEvent&); + QMF_EXTERN ~AgentEvent(); + + QMF_EXTERN AgentEventCode getType() const; + QMF_EXTERN const std::string& getUserId() const; + QMF_EXTERN Query getQuery() const; + QMF_EXTERN bool hasDataAddr() const; + QMF_EXTERN DataAddr getDataAddr() const; + QMF_EXTERN const std::string& getMethodName() const; + QMF_EXTERN qpid::types::Variant::Map& getArguments(); + QMF_EXTERN qpid::types::Variant::Map& getArgumentSubtypes(); + QMF_EXTERN void addReturnArgument(const std::string&, const qpid::types::Variant&, const std::string& st=""); + +#ifndef SWIG + private: + friend class qmf::PrivateImplRef; + friend struct AgentEventImplAccess; +#endif + }; +} + +#endif diff --git a/qpid/cpp/include/qmf/AgentSession.h b/qpid/cpp/include/qmf/AgentSession.h new file mode 100644 index 0000000000..5259aee360 --- /dev/null +++ b/qpid/cpp/include/qmf/AgentSession.h @@ -0,0 +1,93 @@ +#ifndef QMF_AGENT_SESSION_H +#define QMF_AGENT_SESSION_H +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include +#include "qmf/Handle.h" +#include "qpid/messaging/Duration.h" +#include "qpid/messaging/Connection.h" +#include "qpid/types/Variant.h" +#include + +namespace qmf { + +#ifndef SWIG + template class PrivateImplRef; +#endif + + class AgentSessionImpl; + class AgentEvent; + class Schema; + class Data; + class DataAddr; + + class AgentSession : public qmf::Handle { + public: + QMF_EXTERN AgentSession(AgentSessionImpl* impl = 0); + QMF_EXTERN AgentSession(const AgentSession&); + QMF_EXTERN AgentSession& operator=(const AgentSession&); + QMF_EXTERN ~AgentSession(); + + /** + * + * The options string is of the form "{key:value,key:value}". The following keys are supported: + * + * interval:N - Heartbeat interval in seconds [default: 60] + * external:{True,False} - Use external data storage (queries are pass-through) [default: False] + * allow-queries:{True,False} - If True: automatically allow all queries [default] + * If False: generate an AUTH_QUERY event to allow per-query authorization + * allow-methods:{True,False} - If True: automatically allow all methods [default] + * If False: generate an AUTH_METHOD event to allow per-method authorization + */ + QMF_EXTERN AgentSession(qpid::messaging::Connection&, const std::string& options=""); + QMF_EXTERN void setDomain(const std::string&); + QMF_EXTERN void setVendor(const std::string&); + QMF_EXTERN void setProduct(const std::string&); + QMF_EXTERN void setInstance(const std::string&); + QMF_EXTERN void setAttribute(const std::string&, const qpid::types::Variant&); + QMF_EXTERN const std::string& getName() const; + QMF_EXTERN void open(); + QMF_EXTERN void close(); + QMF_EXTERN bool nextEvent(AgentEvent&, qpid::messaging::Duration timeout=qpid::messaging::Duration::FOREVER); + + QMF_EXTERN void registerSchema(Schema&); + QMF_EXTERN DataAddr addData(Data&, const std::string& name="", bool persistent=false); + QMF_EXTERN void delData(const DataAddr&); + + QMF_EXTERN void authAccept(AgentEvent&); + QMF_EXTERN void authReject(AgentEvent&, const std::string& diag=""); + QMF_EXTERN void raiseException(AgentEvent&, const std::string&); + QMF_EXTERN void raiseException(AgentEvent&, const Data&); + QMF_EXTERN void response(AgentEvent&, const Data&); + QMF_EXTERN void complete(AgentEvent&); + QMF_EXTERN void methodSuccess(AgentEvent&); + QMF_EXTERN void raiseEvent(const Data&); + +#ifndef SWIG + private: + friend class qmf::PrivateImplRef; +#endif + }; + +} + +#endif diff --git a/qpid/cpp/include/qmf/ConsoleEvent.h b/qpid/cpp/include/qmf/ConsoleEvent.h new file mode 100644 index 0000000000..61f625b137 --- /dev/null +++ b/qpid/cpp/include/qmf/ConsoleEvent.h @@ -0,0 +1,73 @@ +#ifndef QMF_CONSOLE_EVENT_H +#define QMF_CONSOLE_EVENT_H +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include +#include "qmf/Handle.h" +#include "qpid/types/Variant.h" + +namespace qmf { + +#ifndef SWIG + template class PrivateImplRef; +#endif + + class ConsoleEventImpl; + class Agent; + class Data; + + enum ConsoleEventCode { + CONSOLE_AGENT_ADD = 1, + CONSOLE_AGENT_AGE = 2, + CONSOLE_EVENT = 3, + CONSOLE_QUERY_RESPONSE = 4, + CONSOLE_METHOD_RESPONSE = 5, + CONSOLE_EXCEPTION = 6, + CONSOLE_SUBSCRIBE_UPDATE = 7, + CONSOLE_THREAD_FAILED = 8 + }; + + class ConsoleEvent : public qmf::Handle { + public: + QMF_EXTERN ConsoleEvent(ConsoleEventImpl* impl = 0); + QMF_EXTERN ConsoleEvent(const ConsoleEvent&); + QMF_EXTERN ConsoleEvent& operator=(const ConsoleEvent&); + QMF_EXTERN ~ConsoleEvent(); + + QMF_EXTERN ConsoleEventCode getType() const; + QMF_EXTERN uint32_t getCorrelator() const; + QMF_EXTERN Agent getAgent() const; + QMF_EXTERN uint32_t getDataCount() const; + QMF_EXTERN Data getData(uint32_t) const; + QMF_EXTERN bool isFinal() const; + QMF_EXTERN const qpid::types::Variant::Map& getArguments() const; + +#ifndef SWIG + private: + friend class qmf::PrivateImplRef; + friend struct ConsoleEventImplAccess; +#endif + }; + +} + +#endif diff --git a/qpid/cpp/include/qmf/ConsoleSession.h b/qpid/cpp/include/qmf/ConsoleSession.h new file mode 100644 index 0000000000..0e58a647d6 --- /dev/null +++ b/qpid/cpp/include/qmf/ConsoleSession.h @@ -0,0 +1,65 @@ +#ifndef QMF_CONSOLE_SESSION_H +#define QMF_CONSOLE_SESSION_H +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include +#include "qmf/Handle.h" +#include "qmf/Agent.h" +#include "qpid/messaging/Duration.h" +#include "qpid/messaging/Connection.h" +#include + +namespace qmf { + +#ifndef SWIG + template class PrivateImplRef; +#endif + + class ConsoleSessionImpl; + class ConsoleEvent; + + class ConsoleSession : public qmf::Handle { + public: + QMF_EXTERN ConsoleSession(ConsoleSessionImpl* impl = 0); + QMF_EXTERN ConsoleSession(const ConsoleSession&); + QMF_EXTERN ConsoleSession& operator=(const ConsoleSession&); + QMF_EXTERN ~ConsoleSession(); + + QMF_EXTERN ConsoleSession(qpid::messaging::Connection&, const std::string& options=""); + QMF_EXTERN void setDomain(const std::string&); + QMF_EXTERN void setAgentFilter(const std::string&); + QMF_EXTERN void open(); + QMF_EXTERN void close(); + QMF_EXTERN bool nextEvent(ConsoleEvent&, qpid::messaging::Duration timeout=qpid::messaging::Duration::FOREVER); + QMF_EXTERN uint32_t getAgentCount() const; + QMF_EXTERN Agent getAgent(uint32_t) const; + QMF_EXTERN Agent getConnectedBrokerAgent() const; + +#ifndef SWIG + private: + friend class qmf::PrivateImplRef; +#endif + }; + +} + +#endif diff --git a/qpid/cpp/include/qmf/Data.h b/qpid/cpp/include/qmf/Data.h new file mode 100644 index 0000000000..27af1c4b04 --- /dev/null +++ b/qpid/cpp/include/qmf/Data.h @@ -0,0 +1,71 @@ +#ifndef QMF_DATA_H +#define QMF_DATA_H +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include +#include "qmf/Handle.h" +#include "qmf/exceptions.h" +#include "qpid/types/Variant.h" +#include + +namespace qmf { + +#ifndef SWIG + template class PrivateImplRef; +#endif + + class DataImpl; + class SchemaId; + class DataAddr; + class Agent; + + class Data : public qmf::Handle { + public: + QMF_EXTERN Data(DataImpl* impl = 0); + QMF_EXTERN Data(const Data&); + QMF_EXTERN Data& operator=(const Data&); + QMF_EXTERN ~Data(); + + QMF_EXTERN Data(const SchemaId&); + QMF_EXTERN void setSchema(const SchemaId&); + QMF_EXTERN void setAddr(const DataAddr&); + QMF_EXTERN void setProperty(const std::string&, const qpid::types::Variant&); + QMF_EXTERN void overwriteProperties(const qpid::types::Variant::Map&); + QMF_EXTERN bool hasSchema() const; + QMF_EXTERN bool hasAddr() const; + QMF_EXTERN const SchemaId& getSchemaId() const; + QMF_EXTERN const DataAddr& getAddr() const; + QMF_EXTERN const qpid::types::Variant& getProperty(const std::string&) const; + QMF_EXTERN const qpid::types::Variant::Map& getProperties() const; + QMF_EXTERN bool hasAgent() const; + QMF_EXTERN const Agent& getAgent() const; + +#ifndef SWIG + private: + friend class qmf::PrivateImplRef; + friend struct DataImplAccess; +#endif + }; + +} + +#endif diff --git a/qpid/cpp/include/qmf/DataAddr.h b/qpid/cpp/include/qmf/DataAddr.h new file mode 100644 index 0000000000..fd8a8599c1 --- /dev/null +++ b/qpid/cpp/include/qmf/DataAddr.h @@ -0,0 +1,62 @@ +#ifndef QMF_DATA_ADDR_H +#define QMF_DATA_ADDR_H +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include +#include "qmf/Handle.h" +#include "qpid/types/Variant.h" +#include + +namespace qmf { + +#ifndef SWIG + template class PrivateImplRef; +#endif + + class DataAddrImpl; + + class DataAddr : public qmf::Handle { + public: + QMF_EXTERN DataAddr(DataAddrImpl* impl = 0); + QMF_EXTERN DataAddr(const DataAddr&); + QMF_EXTERN DataAddr& operator=(const DataAddr&); + QMF_EXTERN ~DataAddr(); + + QMF_EXTERN bool operator==(const DataAddr&); + QMF_EXTERN bool operator<(const DataAddr&); + + QMF_EXTERN DataAddr(const std::string& name, const std::string& agentName, uint32_t agentEpoch=0); + QMF_EXTERN const std::string& getName() const; + QMF_EXTERN const std::string& getAgentName() const; + QMF_EXTERN uint32_t getAgentEpoch() const; + QMF_EXTERN qpid::types::Variant::Map asMap() const; + +#ifndef SWIG + private: + friend class qmf::PrivateImplRef; + friend struct DataAddrImplAccess; +#endif + }; + +} + +#endif diff --git a/qpid/cpp/include/qmf/Handle.h b/qpid/cpp/include/qmf/Handle.h new file mode 100644 index 0000000000..510e2993aa --- /dev/null +++ b/qpid/cpp/include/qmf/Handle.h @@ -0,0 +1,70 @@ +#ifndef QMF_HANDLE_H +#define QMF_HANDLE_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qmf/ImportExport.h" + +namespace qmf { + +template class PrivateImplRef; + +/** \ingroup qmf + * A handle is like a pointer: refers to an underlying implementation object. + * Copying the handle does not copy the object. + * + * Handles can be null, like a 0 pointer. Use isValid(), isNull() or the + * conversion to bool to test for a null handle. + */ +template class Handle { + public: + + /**@return true if handle is valid, i.e. not null. */ + QMF_EXTERN bool isValid() const { return impl; } + + /**@return true if handle is null. It is an error to call any function on a null handle. */ + QMF_EXTERN bool isNull() const { return !impl; } + + /** Conversion to bool supports idiom if (handle) { handle->... } */ + QMF_EXTERN operator bool() const { return impl; } + + /** Operator ! supports idiom if (!handle) { do_if_handle_is_null(); } */ + QMF_EXTERN bool operator !() const { return !impl; } + + void swap(Handle& h) { T* t = h.impl; h.impl = impl; impl = t; } + + protected: + typedef T Impl; + QMF_EXTERN Handle() :impl() {} + + // Not implemented,subclasses must implement. + QMF_EXTERN Handle(const Handle&); + QMF_EXTERN Handle& operator=(const Handle&); + + Impl* impl; + + friend class PrivateImplRef; +}; + +} // namespace qmf + +#endif /*!QMF_HANDLE_H*/ diff --git a/qpid/cpp/include/qmf/ImportExport.h b/qpid/cpp/include/qmf/ImportExport.h new file mode 100644 index 0000000000..f5e1d9127c --- /dev/null +++ b/qpid/cpp/include/qmf/ImportExport.h @@ -0,0 +1,33 @@ +#ifndef QMF_IMPORT_EXPORT_H +#define QMF_IMPORT_EXPORT_H + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#if defined(WIN32) && !defined(QPID_DECLARE_STATIC) +# if defined(QMF_EXPORT) || defined (qmfcommon_EXPORTS) +# define QMF_EXTERN __declspec(dllexport) +# else +# define QMF_EXTERN __declspec(dllimport) +# endif +#else +# define QMF_EXTERN +#endif + +#endif diff --git a/qpid/cpp/include/qmf/Query.h b/qpid/cpp/include/qmf/Query.h new file mode 100644 index 0000000000..71ef31b104 --- /dev/null +++ b/qpid/cpp/include/qmf/Query.h @@ -0,0 +1,65 @@ +#ifndef QMF_QUERY_H +#define QMF_QUERY_H +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include +#include "qmf/Handle.h" +#include "qpid/types/Variant.h" +#include + +namespace qmf { + +#ifndef SWIG + template class PrivateImplRef; +#endif + + class QueryImpl; + class SchemaId; + class DataAddr; + + class Query : public qmf::Handle { + public: + QMF_EXTERN Query(QueryImpl* impl = 0); + QMF_EXTERN Query(const Query&); + QMF_EXTERN Query& operator=(const Query&); + QMF_EXTERN ~Query(); + + QMF_EXTERN Query(const std::string& className, const std::string& package="", const std::string& predicate=""); + QMF_EXTERN Query(const SchemaId&); + QMF_EXTERN Query(const DataAddr&); + + QMF_EXTERN const DataAddr& getDataAddr() const; + QMF_EXTERN const SchemaId& getSchemaId() const; + QMF_EXTERN const std::string& getClassName() const; + QMF_EXTERN const std::string& getPackageName() const; + QMF_EXTERN void addPredicate(const std::string&, const qpid::types::Variant&); + QMF_EXTERN const qpid::types::Variant::Map& getPredicate() const; + +#ifndef SWIG + private: + friend class qmf::PrivateImplRef; +#endif + }; + +} + +#endif diff --git a/qpid/cpp/include/qmf/Schema.h b/qpid/cpp/include/qmf/Schema.h new file mode 100644 index 0000000000..cf316138c1 --- /dev/null +++ b/qpid/cpp/include/qmf/Schema.h @@ -0,0 +1,76 @@ +#ifndef QMF_SCHEMA_H +#define QMF_SCHEMA_H +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include +#include "qpid/sys/IntegerTypes.h" +#include "qmf/Handle.h" +#include "qmf/SchemaTypes.h" +#include + +namespace qmf { + +#ifndef SWIG + template class PrivateImplRef; +#endif + + class SchemaImpl; + class SchemaId; + class SchemaProperty; + class SchemaMethod; + + class Schema : public qmf::Handle { + public: + QMF_EXTERN Schema(SchemaImpl* impl = 0); + QMF_EXTERN Schema(const Schema&); + QMF_EXTERN Schema& operator=(const Schema&); + QMF_EXTERN ~Schema(); + + QMF_EXTERN Schema(int, const std::string&, const std::string&); + QMF_EXTERN const SchemaId& getSchemaId() const; + + QMF_EXTERN void finalize(); + QMF_EXTERN bool isFinalized() const; + QMF_EXTERN void addProperty(const SchemaProperty&); + QMF_EXTERN void addMethod(const SchemaMethod&); + QMF_EXTERN void setDesc(const std::string&); + QMF_EXTERN const std::string& getDesc() const; + + QMF_EXTERN void setDefaultSeverity(int); + QMF_EXTERN int getDefaultSeverity() const; + + QMF_EXTERN uint32_t getPropertyCount() const; + QMF_EXTERN SchemaProperty getProperty(uint32_t) const; + + QMF_EXTERN uint32_t getMethodCount() const; + QMF_EXTERN SchemaMethod getMethod(uint32_t) const; + +#ifndef SWIG + private: + friend class qmf::PrivateImplRef; + friend struct SchemaImplAccess; +#endif + }; + +} + +#endif diff --git a/qpid/cpp/include/qmf/SchemaId.h b/qpid/cpp/include/qmf/SchemaId.h new file mode 100644 index 0000000000..13fb1cb902 --- /dev/null +++ b/qpid/cpp/include/qmf/SchemaId.h @@ -0,0 +1,61 @@ +#ifndef QMF_SCHEMA_ID_H +#define QMF_SCHEMA_ID_H +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include +#include "qmf/Handle.h" +#include "qpid/types/Uuid.h" +#include "qmf/SchemaTypes.h" +#include + +namespace qmf { + +#ifndef SWIG + template class PrivateImplRef; +#endif + + class SchemaIdImpl; + + class SchemaId : public qmf::Handle { + public: + QMF_EXTERN SchemaId(SchemaIdImpl* impl = 0); + QMF_EXTERN SchemaId(const SchemaId&); + QMF_EXTERN SchemaId& operator=(const SchemaId&); + QMF_EXTERN ~SchemaId(); + + QMF_EXTERN SchemaId(int, const std::string&, const std::string&); + QMF_EXTERN void setHash(const qpid::types::Uuid&); + QMF_EXTERN int getType() const; + QMF_EXTERN const std::string& getPackageName() const; + QMF_EXTERN const std::string& getName() const; + QMF_EXTERN const qpid::types::Uuid& getHash() const; + +#ifndef SWIG + private: + friend class qmf::PrivateImplRef; + friend struct SchemaIdImplAccess; +#endif + }; + +} + +#endif diff --git a/qpid/cpp/include/qmf/SchemaMethod.h b/qpid/cpp/include/qmf/SchemaMethod.h new file mode 100644 index 0000000000..47302b62b9 --- /dev/null +++ b/qpid/cpp/include/qmf/SchemaMethod.h @@ -0,0 +1,65 @@ +#ifndef QMF_SCHEMA_METHOD_H +#define QMF_SCHEMA_METHOD_H +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qmf/ImportExport.h" +#include "qpid/sys/IntegerTypes.h" +#include "qmf/Handle.h" +#include "qmf/SchemaTypes.h" +#include + +namespace qmf { + +#ifndef SWIG + template class PrivateImplRef; +#endif + + class SchemaMethodImpl; + class SchemaProperty; + + class SchemaMethod : public qmf::Handle { + public: + QMF_EXTERN SchemaMethod(SchemaMethodImpl* impl = 0); + QMF_EXTERN SchemaMethod(const SchemaMethod&); + QMF_EXTERN SchemaMethod& operator=(const SchemaMethod&); + QMF_EXTERN ~SchemaMethod(); + + QMF_EXTERN SchemaMethod(const std::string&, const std::string& o=""); + + QMF_EXTERN void setDesc(const std::string&); + QMF_EXTERN void addArgument(const SchemaProperty&); + + QMF_EXTERN const std::string& getName() const; + QMF_EXTERN const std::string& getDesc() const; + QMF_EXTERN uint32_t getArgumentCount() const; + QMF_EXTERN SchemaProperty getArgument(uint32_t) const; + +#ifndef SWIG + private: + friend class qmf::PrivateImplRef; + friend struct SchemaMethodImplAccess; +#endif + }; + +} + +#endif diff --git a/qpid/cpp/include/qmf/SchemaProperty.h b/qpid/cpp/include/qmf/SchemaProperty.h new file mode 100644 index 0000000000..2e770c2ef1 --- /dev/null +++ b/qpid/cpp/include/qmf/SchemaProperty.h @@ -0,0 +1,74 @@ +#ifndef QMF_SCHEMA_PROPERTY_H +#define QMF_SCHEMA_PROPERTY_H +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include +#include "qmf/Handle.h" +#include "qpid/types/Uuid.h" +#include "qpid/types/Variant.h" +#include "qmf/SchemaTypes.h" +#include + +namespace qmf { + +#ifndef SWIG + template class PrivateImplRef; +#endif + + class SchemaPropertyImpl; + + class SchemaProperty : public Handle { + public: + QMF_EXTERN SchemaProperty(SchemaPropertyImpl* impl = 0); + QMF_EXTERN SchemaProperty(const SchemaProperty&); + QMF_EXTERN SchemaProperty& operator=(const SchemaProperty&); + QMF_EXTERN ~SchemaProperty(); + + QMF_EXTERN SchemaProperty(const std::string&, int, const std::string& o=""); + + QMF_EXTERN void setAccess(int); + QMF_EXTERN void setIndex(bool); + QMF_EXTERN void setOptional(bool); + QMF_EXTERN void setUnit(const std::string&); + QMF_EXTERN void setDesc(const std::string&); + QMF_EXTERN void setSubtype(const std::string&); + QMF_EXTERN void setDirection(int); + + QMF_EXTERN const std::string& getName() const; + QMF_EXTERN int getAccess() const; + QMF_EXTERN bool isIndex() const; + QMF_EXTERN bool isOptional() const; + QMF_EXTERN const std::string& getUnit() const; + QMF_EXTERN const std::string& getDesc() const; + QMF_EXTERN const std::string& getSubtype() const; + QMF_EXTERN int getDirection() const; + +#ifndef SWIG + private: + friend class qmf::PrivateImplRef; + friend struct SchemaPropertyImplAccess; +#endif + }; + +} + +#endif diff --git a/qpid/cpp/include/qmf/SchemaTypes.h b/qpid/cpp/include/qmf/SchemaTypes.h new file mode 100644 index 0000000000..af3da612e5 --- /dev/null +++ b/qpid/cpp/include/qmf/SchemaTypes.h @@ -0,0 +1,56 @@ +#ifndef QMF_SCHEMA_TYPES_H +#define QMF_SCHEMA_TYPES_H +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +namespace qmf { + + const int SCHEMA_TYPE_DATA = 1; + const int SCHEMA_TYPE_EVENT = 2; + + const int SCHEMA_DATA_VOID = 1; + const int SCHEMA_DATA_BOOL = 2; + const int SCHEMA_DATA_INT = 3; + const int SCHEMA_DATA_FLOAT = 4; + const int SCHEMA_DATA_STRING = 5; + const int SCHEMA_DATA_MAP = 6; + const int SCHEMA_DATA_LIST = 7; + const int SCHEMA_DATA_UUID = 8; + + const int ACCESS_READ_CREATE = 1; + const int ACCESS_READ_WRITE = 2; + const int ACCESS_READ_ONLY = 3; + + const int DIR_IN = 1; + const int DIR_OUT = 2; + const int DIR_IN_OUT = 3; + + const int SEV_EMERG = 0; + const int SEV_ALERT = 1; + const int SEV_CRIT = 2; + const int SEV_ERROR = 3; + const int SEV_WARN = 4; + const int SEV_NOTICE = 5; + const int SEV_INFORM = 6; + const int SEV_DEBUG = 7; +} + +#endif diff --git a/qpid/cpp/include/qmf/exceptions.h b/qpid/cpp/include/qmf/exceptions.h new file mode 100644 index 0000000000..7959499d63 --- /dev/null +++ b/qpid/cpp/include/qmf/exceptions.h @@ -0,0 +1,59 @@ +#ifndef QMF_EXCEPTIONS_H +#define QMF_EXCEPTIONS_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qmf/ImportExport.h" +#include "qpid/types/Exception.h" +#include "qpid/types/Variant.h" + +namespace qmf { + +/** \ingroup qmf + */ + + struct QmfException : public qpid::types::Exception { + QMF_EXTERN QmfException(const std::string& msg); + QMF_EXTERN virtual ~QmfException() throw(); + + qpid::types::Variant::Map detail; + }; + + struct KeyNotFound : public QmfException { + QMF_EXTERN KeyNotFound(const std::string& msg); + QMF_EXTERN virtual ~KeyNotFound() throw(); + }; + + struct IndexOutOfRange : public QmfException { + QMF_EXTERN IndexOutOfRange(); + QMF_EXTERN virtual ~IndexOutOfRange() throw(); + }; + + struct OperationTimedOut : public QmfException { + QMF_EXTERN OperationTimedOut(); + QMF_EXTERN virtual ~OperationTimedOut() throw(); + }; + +} + +#endif + -- cgit v1.2.1 From 58c7fd662a4d37ff3b387575e0c0d3b80e7e7368 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Fri, 13 Aug 2010 02:25:28 +0000 Subject: QPID-2793 - Added doxygen text git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@985074 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/AgentSession.h | 77 +++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qmf/AgentSession.h b/qpid/cpp/include/qmf/AgentSession.h index 5259aee360..4ac2b2f3ed 100644 --- a/qpid/cpp/include/qmf/AgentSession.h +++ b/qpid/cpp/include/qmf/AgentSession.h @@ -48,6 +48,11 @@ namespace qmf { QMF_EXTERN ~AgentSession(); /** + * AgentSession + * A session that runs over an AMQP connection for QMF agent operation. + * + * @param connection - An opened qpid::messaging::Connection + * @param options - An optional string containing options * * The options string is of the form "{key:value,key:value}". The following keys are supported: * @@ -59,20 +64,88 @@ namespace qmf { * If False: generate an AUTH_METHOD event to allow per-method authorization */ QMF_EXTERN AgentSession(qpid::messaging::Connection&, const std::string& options=""); + + /** + * setDomain - Change the QMF domain that this agent will operate in. If this is not called, + * the domain will be "default". Agents in a domain can be seen only by consoles in the same domain. + * This must be called prior to opening the agent session. + */ QMF_EXTERN void setDomain(const std::string&); + + /** + * Set identifying attributes of this agent. + * setVendor - Set the vendor string + * setProduct - Set the product name string + * setInstance - Set the unique instance name (if not set, a UUID will be assigned) + * These must be called prior to opening the agent session. + */ QMF_EXTERN void setVendor(const std::string&); QMF_EXTERN void setProduct(const std::string&); QMF_EXTERN void setInstance(const std::string&); + + /** + * setAttribute - Set an arbitrary attribute for this agent. The attributes are not used + * to uniquely identify the agent but can be used as a search criteria when looking for agents. + * This must be called prior to opening the agent session. + */ QMF_EXTERN void setAttribute(const std::string&, const qpid::types::Variant&); + + /** + * Get the identifying name of the agent. + */ QMF_EXTERN const std::string& getName() const; + + /** + * Open the agent session. After opening the session, the domain, identifying strings, and attributes cannot + * be changed. + */ QMF_EXTERN void open(); + + /** + * Close the session. Once closed, the session no longer communicates on the messaging network. + */ QMF_EXTERN void close(); + + /** + * Get the next event from the agent session. Events represent actions that must be acted upon by the + * agent application. This method blocks for up to the timeout if there are no events to be handled. + * This method will typically be the focus of the agent application's main execution loop. + */ QMF_EXTERN bool nextEvent(AgentEvent&, qpid::messaging::Duration timeout=qpid::messaging::Duration::FOREVER); + /** + * Register a schema to be exposed by this agent. + */ QMF_EXTERN void registerSchema(Schema&); + + /** + * Add data to be managed internally by the agent. If the option external:True is selected, this call + * should not be used. + * + * @param data - The data object being managed by the agent. + * @param name - A name unique to this object to be used to address the object. + * If left default, a unique name will be assigned by the agent. + * @param persistent - Set this to true if the data object is to be considered persistent + * across different sessions. If persistent, it is the agent application's + * responsibility to ensure the name is the same each time it is added. + */ QMF_EXTERN DataAddr addData(Data&, const std::string& name="", bool persistent=false); + + /** + * Delete data from internal agent management. + */ QMF_EXTERN void delData(const DataAddr&); + /** + * The following methods are used to respond to events received in nextEvent. + * + * authAccept - Accept an authorization request. + * authReject - Reject/forbid an authorization request. + * raiseException - indicate failure of an operation (i.e. query or method call). + * response - Provide data in response to a query (only for option: external:True) + * complete - Indicate that the response to a query is complete (external:true only) + * methodSuccess - Indicate the successful completion of a method call. + */ QMF_EXTERN void authAccept(AgentEvent&); QMF_EXTERN void authReject(AgentEvent&, const std::string& diag=""); QMF_EXTERN void raiseException(AgentEvent&, const std::string&); @@ -80,6 +153,10 @@ namespace qmf { QMF_EXTERN void response(AgentEvent&, const Data&); QMF_EXTERN void complete(AgentEvent&); QMF_EXTERN void methodSuccess(AgentEvent&); + + /** + * Raise an event to be sent into the QMF network. + */ QMF_EXTERN void raiseEvent(const Data&); #ifndef SWIG -- cgit v1.2.1 From 4522e6a49bab8d8256b9b16b20ba26bbf24354b7 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Fri, 20 Aug 2010 11:32:11 +0000 Subject: QPID-2807: Allow per message acknowledgement git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@987459 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Session.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Session.h b/qpid/cpp/include/qpid/messaging/Session.h index 688a4dd102..07a76993ee 100644 --- a/qpid/cpp/include/qpid/messaging/Session.h +++ b/qpid/cpp/include/qpid/messaging/Session.h @@ -75,6 +75,10 @@ class Session : public qpid::messaging::Handle * processed by the server */ QPID_MESSAGING_EXTERN void acknowledge(bool sync=false); + /** + * Acknowledges the specified message. + */ + QPID_MESSAGING_EXTERN void acknowledge(Message&, bool sync=false); /** * Rejects the specified message. This will prevent the message * being redelivered. This must be called before the message is -- cgit v1.2.1 From d47927b3e150057f6d615a0d00c8eff6c83320ac Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Tue, 21 Sep 2010 21:48:41 +0000 Subject: QMFv2 Additions: - QMFv2 schema encoding completed - Schema queries handled by the agent and initiated by the console by user request - Full query support with predicates evaluated on the agent (regex not yet implemented) - Agent filtering in the console - Agent aging in the console - Unit tests git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@999662 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/Agent.h | 42 +++++++++++++++++++++++++++++++++++ qpid/cpp/include/qmf/ConsoleEvent.h | 32 +++++++++++++++++--------- qpid/cpp/include/qmf/ConsoleSession.h | 13 +++++++++++ qpid/cpp/include/qmf/Query.h | 21 +++++++++++++----- qpid/cpp/include/qmf/SchemaProperty.h | 1 + 5 files changed, 93 insertions(+), 16 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qmf/Agent.h b/qpid/cpp/include/qmf/Agent.h index 8ddea0fae9..8d427ab2fb 100644 --- a/qpid/cpp/include/qmf/Agent.h +++ b/qpid/cpp/include/qmf/Agent.h @@ -65,10 +65,52 @@ namespace qmf { qpid::messaging::Duration timeout=qpid::messaging::Duration::MINUTE); QMF_EXTERN uint32_t callMethodAsync(const std::string&, const qpid::types::Variant::Map&, const DataAddr&); + /** + * Query the agent for a list of schema classes that it exposes. This operation comes in both + * synchronous (blocking) and asynchronous flavors. + * + * This method will typically be used after receiving an AGENT_SCHEMA_UPDATE event from the console session. + * It may also be used on a newly discovered agent to learn what schemata are exposed. + * + * querySchema returns a ConsoleEvent that contains a list of SchemaId objects exposed by the agent. + * This list is cached locally and can be locally queried using getPackage[Count] and getSchemaId[Count]. + */ + QMF_EXTERN ConsoleEvent querySchema(qpid::messaging::Duration timeout=qpid::messaging::Duration::MINUTE); + QMF_EXTERN uint32_t querySchemaAsync(); + + /** + * Get the list of schema packages exposed by the agent. + * + * getPackageCount returns the number of packages exposed. + * getPackage returns the name of the package by index (0..package-count) + * + * Note that both of these calls are synchronous and non-blocking. They only return locally cached data + * and will not send any messages to the remote agent. Use querySchema[Async] to get the latest schema + * information from the remote agent. + */ QMF_EXTERN uint32_t getPackageCount() const; QMF_EXTERN const std::string& getPackage(uint32_t) const; + + /** + * Get the list of schema identifiers for a particular package. + * + * getSchemaIdCount returns the number of IDs in the indicates package. + * getSchemaId returns the SchemaId by index (0..schema-id-count) + * + * Note that both of these calls are synchronous and non-blocking. They only return locally cached data + * and will not send any messages to the remote agent. Use querySchema[Async] to get the latest schema + * information from the remote agent. + */ QMF_EXTERN uint32_t getSchemaIdCount(const std::string&) const; QMF_EXTERN SchemaId getSchemaId(const std::string&, uint32_t) const; + + /** + * Get detailed schema information for a specified schema ID. + * + * This call will return cached information if it is available. If not, it will send a query message to the + * remote agent and block waiting for a response. The timeout argument specifies the maximum time to wait + * for a response from the agent. + */ QMF_EXTERN Schema getSchema(const SchemaId&, qpid::messaging::Duration timeout=qpid::messaging::Duration::MINUTE); diff --git a/qpid/cpp/include/qmf/ConsoleEvent.h b/qpid/cpp/include/qmf/ConsoleEvent.h index 61f625b137..3e75631a61 100644 --- a/qpid/cpp/include/qmf/ConsoleEvent.h +++ b/qpid/cpp/include/qmf/ConsoleEvent.h @@ -23,6 +23,9 @@ #include #include "qmf/Handle.h" +#include "qmf/Agent.h" +#include "qmf/Data.h" +#include "qmf/SchemaId.h" #include "qpid/types/Variant.h" namespace qmf { @@ -32,18 +35,24 @@ namespace qmf { #endif class ConsoleEventImpl; - class Agent; - class Data; enum ConsoleEventCode { - CONSOLE_AGENT_ADD = 1, - CONSOLE_AGENT_AGE = 2, - CONSOLE_EVENT = 3, - CONSOLE_QUERY_RESPONSE = 4, - CONSOLE_METHOD_RESPONSE = 5, - CONSOLE_EXCEPTION = 6, - CONSOLE_SUBSCRIBE_UPDATE = 7, - CONSOLE_THREAD_FAILED = 8 + CONSOLE_AGENT_ADD = 1, + CONSOLE_AGENT_DEL = 2, + CONSOLE_AGENT_RESTART = 3, + CONSOLE_AGENT_SCHEMA_UPDATE = 4, + CONSOLE_AGENT_SCHEMA_RESPONSE = 5, + CONSOLE_EVENT = 6, + CONSOLE_QUERY_RESPONSE = 7, + CONSOLE_METHOD_RESPONSE = 8, + CONSOLE_EXCEPTION = 9, + CONSOLE_SUBSCRIBE_UPDATE = 10, + CONSOLE_THREAD_FAILED = 11 + }; + + enum AgentDelReason { + AGENT_DEL_AGED = 1, + AGENT_DEL_FILTER = 2 }; class ConsoleEvent : public qmf::Handle { @@ -56,6 +65,9 @@ namespace qmf { QMF_EXTERN ConsoleEventCode getType() const; QMF_EXTERN uint32_t getCorrelator() const; QMF_EXTERN Agent getAgent() const; + QMF_EXTERN AgentDelReason getAgentDelReason() const; + QMF_EXTERN uint32_t getSchemaIdCount() const; + QMF_EXTERN SchemaId getSchemaId(uint32_t) const; QMF_EXTERN uint32_t getDataCount() const; QMF_EXTERN Data getData(uint32_t) const; QMF_EXTERN bool isFinal() const; diff --git a/qpid/cpp/include/qmf/ConsoleSession.h b/qpid/cpp/include/qmf/ConsoleSession.h index 0e58a647d6..c17f4510f1 100644 --- a/qpid/cpp/include/qmf/ConsoleSession.h +++ b/qpid/cpp/include/qmf/ConsoleSession.h @@ -44,6 +44,19 @@ namespace qmf { QMF_EXTERN ConsoleSession& operator=(const ConsoleSession&); QMF_EXTERN ~ConsoleSession(); + /** + * ConsoleSession + * A session that runs over an AMQP connection for QMF console operation. + * + * @param connection - An opened qpid::messaging::Connection + * @param options - An optional string containing options + * + * The options string is of the form "{key:value,key:value}". The following keys are supported: + * + * domain:NAME - QMF Domain to join [default: "default"] + * max-agent-age:N - Maximum time, in minutes, that we will tolerate not hearing from + * an agent before deleting it [default: 5] + */ QMF_EXTERN ConsoleSession(qpid::messaging::Connection&, const std::string& options=""); QMF_EXTERN void setDomain(const std::string&); QMF_EXTERN void setAgentFilter(const std::string&); diff --git a/qpid/cpp/include/qmf/Query.h b/qpid/cpp/include/qmf/Query.h index 71ef31b104..fec4660bd7 100644 --- a/qpid/cpp/include/qmf/Query.h +++ b/qpid/cpp/include/qmf/Query.h @@ -36,6 +36,13 @@ namespace qmf { class SchemaId; class DataAddr; + enum QueryTarget { + QUERY_OBJECT = 1, + QUERY_OBJECT_ID = 2, + QUERY_SCHEMA = 3, + QUERY_SCHEMA_ID = 4 + }; + class Query : public qmf::Handle { public: QMF_EXTERN Query(QueryImpl* impl = 0); @@ -43,20 +50,22 @@ namespace qmf { QMF_EXTERN Query& operator=(const Query&); QMF_EXTERN ~Query(); - QMF_EXTERN Query(const std::string& className, const std::string& package="", const std::string& predicate=""); - QMF_EXTERN Query(const SchemaId&); + QMF_EXTERN Query(QueryTarget, const std::string& predicate=""); + QMF_EXTERN Query(QueryTarget, const std::string& className, const std::string& package, const std::string& predicate=""); + QMF_EXTERN Query(QueryTarget, const SchemaId&, const std::string& predicate=""); QMF_EXTERN Query(const DataAddr&); + QMF_EXTERN QueryTarget getTarget() const; QMF_EXTERN const DataAddr& getDataAddr() const; QMF_EXTERN const SchemaId& getSchemaId() const; - QMF_EXTERN const std::string& getClassName() const; - QMF_EXTERN const std::string& getPackageName() const; - QMF_EXTERN void addPredicate(const std::string&, const qpid::types::Variant&); - QMF_EXTERN const qpid::types::Variant::Map& getPredicate() const; + QMF_EXTERN void setPredicate(const qpid::types::Variant::List&); + QMF_EXTERN const qpid::types::Variant::List& getPredicate() const; + QMF_EXTERN bool matchesPredicate(const qpid::types::Variant::Map& map) const; #ifndef SWIG private: friend class qmf::PrivateImplRef; + friend class QueryImplAccess; #endif }; diff --git a/qpid/cpp/include/qmf/SchemaProperty.h b/qpid/cpp/include/qmf/SchemaProperty.h index 2e770c2ef1..a3a328b60b 100644 --- a/qpid/cpp/include/qmf/SchemaProperty.h +++ b/qpid/cpp/include/qmf/SchemaProperty.h @@ -54,6 +54,7 @@ namespace qmf { QMF_EXTERN void setDirection(int); QMF_EXTERN const std::string& getName() const; + QMF_EXTERN int getType() const; QMF_EXTERN int getAccess() const; QMF_EXTERN bool isIndex() const; QMF_EXTERN bool isOptional() const; -- cgit v1.2.1 From 0d5fab5c052c5c4e4519ec3b0e9973aea45bd5f4 Mon Sep 17 00:00:00 2001 From: Jonathan Robie Date: Thu, 14 Oct 2010 21:11:38 +0000 Subject: Removed confusing text from reject() and release() doxygen strings. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1022712 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Session.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Session.h b/qpid/cpp/include/qpid/messaging/Session.h index 07a76993ee..ed8d87ceb2 100644 --- a/qpid/cpp/include/qpid/messaging/Session.h +++ b/qpid/cpp/include/qpid/messaging/Session.h @@ -80,15 +80,13 @@ class Session : public qpid::messaging::Handle */ QPID_MESSAGING_EXTERN void acknowledge(Message&, bool sync=false); /** - * Rejects the specified message. This will prevent the message - * being redelivered. This must be called before the message is - * acknowledged. + * Rejects the specified message. The broker does not redeliver + * a message that has been rejected. */ QPID_MESSAGING_EXTERN void reject(Message&); /** - * Releases the specified message. This will allow the broker to - * redeliver the message. This must be called before the message - * is acknowledged. + * Releases the specified message. The broker may + * redeliver the message. */ QPID_MESSAGING_EXTERN void release(Message&); @@ -97,7 +95,7 @@ class Session : public qpid::messaging::Handle * * @param block if true, this call will block until the server * confirms completion of all pending operations; if false the - * call will request notifcation from the server but will return + * call will request notification from the server but will return * before receiving it. */ QPID_MESSAGING_EXTERN void sync(bool block=true); -- cgit v1.2.1 From bba57b32b6b67bbce808a15858c9b70fe406c20d Mon Sep 17 00:00:00 2001 From: Jonathan Robie Date: Fri, 15 Oct 2010 13:00:13 +0000 Subject: Improved wording in the doxygen strings for session::reject(), session::release(). git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1022902 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Session.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Session.h b/qpid/cpp/include/qpid/messaging/Session.h index ed8d87ceb2..bb631f1563 100644 --- a/qpid/cpp/include/qpid/messaging/Session.h +++ b/qpid/cpp/include/qpid/messaging/Session.h @@ -80,13 +80,15 @@ class Session : public qpid::messaging::Handle */ QPID_MESSAGING_EXTERN void acknowledge(Message&, bool sync=false); /** - * Rejects the specified message. The broker does not redeliver - * a message that has been rejected. + * Rejects the specified message. The broker does not redeliver a + * message that has been rejected. Once a message has been + * acknowledged, it can no longer be rejected. */ QPID_MESSAGING_EXTERN void reject(Message&); /** - * Releases the specified message. The broker may - * redeliver the message. + * Releases the specified message. The broker may redeliver the + * message. One a message has been acknowledged, it can no longer + * be released. */ QPID_MESSAGING_EXTERN void release(Message&); -- cgit v1.2.1 From d7ab0ad10315ea5fcca15e88993c523c23be53ea Mon Sep 17 00:00:00 2001 From: Jonathan Robie Date: Fri, 29 Oct 2010 17:26:05 +0000 Subject: Corrects AddressParser to use typed simple values. Adds Variant::fromString(). Resolves QPID-2896 and QPID-2908. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1028860 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/types/Variant.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/types/Variant.h b/qpid/cpp/include/qpid/types/Variant.h index 3ed1db4452..2b692f9bdf 100644 --- a/qpid/cpp/include/qpid/types/Variant.h +++ b/qpid/cpp/include/qpid/types/Variant.h @@ -113,6 +113,8 @@ class Variant QPID_TYPES_EXTERN Variant& operator=(const Variant&); QPID_TYPES_EXTERN Variant& operator=(const Uuid&); + QPID_TYPES_EXTERN Variant& fromString(const std::string&); + QPID_TYPES_EXTERN bool asBool() const; QPID_TYPES_EXTERN uint8_t asUint8() const; QPID_TYPES_EXTERN uint16_t asUint16() const; -- cgit v1.2.1 From f3737cc2b38d3a0494a64d1b5d618229a80651bd Mon Sep 17 00:00:00 2001 From: Jonathan Robie Date: Mon, 1 Nov 2010 14:18:07 +0000 Subject: Changed Variant::fromString() to Variant::parse(). Also changed implementation. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1029673 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/types/Variant.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/types/Variant.h b/qpid/cpp/include/qpid/types/Variant.h index 2b692f9bdf..9ae672b7c2 100644 --- a/qpid/cpp/include/qpid/types/Variant.h +++ b/qpid/cpp/include/qpid/types/Variant.h @@ -113,7 +113,11 @@ class Variant QPID_TYPES_EXTERN Variant& operator=(const Variant&); QPID_TYPES_EXTERN Variant& operator=(const Uuid&); - QPID_TYPES_EXTERN Variant& fromString(const std::string&); + /** + * Parses the argument and assigns itself the appropriate + * value. Recognises integers, doubles and booleans. + */ + QPID_TYPES_EXTERN Variant& parse(const std::string&); QPID_TYPES_EXTERN bool asBool() const; QPID_TYPES_EXTERN uint8_t asUint8() const; -- cgit v1.2.1 From 8a96f77d3446326911a1b78b5b01c5712ac3a058 Mon Sep 17 00:00:00 2001 From: "Stephen D. Huston" Date: Mon, 1 Nov 2010 23:51:18 +0000 Subject: Squish some "could lose data" compile warnings from MSVC. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1029896 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/framing/Uuid.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/framing/Uuid.h b/qpid/cpp/include/qpid/framing/Uuid.h index d357538b4d..d0a8d02411 100644 --- a/qpid/cpp/include/qpid/framing/Uuid.h +++ b/qpid/cpp/include/qpid/framing/Uuid.h @@ -67,7 +67,8 @@ struct Uuid : public boost::array { QPID_COMMON_EXTERN void encode(framing::Buffer& buf) const; QPID_COMMON_EXTERN void decode(framing::Buffer& buf); - QPID_COMMON_EXTERN uint32_t encodedSize() const { return size(); } + QPID_COMMON_EXTERN uint32_t encodedSize() const + { return static_cast(size()); } /** String value in format 1b4e28ba-2fa1-11d2-883f-b9a761bde3fb. */ QPID_COMMON_EXTERN std::string str() const; -- cgit v1.2.1 From 42d18e5791c0f79588d5264f2b0c96ee0a39c122 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Tue, 9 Nov 2010 21:15:03 +0000 Subject: QPID-2934 Feature to pass the authenticated userId to QMF agent method handlers for authorization git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1033232 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/management/Manageable.h | 5 +++++ qpid/cpp/include/qpid/management/ManagementObject.h | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/management/Manageable.h b/qpid/cpp/include/qpid/management/Manageable.h index 7a72cc1592..1e5cd8bc42 100644 --- a/qpid/cpp/include/qpid/management/Manageable.h +++ b/qpid/cpp/include/qpid/management/Manageable.h @@ -63,6 +63,11 @@ class QPID_COMMON_EXTERN Manageable // method being called and must be down-cast to the appropriate sub class // before use. virtual status_t ManagementMethod(uint32_t methodId, Args& args, std::string& text); + + // This optional method can be overridden to allow the agent application to + // authorize method invocations. Return true iff the authenticated user identified + // in userId us authorized to execute the method. + virtual bool AuthorizeMethod(uint32_t methodId, Args& args, const std::string& userId); }; inline Manageable::~Manageable(void) {} diff --git a/qpid/cpp/include/qpid/management/ManagementObject.h b/qpid/cpp/include/qpid/management/ManagementObject.h index 59a7f00603..dec5a63ee9 100644 --- a/qpid/cpp/include/qpid/management/ManagementObject.h +++ b/qpid/cpp/include/qpid/management/ManagementObject.h @@ -175,7 +175,8 @@ protected: virtual void mapDecodeValues(const types::Variant::Map& map) = 0; virtual void doMethod(std::string& methodName, const types::Variant::Map& inMap, - types::Variant::Map& outMap) = 0; + types::Variant::Map& outMap, + const std::string& userId) = 0; QPID_COMMON_EXTERN void writeTimestamps(types::Variant::Map& map) const; QPID_COMMON_EXTERN void readTimestamps(const types::Variant::Map& buf); @@ -187,7 +188,7 @@ protected: virtual void readProperties(const std::string&) {} virtual void writeProperties(std::string&) const {} virtual void writeStatistics(std::string&, bool = false) {} - virtual void doMethod(std::string&, const std::string&, std::string&) {} + virtual void doMethod(std::string&, const std::string&, std::string&, const std::string&) {} QPID_COMMON_EXTERN virtual void setReference(ObjectId objectId); -- cgit v1.2.1 From cac1b88440584a9d69a212f01486bc9041278c66 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Wed, 17 Nov 2010 19:12:08 +0000 Subject: Aggregate Timer warnings. The Timer code logs a warning if a timer callback is started late or overruns the start time for the next callback. In cases where there are a lot of these warnings, the time taken to do the logging itself severly worsens the situation. This commit aggregates timer warnings and give a statistical report every 5 seconds at most. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1036169 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/log/Statement.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/log/Statement.h b/qpid/cpp/include/qpid/log/Statement.h index 8f73175630..7b3ab60b81 100644 --- a/qpid/cpp/include/qpid/log/Statement.h +++ b/qpid/cpp/include/qpid/log/Statement.h @@ -95,6 +95,24 @@ struct Statement { stmt_.log(::qpid::Msg() << MESSAGE); \ } while(0) +/** + * FLAG must be a boolean variable. Assigns FLAG to true iff logging + * is enabled for LEVEL in the calling context. Use when extra + * support code is needed to generate log messages, to ensure that it + * is only run if the logging level is enabled. + * e.g. + * bool logWarning; + * QPID_LOG_TEST(LEVEL, logWarning); + * if (logWarning) { do stuff needed for warning log messages } + */ +#define QPID_LOG_TEST(LEVEL, FLAG) \ + do { \ + using ::qpid::log::Statement; \ + static Statement stmt_= QPID_LOG_STATEMENT_INIT(LEVEL); \ + static Statement::Initializer init_(stmt_); \ + FLAG = stmt_.enabled; \ + } while(0) + /** * Macro for log statements. Example of use: * @code -- cgit v1.2.1 From 7083eeafdfa93dabd65d1e2506355fe873a10531 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Fri, 10 Dec 2010 09:17:18 +0000 Subject: QPID-2966: Add QMF method to dynamically set the log level. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1044248 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/log/Logger.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/log/Logger.h b/qpid/cpp/include/qpid/log/Logger.h index d7da1f077a..783ab7bdb9 100644 --- a/qpid/cpp/include/qpid/log/Logger.h +++ b/qpid/cpp/include/qpid/log/Logger.h @@ -74,6 +74,9 @@ class Logger : private boost::noncopyable { /** Configure logger from Options */ QPID_COMMON_EXTERN void configure(const Options& o); + /** Reset the log selectors */ + QPID_COMMON_EXTERN void reconfigure(const std::vector& selectors); + /** Add a statement. */ QPID_COMMON_EXTERN void add(Statement& s); -- cgit v1.2.1 From b1cd22ae277d9a987d37e2538aded2f3521bc362 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Mon, 10 Jan 2011 14:06:16 +0000 Subject: Updates to the C++ implementation of QMFv2: 1) Consolidated string constants for the protocol into a definition file. 2) Added hooks for subscription handling. 3) Added checks to validate properties and arguments against the schema (if there is a schema). git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1057199 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/Agent.h | 7 +++ qpid/cpp/include/qmf/AgentSession.h | 9 +++- qpid/cpp/include/qmf/ConsoleEvent.h | 6 ++- qpid/cpp/include/qmf/ConsoleSession.h | 11 +++++ qpid/cpp/include/qmf/Data.h | 4 +- qpid/cpp/include/qmf/Subscription.h | 82 +++++++++++++++++++++++++++++++++++ 6 files changed, 113 insertions(+), 6 deletions(-) create mode 100644 qpid/cpp/include/qmf/Subscription.h (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qmf/Agent.h b/qpid/cpp/include/qmf/Agent.h index 8d427ab2fb..8c0f48b8b1 100644 --- a/qpid/cpp/include/qmf/Agent.h +++ b/qpid/cpp/include/qmf/Agent.h @@ -23,6 +23,7 @@ #include #include "qmf/Handle.h" +//#include "qmf/Subscription.h" #include "qmf/exceptions.h" #include "qpid/messaging/Duration.h" #include "qpid/types/Variant.h" @@ -61,6 +62,12 @@ namespace qmf { QMF_EXTERN uint32_t queryAsync(const Query&); QMF_EXTERN uint32_t queryAsync(const std::string&); + /** + * Create a subscription to this agent + */ + //QMF_EXTERN Subscription subscribe(const Query&, const std::string& options = ""); + //QMF_EXTERN Subscription subscribe(const std::string&, const std::string& options = ""); + QMF_EXTERN ConsoleEvent callMethod(const std::string&, const qpid::types::Variant::Map&, const DataAddr&, qpid::messaging::Duration timeout=qpid::messaging::Duration::MINUTE); QMF_EXTERN uint32_t callMethodAsync(const std::string&, const qpid::types::Variant::Map&, const DataAddr&); diff --git a/qpid/cpp/include/qmf/AgentSession.h b/qpid/cpp/include/qmf/AgentSession.h index 4ac2b2f3ed..090017779f 100644 --- a/qpid/cpp/include/qmf/AgentSession.h +++ b/qpid/cpp/include/qmf/AgentSession.h @@ -57,11 +57,16 @@ namespace qmf { * The options string is of the form "{key:value,key:value}". The following keys are supported: * * interval:N - Heartbeat interval in seconds [default: 60] - * external:{True,False} - Use external data storage (queries are pass-through) [default: False] + * external:{True,False} - Use external data storage (queries and subscriptions are pass-through) [default: False] * allow-queries:{True,False} - If True: automatically allow all queries [default] * If False: generate an AUTH_QUERY event to allow per-query authorization * allow-methods:{True,False} - If True: automatically allow all methods [default] * If False: generate an AUTH_METHOD event to allow per-method authorization + * max-subscriptions:N - Maximum number of concurrent subscription queries permitted [default: 64] + * min-sub-interval:N - Minimum publish interval (in milliseconds) permitted for a subscription [default: 3000] + * sub-lifetime:N - Lifetime (in seconds with no keepalive) for a subscription [default: 300] + * public-events:{True,False} - If True: QMF events are sent to the topic exchange [default] + * If False: QMF events are only sent to authorized subscribers */ QMF_EXTERN AgentSession(qpid::messaging::Connection&, const std::string& options=""); @@ -143,7 +148,7 @@ namespace qmf { * authReject - Reject/forbid an authorization request. * raiseException - indicate failure of an operation (i.e. query or method call). * response - Provide data in response to a query (only for option: external:True) - * complete - Indicate that the response to a query is complete (external:true only) + * complete - Indicate that the response to a query is complete (external:True only) * methodSuccess - Indicate the successful completion of a method call. */ QMF_EXTERN void authAccept(AgentEvent&); diff --git a/qpid/cpp/include/qmf/ConsoleEvent.h b/qpid/cpp/include/qmf/ConsoleEvent.h index 3e75631a61..54272334a4 100644 --- a/qpid/cpp/include/qmf/ConsoleEvent.h +++ b/qpid/cpp/include/qmf/ConsoleEvent.h @@ -46,8 +46,10 @@ namespace qmf { CONSOLE_QUERY_RESPONSE = 7, CONSOLE_METHOD_RESPONSE = 8, CONSOLE_EXCEPTION = 9, - CONSOLE_SUBSCRIBE_UPDATE = 10, - CONSOLE_THREAD_FAILED = 11 + CONSOLE_SUBSCRIBE_ADD = 10, + CONSOLE_SUBSCRIBE_UPDATE = 11, + CONSOLE_SUBSCRIBE_DEL = 12, + CONSOLE_THREAD_FAILED = 13 }; enum AgentDelReason { diff --git a/qpid/cpp/include/qmf/ConsoleSession.h b/qpid/cpp/include/qmf/ConsoleSession.h index c17f4510f1..ba8b3de92f 100644 --- a/qpid/cpp/include/qmf/ConsoleSession.h +++ b/qpid/cpp/include/qmf/ConsoleSession.h @@ -24,6 +24,7 @@ #include #include "qmf/Handle.h" #include "qmf/Agent.h" +#include "qmf/Subscription.h" #include "qpid/messaging/Duration.h" #include "qpid/messaging/Connection.h" #include @@ -67,6 +68,16 @@ namespace qmf { QMF_EXTERN Agent getAgent(uint32_t) const; QMF_EXTERN Agent getConnectedBrokerAgent() const; + /** + * Create a subscription that involves a subset of the known agents. The set of known agents is defined by + * the session's agent-filter (see setAgentFilter). The agentFilter argument to the subscribe method is used + * to further refine the set of agents. If agentFilter is the empty string (i.e. match-all) the subscription + * will involve all known agents. If agentFilter is non-empty, it will be applied only to the set of known + * agents. A subscription cannot be created that involves an agent not known by the session. + */ + QMF_EXTERN Subscription subscribe(const Query&, const std::string& agentFilter = "", const std::string& options = ""); + QMF_EXTERN Subscription subscribe(const std::string&, const std::string& agentFilter = "", const std::string& options = ""); + #ifndef SWIG private: friend class qmf::PrivateImplRef; diff --git a/qpid/cpp/include/qmf/Data.h b/qpid/cpp/include/qmf/Data.h index 27af1c4b04..82f1569a0b 100644 --- a/qpid/cpp/include/qmf/Data.h +++ b/qpid/cpp/include/qmf/Data.h @@ -34,6 +34,7 @@ namespace qmf { #endif class DataImpl; + class Schema; class SchemaId; class DataAddr; class Agent; @@ -45,8 +46,7 @@ namespace qmf { QMF_EXTERN Data& operator=(const Data&); QMF_EXTERN ~Data(); - QMF_EXTERN Data(const SchemaId&); - QMF_EXTERN void setSchema(const SchemaId&); + QMF_EXTERN Data(const Schema&); QMF_EXTERN void setAddr(const DataAddr&); QMF_EXTERN void setProperty(const std::string&, const qpid::types::Variant&); QMF_EXTERN void overwriteProperties(const qpid::types::Variant::Map&); diff --git a/qpid/cpp/include/qmf/Subscription.h b/qpid/cpp/include/qmf/Subscription.h new file mode 100644 index 0000000000..4e60eb984e --- /dev/null +++ b/qpid/cpp/include/qmf/Subscription.h @@ -0,0 +1,82 @@ +#ifndef QMF_SUBSCRIPTION_H +#define QMF_SUBSCRIPTION_H +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include +#include "qmf/Handle.h" +#include "qpid/types/Variant.h" +#include + +namespace qmf { + +#ifndef SWIG + template class PrivateImplRef; +#endif + + class SubscriptionImpl; + class Data; + + class Subscription : public qmf::Handle { + public: + QMF_EXTERN Subscription(SubscriptionImpl* impl = 0); + QMF_EXTERN Subscription(const Subscription&); + QMF_EXTERN Subscription& operator=(const Subscription&); + QMF_EXTERN ~Subscription(); + + /** + * Construction: A subscription is created by calling ConsoleSession::subscribe. + */ + + /** + * Cancel subscriptions to all subscribed agents. After this is called, the subscription + * shall be inactive. + */ + QMF_EXTERN void cancel(); + + /** + * Check to see if this subscription is active. It is active if it has a live subscription + * on at least one agent. If it is not active, there is nothing that can be done to make it + * active, it can only be deleted. + */ + QMF_EXTERN bool isActive() const; + + /** + * lock and unlock should be used to bracket a traversal of the data set. After lock is called, + * the subscription will not change its set of available data objects. Between calls to getDataCount + * and getData, no data objects will be added or removed. After unlock is called, the set of data + * will catch up to any activity that occurred while the lock was in effect. + */ + QMF_EXTERN void lock(); + QMF_EXTERN void unlock(); + QMF_EXTERN uint32_t getDataCount() const; + QMF_EXTERN Data getData(uint32_t) const; + +#ifndef SWIG + private: + friend class qmf::PrivateImplRef; + friend class SubscriptionImplAccess; +#endif + }; + +} + +#endif -- cgit v1.2.1 From 8850626ab31ff00e0eca619fda60a72775005eaa Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Tue, 11 Jan 2011 16:02:23 +0000 Subject: QMFv2 API change: 1) Added public constructor for DataAddr(Variant::Map) 2) Fixed Python and Ruby typemaps to support Variant::Map& and Variant::List& with const 3) Added support for building Queries based on object-id maps in both Python and Ruby wrappers git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1057709 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/DataAddr.h | 1 + 1 file changed, 1 insertion(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qmf/DataAddr.h b/qpid/cpp/include/qmf/DataAddr.h index fd8a8599c1..72de0c986a 100644 --- a/qpid/cpp/include/qmf/DataAddr.h +++ b/qpid/cpp/include/qmf/DataAddr.h @@ -44,6 +44,7 @@ namespace qmf { QMF_EXTERN bool operator==(const DataAddr&); QMF_EXTERN bool operator<(const DataAddr&); + QMF_EXTERN DataAddr(const qpid::types::Variant::Map&); QMF_EXTERN DataAddr(const std::string& name, const std::string& agentName, uint32_t agentEpoch=0); QMF_EXTERN const std::string& getName() const; QMF_EXTERN const std::string& getAgentName() const; -- cgit v1.2.1 From 2b73bd3fa303bf048d4b7f361a30652f6ffa9079 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Mon, 17 Jan 2011 09:46:50 +0000 Subject: QPID-2998: Remove spurious class definitions git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1059835 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Session.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Session.h b/qpid/cpp/include/qpid/messaging/Session.h index bb631f1563..6c023629e0 100644 --- a/qpid/cpp/include/qpid/messaging/Session.h +++ b/qpid/cpp/include/qpid/messaging/Session.h @@ -38,11 +38,9 @@ template class PrivateImplRef; class Address; class Connection; class Message; -class MessageListener; class Sender; class Receiver; class SessionImpl; -class Subscription; /** \ingroup messaging * A session represents a distinct 'conversation' which can involve -- cgit v1.2.1 From 7810b4b3407be896f6c600d6231a1f7049adec1d Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Mon, 17 Jan 2011 10:24:35 +0000 Subject: QPID-3001: Add const version of Connection::isOpen() git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1059846 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Connection.h | 1 + 1 file changed, 1 insertion(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Connection.h b/qpid/cpp/include/qpid/messaging/Connection.h index 59f5616a2f..1ad7a7242f 100644 --- a/qpid/cpp/include/qpid/messaging/Connection.h +++ b/qpid/cpp/include/qpid/messaging/Connection.h @@ -90,6 +90,7 @@ class Connection : public qpid::messaging::Handle QPID_MESSAGING_EXTERN void setOption(const std::string& name, const qpid::types::Variant& value); QPID_MESSAGING_EXTERN void open(); QPID_MESSAGING_EXTERN bool isOpen(); + QPID_MESSAGING_EXTERN bool isOpen() const; /** * Closes a connection and all sessions associated with it. An * opened connection must be closed before the last handle is -- cgit v1.2.1 From 54895c3ce0a66a4630289bfeb6ed4f86516e784e Mon Sep 17 00:00:00 2001 From: Kenneth Anthony Giusti Date: Tue, 18 Jan 2011 14:51:31 +0000 Subject: QPID-2997: remove oid disambiguation, re-order mgmt object status updates. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1060401 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/management/ManagementObject.h | 1 - 1 file changed, 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/management/ManagementObject.h b/qpid/cpp/include/qpid/management/ManagementObject.h index dec5a63ee9..747edda150 100644 --- a/qpid/cpp/include/qpid/management/ManagementObject.h +++ b/qpid/cpp/include/qpid/management/ManagementObject.h @@ -82,7 +82,6 @@ public: QPID_COMMON_EXTERN bool equalV1(const ObjectId &other) const; QPID_COMMON_EXTERN void setV2Key(const std::string& _key) { v2Key = _key; } QPID_COMMON_EXTERN void setV2Key(const ManagementObject& object); - QPID_COMMON_EXTERN void disambiguate(); QPID_COMMON_EXTERN void setAgentName(const std::string& _name) { agentName = _name; } QPID_COMMON_EXTERN const std::string& getAgentName() const { return agentName; } QPID_COMMON_EXTERN const std::string& getV2Key() const { return v2Key; } -- cgit v1.2.1 From 888f2f8b812308c32594f8abcca7aefc956b5803 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Thu, 20 Jan 2011 14:13:08 +0000 Subject: Bug 654872, QPID-3007: Batch management messages by count, not size. QMF V1 management messages were being batched by accumulating up to a certain total size of data. Since management messages may have different sizes on brokers in a cluster, this was leading to inconsistencies. This patch batches V1 messages by count rather than by size, similar to V2 messages. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1061308 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/framing/ResizableBuffer.h | 60 +++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 qpid/cpp/include/qpid/framing/ResizableBuffer.h (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/framing/ResizableBuffer.h b/qpid/cpp/include/qpid/framing/ResizableBuffer.h new file mode 100644 index 0000000000..e6c9e7a113 --- /dev/null +++ b/qpid/cpp/include/qpid/framing/ResizableBuffer.h @@ -0,0 +1,60 @@ +#ifndef QPID_FRAMING_RESIZABLEBUFFER_H +#define QPID_FRAMING_RESIZABLEBUFFER_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "Buffer.h" +#include + +namespace qpid { +namespace framing { + +/** + * A buffer that maintains its own storage and can be resized, + * keeping any data already written to the buffer. + */ +class ResizableBuffer : public Buffer +{ + public: + ResizableBuffer(size_t initialSize) : store(initialSize) { + static_cast(*this) = Buffer(&store[0], store.size()); + } + + void resize(size_t newSize) { + size_t oldPos = getPosition(); + store.resize(newSize); + static_cast(*this) = Buffer(&store[0], store.size()); + setPosition(oldPos); + } + + /** Make sure at least n bytes are available */ + void makeAvailable(size_t n) { + if (n > available()) + resize(getSize() + n - available()); + } + + private: + std::vector store; +}; +}} // namespace qpid::framing + +#endif /*!QPID_FRAMING_RESIZABLEBUFFER_H*/ -- cgit v1.2.1 From c386d887cafdd5e56277fed0e6c6805d30513147 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Fri, 21 Jan 2011 17:47:43 +0000 Subject: Moved ResizableBuffer.h from include to src. Not part of the public API. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1061932 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/framing/ResizableBuffer.h | 60 ------------------------- 1 file changed, 60 deletions(-) delete mode 100644 qpid/cpp/include/qpid/framing/ResizableBuffer.h (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/framing/ResizableBuffer.h b/qpid/cpp/include/qpid/framing/ResizableBuffer.h deleted file mode 100644 index e6c9e7a113..0000000000 --- a/qpid/cpp/include/qpid/framing/ResizableBuffer.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef QPID_FRAMING_RESIZABLEBUFFER_H -#define QPID_FRAMING_RESIZABLEBUFFER_H - -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -#include "Buffer.h" -#include - -namespace qpid { -namespace framing { - -/** - * A buffer that maintains its own storage and can be resized, - * keeping any data already written to the buffer. - */ -class ResizableBuffer : public Buffer -{ - public: - ResizableBuffer(size_t initialSize) : store(initialSize) { - static_cast(*this) = Buffer(&store[0], store.size()); - } - - void resize(size_t newSize) { - size_t oldPos = getPosition(); - store.resize(newSize); - static_cast(*this) = Buffer(&store[0], store.size()); - setPosition(oldPos); - } - - /** Make sure at least n bytes are available */ - void makeAvailable(size_t n) { - if (n > available()) - resize(getSize() + n - available()); - } - - private: - std::vector store; -}; -}} // namespace qpid::framing - -#endif /*!QPID_FRAMING_RESIZABLEBUFFER_H*/ -- cgit v1.2.1 From e44096239bbbcef198fd4217b62d422b452bc237 Mon Sep 17 00:00:00 2001 From: Jonathan Robie Date: Wed, 2 Feb 2011 16:00:51 +0000 Subject: Resolves QPID-3031. Allows client connection options to specify an SSL cert-name. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1066508 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/client/ConnectionSettings.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/client/ConnectionSettings.h b/qpid/cpp/include/qpid/client/ConnectionSettings.h index bf060e73bb..1c2ee28b1b 100644 --- a/qpid/cpp/include/qpid/client/ConnectionSettings.h +++ b/qpid/cpp/include/qpid/client/ConnectionSettings.h @@ -122,6 +122,11 @@ struct ConnectionSettings { * layer. 0 means no security layer allowed. */ unsigned int maxSsf; + /** + * SSL cert-name for the connection. Overrides global SSL + * settings. Used only when a client connects to the broker. + */ + std::string sslCertName; }; }} // namespace qpid::client -- cgit v1.2.1 From 1e77b7bcf6766afbf161137284edbf2a6a255447 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Wed, 2 Feb 2011 18:16:57 +0000 Subject: QPID-3032 - Modifications to the QMFv2 implementation: 1) Use the topic exchange as the base for direct and reply-to addresses. 2) Add a strict-security option to the Console and Agent APIs that narrows the messaging patterns used such that they can easily be controlled by broker ACL policy. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1066562 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/AgentSession.h | 4 ++++ qpid/cpp/include/qmf/ConsoleSession.h | 4 ++++ 2 files changed, 8 insertions(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qmf/AgentSession.h b/qpid/cpp/include/qmf/AgentSession.h index 090017779f..23058c56c6 100644 --- a/qpid/cpp/include/qmf/AgentSession.h +++ b/qpid/cpp/include/qmf/AgentSession.h @@ -67,6 +67,10 @@ namespace qmf { * sub-lifetime:N - Lifetime (in seconds with no keepalive) for a subscription [default: 300] * public-events:{True,False} - If True: QMF events are sent to the topic exchange [default] * If False: QMF events are only sent to authorized subscribers + * listen-on-direct:{True,False} - If True: Listen on legacy direct-exchange address for backward compatibility [default] + * If False: Listen only on the routable direct address + * strict-security:{True,False} - If True: Cooperate with the broker to enforce string access control to the network + * - If False: Operate more flexibly with regard to use of messaging facilities [default] */ QMF_EXTERN AgentSession(qpid::messaging::Connection&, const std::string& options=""); diff --git a/qpid/cpp/include/qmf/ConsoleSession.h b/qpid/cpp/include/qmf/ConsoleSession.h index ba8b3de92f..2422383fa3 100644 --- a/qpid/cpp/include/qmf/ConsoleSession.h +++ b/qpid/cpp/include/qmf/ConsoleSession.h @@ -57,6 +57,10 @@ namespace qmf { * domain:NAME - QMF Domain to join [default: "default"] * max-agent-age:N - Maximum time, in minutes, that we will tolerate not hearing from * an agent before deleting it [default: 5] + * listen-on-direct:{True,False} - If True: Listen on legacy direct-exchange address for backward compatibility [default] + * If False: Listen only on the routable direct address + * strict-security:{True,False} - If True: Cooperate with the broker to enforce string access control to the network + * - If False: Operate more flexibly with regard to use of messaging facilities [default] */ QMF_EXTERN ConsoleSession(qpid::messaging::Connection&, const std::string& options=""); QMF_EXTERN void setDomain(const std::string&); -- cgit v1.2.1 From bc413d94f96b787f1a5f20f15100545a138cf62f Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Thu, 3 Feb 2011 02:46:01 +0000 Subject: Added severity and timestamp fields to raised events. Enhanced the example agent to illustrate the raising of events. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1066726 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/AgentSession.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qmf/AgentSession.h b/qpid/cpp/include/qmf/AgentSession.h index 23058c56c6..d6ac5adf83 100644 --- a/qpid/cpp/include/qmf/AgentSession.h +++ b/qpid/cpp/include/qmf/AgentSession.h @@ -165,8 +165,14 @@ namespace qmf { /** * Raise an event to be sent into the QMF network. + * + * @param data - A data object that contains the event contents. + * @param severity - Explicit severity (from qmf/SchemaTypes.h). If omitted, the severity is set to + * the default severity for the data's schema. If the data has no schema, the severity defaults + * to SEV_NOTICE. */ - QMF_EXTERN void raiseEvent(const Data&); + QMF_EXTERN void raiseEvent(const Data& data); + QMF_EXTERN void raiseEvent(const Data& data, int severity); #ifndef SWIG private: -- cgit v1.2.1 From 786ea3c47f962357bc06f956b0397182e4fc6cd6 Mon Sep 17 00:00:00 2001 From: Kenneth Anthony Giusti Date: Thu, 3 Feb 2011 15:56:08 +0000 Subject: QPID-3035: fix incorrect removal at end of SequenceSet git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1066841 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/RangeSet.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/RangeSet.h b/qpid/cpp/include/qpid/RangeSet.h index 1b2e4201a6..36991fd784 100644 --- a/qpid/cpp/include/qpid/RangeSet.h +++ b/qpid/cpp/include/qpid/RangeSet.h @@ -265,8 +265,8 @@ template void RangeSet::removeRange(const Range& r) { } for (j = i; j != ranges.end() && r.contains(*j); ++j) ; // Ranges to erase. - if (j != ranges.end() && j->end() > r.end()) - j->begin(r.end()); // Truncate j + if (j != ranges.end() && r.end() > j->begin()) + j->begin(r.end()); // Truncate j ranges.erase(i,j); } } -- cgit v1.2.1 From eaa84eeb11e11c41da59844675b13ef1a7aaf198 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Fri, 4 Feb 2011 05:19:43 +0000 Subject: Fixed typos in the documentation text. Fixed bug in the propagation of exceptions in query-processing. Added user-id to messages sent by the console. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1067087 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/AgentSession.h | 2 +- qpid/cpp/include/qmf/ConsoleSession.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qmf/AgentSession.h b/qpid/cpp/include/qmf/AgentSession.h index d6ac5adf83..9e29d6b54b 100644 --- a/qpid/cpp/include/qmf/AgentSession.h +++ b/qpid/cpp/include/qmf/AgentSession.h @@ -69,7 +69,7 @@ namespace qmf { * If False: QMF events are only sent to authorized subscribers * listen-on-direct:{True,False} - If True: Listen on legacy direct-exchange address for backward compatibility [default] * If False: Listen only on the routable direct address - * strict-security:{True,False} - If True: Cooperate with the broker to enforce string access control to the network + * strict-security:{True,False} - If True: Cooperate with the broker to enforce strict access control to the network * - If False: Operate more flexibly with regard to use of messaging facilities [default] */ QMF_EXTERN AgentSession(qpid::messaging::Connection&, const std::string& options=""); diff --git a/qpid/cpp/include/qmf/ConsoleSession.h b/qpid/cpp/include/qmf/ConsoleSession.h index 2422383fa3..0c73e7a6db 100644 --- a/qpid/cpp/include/qmf/ConsoleSession.h +++ b/qpid/cpp/include/qmf/ConsoleSession.h @@ -59,7 +59,7 @@ namespace qmf { * an agent before deleting it [default: 5] * listen-on-direct:{True,False} - If True: Listen on legacy direct-exchange address for backward compatibility [default] * If False: Listen only on the routable direct address - * strict-security:{True,False} - If True: Cooperate with the broker to enforce string access control to the network + * strict-security:{True,False} - If True: Cooperate with the broker to enforce strict access control to the network * - If False: Operate more flexibly with regard to use of messaging facilities [default] */ QMF_EXTERN ConsoleSession(qpid::messaging::Connection&, const std::string& options=""); -- cgit v1.2.1 From 6b455d864349e7b90369fd424051210599fc9565 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Fri, 4 Feb 2011 08:22:30 +0000 Subject: Added missing even handling in the console. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1067111 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/ConsoleEvent.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qmf/ConsoleEvent.h b/qpid/cpp/include/qmf/ConsoleEvent.h index 54272334a4..b836b629af 100644 --- a/qpid/cpp/include/qmf/ConsoleEvent.h +++ b/qpid/cpp/include/qmf/ConsoleEvent.h @@ -74,6 +74,8 @@ namespace qmf { QMF_EXTERN Data getData(uint32_t) const; QMF_EXTERN bool isFinal() const; QMF_EXTERN const qpid::types::Variant::Map& getArguments() const; + QMF_EXTERN int getSeverity() const; + QMF_EXTERN uint64_t getTimestamp() const; #ifndef SWIG private: -- cgit v1.2.1 From b657f00b7b05fd6ac36da7e53680b6cd01dd4d35 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Mon, 28 Feb 2011 15:35:28 +0000 Subject: QPID-3089: make getTypeName() a public method git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1075380 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/types/Variant.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/types/Variant.h b/qpid/cpp/include/qpid/types/Variant.h index 9ae672b7c2..d9260133a7 100644 --- a/qpid/cpp/include/qpid/types/Variant.h +++ b/qpid/cpp/include/qpid/types/Variant.h @@ -60,6 +60,8 @@ enum VariantType { VAR_UUID }; +std::string getTypeName(VariantType type); + class VariantImpl; /** -- cgit v1.2.1 From 5edf77f2c04c8428117a04d1d1a4b4cfc1770072 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Thu, 3 Mar 2011 13:55:11 +0000 Subject: QPID-3046 - Updates - Additional header comments - Added pendingEvents method to ConsoleSession and AgentSession - Ensure that nextEvent will not block if timeout is IMMEDIATE (ConsoleSession and AgentSession). git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1076625 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/AgentSession.h | 40 ++++++++++++++++------------- qpid/cpp/include/qmf/ConsoleSession.h | 48 ++++++++++++++++++++++++++++++----- 2 files changed, 64 insertions(+), 24 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qmf/AgentSession.h b/qpid/cpp/include/qmf/AgentSession.h index 9e29d6b54b..39d921a8ec 100644 --- a/qpid/cpp/include/qmf/AgentSession.h +++ b/qpid/cpp/include/qmf/AgentSession.h @@ -72,14 +72,14 @@ namespace qmf { * strict-security:{True,False} - If True: Cooperate with the broker to enforce strict access control to the network * - If False: Operate more flexibly with regard to use of messaging facilities [default] */ - QMF_EXTERN AgentSession(qpid::messaging::Connection&, const std::string& options=""); + QMF_EXTERN AgentSession(qpid::messaging::Connection& conn, const std::string& options=""); /** * setDomain - Change the QMF domain that this agent will operate in. If this is not called, * the domain will be "default". Agents in a domain can be seen only by consoles in the same domain. * This must be called prior to opening the agent session. */ - QMF_EXTERN void setDomain(const std::string&); + QMF_EXTERN void setDomain(const std::string& domain); /** * Set identifying attributes of this agent. @@ -88,16 +88,16 @@ namespace qmf { * setInstance - Set the unique instance name (if not set, a UUID will be assigned) * These must be called prior to opening the agent session. */ - QMF_EXTERN void setVendor(const std::string&); - QMF_EXTERN void setProduct(const std::string&); - QMF_EXTERN void setInstance(const std::string&); + QMF_EXTERN void setVendor(const std::string& vendor); + QMF_EXTERN void setProduct(const std::string& product); + QMF_EXTERN void setInstance(const std::string& instance); /** * setAttribute - Set an arbitrary attribute for this agent. The attributes are not used * to uniquely identify the agent but can be used as a search criteria when looking for agents. * This must be called prior to opening the agent session. */ - QMF_EXTERN void setAttribute(const std::string&, const qpid::types::Variant&); + QMF_EXTERN void setAttribute(const std::string& key, const qpid::types::Variant& value); /** * Get the identifying name of the agent. @@ -119,13 +119,19 @@ namespace qmf { * Get the next event from the agent session. Events represent actions that must be acted upon by the * agent application. This method blocks for up to the timeout if there are no events to be handled. * This method will typically be the focus of the agent application's main execution loop. + * If the timeout is set to Duration::IMMEDIATE, the call will not block. */ - QMF_EXTERN bool nextEvent(AgentEvent&, qpid::messaging::Duration timeout=qpid::messaging::Duration::FOREVER); + QMF_EXTERN bool nextEvent(AgentEvent& outEvent, qpid::messaging::Duration timeout=qpid::messaging::Duration::FOREVER); + + /** + * Return the number of events pending for nextEvent. This method will never block. + */ + QMF_EXTERN int pendingEvents() const; /** * Register a schema to be exposed by this agent. */ - QMF_EXTERN void registerSchema(Schema&); + QMF_EXTERN void registerSchema(Schema& schema); /** * Add data to be managed internally by the agent. If the option external:True is selected, this call @@ -138,12 +144,12 @@ namespace qmf { * across different sessions. If persistent, it is the agent application's * responsibility to ensure the name is the same each time it is added. */ - QMF_EXTERN DataAddr addData(Data&, const std::string& name="", bool persistent=false); + QMF_EXTERN DataAddr addData(Data& data, const std::string& name="", bool persistent=false); /** * Delete data from internal agent management. */ - QMF_EXTERN void delData(const DataAddr&); + QMF_EXTERN void delData(const DataAddr& dataAddr); /** * The following methods are used to respond to events received in nextEvent. @@ -155,13 +161,13 @@ namespace qmf { * complete - Indicate that the response to a query is complete (external:True only) * methodSuccess - Indicate the successful completion of a method call. */ - QMF_EXTERN void authAccept(AgentEvent&); - QMF_EXTERN void authReject(AgentEvent&, const std::string& diag=""); - QMF_EXTERN void raiseException(AgentEvent&, const std::string&); - QMF_EXTERN void raiseException(AgentEvent&, const Data&); - QMF_EXTERN void response(AgentEvent&, const Data&); - QMF_EXTERN void complete(AgentEvent&); - QMF_EXTERN void methodSuccess(AgentEvent&); + QMF_EXTERN void authAccept(AgentEvent& event); + QMF_EXTERN void authReject(AgentEvent& event, const std::string& diag=""); + QMF_EXTERN void raiseException(AgentEvent& event, const std::string& errorText); + QMF_EXTERN void raiseException(AgentEvent& event, const Data& errorData); + QMF_EXTERN void response(AgentEvent& event, const Data& responseData); + QMF_EXTERN void complete(AgentEvent& event); + QMF_EXTERN void methodSuccess(AgentEvent& event); /** * Raise an event to be sent into the QMF network. diff --git a/qpid/cpp/include/qmf/ConsoleSession.h b/qpid/cpp/include/qmf/ConsoleSession.h index 0c73e7a6db..896f8ffda7 100644 --- a/qpid/cpp/include/qmf/ConsoleSession.h +++ b/qpid/cpp/include/qmf/ConsoleSession.h @@ -62,14 +62,48 @@ namespace qmf { * strict-security:{True,False} - If True: Cooperate with the broker to enforce strict access control to the network * - If False: Operate more flexibly with regard to use of messaging facilities [default] */ - QMF_EXTERN ConsoleSession(qpid::messaging::Connection&, const std::string& options=""); - QMF_EXTERN void setDomain(const std::string&); - QMF_EXTERN void setAgentFilter(const std::string&); + QMF_EXTERN ConsoleSession(qpid::messaging::Connection& conn, const std::string& options=""); + + /** + * setDomain - Change the QMF domain that this console will operate in. If this is not called, + * the domain will be "default". Agents in a domain can be seen only by consoles in the same domain. + * This must be called prior to opening the console session. + */ + QMF_EXTERN void setDomain(const std::string& domain); + QMF_EXTERN void setAgentFilter(const std::string& filter); + + /** + * Open the console session. After opening the session, the domain cannot be changed. + */ QMF_EXTERN void open(); + + /** + * Close the session. Once closed, the session no longer communicates on the messaging network. + */ QMF_EXTERN void close(); - QMF_EXTERN bool nextEvent(ConsoleEvent&, qpid::messaging::Duration timeout=qpid::messaging::Duration::FOREVER); + + /** + * Get the next event from the console session. Events represent actions that must be acted upon by the + * console application. This method blocks for up to the timeout if there are no events to be handled. + * This method will typically be the focus of the console application's main execution loop. + * If the timeout is set to Duration::IMMEDIATE, the call will not block. + */ + QMF_EXTERN bool nextEvent(ConsoleEvent& outEvent, qpid::messaging::Duration timeout=qpid::messaging::Duration::FOREVER); + + /** + * Return the number of events pending for nextEvent. This method will never block. + */ + QMF_EXTERN int pendingEvents() const; + + /** + * getAgentCount, getAgent - Retrieve the set of agents that match the console session's agent filter. + */ QMF_EXTERN uint32_t getAgentCount() const; - QMF_EXTERN Agent getAgent(uint32_t) const; + QMF_EXTERN Agent getAgent(uint32_t agentIndex) const; + + /** + * Get the agent for the connected broker (i.e. the agent embedded in the broker to which we have a connection). + */ QMF_EXTERN Agent getConnectedBrokerAgent() const; /** @@ -79,8 +113,8 @@ namespace qmf { * will involve all known agents. If agentFilter is non-empty, it will be applied only to the set of known * agents. A subscription cannot be created that involves an agent not known by the session. */ - QMF_EXTERN Subscription subscribe(const Query&, const std::string& agentFilter = "", const std::string& options = ""); - QMF_EXTERN Subscription subscribe(const std::string&, const std::string& agentFilter = "", const std::string& options = ""); + QMF_EXTERN Subscription subscribe(const Query& query, const std::string& agentFilter = "", const std::string& options = ""); + QMF_EXTERN Subscription subscribe(const std::string& query, const std::string& agentFilter = "", const std::string& options = ""); #ifndef SWIG private: -- cgit v1.2.1 From 6c904379b3ba82dd5d5b46723363f51e5770e17f Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Mon, 18 Apr 2011 20:40:53 +0000 Subject: QPID-3208: Exchanges make best effort to route messages if there is an error. Previously if multiple queues were bound to the same routing key, then a failure to deliver to one of the queues (e.g. policy limit error) could prevent delivery on some of the other queues. With this commit the exchange delivers to every queue that did not have an error before raising an error. Note: this was originally committed as r1092765, but it caused test failures was reverted as r1092804. The original commit did not create exceptions of the correct type. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1094734 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/sys/ExceptionHolder.h | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/sys/ExceptionHolder.h b/qpid/cpp/include/qpid/sys/ExceptionHolder.h index 9eff1d64c7..4bc934cf75 100644 --- a/qpid/cpp/include/qpid/sys/ExceptionHolder.h +++ b/qpid/cpp/include/qpid/sys/ExceptionHolder.h @@ -10,9 +10,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -42,14 +42,11 @@ class ExceptionHolder : public Raisable { public: ExceptionHolder() {} // Use default copy & assign. - + /** Take ownership of ex */ template ExceptionHolder(Ex* ex) { wrap(ex); } - template ExceptionHolder(const boost::shared_ptr& ex) { wrap(ex.release()); } - template ExceptionHolder& operator=(Ex* ex) { wrap(ex); return *this; } - template ExceptionHolder& operator=(boost::shared_ptr ex) { wrap(ex.release()); return *this; } - + void raise() const { if (wrapper.get()) wrapper->raise() ; } std::string what() const { return wrapper.get() ? wrapper->what() : std::string(); } bool empty() const { return !wrapper.get(); } @@ -66,7 +63,7 @@ class ExceptionHolder : public Raisable { template void wrap(Ex* ex) { wrapper.reset(new Wrapper(ex)); } boost::shared_ptr wrapper; }; - + }} // namespace qpid::sys -- cgit v1.2.1 From 1b07a80e85386a223b5661c0391e8dd8b2c598c3 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Tue, 26 Apr 2011 13:42:24 +0000 Subject: QPID-3222: Prevent ttl overflow; also adds equality operators for qpid::messaging::Duration. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1096751 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/messaging/Duration.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/messaging/Duration.h b/qpid/cpp/include/qpid/messaging/Duration.h index abcf169090..1406e354c6 100644 --- a/qpid/cpp/include/qpid/messaging/Duration.h +++ b/qpid/cpp/include/qpid/messaging/Duration.h @@ -49,6 +49,8 @@ QPID_MESSAGING_EXTERN Duration operator*(const Duration& duration, uint64_t multiplier); QPID_MESSAGING_EXTERN Duration operator*(uint64_t multiplier, const Duration& duration); +QPID_MESSAGING_EXTERN bool operator==(const Duration& a, const Duration& b); +QPID_MESSAGING_EXTERN bool operator!=(const Duration& a, const Duration& b); }} // namespace qpid::messaging -- cgit v1.2.1 From ec321fedb7067715b76a196a32c29367bc0e5e30 Mon Sep 17 00:00:00 2001 From: Kim van der Riet Date: Mon, 2 May 2011 13:20:36 +0000 Subject: QPID-3236 - Add high-resolution timestamps to log files for debug situations. Windows impl has a stub only. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1098554 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/log/Logger.h | 2 +- qpid/cpp/include/qpid/log/Options.h | 2 +- qpid/cpp/include/qpid/sys/Time.h | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/log/Logger.h b/qpid/cpp/include/qpid/log/Logger.h index 783ab7bdb9..7606436e56 100644 --- a/qpid/cpp/include/qpid/log/Logger.h +++ b/qpid/cpp/include/qpid/log/Logger.h @@ -36,7 +36,7 @@ namespace log { class Logger : private boost::noncopyable { public: /** Flags indicating what to include in the log output */ - enum FormatFlag { FILE=1, LINE=2, FUNCTION=4, LEVEL=8, TIME=16, THREAD=32}; + enum FormatFlag { FILE=1, LINE=2, FUNCTION=4, LEVEL=8, TIME=16, THREAD=32, HIRES=64}; /** * Logging output sink. diff --git a/qpid/cpp/include/qpid/log/Options.h b/qpid/cpp/include/qpid/log/Options.h index bbc47b47d3..17cbfde9bc 100644 --- a/qpid/cpp/include/qpid/log/Options.h +++ b/qpid/cpp/include/qpid/log/Options.h @@ -39,7 +39,7 @@ struct Options : public qpid::Options { std::string argv0; std::string name; std::vector selectors; - bool time, level, thread, source, function; + bool time, level, thread, source, function, hiresTs; bool trace; std::string prefix; std::auto_ptr sinkOptions; diff --git a/qpid/cpp/include/qpid/sys/Time.h b/qpid/cpp/include/qpid/sys/Time.h index d3ab832229..154a068d83 100644 --- a/qpid/cpp/include/qpid/sys/Time.h +++ b/qpid/cpp/include/qpid/sys/Time.h @@ -167,6 +167,9 @@ QPID_COMMON_EXTERN void usleep(uint64_t usecs); /** Output formatted date/time for now*/ void outputFormattedNow(std::ostream&); +/** Output unformatted nanosecond-resolution time for now */ +void outputHiresNow(std::ostream&); + }} #endif /*!_sys_Time_h*/ -- cgit v1.2.1 From 36228697da7e1288b2ab808346710fa4228d9b06 Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Mon, 9 May 2011 19:55:29 +0000 Subject: QPID-3004: Get Clang to compile qpid c++ - Change class/struct declarations to be consistent with the definition to avoid warnings git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1101178 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/Query.h | 2 +- qpid/cpp/include/qmf/Subscription.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qmf/Query.h b/qpid/cpp/include/qmf/Query.h index fec4660bd7..1867b59d81 100644 --- a/qpid/cpp/include/qmf/Query.h +++ b/qpid/cpp/include/qmf/Query.h @@ -65,7 +65,7 @@ namespace qmf { #ifndef SWIG private: friend class qmf::PrivateImplRef; - friend class QueryImplAccess; + friend struct QueryImplAccess; #endif }; diff --git a/qpid/cpp/include/qmf/Subscription.h b/qpid/cpp/include/qmf/Subscription.h index 4e60eb984e..0a01b7c526 100644 --- a/qpid/cpp/include/qmf/Subscription.h +++ b/qpid/cpp/include/qmf/Subscription.h @@ -73,7 +73,7 @@ namespace qmf { #ifndef SWIG private: friend class qmf::PrivateImplRef; - friend class SubscriptionImplAccess; + friend struct SubscriptionImplAccess; #endif }; -- cgit v1.2.1 From 35f91f5e74abfc0c0214e5d7eaf1bad69405801b Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Mon, 9 May 2011 19:56:11 +0000 Subject: QPID-3004: Get Clang to compile qpid c++ - Add new template function for FieldValue::getIntegerValue() to avoid compile error when extracting into 1 byte ints. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1101183 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/framing/FieldValue.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/framing/FieldValue.h b/qpid/cpp/include/qpid/framing/FieldValue.h index 19220e74d5..e6255066c4 100644 --- a/qpid/cpp/include/qpid/framing/FieldValue.h +++ b/qpid/cpp/include/qpid/framing/FieldValue.h @@ -98,6 +98,7 @@ class FieldValue { template T get() const { throw InvalidConversionException(); } template T getIntegerValue() const; + template T getIntegerValue() const; template T getFloatingPointValue() const; template void getFixedWidthValue(unsigned char*) const; template bool get(T&) const; @@ -196,6 +197,18 @@ inline T FieldValue::getIntegerValue() const } } +template +inline T FieldValue::getIntegerValue() const +{ + FixedWidthValue<1>* const fwv = dynamic_cast< FixedWidthValue<1>* const>(data.get()); + if (fwv) { + uint8_t* octets = fwv->rawOctets(); + return octets[0]; + } else { + throw InvalidConversionException(); + } +} + template inline T FieldValue::getFloatingPointValue() const { FixedWidthValue* const fwv = dynamic_cast< FixedWidthValue* const>(data.get()); -- cgit v1.2.1 From cc77efaa96a95173fd009a3a5f855e2507da643c Mon Sep 17 00:00:00 2001 From: Michael Goulish Date: Tue, 17 May 2011 14:43:53 +0000 Subject: Remove support for archaic Boost version 1_32 ( 103200 ). ( As promised, long ago. ) git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1104291 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/Options.h | 88 ----------------------------------------- 1 file changed, 88 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/Options.h b/qpid/cpp/include/qpid/Options.h index 078a6b4d95..63d91c2d72 100644 --- a/qpid/cpp/include/qpid/Options.h +++ b/qpid/cpp/include/qpid/Options.h @@ -133,77 +133,6 @@ inline po::value_semantic* optValue(bool& value) { return po::bool_switch(&value -/* - * --------------------------------------------- - * Explanation for Boost 103200 conditional code - * --------------------------------------------- - * - * This boost version has an implementation of the program_options library - * that has no provision for allowing unregistered options to pass by. - * - * But that means that, if you have a program that loads optional modules - * after start-up, and those modules each have their own set of options, - * then if you parse the command line too soon, you will get spurious - * reports of unrecognized options -- and the program will exit! - * - * And we must process the command-line before module-loading, because we - * need to look at the "bootstrap" options. - * - * This conditional code: - * - * 1. implements it's own functor class, derived from the Boost - * "options_description_easy_init" class. This functor is used - * to process added options and do the functor chaining, so that - * I can snoop on the arguments before doing an explicit call - * to its parent. - * - * 2. It implements two static vectors, one to hold long names, and - * one for short names, so that options declared by modules are - * not forgotten when their options_description goes out of scope. - * - * I will be thrilled to personally delete this code if we ever decide - * that qpid doesn't really need to support this antique version of Boost. - * - */ - -#if ( BOOST_VERSION == 103200 ) -struct Options; - - -struct -options_description_less_easy_init - : public po::options_description_easy_init -{ - options_description_less_easy_init ( Options * my_owner, - po::options_description * my_parents_owner - ) - : po::options_description_easy_init(my_parents_owner) - { - owner = my_owner; - } - - - options_description_less_easy_init& - operator()(char const * name, - char const * description); - - - options_description_less_easy_init& - operator()(char const * name, - const po::value_semantic* s); - - - options_description_less_easy_init& - operator()(const char* name, - const po::value_semantic* s, - const char* description); - - - Options * owner; -}; -#endif - - struct Options : public po::options_description { struct Exception : public qpid::Exception { @@ -222,26 +151,9 @@ struct Options : public po::options_description { bool allowUnknown = false); - #if ( BOOST_VERSION == 103200 ) - options_description_less_easy_init m_less_easy; - - options_description_less_easy_init addOptions() { - return m_less_easy; - } - - bool - is_registered_option ( std::string s ); - - void - register_names ( std::string s ); - - static std::vector long_names; - static std::vector short_names; - #else boost::program_options::options_description_easy_init addOptions() { return add_options(); } - #endif }; -- cgit v1.2.1 From 2d0338895a2d3629b674f4a3aabea58c77f76504 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Tue, 17 May 2011 21:02:34 +0000 Subject: QPID-3186 - Import Export generalization to support a larger set of compilers and run time environments git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1104559 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/Agent.h | 2 +- qpid/cpp/include/qmf/AgentEvent.h | 2 +- qpid/cpp/include/qmf/AgentSession.h | 2 +- qpid/cpp/include/qmf/ConsoleEvent.h | 2 +- qpid/cpp/include/qmf/ConsoleSession.h | 2 +- qpid/cpp/include/qmf/Data.h | 2 +- qpid/cpp/include/qmf/DataAddr.h | 2 +- qpid/cpp/include/qmf/Handle.h | 10 +-- qpid/cpp/include/qmf/ImportExport.h | 16 ++--- qpid/cpp/include/qmf/Query.h | 2 +- qpid/cpp/include/qmf/Schema.h | 2 +- qpid/cpp/include/qmf/SchemaId.h | 2 +- qpid/cpp/include/qmf/SchemaMethod.h | 2 +- qpid/cpp/include/qmf/SchemaProperty.h | 2 +- qpid/cpp/include/qmf/Subscription.h | 2 +- .../cpp/include/qmf/engine/QmfEngineImportExport.h | 9 +++ qpid/cpp/include/qmf/exceptions.h | 8 +-- qpid/cpp/include/qpid/Address.h | 2 +- qpid/cpp/include/qpid/CommonImportExport.h | 14 +++-- qpid/cpp/include/qpid/Exception.h | 12 ++-- qpid/cpp/include/qpid/ImportExport.h | 71 ++++++++++++++++++++++ qpid/cpp/include/qpid/Url.h | 2 +- qpid/cpp/include/qpid/agent/QmfAgentImportExport.h | 16 ++--- qpid/cpp/include/qpid/client/ClientImportExport.h | 14 +++-- qpid/cpp/include/qpid/client/Completion.h | 2 +- qpid/cpp/include/qpid/client/Connection.h | 2 +- qpid/cpp/include/qpid/client/ConnectionSettings.h | 2 +- qpid/cpp/include/qpid/client/FailoverListener.h | 2 +- qpid/cpp/include/qpid/client/FailoverManager.h | 2 +- qpid/cpp/include/qpid/client/Future.h | 2 +- qpid/cpp/include/qpid/client/FutureResult.h | 2 +- qpid/cpp/include/qpid/client/Handle.h | 10 +-- qpid/cpp/include/qpid/client/LocalQueue.h | 2 +- qpid/cpp/include/qpid/client/Message.h | 2 +- qpid/cpp/include/qpid/client/MessageListener.h | 2 +- .../cpp/include/qpid/client/MessageReplayTracker.h | 2 +- qpid/cpp/include/qpid/client/QueueOptions.h | 2 +- qpid/cpp/include/qpid/client/SessionBase_0_10.h | 2 +- qpid/cpp/include/qpid/client/Subscription.h | 8 +-- qpid/cpp/include/qpid/client/SubscriptionManager.h | 2 +- qpid/cpp/include/qpid/console/Agent.h | 14 ++--- qpid/cpp/include/qpid/console/Broker.h | 16 ++--- .../cpp/include/qpid/console/ConsoleImportExport.h | 14 +++-- qpid/cpp/include/qpid/framing/Array.h | 26 ++++---- qpid/cpp/include/qpid/framing/Buffer.h | 16 ++--- qpid/cpp/include/qpid/framing/FieldTable.h | 4 +- qpid/cpp/include/qpid/framing/FieldValue.h | 8 +-- qpid/cpp/include/qpid/framing/List.h | 24 ++++---- qpid/cpp/include/qpid/framing/ProtocolVersion.h | 12 ++-- qpid/cpp/include/qpid/framing/SequenceNumber.h | 2 +- qpid/cpp/include/qpid/framing/SequenceSet.h | 2 +- qpid/cpp/include/qpid/framing/StructHelper.h | 2 +- qpid/cpp/include/qpid/framing/Uuid.h | 10 +-- qpid/cpp/include/qpid/log/Logger.h | 4 +- .../cpp/include/qpid/management/ManagementObject.h | 18 +++--- qpid/cpp/include/qpid/messaging/Address.h | 2 +- qpid/cpp/include/qpid/messaging/Connection.h | 2 +- qpid/cpp/include/qpid/messaging/Duration.h | 6 +- qpid/cpp/include/qpid/messaging/FailoverUpdates.h | 2 +- qpid/cpp/include/qpid/messaging/Handle.h | 10 +-- qpid/cpp/include/qpid/messaging/ImportExport.h | 14 +++-- qpid/cpp/include/qpid/messaging/Message.h | 22 +++---- qpid/cpp/include/qpid/messaging/Receiver.h | 2 +- qpid/cpp/include/qpid/messaging/Sender.h | 2 +- qpid/cpp/include/qpid/messaging/Session.h | 2 +- qpid/cpp/include/qpid/messaging/exceptions.h | 42 ++++++------- qpid/cpp/include/qpid/sys/IntegerTypes.h | 2 +- qpid/cpp/include/qpid/sys/Runnable.h | 2 +- qpid/cpp/include/qpid/sys/Time.h | 2 +- qpid/cpp/include/qpid/types/Exception.h | 2 +- qpid/cpp/include/qpid/types/ImportExport.h | 14 +++-- qpid/cpp/include/qpid/types/Uuid.h | 2 +- qpid/cpp/include/qpid/types/Variant.h | 4 +- 73 files changed, 323 insertions(+), 229 deletions(-) create mode 100644 qpid/cpp/include/qpid/ImportExport.h (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qmf/Agent.h b/qpid/cpp/include/qmf/Agent.h index 8c0f48b8b1..94083be4f3 100644 --- a/qpid/cpp/include/qmf/Agent.h +++ b/qpid/cpp/include/qmf/Agent.h @@ -42,7 +42,7 @@ namespace qmf { class SchemaId; class Schema; - class Agent : public qmf::Handle { + class QMF_CLASS_EXTERN Agent : public qmf::Handle { public: QMF_EXTERN Agent(AgentImpl* impl = 0); QMF_EXTERN Agent(const Agent&); diff --git a/qpid/cpp/include/qmf/AgentEvent.h b/qpid/cpp/include/qmf/AgentEvent.h index 59a41c3267..0f93a9bb0a 100644 --- a/qpid/cpp/include/qmf/AgentEvent.h +++ b/qpid/cpp/include/qmf/AgentEvent.h @@ -46,7 +46,7 @@ namespace qmf { AGENT_THREAD_FAILED = 8 }; - class AgentEvent : public qmf::Handle { + class QMF_CLASS_EXTERN AgentEvent : public qmf::Handle { public: QMF_EXTERN AgentEvent(AgentEventImpl* impl = 0); QMF_EXTERN AgentEvent(const AgentEvent&); diff --git a/qpid/cpp/include/qmf/AgentSession.h b/qpid/cpp/include/qmf/AgentSession.h index 39d921a8ec..1eeb252143 100644 --- a/qpid/cpp/include/qmf/AgentSession.h +++ b/qpid/cpp/include/qmf/AgentSession.h @@ -40,7 +40,7 @@ namespace qmf { class Data; class DataAddr; - class AgentSession : public qmf::Handle { + class QMF_CLASS_EXTERN AgentSession : public qmf::Handle { public: QMF_EXTERN AgentSession(AgentSessionImpl* impl = 0); QMF_EXTERN AgentSession(const AgentSession&); diff --git a/qpid/cpp/include/qmf/ConsoleEvent.h b/qpid/cpp/include/qmf/ConsoleEvent.h index b836b629af..94600f9357 100644 --- a/qpid/cpp/include/qmf/ConsoleEvent.h +++ b/qpid/cpp/include/qmf/ConsoleEvent.h @@ -57,7 +57,7 @@ namespace qmf { AGENT_DEL_FILTER = 2 }; - class ConsoleEvent : public qmf::Handle { + class QMF_CLASS_EXTERN ConsoleEvent : public qmf::Handle { public: QMF_EXTERN ConsoleEvent(ConsoleEventImpl* impl = 0); QMF_EXTERN ConsoleEvent(const ConsoleEvent&); diff --git a/qpid/cpp/include/qmf/ConsoleSession.h b/qpid/cpp/include/qmf/ConsoleSession.h index 896f8ffda7..6008036eec 100644 --- a/qpid/cpp/include/qmf/ConsoleSession.h +++ b/qpid/cpp/include/qmf/ConsoleSession.h @@ -38,7 +38,7 @@ namespace qmf { class ConsoleSessionImpl; class ConsoleEvent; - class ConsoleSession : public qmf::Handle { + class QMF_CLASS_EXTERN ConsoleSession : public qmf::Handle { public: QMF_EXTERN ConsoleSession(ConsoleSessionImpl* impl = 0); QMF_EXTERN ConsoleSession(const ConsoleSession&); diff --git a/qpid/cpp/include/qmf/Data.h b/qpid/cpp/include/qmf/Data.h index 82f1569a0b..487a02fe95 100644 --- a/qpid/cpp/include/qmf/Data.h +++ b/qpid/cpp/include/qmf/Data.h @@ -39,7 +39,7 @@ namespace qmf { class DataAddr; class Agent; - class Data : public qmf::Handle { + class QMF_CLASS_EXTERN Data : public qmf::Handle { public: QMF_EXTERN Data(DataImpl* impl = 0); QMF_EXTERN Data(const Data&); diff --git a/qpid/cpp/include/qmf/DataAddr.h b/qpid/cpp/include/qmf/DataAddr.h index 72de0c986a..63d309cc4b 100644 --- a/qpid/cpp/include/qmf/DataAddr.h +++ b/qpid/cpp/include/qmf/DataAddr.h @@ -34,7 +34,7 @@ namespace qmf { class DataAddrImpl; - class DataAddr : public qmf::Handle { + class QMF_CLASS_EXTERN DataAddr : public qmf::Handle { public: QMF_EXTERN DataAddr(DataAddrImpl* impl = 0); QMF_EXTERN DataAddr(const DataAddr&); diff --git a/qpid/cpp/include/qmf/Handle.h b/qpid/cpp/include/qmf/Handle.h index 510e2993aa..50971ea626 100644 --- a/qpid/cpp/include/qmf/Handle.h +++ b/qpid/cpp/include/qmf/Handle.h @@ -39,22 +39,22 @@ template class Handle { public: /**@return true if handle is valid, i.e. not null. */ - QMF_EXTERN bool isValid() const { return impl; } + QMF_INLINE_EXTERN bool isValid() const { return impl; } /**@return true if handle is null. It is an error to call any function on a null handle. */ - QMF_EXTERN bool isNull() const { return !impl; } + QMF_INLINE_EXTERN bool isNull() const { return !impl; } /** Conversion to bool supports idiom if (handle) { handle->... } */ - QMF_EXTERN operator bool() const { return impl; } + QMF_INLINE_EXTERN operator bool() const { return impl; } /** Operator ! supports idiom if (!handle) { do_if_handle_is_null(); } */ - QMF_EXTERN bool operator !() const { return !impl; } + QMF_INLINE_EXTERN bool operator !() const { return !impl; } void swap(Handle& h) { T* t = h.impl; h.impl = impl; impl = t; } protected: typedef T Impl; - QMF_EXTERN Handle() :impl() {} + QMF_INLINE_EXTERN Handle() :impl() {} // Not implemented,subclasses must implement. QMF_EXTERN Handle(const Handle&); diff --git a/qpid/cpp/include/qmf/ImportExport.h b/qpid/cpp/include/qmf/ImportExport.h index f5e1d9127c..7405c15259 100644 --- a/qpid/cpp/include/qmf/ImportExport.h +++ b/qpid/cpp/include/qmf/ImportExport.h @@ -20,14 +20,16 @@ * under the License. */ -#if defined(WIN32) && !defined(QPID_DECLARE_STATIC) -# if defined(QMF_EXPORT) || defined (qmfcommon_EXPORTS) -# define QMF_EXTERN __declspec(dllexport) -# else -# define QMF_EXTERN __declspec(dllimport) -# endif +#include "qpid/ImportExport.h" + +#if defined(QMF_EXPORT) || defined (qmf2_EXPORTS) +# define QMF_EXTERN QPID_EXPORT +# define QMF_CLASS_EXTERN QPID_CLASS_EXPORT +# define QMF_INLINE_EXTERN QPID_INLINE_EXPORT #else -# define QMF_EXTERN +# define QMF_EXTERN QPID_IMPORT +# define QMF_CLASS_EXTERN QPID_CLASS_IMPORT +# define QMF_INLINE_EXTERN QPID_INLINE_IMPORT #endif #endif diff --git a/qpid/cpp/include/qmf/Query.h b/qpid/cpp/include/qmf/Query.h index 1867b59d81..c1264f8901 100644 --- a/qpid/cpp/include/qmf/Query.h +++ b/qpid/cpp/include/qmf/Query.h @@ -43,7 +43,7 @@ namespace qmf { QUERY_SCHEMA_ID = 4 }; - class Query : public qmf::Handle { + class QMF_CLASS_EXTERN Query : public qmf::Handle { public: QMF_EXTERN Query(QueryImpl* impl = 0); QMF_EXTERN Query(const Query&); diff --git a/qpid/cpp/include/qmf/Schema.h b/qpid/cpp/include/qmf/Schema.h index cf316138c1..6cfd2e2a56 100644 --- a/qpid/cpp/include/qmf/Schema.h +++ b/qpid/cpp/include/qmf/Schema.h @@ -38,7 +38,7 @@ namespace qmf { class SchemaProperty; class SchemaMethod; - class Schema : public qmf::Handle { + class QMF_CLASS_EXTERN Schema : public qmf::Handle { public: QMF_EXTERN Schema(SchemaImpl* impl = 0); QMF_EXTERN Schema(const Schema&); diff --git a/qpid/cpp/include/qmf/SchemaId.h b/qpid/cpp/include/qmf/SchemaId.h index 13fb1cb902..2dafc1c091 100644 --- a/qpid/cpp/include/qmf/SchemaId.h +++ b/qpid/cpp/include/qmf/SchemaId.h @@ -35,7 +35,7 @@ namespace qmf { class SchemaIdImpl; - class SchemaId : public qmf::Handle { + class QMF_CLASS_EXTERN SchemaId : public qmf::Handle { public: QMF_EXTERN SchemaId(SchemaIdImpl* impl = 0); QMF_EXTERN SchemaId(const SchemaId&); diff --git a/qpid/cpp/include/qmf/SchemaMethod.h b/qpid/cpp/include/qmf/SchemaMethod.h index 47302b62b9..b5944dc29e 100644 --- a/qpid/cpp/include/qmf/SchemaMethod.h +++ b/qpid/cpp/include/qmf/SchemaMethod.h @@ -36,7 +36,7 @@ namespace qmf { class SchemaMethodImpl; class SchemaProperty; - class SchemaMethod : public qmf::Handle { + class QMF_CLASS_EXTERN SchemaMethod : public qmf::Handle { public: QMF_EXTERN SchemaMethod(SchemaMethodImpl* impl = 0); QMF_EXTERN SchemaMethod(const SchemaMethod&); diff --git a/qpid/cpp/include/qmf/SchemaProperty.h b/qpid/cpp/include/qmf/SchemaProperty.h index a3a328b60b..bbb603fa50 100644 --- a/qpid/cpp/include/qmf/SchemaProperty.h +++ b/qpid/cpp/include/qmf/SchemaProperty.h @@ -36,7 +36,7 @@ namespace qmf { class SchemaPropertyImpl; - class SchemaProperty : public Handle { + class QMF_CLASS_EXTERN SchemaProperty : public Handle { public: QMF_EXTERN SchemaProperty(SchemaPropertyImpl* impl = 0); QMF_EXTERN SchemaProperty(const SchemaProperty&); diff --git a/qpid/cpp/include/qmf/Subscription.h b/qpid/cpp/include/qmf/Subscription.h index 0a01b7c526..398a45b922 100644 --- a/qpid/cpp/include/qmf/Subscription.h +++ b/qpid/cpp/include/qmf/Subscription.h @@ -35,7 +35,7 @@ namespace qmf { class SubscriptionImpl; class Data; - class Subscription : public qmf::Handle { + class QMF_CLASS_EXTERN Subscription : public qmf::Handle { public: QMF_EXTERN Subscription(SubscriptionImpl* impl = 0); QMF_EXTERN Subscription(const Subscription&); diff --git a/qpid/cpp/include/qmf/engine/QmfEngineImportExport.h b/qpid/cpp/include/qmf/engine/QmfEngineImportExport.h index 373617e046..cf8fffdb17 100644 --- a/qpid/cpp/include/qmf/engine/QmfEngineImportExport.h +++ b/qpid/cpp/include/qmf/engine/QmfEngineImportExport.h @@ -26,8 +26,17 @@ # else # define QMFE_EXTERN __declspec(dllimport) # endif +# ifdef _MSC_VER +# define QMFE_CLASS_EXTERN +# define QMFE_INLINE_EXTERN QMFE_EXTERN +# else +# define QMFE_CLASS_EXTERN QMFE_EXTERN +# define QMFE_INLINE_EXTERN +# endif #else # define QMFE_EXTERN +# define QMFE_CLASS_EXTERN +# define QMFE_INLINE_EXTERN #endif #endif diff --git a/qpid/cpp/include/qmf/exceptions.h b/qpid/cpp/include/qmf/exceptions.h index 7959499d63..c7ffa68ce2 100644 --- a/qpid/cpp/include/qmf/exceptions.h +++ b/qpid/cpp/include/qmf/exceptions.h @@ -31,24 +31,24 @@ namespace qmf { /** \ingroup qmf */ - struct QmfException : public qpid::types::Exception { + struct QMF_CLASS_EXTERN QmfException : public qpid::types::Exception { QMF_EXTERN QmfException(const std::string& msg); QMF_EXTERN virtual ~QmfException() throw(); qpid::types::Variant::Map detail; }; - struct KeyNotFound : public QmfException { + struct QMF_CLASS_EXTERN KeyNotFound : public QmfException { QMF_EXTERN KeyNotFound(const std::string& msg); QMF_EXTERN virtual ~KeyNotFound() throw(); }; - struct IndexOutOfRange : public QmfException { + struct QMF_CLASS_EXTERN IndexOutOfRange : public QmfException { QMF_EXTERN IndexOutOfRange(); QMF_EXTERN virtual ~IndexOutOfRange() throw(); }; - struct OperationTimedOut : public QmfException { + struct QMF_CLASS_EXTERN OperationTimedOut : public QmfException { QMF_EXTERN OperationTimedOut(); QMF_EXTERN virtual ~OperationTimedOut() throw(); }; diff --git a/qpid/cpp/include/qpid/Address.h b/qpid/cpp/include/qpid/Address.h index 57c9139f87..f5b19d0532 100755 --- a/qpid/cpp/include/qpid/Address.h +++ b/qpid/cpp/include/qpid/Address.h @@ -36,7 +36,7 @@ public: static const std::string TCP; // Default TCP protocol tag. static const uint16_t AMQP_PORT=5672; // Default AMQP port. - QPID_COMMON_EXTERN explicit Address( + QPID_COMMON_INLINE_EXTERN explicit Address( const std::string& protocol_=std::string(), const std::string& host_=std::string(), uint16_t port_=0 diff --git a/qpid/cpp/include/qpid/CommonImportExport.h b/qpid/cpp/include/qpid/CommonImportExport.h index 02c06ed7af..dd2b900b73 100644 --- a/qpid/cpp/include/qpid/CommonImportExport.h +++ b/qpid/cpp/include/qpid/CommonImportExport.h @@ -20,14 +20,16 @@ * under the License. */ -#if defined(WIN32) && !defined(QPID_DECLARE_STATIC) +#include "qpid/ImportExport.h" + #if defined(COMMON_EXPORT) || defined (qpidcommon_EXPORTS) -#define QPID_COMMON_EXTERN __declspec(dllexport) -#else -#define QPID_COMMON_EXTERN __declspec(dllimport) -#endif +# define QPID_COMMON_EXTERN QPID_EXPORT +# define QPID_COMMON_CLASS_EXTERN QPID_CLASS_EXPORT +# define QPID_COMMON_INLINE_EXTERN QPID_INLINE_EXPORT #else -#define QPID_COMMON_EXTERN +# define QPID_COMMON_EXTERN QPID_IMPORT +# define QPID_COMMON_CLASS_EXTERN QPID_CLASS_IMPORT +# define QPID_COMMON_INLINE_EXTERN QPID_INLINE_IMPORT #endif #endif diff --git a/qpid/cpp/include/qpid/Exception.h b/qpid/cpp/include/qpid/Exception.h index fa7111160c..cbd175214d 100644 --- a/qpid/cpp/include/qpid/Exception.h +++ b/qpid/cpp/include/qpid/Exception.h @@ -36,7 +36,7 @@ namespace qpid /** * Base class for Qpid runtime exceptions. */ -class Exception : public std::exception +class QPID_COMMON_CLASS_EXTERN Exception : public std::exception { public: QPID_COMMON_EXTERN explicit Exception(const std::string& message=std::string()) throw(); @@ -51,30 +51,30 @@ class Exception : public std::exception }; /** Exception that includes an errno message. */ -struct ErrnoException : public Exception { +struct QPID_COMMON_CLASS_EXTERN ErrnoException : public Exception { ErrnoException(const std::string& msg, int err) : Exception(msg+": "+qpid::sys::strError(err)) {} ErrnoException(const std::string& msg) : Exception(msg+": "+qpid::sys::strError(errno)) {} }; -struct SessionException : public Exception { +struct QPID_COMMON_CLASS_EXTERN SessionException : public Exception { const framing::execution::ErrorCode code; SessionException(framing::execution::ErrorCode code_, const std::string& message) : Exception(message), code(code_) {} }; -struct ChannelException : public Exception { +struct QPID_COMMON_CLASS_EXTERN ChannelException : public Exception { const framing::session::DetachCode code; ChannelException(framing::session::DetachCode _code, const std::string& message) : Exception(message), code(_code) {} }; -struct ConnectionException : public Exception { +struct QPID_COMMON_CLASS_EXTERN ConnectionException : public Exception { const framing::connection::CloseCode code; ConnectionException(framing::connection::CloseCode _code, const std::string& message) : Exception(message), code(_code) {} }; -struct ClosedException : public Exception { +struct QPID_COMMON_CLASS_EXTERN ClosedException : public Exception { QPID_COMMON_EXTERN ClosedException(const std::string& msg=std::string()); QPID_COMMON_EXTERN std::string getPrefix() const; }; diff --git a/qpid/cpp/include/qpid/ImportExport.h b/qpid/cpp/include/qpid/ImportExport.h new file mode 100644 index 0000000000..e62399faf7 --- /dev/null +++ b/qpid/cpp/include/qpid/ImportExport.h @@ -0,0 +1,71 @@ +#ifndef QPID_IMPORTEXPORT_H +#define QPID_IMPORTEXPORT_H + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +// +// This header file defines the following macros for the control of library/DLL +// import and export: +// +// QPID_EXPORT - Export declaration for Methods +// QPID_CLASS_EXPORT - Export declaration for Classes +// QPID_INLINE_EXPORT - Export declaration for Inline methods +// +// QPID_IMPORT - Import declaration for Methods +// QPID_CLASS_IMPORT - Import declaration for Classes +// QPID_INLINE_IMPORT - Import declaration for Inline methods +// + +#if defined(WIN32) && !defined(QPID_DECLARE_STATIC) + // + // Import and Export definitions for Windows: + // +# define QPID_EXPORT __declspec(dllexport) +# define QPID_IMPORT __declspec(dllimport) +# ifdef _MSC_VER + // + // Specific to the Microsoft compiler: + // +# define QPID_CLASS_EXPORT +# define QPID_CLASS_IMPORT +# define QPID_INLINE_EXPORT QPID_EXPORT +# define QPID_INLINE_IMPORT QPID_IMPORT +# else + // + // Specific to non-Microsoft compilers (mingw32): + // +# define QPID_CLASS_EXPORT QPID_EXPORT +# define QPID_CLASS_IMPORT QPID_IMPORT +# define QPID_INLINE_EXPORT +# define QPID_INLINE_IMPORT +# endif +#else + // + // Non-Windows (Linux, etc.) definitions: + // +# define QPID_EXPORT +# define QPID_IMPORT +# define QPID_CLASS_EXPORT +# define QPID_CLASS_IMPORT +# define QPID_INLINE_EXPORT +# define QPID_INLINE_IMPORT +#endif + +#endif /*!QPID_IMPORTEXPORT_H*/ diff --git a/qpid/cpp/include/qpid/Url.h b/qpid/cpp/include/qpid/Url.h index 353e9d5599..915b08ac5f 100644 --- a/qpid/cpp/include/qpid/Url.h +++ b/qpid/cpp/include/qpid/Url.h @@ -66,7 +66,7 @@ struct Url : public std::vector
    { *@exception Invalid if the url is invalid. */ QPID_COMMON_EXTERN void parse(const char* url); - QPID_COMMON_EXTERN void parse(const std::string& url) { parse(url.c_str()); } + QPID_COMMON_INLINE_EXTERN void parse(const std::string& url) { parse(url.c_str()); } /** Replace contesnts with parsed URL. Replace with empty URL if invalid. */ QPID_COMMON_EXTERN void parseNoThrow(const char* url); diff --git a/qpid/cpp/include/qpid/agent/QmfAgentImportExport.h b/qpid/cpp/include/qpid/agent/QmfAgentImportExport.h index e41425a7ba..3f923ac4b2 100644 --- a/qpid/cpp/include/qpid/agent/QmfAgentImportExport.h +++ b/qpid/cpp/include/qpid/agent/QmfAgentImportExport.h @@ -20,14 +20,16 @@ * under the License. */ -#if defined(WIN32) && !defined(QPID_DECLARE_STATIC) -#if defined (qmf_EXPORTS) -#define QMF_AGENT_EXTERN __declspec(dllexport) -#else -#define QMF_AGENT_EXTERN __declspec(dllimport) -#endif +#include "qpid/ImportExport.h" + +#if defined(QMF_EXPORT) || defined (qmf_EXPORTS) +# define QMF_AGENT_EXTERN QPID_EXPORT +# define QMF_AGENT_CLASS_EXTERN QPID_CLASS_EXPORT +# define QMF_AGENT_INLINE_EXTERN QPID_INLINE_EXPORT #else -#define QMF_AGENT_EXTERN +# define QMF_AGENT_EXTERN QPID_IMPORT +# define QMF_AGENT_CLASS_EXTERN QPID_CLASS_IMPORT +# define QMF_AGENT_INLINE_EXTERN QPID_INLINE_IMPORT #endif #endif diff --git a/qpid/cpp/include/qpid/client/ClientImportExport.h b/qpid/cpp/include/qpid/client/ClientImportExport.h index 42b02e33c3..2a3a5a52e9 100644 --- a/qpid/cpp/include/qpid/client/ClientImportExport.h +++ b/qpid/cpp/include/qpid/client/ClientImportExport.h @@ -20,14 +20,16 @@ * under the License. */ -#if defined(WIN32) && !defined(QPID_DECLARE_STATIC) +#include "qpid/ImportExport.h" + #if defined(CLIENT_EXPORT) || defined (qpidclient_EXPORTS) -#define QPID_CLIENT_EXTERN __declspec(dllexport) -#else -#define QPID_CLIENT_EXTERN __declspec(dllimport) -#endif +# define QPID_CLIENT_EXTERN QPID_EXPORT +# define QPID_CLIENT_CLASS_EXTERN QPID_CLASS_EXPORT +# define QPID_CLIENT_INLINE_EXTERN QPID_INLINE_EXPORT #else -#define QPID_CLIENT_EXTERN +# define QPID_CLIENT_EXTERN QPID_IMPORT +# define QPID_CLIENT_CLASS_EXTERN QPID_CLASS_IMPORT +# define QPID_CLIENT_INLINE_EXTERN QPID_INLINE_IMPORT #endif #endif diff --git a/qpid/cpp/include/qpid/client/Completion.h b/qpid/cpp/include/qpid/client/Completion.h index 99d940f031..9546db9258 100644 --- a/qpid/cpp/include/qpid/client/Completion.h +++ b/qpid/cpp/include/qpid/client/Completion.h @@ -41,7 +41,7 @@ template class PrivateImplRef; * *\ingroup clientapi */ -class Completion : public Handle +class QPID_CLIENT_CLASS_EXTERN Completion : public Handle { public: QPID_CLIENT_EXTERN Completion(CompletionImpl* = 0); diff --git a/qpid/cpp/include/qpid/client/Connection.h b/qpid/cpp/include/qpid/client/Connection.h index 6ed0d98bc0..2477bf4800 100644 --- a/qpid/cpp/include/qpid/client/Connection.h +++ b/qpid/cpp/include/qpid/client/Connection.h @@ -60,7 +60,7 @@ class ConnectionImpl; * */ -class Connection +class QPID_CLIENT_CLASS_EXTERN Connection { framing::ProtocolVersion version; diff --git a/qpid/cpp/include/qpid/client/ConnectionSettings.h b/qpid/cpp/include/qpid/client/ConnectionSettings.h index 1c2ee28b1b..2b6b86f891 100644 --- a/qpid/cpp/include/qpid/client/ConnectionSettings.h +++ b/qpid/cpp/include/qpid/client/ConnectionSettings.h @@ -37,7 +37,7 @@ namespace client { /** * Settings for a Connection. */ -struct ConnectionSettings { +struct QPID_CLIENT_CLASS_EXTERN ConnectionSettings { QPID_CLIENT_EXTERN ConnectionSettings(); QPID_CLIENT_EXTERN virtual ~ConnectionSettings(); diff --git a/qpid/cpp/include/qpid/client/FailoverListener.h b/qpid/cpp/include/qpid/client/FailoverListener.h index 59108eb7cb..53c7c26211 100644 --- a/qpid/cpp/include/qpid/client/FailoverListener.h +++ b/qpid/cpp/include/qpid/client/FailoverListener.h @@ -48,7 +48,7 @@ namespace client { * FailoverListener::decode to extract a list of broker URLs from a * failover exchange message. */ -class FailoverListener : private MessageListener, private qpid::sys::Runnable +class QPID_CLIENT_CLASS_EXTERN FailoverListener : private MessageListener, private qpid::sys::Runnable { public: /** The name of the standard failover exchange amq.failover */ diff --git a/qpid/cpp/include/qpid/client/FailoverManager.h b/qpid/cpp/include/qpid/client/FailoverManager.h index 0d30e2ed60..d3a0dbc976 100644 --- a/qpid/cpp/include/qpid/client/FailoverManager.h +++ b/qpid/cpp/include/qpid/client/FailoverManager.h @@ -42,7 +42,7 @@ struct CannotConnectException : qpid::Exception /** * Utility to manage failover. */ -class FailoverManager +class QPID_CLIENT_CLASS_EXTERN FailoverManager { public: /** diff --git a/qpid/cpp/include/qpid/client/Future.h b/qpid/cpp/include/qpid/client/Future.h index 09088e68f6..630a7e03c0 100644 --- a/qpid/cpp/include/qpid/client/Future.h +++ b/qpid/cpp/include/qpid/client/Future.h @@ -34,7 +34,7 @@ namespace qpid { namespace client { /**@internal */ -class Future +class QPID_CLIENT_CLASS_EXTERN Future { framing::SequenceNumber command; boost::shared_ptr result; diff --git a/qpid/cpp/include/qpid/client/FutureResult.h b/qpid/cpp/include/qpid/client/FutureResult.h index b2b663daa1..ead4929571 100644 --- a/qpid/cpp/include/qpid/client/FutureResult.h +++ b/qpid/cpp/include/qpid/client/FutureResult.h @@ -34,7 +34,7 @@ namespace client { class SessionImpl; ///@internal -class FutureResult : public FutureCompletion +class QPID_CLIENT_CLASS_EXTERN FutureResult : public FutureCompletion { std::string result; public: diff --git a/qpid/cpp/include/qpid/client/Handle.h b/qpid/cpp/include/qpid/client/Handle.h index 088e836fcf..b8315481a9 100644 --- a/qpid/cpp/include/qpid/client/Handle.h +++ b/qpid/cpp/include/qpid/client/Handle.h @@ -40,22 +40,22 @@ template class Handle { public: /**@return true if handle is valid, i.e. not null. */ - QPID_CLIENT_EXTERN bool isValid() const { return impl; } + QPID_CLIENT_INLINE_EXTERN bool isValid() const { return impl; } /**@return true if handle is null. It is an error to call any function on a null handle. */ - QPID_CLIENT_EXTERN bool isNull() const { return !impl; } + QPID_CLIENT_INLINE_EXTERN bool isNull() const { return !impl; } /** Conversion to bool supports idiom if (handle) { handle->... } */ - QPID_CLIENT_EXTERN operator bool() const { return impl; } + QPID_CLIENT_INLINE_EXTERN operator bool() const { return impl; } /** Operator ! supports idiom if (!handle) { do_if_handle_is_null(); } */ - QPID_CLIENT_EXTERN bool operator !() const { return !impl; } + QPID_CLIENT_INLINE_EXTERN bool operator !() const { return !impl; } void swap(Handle& h) { T* t = h.impl; h.impl = impl; impl = t; } protected: typedef T Impl; - QPID_CLIENT_EXTERN Handle() :impl() {} + QPID_CLIENT_INLINE_EXTERN Handle() :impl() {} // Not implemented,subclasses must implement. QPID_CLIENT_EXTERN Handle(const Handle&); diff --git a/qpid/cpp/include/qpid/client/LocalQueue.h b/qpid/cpp/include/qpid/client/LocalQueue.h index 70e4cebcf1..1a19a8499d 100644 --- a/qpid/cpp/include/qpid/client/LocalQueue.h +++ b/qpid/cpp/include/qpid/client/LocalQueue.h @@ -71,7 +71,7 @@ template class PrivateImplRef; * */ -class LocalQueue : public Handle { +class QPID_CLIENT_CLASS_EXTERN LocalQueue : public Handle { public: /** Create a local queue. Subscribe the local queue to a remote broker * queue with a SubscriptionManager. diff --git a/qpid/cpp/include/qpid/client/Message.h b/qpid/cpp/include/qpid/client/Message.h index 2401cbdc92..ba50dda9ba 100644 --- a/qpid/cpp/include/qpid/client/Message.h +++ b/qpid/cpp/include/qpid/client/Message.h @@ -112,7 +112,7 @@ class MessageImpl; * * */ -class Message +class QPID_CLIENT_CLASS_EXTERN Message { public: /** Create a Message. diff --git a/qpid/cpp/include/qpid/client/MessageListener.h b/qpid/cpp/include/qpid/client/MessageListener.h index d200f8cf21..3ca2fa964a 100644 --- a/qpid/cpp/include/qpid/client/MessageListener.h +++ b/qpid/cpp/include/qpid/client/MessageListener.h @@ -84,7 +84,7 @@ namespace client { * */ - class MessageListener{ + class QPID_CLIENT_CLASS_EXTERN MessageListener{ public: QPID_CLIENT_EXTERN virtual ~MessageListener(); diff --git a/qpid/cpp/include/qpid/client/MessageReplayTracker.h b/qpid/cpp/include/qpid/client/MessageReplayTracker.h index 6f5a0f4ac3..06a3f29c7d 100644 --- a/qpid/cpp/include/qpid/client/MessageReplayTracker.h +++ b/qpid/cpp/include/qpid/client/MessageReplayTracker.h @@ -34,7 +34,7 @@ namespace client { * Utility to track messages sent asynchronously, allowing those that * are indoubt to be replayed over a new session. */ -class MessageReplayTracker +class QPID_CLIENT_CLASS_EXTERN MessageReplayTracker { public: QPID_CLIENT_EXTERN MessageReplayTracker(uint flushInterval); diff --git a/qpid/cpp/include/qpid/client/QueueOptions.h b/qpid/cpp/include/qpid/client/QueueOptions.h index f8a4963f06..3984b63fdd 100644 --- a/qpid/cpp/include/qpid/client/QueueOptions.h +++ b/qpid/cpp/include/qpid/client/QueueOptions.h @@ -35,7 +35,7 @@ enum QueueOrderingPolicy {FIFO, LVQ, LVQ_NO_BROWSE}; * A help class to set options on the Queue. Create a configured args while * still allowing any custom configuration via the FieldTable base class */ -class QueueOptions: public framing::FieldTable +class QPID_CLIENT_CLASS_EXTERN QueueOptions: public framing::FieldTable { public: QPID_CLIENT_EXTERN QueueOptions(); diff --git a/qpid/cpp/include/qpid/client/SessionBase_0_10.h b/qpid/cpp/include/qpid/client/SessionBase_0_10.h index 3b5c84e74b..ea50ab32f7 100644 --- a/qpid/cpp/include/qpid/client/SessionBase_0_10.h +++ b/qpid/cpp/include/qpid/client/SessionBase_0_10.h @@ -54,7 +54,7 @@ enum CreditUnit { MESSAGE_CREDIT=0, BYTE_CREDIT=1, UNLIMITED_CREDIT=0xFFFFFFFF } * Subclasses provide the AMQP commands for a given * version of the protocol. */ -class SessionBase_0_10 { +class QPID_CLIENT_CLASS_EXTERN SessionBase_0_10 { public: ///@internal diff --git a/qpid/cpp/include/qpid/client/Subscription.h b/qpid/cpp/include/qpid/client/Subscription.h index 425b6b92e2..bb9b98e8ff 100644 --- a/qpid/cpp/include/qpid/client/Subscription.h +++ b/qpid/cpp/include/qpid/client/Subscription.h @@ -39,7 +39,7 @@ class SubscriptionManager; * A handle to an active subscription. Provides methods to query the subscription status * and control acknowledgement (acquire and accept) of messages. */ -class Subscription : public Handle { +class QPID_CLIENT_CLASS_EXTERN Subscription : public Handle { public: QPID_CLIENT_EXTERN Subscription(SubscriptionImpl* = 0); QPID_CLIENT_EXTERN Subscription(const Subscription&); @@ -91,13 +91,13 @@ class Subscription : public Handle { QPID_CLIENT_EXTERN void release(const SequenceSet& messageIds); /* Acquire a single message */ - QPID_CLIENT_EXTERN void acquire(const Message& m) { acquire(SequenceSet(m.getId())); } + QPID_CLIENT_INLINE_EXTERN void acquire(const Message& m) { acquire(SequenceSet(m.getId())); } /* Accept a single message */ - QPID_CLIENT_EXTERN void accept(const Message& m) { accept(SequenceSet(m.getId())); } + QPID_CLIENT_INLINE_EXTERN void accept(const Message& m) { accept(SequenceSet(m.getId())); } /* Release a single message */ - QPID_CLIENT_EXTERN void release(const Message& m) { release(SequenceSet(m.getId())); } + QPID_CLIENT_INLINE_EXTERN void release(const Message& m) { release(SequenceSet(m.getId())); } /** Get the session associated with this subscription */ QPID_CLIENT_EXTERN Session getSession() const; diff --git a/qpid/cpp/include/qpid/client/SubscriptionManager.h b/qpid/cpp/include/qpid/client/SubscriptionManager.h index e70e05f73a..b69819a8ff 100644 --- a/qpid/cpp/include/qpid/client/SubscriptionManager.h +++ b/qpid/cpp/include/qpid/client/SubscriptionManager.h @@ -94,7 +94,7 @@ class SubscriptionManagerImpl; * * */ -class SubscriptionManager : public sys::Runnable, public Handle +class QPID_CLIENT_CLASS_EXTERN SubscriptionManager : public sys::Runnable, public Handle { public: /** Create a new SubscriptionManager associated with a session */ diff --git a/qpid/cpp/include/qpid/console/Agent.h b/qpid/cpp/include/qpid/console/Agent.h index 97d75da250..629dd71dee 100644 --- a/qpid/cpp/include/qpid/console/Agent.h +++ b/qpid/cpp/include/qpid/console/Agent.h @@ -31,17 +31,17 @@ namespace console { * * \ingroup qmfconsoleapi */ - class QPID_CONSOLE_EXTERN Agent { + class QPID_CONSOLE_CLASS_EXTERN Agent { public: typedef std::vector Vector; - Agent(Broker* _broker, uint32_t _bank, const std::string& _label) : + QPID_CONSOLE_INLINE_EXTERN Agent(Broker* _broker, uint32_t _bank, const std::string& _label) : broker(_broker), brokerBank(broker->getBrokerBank()), agentBank(_bank), label(_label) {} - Broker* getBroker() const { return broker; } - uint32_t getBrokerBank() const { return brokerBank; } - uint32_t getAgentBank() const { return agentBank; } - const std::string& getLabel() const { return label; } + QPID_CONSOLE_INLINE_EXTERN Broker* getBroker() const { return broker; } + QPID_CONSOLE_INLINE_EXTERN uint32_t getBrokerBank() const { return brokerBank; } + QPID_CONSOLE_INLINE_EXTERN uint32_t getAgentBank() const { return agentBank; } + QPID_CONSOLE_INLINE_EXTERN const std::string& getLabel() const { return label; } private: Broker* broker; @@ -50,7 +50,7 @@ namespace console { const std::string label; }; - QPID_CONSOLE_EXTERN std::ostream& operator<<(std::ostream& o, const Agent& agent); + std::ostream& operator<<(std::ostream& o, const Agent& agent); } } diff --git a/qpid/cpp/include/qpid/console/Broker.h b/qpid/cpp/include/qpid/console/Broker.h index 0b2d1bcb61..c2ba8ac81f 100644 --- a/qpid/cpp/include/qpid/console/Broker.h +++ b/qpid/cpp/include/qpid/console/Broker.h @@ -55,12 +55,12 @@ namespace console { client::ConnectionSettings& settings); QPID_CONSOLE_EXTERN ~Broker(); - QPID_CONSOLE_EXTERN bool isConnected() const { return connected; } - QPID_CONSOLE_EXTERN const std::string& getError() const { return error; } - QPID_CONSOLE_EXTERN const std::string& getSessionId() const { return amqpSessionId; } - QPID_CONSOLE_EXTERN const framing::Uuid& getBrokerId() const { return brokerId; } - QPID_CONSOLE_EXTERN uint32_t getBrokerBank() const { return 1; } - QPID_CONSOLE_EXTERN void addBinding(const std::string& key) { + QPID_CONSOLE_INLINE_EXTERN bool isConnected() const { return connected; } + QPID_CONSOLE_INLINE_EXTERN const std::string& getError() const { return error; } + QPID_CONSOLE_INLINE_EXTERN const std::string& getSessionId() const { return amqpSessionId; } + QPID_CONSOLE_INLINE_EXTERN const framing::Uuid& getBrokerId() const { return brokerId; } + QPID_CONSOLE_INLINE_EXTERN uint32_t getBrokerBank() const { return 1; } + QPID_CONSOLE_INLINE_EXTERN void addBinding(const std::string& key) { connThreadBody.bindExchange("qpid.management", key); } QPID_CONSOLE_EXTERN std::string getUrl() const; @@ -123,10 +123,10 @@ namespace console { void setBrokerId(const framing::Uuid& id) { brokerId = id; } void appendAgents(std::vector& agents) const; - friend QPID_CONSOLE_EXTERN std::ostream& operator<<(std::ostream& o, const Broker& k); + friend std::ostream& operator<<(std::ostream& o, const Broker& k); }; - QPID_CONSOLE_EXTERN std::ostream& operator<<(std::ostream& o, const Broker& k); + std::ostream& operator<<(std::ostream& o, const Broker& k); } } diff --git a/qpid/cpp/include/qpid/console/ConsoleImportExport.h b/qpid/cpp/include/qpid/console/ConsoleImportExport.h index c2d7cb3a14..aac30858f7 100644 --- a/qpid/cpp/include/qpid/console/ConsoleImportExport.h +++ b/qpid/cpp/include/qpid/console/ConsoleImportExport.h @@ -20,14 +20,16 @@ * under the License. */ -#if defined(WIN32) && !defined(QPID_DECLARE_STATIC) +#include "qpid/ImportExport.h" + #if defined(CONSOLE_EXPORT) || defined (qmfconsole_EXPORTS) -#define QPID_CONSOLE_EXTERN __declspec(dllexport) -#else -#define QPID_CONSOLE_EXTERN __declspec(dllimport) -#endif +# define QPID_CONSOLE_EXTERN QPID_EXPORT +# define QPID_CONSOLE_CLASS_EXTERN QPID_CLASS_EXPORT +# define QPID_CONSOLE_INLINE_EXTERN QPID_INLINE_EXPORT #else -#define QPID_CONSOLE_EXTERN +# define QPID_CONSOLE_EXTERN QPID_IMPORT +# define QPID_CONSOLE_CLASS_EXTERN QPID_CLASS_IMPORT +# define QPID_CONSOLE_INLINE_EXTERN QPID_INLINE_IMPORT #endif #endif diff --git a/qpid/cpp/include/qpid/framing/Array.h b/qpid/cpp/include/qpid/framing/Array.h index d3bdd36aa6..1e97be3bb4 100644 --- a/qpid/cpp/include/qpid/framing/Array.h +++ b/qpid/cpp/include/qpid/framing/Array.h @@ -34,7 +34,7 @@ namespace framing { class Buffer; -class Array +class QPID_COMMON_CLASS_EXTERN Array { public: typedef boost::shared_ptr ValuePtr; @@ -55,25 +55,25 @@ class Array //creates a longstr array QPID_COMMON_EXTERN Array(const std::vector& in); - QPID_COMMON_EXTERN TypeCode getType() const { return type; } + QPID_COMMON_INLINE_EXTERN TypeCode getType() const { return type; } // std collection interface. - QPID_COMMON_EXTERN const_iterator begin() const { return values.begin(); } - QPID_COMMON_EXTERN const_iterator end() const { return values.end(); } - QPID_COMMON_EXTERN iterator begin() { return values.begin(); } - QPID_COMMON_EXTERN iterator end(){ return values.end(); } + QPID_COMMON_INLINE_EXTERN const_iterator begin() const { return values.begin(); } + QPID_COMMON_INLINE_EXTERN const_iterator end() const { return values.end(); } + QPID_COMMON_INLINE_EXTERN iterator begin() { return values.begin(); } + QPID_COMMON_INLINE_EXTERN iterator end(){ return values.end(); } - QPID_COMMON_EXTERN ValuePtr front() const { return values.front(); } - QPID_COMMON_EXTERN ValuePtr back() const { return values.back(); } - QPID_COMMON_EXTERN size_t size() const { return values.size(); } + QPID_COMMON_INLINE_EXTERN ValuePtr front() const { return values.front(); } + QPID_COMMON_INLINE_EXTERN ValuePtr back() const { return values.back(); } + QPID_COMMON_INLINE_EXTERN size_t size() const { return values.size(); } QPID_COMMON_EXTERN void insert(iterator i, ValuePtr value); - QPID_COMMON_EXTERN void erase(iterator i) { values.erase(i); } - QPID_COMMON_EXTERN void push_back(ValuePtr value) { values.insert(end(), value); } - QPID_COMMON_EXTERN void pop_back() { values.pop_back(); } + QPID_COMMON_INLINE_EXTERN void erase(iterator i) { values.erase(i); } + QPID_COMMON_INLINE_EXTERN void push_back(ValuePtr value) { values.insert(end(), value); } + QPID_COMMON_INLINE_EXTERN void pop_back() { values.pop_back(); } // Non-std interface - QPID_COMMON_EXTERN void add(ValuePtr value) { push_back(value); } + QPID_COMMON_INLINE_EXTERN void add(ValuePtr value) { push_back(value); } template void collect(std::vector& out) const diff --git a/qpid/cpp/include/qpid/framing/Buffer.h b/qpid/cpp/include/qpid/framing/Buffer.h index 04583433c5..8b08e60762 100644 --- a/qpid/cpp/include/qpid/framing/Buffer.h +++ b/qpid/cpp/include/qpid/framing/Buffer.h @@ -29,14 +29,14 @@ namespace qpid { namespace framing { -struct OutOfBounds : qpid::Exception { +struct QPID_COMMON_CLASS_EXTERN OutOfBounds : qpid::Exception { OutOfBounds() : qpid::Exception(std::string("Out of Bounds")) {} }; class Content; class FieldTable; -class Buffer +class QPID_COMMON_CLASS_EXTERN Buffer { uint32_t size; char* data; @@ -72,12 +72,12 @@ class Buffer QPID_COMMON_EXTERN void restore(bool reRecord = false); QPID_COMMON_EXTERN void reset(); - QPID_COMMON_EXTERN uint32_t available() { return size - position; } - QPID_COMMON_EXTERN uint32_t getSize() { return size; } - QPID_COMMON_EXTERN uint32_t getPosition() { return position; } - QPID_COMMON_EXTERN void setPosition(uint32_t p) { position = p; } - QPID_COMMON_EXTERN Iterator getIterator() { return Iterator(*this); } - QPID_COMMON_EXTERN char* getPointer() { return data; } + QPID_COMMON_INLINE_EXTERN uint32_t available() { return size - position; } + QPID_COMMON_INLINE_EXTERN uint32_t getSize() { return size; } + QPID_COMMON_INLINE_EXTERN uint32_t getPosition() { return position; } + QPID_COMMON_INLINE_EXTERN void setPosition(uint32_t p) { position = p; } + QPID_COMMON_INLINE_EXTERN Iterator getIterator() { return Iterator(*this); } + QPID_COMMON_INLINE_EXTERN char* getPointer() { return data; } QPID_COMMON_EXTERN void putOctet(uint8_t i); QPID_COMMON_EXTERN void putShort(uint16_t i); diff --git a/qpid/cpp/include/qpid/framing/FieldTable.h b/qpid/cpp/include/qpid/framing/FieldTable.h index fdb1a28b9d..fed431129a 100644 --- a/qpid/cpp/include/qpid/framing/FieldTable.h +++ b/qpid/cpp/include/qpid/framing/FieldTable.h @@ -56,7 +56,7 @@ class FieldTable typedef ValueMap::reference reference; typedef ValueMap::value_type value_type; - QPID_COMMON_EXTERN FieldTable() {}; + QPID_COMMON_INLINE_EXTERN FieldTable() {}; QPID_COMMON_EXTERN FieldTable(const FieldTable& ft); QPID_COMMON_EXTERN ~FieldTable(); QPID_COMMON_EXTERN FieldTable& operator=(const FieldTable& ft); @@ -67,7 +67,7 @@ class FieldTable QPID_COMMON_EXTERN int count() const; QPID_COMMON_EXTERN void set(const std::string& name, const ValuePtr& value); QPID_COMMON_EXTERN ValuePtr get(const std::string& name) const; - QPID_COMMON_EXTERN bool isSet(const std::string& name) const { return get(name).get() != 0; } + QPID_COMMON_INLINE_EXTERN bool isSet(const std::string& name) const { return get(name).get() != 0; } QPID_COMMON_EXTERN void setString(const std::string& name, const std::string& value); QPID_COMMON_EXTERN void setInt(const std::string& name, const int value); diff --git a/qpid/cpp/include/qpid/framing/FieldValue.h b/qpid/cpp/include/qpid/framing/FieldValue.h index e6255066c4..458de62fdf 100644 --- a/qpid/cpp/include/qpid/framing/FieldValue.h +++ b/qpid/cpp/include/qpid/framing/FieldValue.h @@ -41,14 +41,14 @@ namespace framing { * * \ingroup clientapi */ -class FieldValueException : public qpid::Exception {}; +class QPID_COMMON_CLASS_EXTERN FieldValueException : public qpid::Exception {}; /** * Exception thrown when we can't perform requested conversion * * \ingroup clientapi */ -struct InvalidConversionException : public FieldValueException { +struct QPID_COMMON_CLASS_EXTERN InvalidConversionException : public FieldValueException { InvalidConversionException() {} }; @@ -59,7 +59,7 @@ class List; * * \ingroup clientapi */ -class FieldValue { +class QPID_COMMON_CLASS_EXTERN FieldValue { public: /* * Abstract type for content of different types @@ -90,7 +90,7 @@ class FieldValue { void encode(Buffer& buffer); void decode(Buffer& buffer); QPID_COMMON_EXTERN bool operator==(const FieldValue&) const; - QPID_COMMON_EXTERN bool operator!=(const FieldValue& v) const { return !(*this == v); } + QPID_COMMON_INLINE_EXTERN bool operator!=(const FieldValue& v) const { return !(*this == v); } QPID_COMMON_EXTERN void print(std::ostream& out) const; diff --git a/qpid/cpp/include/qpid/framing/List.h b/qpid/cpp/include/qpid/framing/List.h index 0f17c7884c..417fd4bffb 100644 --- a/qpid/cpp/include/qpid/framing/List.h +++ b/qpid/cpp/include/qpid/framing/List.h @@ -36,7 +36,7 @@ class FieldValue; /** * Representation of an AMQP 0-10 list */ -class List +class QPID_COMMON_CLASS_EXTERN List { public: typedef boost::shared_ptr ValuePtr; @@ -53,19 +53,19 @@ class List QPID_COMMON_EXTERN bool operator==(const List& other) const; // std collection interface. - QPID_COMMON_EXTERN const_iterator begin() const { return values.begin(); } - QPID_COMMON_EXTERN const_iterator end() const { return values.end(); } - QPID_COMMON_EXTERN iterator begin() { return values.begin(); } - QPID_COMMON_EXTERN iterator end(){ return values.end(); } + QPID_COMMON_INLINE_EXTERN const_iterator begin() const { return values.begin(); } + QPID_COMMON_INLINE_EXTERN const_iterator end() const { return values.end(); } + QPID_COMMON_INLINE_EXTERN iterator begin() { return values.begin(); } + QPID_COMMON_INLINE_EXTERN iterator end(){ return values.end(); } - QPID_COMMON_EXTERN ValuePtr front() const { return values.front(); } - QPID_COMMON_EXTERN ValuePtr back() const { return values.back(); } - QPID_COMMON_EXTERN size_t size() const { return values.size(); } + QPID_COMMON_INLINE_EXTERN ValuePtr front() const { return values.front(); } + QPID_COMMON_INLINE_EXTERN ValuePtr back() const { return values.back(); } + QPID_COMMON_INLINE_EXTERN size_t size() const { return values.size(); } - QPID_COMMON_EXTERN iterator insert(iterator i, ValuePtr value) { return values.insert(i, value); } - QPID_COMMON_EXTERN void erase(iterator i) { values.erase(i); } - QPID_COMMON_EXTERN void push_back(ValuePtr value) { values.insert(end(), value); } - QPID_COMMON_EXTERN void pop_back() { values.pop_back(); } + QPID_COMMON_INLINE_EXTERN iterator insert(iterator i, ValuePtr value) { return values.insert(i, value); } + QPID_COMMON_INLINE_EXTERN void erase(iterator i) { values.erase(i); } + QPID_COMMON_INLINE_EXTERN void push_back(ValuePtr value) { values.insert(end(), value); } + QPID_COMMON_INLINE_EXTERN void pop_back() { values.pop_back(); } private: Values values; diff --git a/qpid/cpp/include/qpid/framing/ProtocolVersion.h b/qpid/cpp/include/qpid/framing/ProtocolVersion.h index e7e75d75f6..30094c165d 100644 --- a/qpid/cpp/include/qpid/framing/ProtocolVersion.h +++ b/qpid/cpp/include/qpid/framing/ProtocolVersion.h @@ -29,7 +29,7 @@ namespace qpid namespace framing { -class ProtocolVersion +class QPID_COMMON_CLASS_EXTERN ProtocolVersion { private: uint8_t major_; @@ -39,16 +39,16 @@ public: explicit ProtocolVersion(uint8_t _major=0, uint8_t _minor=0) : major_(_major), minor_(_minor) {} - QPID_COMMON_EXTERN uint8_t getMajor() const { return major_; } - QPID_COMMON_EXTERN void setMajor(uint8_t major) { major_ = major; } - QPID_COMMON_EXTERN uint8_t getMinor() const { return minor_; } - QPID_COMMON_EXTERN void setMinor(uint8_t minor) { minor_ = minor; } + QPID_COMMON_INLINE_EXTERN uint8_t getMajor() const { return major_; } + QPID_COMMON_INLINE_EXTERN void setMajor(uint8_t major) { major_ = major; } + QPID_COMMON_INLINE_EXTERN uint8_t getMinor() const { return minor_; } + QPID_COMMON_INLINE_EXTERN void setMinor(uint8_t minor) { minor_ = minor; } QPID_COMMON_EXTERN const std::string toString() const; QPID_COMMON_EXTERN ProtocolVersion& operator=(ProtocolVersion p); QPID_COMMON_EXTERN bool operator==(ProtocolVersion p) const; - QPID_COMMON_EXTERN bool operator!=(ProtocolVersion p) const { return ! (*this == p); } + QPID_COMMON_INLINE_EXTERN bool operator!=(ProtocolVersion p) const { return ! (*this == p); } }; } // namespace framing diff --git a/qpid/cpp/include/qpid/framing/SequenceNumber.h b/qpid/cpp/include/qpid/framing/SequenceNumber.h index 1e53058df8..eed15a4b75 100644 --- a/qpid/cpp/include/qpid/framing/SequenceNumber.h +++ b/qpid/cpp/include/qpid/framing/SequenceNumber.h @@ -34,7 +34,7 @@ class Buffer; /** * 4-byte sequence number that 'wraps around'. */ -class SequenceNumber : public +class QPID_COMMON_CLASS_EXTERN SequenceNumber : public boost::equality_comparable< SequenceNumber, boost::less_than_comparable< SequenceNumber, boost::incrementable< diff --git a/qpid/cpp/include/qpid/framing/SequenceSet.h b/qpid/cpp/include/qpid/framing/SequenceSet.h index 39395e9ad7..0a78e418ba 100644 --- a/qpid/cpp/include/qpid/framing/SequenceSet.h +++ b/qpid/cpp/include/qpid/framing/SequenceSet.h @@ -29,7 +29,7 @@ namespace qpid { namespace framing { class Buffer; -class SequenceSet : public RangeSet { +class QPID_COMMON_CLASS_EXTERN SequenceSet : public RangeSet { public: SequenceSet() {} SequenceSet(const RangeSet& r) diff --git a/qpid/cpp/include/qpid/framing/StructHelper.h b/qpid/cpp/include/qpid/framing/StructHelper.h index fc9a7909cc..21f9b91fa9 100644 --- a/qpid/cpp/include/qpid/framing/StructHelper.h +++ b/qpid/cpp/include/qpid/framing/StructHelper.h @@ -30,7 +30,7 @@ namespace qpid { namespace framing { -class StructHelper +class QPID_COMMON_CLASS_EXTERN StructHelper { public: diff --git a/qpid/cpp/include/qpid/framing/Uuid.h b/qpid/cpp/include/qpid/framing/Uuid.h index d0a8d02411..ccfd7e9534 100644 --- a/qpid/cpp/include/qpid/framing/Uuid.h +++ b/qpid/cpp/include/qpid/framing/Uuid.h @@ -52,22 +52,22 @@ struct Uuid : public boost::array { // boost::array gives us ==, < etc. /** Copy from 16 bytes of data. */ - void assign(const uint8_t* data); + QPID_COMMON_EXTERN void assign(const uint8_t* data); /** Set to a new unique identifier. */ QPID_COMMON_EXTERN void generate(); /** Set to all zeros. */ - void clear(); + QPID_COMMON_EXTERN void clear(); /** Test for null (all zeros). */ QPID_COMMON_EXTERN bool isNull() const; - operator bool() const { return !isNull(); } - bool operator!() const { return isNull(); } + QPID_COMMON_INLINE_EXTERN operator bool() const { return !isNull(); } + QPID_COMMON_INLINE_EXTERN bool operator!() const { return isNull(); } QPID_COMMON_EXTERN void encode(framing::Buffer& buf) const; QPID_COMMON_EXTERN void decode(framing::Buffer& buf); - QPID_COMMON_EXTERN uint32_t encodedSize() const + QPID_COMMON_INLINE_EXTERN uint32_t encodedSize() const { return static_cast(size()); } /** String value in format 1b4e28ba-2fa1-11d2-883f-b9a761bde3fb. */ diff --git a/qpid/cpp/include/qpid/log/Logger.h b/qpid/cpp/include/qpid/log/Logger.h index 7606436e56..d255b7e150 100644 --- a/qpid/cpp/include/qpid/log/Logger.h +++ b/qpid/cpp/include/qpid/log/Logger.h @@ -33,7 +33,7 @@ namespace log { * is handled by Logger::Output-derived classes instantiated by the * platform's sink-related options. */ -class Logger : private boost::noncopyable { +class QPID_COMMON_CLASS_EXTERN Logger : private boost::noncopyable { public: /** Flags indicating what to include in the log output */ enum FormatFlag { FILE=1, LINE=2, FUNCTION=4, LEVEL=8, TIME=16, THREAD=32, HIRES=64}; @@ -93,7 +93,7 @@ class Logger : private boost::noncopyable { QPID_COMMON_EXTERN void clear(); /** Get the options used to configure the logger. */ - QPID_COMMON_EXTERN const Options& getOptions() const { return options; } + QPID_COMMON_INLINE_EXTERN const Options& getOptions() const { return options; } private: diff --git a/qpid/cpp/include/qpid/management/ManagementObject.h b/qpid/cpp/include/qpid/management/ManagementObject.h index 747edda150..16bf21038c 100644 --- a/qpid/cpp/include/qpid/management/ManagementObject.h +++ b/qpid/cpp/include/qpid/management/ManagementObject.h @@ -58,14 +58,14 @@ protected: std::string agentName; void fromString(const std::string&); public: - QPID_COMMON_EXTERN ObjectId() : agent(0), first(0), second(0), agentEpoch(0) {} - QPID_COMMON_EXTERN ObjectId(const types::Variant& map) : + QPID_COMMON_INLINE_EXTERN ObjectId() : agent(0), first(0), second(0), agentEpoch(0) {} + QPID_COMMON_INLINE_EXTERN ObjectId(const types::Variant& map) : agent(0), first(0), second(0), agentEpoch(0) { mapDecode(map.asMap()); } QPID_COMMON_EXTERN ObjectId(uint8_t flags, uint16_t seq, uint32_t broker); QPID_COMMON_EXTERN ObjectId(AgentAttachment* _agent, uint8_t flags, uint16_t seq); QPID_COMMON_EXTERN ObjectId(std::istream&); QPID_COMMON_EXTERN ObjectId(const std::string&); - QPID_COMMON_EXTERN ObjectId(const std::string& agentAddress, const std::string& key, + QPID_COMMON_INLINE_EXTERN ObjectId(const std::string& agentAddress, const std::string& key, uint64_t epoch=0) : agent(0), first(0), second(0), agentEpoch(epoch), v2Key(key), agentName(agentAddress) {} @@ -76,15 +76,15 @@ public: QPID_COMMON_EXTERN void mapEncode(types::Variant::Map& map) const; QPID_COMMON_EXTERN void mapDecode(const types::Variant::Map& map); QPID_COMMON_EXTERN operator types::Variant::Map() const; - QPID_COMMON_EXTERN uint32_t encodedSize() const { return 16; }; + QPID_COMMON_INLINE_EXTERN uint32_t encodedSize() const { return 16; }; QPID_COMMON_EXTERN void encode(std::string& buffer) const; QPID_COMMON_EXTERN void decode(const std::string& buffer); QPID_COMMON_EXTERN bool equalV1(const ObjectId &other) const; - QPID_COMMON_EXTERN void setV2Key(const std::string& _key) { v2Key = _key; } + QPID_COMMON_INLINE_EXTERN void setV2Key(const std::string& _key) { v2Key = _key; } QPID_COMMON_EXTERN void setV2Key(const ManagementObject& object); - QPID_COMMON_EXTERN void setAgentName(const std::string& _name) { agentName = _name; } - QPID_COMMON_EXTERN const std::string& getAgentName() const { return agentName; } - QPID_COMMON_EXTERN const std::string& getV2Key() const { return v2Key; } + QPID_COMMON_INLINE_EXTERN void setAgentName(const std::string& _name) { agentName = _name; } + QPID_COMMON_INLINE_EXTERN const std::string& getAgentName() const { return agentName; } + QPID_COMMON_INLINE_EXTERN const std::string& getV2Key() const { return v2Key; } friend QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream&, const ObjectId&); }; @@ -131,7 +131,7 @@ public: virtual ~ManagementItem() {} }; -class ManagementObject : public ManagementItem +class QPID_COMMON_CLASS_EXTERN ManagementObject : public ManagementItem { protected: diff --git a/qpid/cpp/include/qpid/messaging/Address.h b/qpid/cpp/include/qpid/messaging/Address.h index bebbfc72f6..63dce0c49d 100644 --- a/qpid/cpp/include/qpid/messaging/Address.h +++ b/qpid/cpp/include/qpid/messaging/Address.h @@ -119,7 +119,7 @@ class AddressImpl; * * An address has value semantics. */ -class Address +class QPID_MESSAGING_CLASS_EXTERN Address { public: QPID_MESSAGING_EXTERN Address(); diff --git a/qpid/cpp/include/qpid/messaging/Connection.h b/qpid/cpp/include/qpid/messaging/Connection.h index 1ad7a7242f..e938f23189 100644 --- a/qpid/cpp/include/qpid/messaging/Connection.h +++ b/qpid/cpp/include/qpid/messaging/Connection.h @@ -42,7 +42,7 @@ class Session; * A connection represents a network connection to a remote endpoint. */ -class Connection : public qpid::messaging::Handle +class QPID_MESSAGING_CLASS_EXTERN Connection : public qpid::messaging::Handle { public: QPID_MESSAGING_EXTERN Connection(ConnectionImpl* impl); diff --git a/qpid/cpp/include/qpid/messaging/Duration.h b/qpid/cpp/include/qpid/messaging/Duration.h index 1406e354c6..6b8f05c7c6 100644 --- a/qpid/cpp/include/qpid/messaging/Duration.h +++ b/qpid/cpp/include/qpid/messaging/Duration.h @@ -32,7 +32,7 @@ namespace messaging { /** \ingroup messaging * A duration is a time in milliseconds. */ -class Duration +class QPID_MESSAGING_CLASS_EXTERN Duration { public: QPID_MESSAGING_EXTERN explicit Duration(uint64_t milliseconds); @@ -46,9 +46,9 @@ class Duration }; QPID_MESSAGING_EXTERN Duration operator*(const Duration& duration, - uint64_t multiplier); + uint64_t multiplier); QPID_MESSAGING_EXTERN Duration operator*(uint64_t multiplier, - const Duration& duration); + const Duration& duration); QPID_MESSAGING_EXTERN bool operator==(const Duration& a, const Duration& b); QPID_MESSAGING_EXTERN bool operator!=(const Duration& a, const Duration& b); diff --git a/qpid/cpp/include/qpid/messaging/FailoverUpdates.h b/qpid/cpp/include/qpid/messaging/FailoverUpdates.h index 14a1a31b63..6d7314620a 100644 --- a/qpid/cpp/include/qpid/messaging/FailoverUpdates.h +++ b/qpid/cpp/include/qpid/messaging/FailoverUpdates.h @@ -32,7 +32,7 @@ struct FailoverUpdatesImpl; * A utility to listen for updates on cluster membership and update * the list of known urls for a connection accordingly. */ -class FailoverUpdates +class QPID_MESSAGING_CLASS_EXTERN FailoverUpdates { public: QPID_MESSAGING_EXTERN FailoverUpdates(Connection& connection); diff --git a/qpid/cpp/include/qpid/messaging/Handle.h b/qpid/cpp/include/qpid/messaging/Handle.h index 1e634ef888..97a8f00b54 100644 --- a/qpid/cpp/include/qpid/messaging/Handle.h +++ b/qpid/cpp/include/qpid/messaging/Handle.h @@ -40,22 +40,22 @@ template class Handle { public: /**@return true if handle is valid, i.e. not null. */ - QPID_MESSAGING_EXTERN bool isValid() const { return impl; } + QPID_MESSAGING_INLINE_EXTERN bool isValid() const { return impl; } /**@return true if handle is null. It is an error to call any function on a null handle. */ - QPID_MESSAGING_EXTERN bool isNull() const { return !impl; } + QPID_MESSAGING_INLINE_EXTERN bool isNull() const { return !impl; } /** Conversion to bool supports idiom if (handle) { handle->... } */ - QPID_MESSAGING_EXTERN operator bool() const { return impl; } + QPID_MESSAGING_INLINE_EXTERN operator bool() const { return impl; } /** Operator ! supports idiom if (!handle) { do_if_handle_is_null(); } */ - QPID_MESSAGING_EXTERN bool operator !() const { return !impl; } + QPID_MESSAGING_INLINE_EXTERN bool operator !() const { return !impl; } void swap(Handle& h) { T* t = h.impl; h.impl = impl; impl = t; } protected: typedef T Impl; - QPID_MESSAGING_EXTERN Handle() :impl() {} + QPID_MESSAGING_INLINE_EXTERN Handle() :impl() {} // Not implemented,subclasses must implement. QPID_MESSAGING_EXTERN Handle(const Handle&); diff --git a/qpid/cpp/include/qpid/messaging/ImportExport.h b/qpid/cpp/include/qpid/messaging/ImportExport.h index 52f3eb8568..ab5f21f618 100644 --- a/qpid/cpp/include/qpid/messaging/ImportExport.h +++ b/qpid/cpp/include/qpid/messaging/ImportExport.h @@ -20,14 +20,16 @@ * under the License. */ -#if defined(WIN32) && !defined(QPID_DECLARE_STATIC) +#include "qpid/ImportExport.h" + #if defined(CLIENT_EXPORT) || defined (qpidmessaging_EXPORTS) -#define QPID_MESSAGING_EXTERN __declspec(dllexport) -#else -#define QPID_MESSAGING_EXTERN __declspec(dllimport) -#endif +# define QPID_MESSAGING_EXTERN QPID_EXPORT +# define QPID_MESSAGING_CLASS_EXTERN QPID_CLASS_EXPORT +# define QPID_MESSAGING_INLINE_EXTERN QPID_INLINE_EXPORT #else -#define QPID_MESSAGING_EXTERN +# define QPID_MESSAGING_EXTERN QPID_IMPORT +# define QPID_MESSAGING_CLASS_EXTERN QPID_CLASS_IMPORT +# define QPID_MESSAGING_INLINE_EXTERN QPID_INLINE_IMPORT #endif #endif /*!QPID_MESSAGING_IMPORTEXPORT_H*/ diff --git a/qpid/cpp/include/qpid/messaging/Message.h b/qpid/cpp/include/qpid/messaging/Message.h index d48af35cc0..5cd978f2a2 100644 --- a/qpid/cpp/include/qpid/messaging/Message.h +++ b/qpid/cpp/include/qpid/messaging/Message.h @@ -39,7 +39,7 @@ struct MessageImpl; /** \ingroup messaging * Representation of a message. */ -class Message +class QPID_MESSAGING_CLASS_EXTERN Message { public: QPID_MESSAGING_EXTERN Message(const std::string& bytes = std::string()); @@ -107,9 +107,9 @@ class Message friend struct MessageImplAccess; }; -struct EncodingException : qpid::types::Exception +struct QPID_MESSAGING_CLASS_EXTERN EncodingException : qpid::types::Exception { - EncodingException(const std::string& msg); + QPID_MESSAGING_EXTERN EncodingException(const std::string& msg); }; /** @@ -122,8 +122,8 @@ struct EncodingException : qpid::types::Exception * @exception EncodingException */ QPID_MESSAGING_EXTERN void decode(const Message& message, - qpid::types::Variant::Map& map, - const std::string& encoding = std::string()); + qpid::types::Variant::Map& map, + const std::string& encoding = std::string()); /** * Decodes message content into a Variant::List. * @@ -134,8 +134,8 @@ QPID_MESSAGING_EXTERN void decode(const Message& message, * @exception EncodingException */ QPID_MESSAGING_EXTERN void decode(const Message& message, - qpid::types::Variant::List& list, - const std::string& encoding = std::string()); + qpid::types::Variant::List& list, + const std::string& encoding = std::string()); /** * Encodes a Variant::Map into a message. * @@ -146,8 +146,8 @@ QPID_MESSAGING_EXTERN void decode(const Message& message, * @exception EncodingException */ QPID_MESSAGING_EXTERN void encode(const qpid::types::Variant::Map& map, - Message& message, - const std::string& encoding = std::string()); + Message& message, + const std::string& encoding = std::string()); /** * Encodes a Variant::List into a message. * @@ -158,8 +158,8 @@ QPID_MESSAGING_EXTERN void encode(const qpid::types::Variant::Map& map, * @exception EncodingException */ QPID_MESSAGING_EXTERN void encode(const qpid::types::Variant::List& list, - Message& message, - const std::string& encoding = std::string()); + Message& message, + const std::string& encoding = std::string()); }} // namespace qpid::messaging diff --git a/qpid/cpp/include/qpid/messaging/Receiver.h b/qpid/cpp/include/qpid/messaging/Receiver.h index 6f3ae961db..13317dfcbd 100644 --- a/qpid/cpp/include/qpid/messaging/Receiver.h +++ b/qpid/cpp/include/qpid/messaging/Receiver.h @@ -41,7 +41,7 @@ class Session; /** \ingroup messaging * Interface through which messages are received. */ -class Receiver : public qpid::messaging::Handle +class QPID_MESSAGING_CLASS_EXTERN Receiver : public qpid::messaging::Handle { public: QPID_MESSAGING_EXTERN Receiver(ReceiverImpl* impl = 0); diff --git a/qpid/cpp/include/qpid/messaging/Sender.h b/qpid/cpp/include/qpid/messaging/Sender.h index 85658f37cc..8e1c5846e9 100644 --- a/qpid/cpp/include/qpid/messaging/Sender.h +++ b/qpid/cpp/include/qpid/messaging/Sender.h @@ -40,7 +40,7 @@ class Session; /** \ingroup messaging * Interface through which messages are sent. */ -class Sender : public qpid::messaging::Handle +class QPID_MESSAGING_CLASS_EXTERN Sender : public qpid::messaging::Handle { public: QPID_MESSAGING_EXTERN Sender(SenderImpl* impl = 0); diff --git a/qpid/cpp/include/qpid/messaging/Session.h b/qpid/cpp/include/qpid/messaging/Session.h index 6c023629e0..52786eb5f4 100644 --- a/qpid/cpp/include/qpid/messaging/Session.h +++ b/qpid/cpp/include/qpid/messaging/Session.h @@ -46,7 +46,7 @@ class SessionImpl; * A session represents a distinct 'conversation' which can involve * sending and receiving messages to and from different addresses. */ -class Session : public qpid::messaging::Handle +class QPID_MESSAGING_CLASS_EXTERN Session : public qpid::messaging::Handle { public: QPID_MESSAGING_EXTERN Session(SessionImpl* impl = 0); diff --git a/qpid/cpp/include/qpid/messaging/exceptions.h b/qpid/cpp/include/qpid/messaging/exceptions.h index 0ff608b343..07d1dc414b 100644 --- a/qpid/cpp/include/qpid/messaging/exceptions.h +++ b/qpid/cpp/include/qpid/messaging/exceptions.h @@ -32,7 +32,7 @@ namespace messaging { /** \ingroup messaging */ -struct MessagingException : public qpid::types::Exception +struct QPID_MESSAGING_CLASS_EXTERN MessagingException : public qpid::types::Exception { QPID_MESSAGING_EXTERN MessagingException(const std::string& msg); QPID_MESSAGING_EXTERN virtual ~MessagingException() throw(); @@ -41,22 +41,22 @@ struct MessagingException : public qpid::types::Exception //TODO: override what() to include detail if present }; -struct InvalidOptionString : public MessagingException +struct QPID_MESSAGING_CLASS_EXTERN InvalidOptionString : public MessagingException { QPID_MESSAGING_EXTERN InvalidOptionString(const std::string& msg); }; -struct KeyError : public MessagingException +struct QPID_MESSAGING_CLASS_EXTERN KeyError : public MessagingException { QPID_MESSAGING_EXTERN KeyError(const std::string&); }; -struct LinkError : public MessagingException +struct QPID_MESSAGING_CLASS_EXTERN LinkError : public MessagingException { QPID_MESSAGING_EXTERN LinkError(const std::string&); }; -struct AddressError : public LinkError +struct QPID_MESSAGING_CLASS_EXTERN AddressError : public LinkError { QPID_MESSAGING_EXTERN AddressError(const std::string&); }; @@ -65,17 +65,17 @@ struct AddressError : public LinkError * Thrown when a syntactically correct address cannot be resolved or * used. */ -struct ResolutionError : public AddressError +struct QPID_MESSAGING_CLASS_EXTERN ResolutionError : public AddressError { QPID_MESSAGING_EXTERN ResolutionError(const std::string& msg); }; -struct AssertionFailed : public ResolutionError +struct QPID_MESSAGING_CLASS_EXTERN AssertionFailed : public ResolutionError { QPID_MESSAGING_EXTERN AssertionFailed(const std::string& msg); }; -struct NotFound : public ResolutionError +struct QPID_MESSAGING_CLASS_EXTERN NotFound : public ResolutionError { QPID_MESSAGING_EXTERN NotFound(const std::string& msg); }; @@ -83,67 +83,67 @@ struct NotFound : public ResolutionError /** * Thrown when an address string with inalid sytanx is used. */ -struct MalformedAddress : public AddressError +struct QPID_MESSAGING_CLASS_EXTERN MalformedAddress : public AddressError { QPID_MESSAGING_EXTERN MalformedAddress(const std::string& msg); }; -struct ReceiverError : public LinkError +struct QPID_MESSAGING_CLASS_EXTERN ReceiverError : public LinkError { QPID_MESSAGING_EXTERN ReceiverError(const std::string&); }; -struct FetchError : public ReceiverError +struct QPID_MESSAGING_CLASS_EXTERN FetchError : public ReceiverError { QPID_MESSAGING_EXTERN FetchError(const std::string&); }; -struct NoMessageAvailable : public FetchError +struct QPID_MESSAGING_CLASS_EXTERN NoMessageAvailable : public FetchError { QPID_MESSAGING_EXTERN NoMessageAvailable(); }; -struct SenderError : public LinkError +struct QPID_MESSAGING_CLASS_EXTERN SenderError : public LinkError { QPID_MESSAGING_EXTERN SenderError(const std::string&); }; -struct SendError : public SenderError +struct QPID_MESSAGING_CLASS_EXTERN SendError : public SenderError { QPID_MESSAGING_EXTERN SendError(const std::string&); }; -struct TargetCapacityExceeded : public SendError +struct QPID_MESSAGING_CLASS_EXTERN TargetCapacityExceeded : public SendError { QPID_MESSAGING_EXTERN TargetCapacityExceeded(const std::string&); }; -struct SessionError : public MessagingException +struct QPID_MESSAGING_CLASS_EXTERN SessionError : public MessagingException { QPID_MESSAGING_EXTERN SessionError(const std::string&); }; -struct TransactionError : public SessionError +struct QPID_MESSAGING_CLASS_EXTERN TransactionError : public SessionError { QPID_MESSAGING_EXTERN TransactionError(const std::string&); }; -struct TransactionAborted : public TransactionError +struct QPID_MESSAGING_CLASS_EXTERN TransactionAborted : public TransactionError { QPID_MESSAGING_EXTERN TransactionAborted(const std::string&); }; -struct UnauthorizedAccess : public SessionError +struct QPID_MESSAGING_CLASS_EXTERN UnauthorizedAccess : public SessionError { QPID_MESSAGING_EXTERN UnauthorizedAccess(const std::string&); }; -struct ConnectionError : public MessagingException +struct QPID_MESSAGING_CLASS_EXTERN ConnectionError : public MessagingException { QPID_MESSAGING_EXTERN ConnectionError(const std::string&); }; -struct TransportFailure : public MessagingException +struct QPID_MESSAGING_CLASS_EXTERN TransportFailure : public MessagingException { QPID_MESSAGING_EXTERN TransportFailure(const std::string&); }; diff --git a/qpid/cpp/include/qpid/sys/IntegerTypes.h b/qpid/cpp/include/qpid/sys/IntegerTypes.h index 89635f033e..75fa921de0 100755 --- a/qpid/cpp/include/qpid/sys/IntegerTypes.h +++ b/qpid/cpp/include/qpid/sys/IntegerTypes.h @@ -21,7 +21,7 @@ * */ -#if (defined(_WINDOWS) || defined (WIN32)) && defined(_MSC_VER) +#if (defined(_WINDOWS) || defined (WIN32)) #include "qpid/sys/windows/IntegerTypes.h" #endif #if !defined _WINDOWS && !defined WIN32 diff --git a/qpid/cpp/include/qpid/sys/Runnable.h b/qpid/cpp/include/qpid/sys/Runnable.h index 0f1243a277..fed7663cb6 100644 --- a/qpid/cpp/include/qpid/sys/Runnable.h +++ b/qpid/cpp/include/qpid/sys/Runnable.h @@ -30,7 +30,7 @@ namespace sys { /** * Interface for objects that can be run, e.g. in a thread. */ -class Runnable +class QPID_COMMON_CLASS_EXTERN Runnable { public: /** Type to represent a runnable as a Functor */ diff --git a/qpid/cpp/include/qpid/sys/Time.h b/qpid/cpp/include/qpid/sys/Time.h index 154a068d83..9c5ac66e9a 100644 --- a/qpid/cpp/include/qpid/sys/Time.h +++ b/qpid/cpp/include/qpid/sys/Time.h @@ -119,7 +119,7 @@ class Duration { friend class AbsTime; public: - QPID_COMMON_EXTERN inline Duration(int64_t time0 = 0); + QPID_COMMON_INLINE_EXTERN inline Duration(int64_t time0 = 0); QPID_COMMON_EXTERN explicit Duration(const AbsTime& start, const AbsTime& finish); inline operator int64_t() const; }; diff --git a/qpid/cpp/include/qpid/types/Exception.h b/qpid/cpp/include/qpid/types/Exception.h index d061a7df0e..483d104cc8 100644 --- a/qpid/cpp/include/qpid/types/Exception.h +++ b/qpid/cpp/include/qpid/types/Exception.h @@ -28,7 +28,7 @@ namespace qpid { namespace types { -class Exception : public std::exception +class QPID_TYPES_CLASS_EXTERN Exception : public std::exception { public: QPID_TYPES_EXTERN explicit Exception(const std::string& message=std::string()) throw(); diff --git a/qpid/cpp/include/qpid/types/ImportExport.h b/qpid/cpp/include/qpid/types/ImportExport.h index bb10575fcd..8fa41884fb 100644 --- a/qpid/cpp/include/qpid/types/ImportExport.h +++ b/qpid/cpp/include/qpid/types/ImportExport.h @@ -20,14 +20,16 @@ * under the License. */ -#if defined(WIN32) && !defined(QPID_DECLARE_STATIC) +#include "qpid/ImportExport.h" + #if defined(TYPES_EXPORT) || defined (qpidtypes_EXPORTS) -#define QPID_TYPES_EXTERN __declspec(dllexport) -#else -#define QPID_TYPES_EXTERN __declspec(dllimport) -#endif +# define QPID_TYPES_EXTERN QPID_EXPORT +# define QPID_TYPES_CLASS_EXTERN QPID_CLASS_EXPORT +# define QPID_TYPES_INLINE_EXTERN QPID_INLINE_EXPORT #else -#define QPID_TYPES_EXTERN +# define QPID_TYPES_EXTERN QPID_IMPORT +# define QPID_TYPES_CLASS_EXTERN QPID_CLASS_IMPORT +# define QPID_TYPES_INLINE_EXTERN QPID_INLINE_IMPORT #endif #endif /*!QPID_TYPES_IMPORTEXPORT_H*/ diff --git a/qpid/cpp/include/qpid/types/Uuid.h b/qpid/cpp/include/qpid/types/Uuid.h index 467a895184..02af4c7e7f 100644 --- a/qpid/cpp/include/qpid/types/Uuid.h +++ b/qpid/cpp/include/qpid/types/Uuid.h @@ -29,7 +29,7 @@ namespace qpid { namespace types { -class Uuid +class QPID_TYPES_CLASS_EXTERN Uuid { public: static const size_t SIZE; diff --git a/qpid/cpp/include/qpid/types/Variant.h b/qpid/cpp/include/qpid/types/Variant.h index d9260133a7..4459fc4123 100644 --- a/qpid/cpp/include/qpid/types/Variant.h +++ b/qpid/cpp/include/qpid/types/Variant.h @@ -36,7 +36,7 @@ namespace types { /** * Thrown when an illegal conversion of a variant is attempted. */ -struct InvalidConversion : public Exception +struct QPID_TYPES_CLASS_EXTERN InvalidConversion : public Exception { InvalidConversion(const std::string& msg); }; @@ -67,7 +67,7 @@ class VariantImpl; /** * Represents a value of variable type. */ -class Variant +class QPID_TYPES_CLASS_EXTERN Variant { public: typedef std::map Map; -- cgit v1.2.1 From 0bab2f6cf49bbfc2db1089fc25d339315e92f2c1 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Wed, 18 May 2011 02:14:07 +0000 Subject: QPID-2905 - Code modifications to enable Windows builds with the mingw32 compiler. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1104662 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/sys/Thread.h | 6 +++++- qpid/cpp/include/qpid/sys/windows/IntegerTypes.h | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/sys/Thread.h b/qpid/cpp/include/qpid/sys/Thread.h index 45a39e796f..f556612908 100644 --- a/qpid/cpp/include/qpid/sys/Thread.h +++ b/qpid/cpp/include/qpid/sys/Thread.h @@ -25,7 +25,11 @@ #include "qpid/CommonImportExport.h" #ifdef _WIN32 -# define QPID_TSS __declspec(thread) +# ifdef _MSC_VER +# define QPID_TSS __declspec(thread) +# else +# define QPID_TSS __thread +# endif #elif defined (__GNUC__) # define QPID_TSS __thread #elif defined (__SUNPRO_CC) diff --git a/qpid/cpp/include/qpid/sys/windows/IntegerTypes.h b/qpid/cpp/include/qpid/sys/windows/IntegerTypes.h index ece1a618e9..fff320bc96 100755 --- a/qpid/cpp/include/qpid/sys/windows/IntegerTypes.h +++ b/qpid/cpp/include/qpid/sys/windows/IntegerTypes.h @@ -22,13 +22,17 @@ */ typedef unsigned char uint8_t; -typedef char int8_t; typedef unsigned short uint16_t; typedef short int16_t; typedef unsigned int uint32_t; typedef int int32_t; +#if defined(_MSC_VER) +typedef char int8_t; typedef unsigned __int64 uint64_t; typedef __int64 int64_t; +#else +#include +#endif // Visual Studio doesn't define other common types, so set them up here too. typedef unsigned int uint; -- cgit v1.2.1