diff options
| author | Andrew Stitcher <astitcher@apache.org> | 2013-07-26 21:32:44 +0000 |
|---|---|---|
| committer | Andrew Stitcher <astitcher@apache.org> | 2013-07-26 21:32:44 +0000 |
| commit | 829b53786a6786b05b5baee274337f3fdf988c6c (patch) | |
| tree | a4bf01804d3d141d2327f4eb24729be4c2c28b5a /qpid/cpp/include | |
| parent | bd5988effd007642ac56cb14ad7e980b78f249bd (diff) | |
| download | qpid-python-829b53786a6786b05b5baee274337f3fdf988c6c.tar.gz | |
QPID-4942: Only install include files that are used by the supported API
- Since we removed a whole lot of old API code we can drastically cut
down on the header files that we export.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1507469 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/include')
76 files changed, 0 insertions, 7654 deletions
diff --git a/qpid/cpp/include/qpid/Address.h b/qpid/cpp/include/qpid/Address.h deleted file mode 100755 index edb405db92..0000000000 --- a/qpid/cpp/include/qpid/Address.h +++ /dev/null @@ -1,56 +0,0 @@ -#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 <iosfwd> -#include <string> - -namespace qpid { -namespace client { struct ConnectionSettings; } - - -/** - * Contains the protocol address of an AMQP broker. - */ -struct Address { -public: - static const std::string TCP; // Default TCP protocol tag. - static const uint16_t AMQP_PORT=5672; // Default AMQP port. - - QPID_COMMON_INLINE_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); -QPID_COMMON_EXTERN bool operator!=(const Address& x, const Address& y); - -} // namespace qpid - -#endif /*!QPID_ADDRESS_H*/ diff --git a/qpid/cpp/include/qpid/CommonImportExport.h b/qpid/cpp/include/qpid/CommonImportExport.h deleted file mode 100644 index dd2b900b73..0000000000 --- a/qpid/cpp/include/qpid/CommonImportExport.h +++ /dev/null @@ -1,35 +0,0 @@ -#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. - */ - -#include "qpid/ImportExport.h" - -#if defined(COMMON_EXPORT) || defined (qpidcommon_EXPORTS) -# 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 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/InlineAllocator.h b/qpid/cpp/include/qpid/InlineAllocator.h deleted file mode 100644 index 2502545dcb..0000000000 --- a/qpid/cpp/include/qpid/InlineAllocator.h +++ /dev/null @@ -1,101 +0,0 @@ -#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 <memory> -#include <assert.h> -#include <boost/type_traits/type_with_alignment.hpp> -#include <boost/type_traits/alignment_of.hpp> - -namespace qpid { - -template <typename RequestedType, typename InlineType, typename BaseAllocator, size_t Max> -struct InlineRebind; - - -/** - * An allocator that has inline storage for up to Max objects - * of type BaseAllocator::value_type. - */ -template <class BaseAllocator, size_t Max> -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<value_type*>(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<typename T1> - struct rebind { - typedef typename InlineRebind<T1, value_type, BaseAllocator, Max>::other other; - }; - - private: - // POD object with alignment and size to hold Max value_types. - static const size_t ALIGNMENT=boost::alignment_of<value_type>::value; - typedef typename boost::type_with_alignment<ALIGNMENT>::type Aligner; - union Store { - Aligner aligner_; - char sizer_[sizeof(value_type)*Max]; - } store; - value_type* address() { return reinterpret_cast<value_type*>(&store); } - bool allocated; -}; - - -// Rebind: if RequestedType == InlineType, use the InlineAllocator, -// otherwise, use the BaseAllocator without any inlining. - -template <typename RequestedType, typename InlineType, typename BaseAllocator, size_t Max> -struct InlineRebind { - typedef typename BaseAllocator::template rebind<RequestedType>::other other; -}; - -template <typename T, typename BaseAllocator, size_t Max> -struct InlineRebind<T, T, BaseAllocator, Max> { - typedef typename qpid::InlineAllocator<BaseAllocator, Max> other; -}; - -} // namespace qpid - -#endif /*!QPID_INLINEALLOCATOR_H*/ diff --git a/qpid/cpp/include/qpid/InlineVector.h b/qpid/cpp/include/qpid/InlineVector.h deleted file mode 100644 index c55db295f3..0000000000 --- a/qpid/cpp/include/qpid/InlineVector.h +++ /dev/null @@ -1,68 +0,0 @@ -#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 <vector> - -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 T, size_t Max, class Alloc=std::allocator<T> > -class InlineVector : public std::vector<T, InlineAllocator<Alloc, Max> > -{ - typedef std::vector<T, InlineAllocator<Alloc, Max> > 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 deleted file mode 100644 index 5f0b11bc60..0000000000 --- a/qpid/cpp/include/qpid/Msg.h +++ /dev/null @@ -1,79 +0,0 @@ -#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 <sstream> -#include <iostream> -#include "qpid/types/ImportExport.h" - -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(); } - - 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 <class T> Msg& operator<<(const T& t) { os <<t; return *this; } -}; - - - -inline std::ostream& operator<<(std::ostream& o, const Msg& m) { - return o << m.str(); -} - -/** Construct a message using operator << and append (file:line) */ -#define QUOTE_(x) #x -#define QUOTE(x) QUOTE_(x) -#define QPID_MSG(message) (::qpid::Msg() << message << " (" __FILE__ ":" QUOTE(__LINE__) ")") - -} // namespace qpid - -#endif /*!QPID_MSG_H*/ diff --git a/qpid/cpp/include/qpid/Options.h b/qpid/cpp/include/qpid/Options.h deleted file mode 100644 index 6c908518b8..0000000000 --- a/qpid/cpp/include/qpid/Options.h +++ /dev/null @@ -1,193 +0,0 @@ -#ifndef QPID_COMMONOPTIONS_H -#define QPID_COMMONOPTIONS_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" - -// Disable warnings triggered by boost. -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable : 4251 4275) -#endif - -#include <boost/program_options.hpp> -#include <boost/format.hpp> - -#ifdef _MSC_VER -# pragma warning(pop) -#endif - -#include <sstream> -#include <iterator> -#include <algorithm> -#include <string> -#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 T> -class OptionValue : public po::typed_value<T> { - public: - OptionValue(T& value, const std::string& arg) - : po::typed_value<T>(&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: - * <name> (=<value>) - * T must support operator <<. - *@see Options for example of use. - */ -template<class T> -po::value_semantic* optValue(T& value, const char* name) { - std::string valstr(boost::lexical_cast<std::string>(value)); - return new OptionValue<T>(value, prettyArg(name, valstr)); -} - -/** Create a vector value. Multiple occurences of the option are - * accumulated into the vector - */ -template <class T> -po::value_semantic* optValue(std::vector<T>& value, const char* name) { - std::ostringstream os; - std::copy(value.begin(), value.end(), std::ostream_iterator<T>(os, " ")); - std::string val=os.str(); - if (!val.empty()) - val.erase(val.end()-1); // Remove trailing " " - return (new OptionValue<std::vector<T> >(value, prettyArg(name, val))); -} - -/** Create a boolean switch value. Presence of the option sets the value. */ -inline po::value_semantic* optValue(bool& value) { -#if (BOOST_VERSION >= 103500) - return (new OptionValue<bool>(value, ""))->implicit_value(true); -#else - return po::bool_switch(&value); -#endif -} - -inline po::value_semantic* pure_switch(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<string> 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 - */ - - - - -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); - - /** - * Tests for presence of argc/argv switch - */ - QPID_COMMON_EXTERN bool findArg(int argc, char const* const* argv, - const std::string& theArg); - - boost::program_options::options_description_easy_init addOptions() { - return add_options(); - } -}; - - - -/** - * Standard options for configuration - */ -struct CommonOptions : public Options { - QPID_COMMON_EXTERN CommonOptions(const std::string& name=std::string(), - const std::string& configfile=std::string(), - const std::string& clientConfigFile=std::string()); - bool help; - bool version; - std::string config; - std::string clientConfig; -}; - - - - -} // namespace qpid - -#endif /*!QPID_COMMONOPTIONS_H*/ diff --git a/qpid/cpp/include/qpid/RangeSet.h b/qpid/cpp/include/qpid/RangeSet.h deleted file mode 100644 index ef0ad032da..0000000000 --- a/qpid/cpp/include/qpid/RangeSet.h +++ /dev/null @@ -1,328 +0,0 @@ -#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 <boost/iterator/iterator_facade.hpp> -#include <boost/operators.hpp> -#include <boost/bind.hpp> -#include <algorithm> -#include <numeric> - -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 T> -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<T>& 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 <class S> 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 T> -class RangeSet - : boost::additive1<RangeSet<T>, - boost::additive2<RangeSet<T>, Range<T>, - boost::additive2<RangeSet<T>, T> > > -{ - typedef InlineVector<Range<T>, 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<T>; - friend class boost::iterator_core_access; - }; - - typedef iterator const_iterator; - - RangeSet() {} - explicit RangeSet(const Range<T>& r) { *this += r; } - RangeSet(const T& a, const T& b) { *this += Range<T>(a,b); } - - bool contiguous() const { return ranges.size() <= 1; } - - bool contains(const T& t) const; - bool contains(const Range<T>&) const; - - /**@pre contiguous() */ - Range<T> toRange() const; - - bool operator==(const RangeSet<T>&) const; - - void addRange (const Range<T>&); - void addSet (const RangeSet<T>&); - - RangeSet<T>& operator+=(const T& t) { return *this += Range<T>(t); } - RangeSet<T>& operator+=(const Range<T>& r) { addRange(r); return *this; } - RangeSet<T>& operator+=(const RangeSet<T>& s) { addSet(s); return *this; } - - void removeRange (const Range<T>&); - void removeSet (const RangeSet<T>&); - - RangeSet<T>& operator-=(const T& t) { return *this -= Range<T>(t); } - RangeSet<T>& operator-=(const Range<T>& r) { removeRange(r); return *this; } - RangeSet<T>& operator-=(const RangeSet<T>& 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<T> rangeContaining(const T&) const; - - template <class S> void serialize(S& s) { s.split(*this); s(ranges.begin(), ranges.end()); } - template <class S> void encode(S& s) const { s(uint16_t(ranges.size()*sizeof(Range<T>))); } - template <class S> void decode(S& s) { uint16_t sz; s(sz); ranges.resize(sz/sizeof(Range<T>)); } - - private: - static size_t accumulateSize(size_t s, const Range<T>& r) { return s+r.size(); } - Ranges ranges; - - template <class U> friend std::ostream& operator<<(std::ostream& o, const RangeSet<U>& r); - - friend class iterator; -}; - -template <class T> -std::ostream& operator<<(std::ostream& o, const Range<T>& r) { - return o << "[" << r.begin() << "," << r.end() << ")"; -} - -template <class T> -std::ostream& operator<<(std::ostream& o, const RangeSet<T>& rs) { - std::ostream_iterator<Range<T> > i(o, " "); - o << "{ "; - std::copy(rs.ranges.begin(), rs.ranges.end(), i); - return o << "}"; -} - -template <class T> -bool RangeSet<T>::contains(const T& t) const { - typename Ranges::const_iterator i = - std::lower_bound(ranges.begin(), ranges.end(), Range<T>(t)); - return i != ranges.end() && i->contains(t); -} - -template <class T> -bool RangeSet<T>::contains(const Range<T>& r) const { - typename Ranges::const_iterator i = - std::lower_bound(ranges.begin(), ranges.end(), r); - return i != ranges.end() && i->contains(r); -} - -template <class T> void RangeSet<T>::addRange(const Range<T>& 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); // No overlap - else { - i->merge(r); - typename Ranges::iterator j = i; - while (++j != ranges.end() && i->touching(*j)) - i->merge(*j); - ranges.erase(i+1,j); - } -} - - -template <class T> void RangeSet<T>::addSet(const RangeSet<T>& s) { - typedef RangeSet<T>& (RangeSet<T>::*RangeSetRangeOp)(const Range<T>&); - std::for_each(s.ranges.begin(), s.ranges.end(), - boost::bind((RangeSetRangeOp)&RangeSet<T>::operator+=, this, _1)); -} - -template <class T> void RangeSet<T>::removeRange(const Range<T>& 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<T> i1(i->begin(), r.begin()); - Range<T> 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() && r.end() > j->begin()) - j->begin(r.end()); // Truncate j - ranges.erase(i,j); - } -} - -template <class T> void RangeSet<T>::removeSet(const RangeSet<T>& r) { - std::for_each( - r.ranges.begin(), r.ranges.end(), - boost::bind(&RangeSet<T>::removeRange, this, _1)); -} - -template <class T> Range<T> RangeSet<T>::toRange() const { - assert(contiguous()); - return empty() ? Range<T>() : ranges.front(); -} - -template <class T> void RangeSet<T>::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 <class T> bool RangeSet<T>::operator==(const RangeSet<T>& r) const { - return ranges.size() == r.ranges.size() && std::equal(ranges.begin(), ranges.end(), r.ranges.begin()); -} - -template <class T> typename RangeSet<T>::iterator RangeSet<T>::begin() const { - return empty() ? end() : iterator(ranges, ranges.begin(), front()); -} - -template <class T> typename RangeSet<T>::iterator RangeSet<T>::end() const { - return iterator(); -} - -template <class T> bool RangeSet<T>::iterator::equal(const iterator& i) const { - return ranges==i.ranges && (ranges==0 || value==i.value); -} - -template <class T> Range<T> RangeSet<T>::rangeContaining(const T& t) const { - typename Ranges::const_iterator i = - std::lower_bound(ranges.begin(), ranges.end(), Range<T>(t)); - return (i != ranges.end() && i->contains(t)) ? *i : Range<T>(t,t); -} - -template <class T> uint32_t RangeSet<T>::span() const { - if (ranges.empty()) return 0; - return ranges.back().last() - ranges.front().first(); -} - -template <class T> size_t RangeSet<T>::size() const { - return std::accumulate(rangesBegin(), rangesEnd(), 0, &RangeSet<T>::accumulateSize); -} - -} // namespace qpid - - -#endif /*!QPID_RANGESET_H*/ diff --git a/qpid/cpp/include/qpid/SessionId.h b/qpid/cpp/include/qpid/SessionId.h deleted file mode 100644 index e18b360999..0000000000 --- a/qpid/cpp/include/qpid/SessionId.h +++ /dev/null @@ -1,60 +0,0 @@ -#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 <boost/operators.hpp> -#include <string> -#include <qpid/CommonImportExport.h> - -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<SessionId> { - 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 deleted file mode 100644 index f9ed87c24b..0000000000 --- a/qpid/cpp/include/qpid/Url.h +++ /dev/null @@ -1,96 +0,0 @@ -#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 <string> -#include <vector> -#include <new> -#include <ostream> -#include "qpid/CommonImportExport.h" - -namespace qpid { - -/** An AMQP URL contains a list of addresses */ -struct Url : public std::vector<Address> { - - struct Invalid : public Exception { QPID_COMMON_EXTERN 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 std::string& url, const std::string& defaultProtocol) { parse(url.c_str(), defaultProtocol); } - - /** Parse url, throw Invalid if invalid. */ - explicit Url(const char* url) { parse(url); } - - 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 - *@exception Invalid if the url is invalid. - */ - QPID_COMMON_EXTERN void parse(const char* url); - QPID_COMMON_EXTERN void parse(const char* url, const std::string& defaultProtocol); - 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); - QPID_COMMON_EXTERN void parseNoThrow(const char* url, const std::string& defaultProtocol); - - /** Add a protocol tag to be recognzed in URLs. - * Only for use by protcol plug-in initializers. - */ - 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. - std::string user, pass; - - friend class UrlParser; -}; - -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/amqp_0_10/Codecs.h b/qpid/cpp/include/qpid/amqp_0_10/Codecs.h deleted file mode 100644 index 408307eb7a..0000000000 --- a/qpid/cpp/include/qpid/amqp_0_10/Codecs.h +++ /dev/null @@ -1,86 +0,0 @@ -#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/CommonImportExport.h" -#include "qpid/types/Variant.h" -#include "boost/shared_ptr.hpp" - -namespace qpid { -namespace framing { -class FieldTable; -class FieldValue; -} -namespace amqp_0_10 { -/** - * Codec for encoding/decoding a map of Variants using the AMQP 0-10 - * map encoding. - */ -class QPID_COMMON_CLASS_EXTERN MapCodec -{ - public: - typedef qpid::types::Variant::Map ObjectType; - static void QPID_COMMON_EXTERN encode(const ObjectType&, std::string&); - static void QPID_COMMON_EXTERN decode(const std::string&, ObjectType&); - static size_t QPID_COMMON_EXTERN encodedSize(const ObjectType&); - static const QPID_COMMON_EXTERN std::string contentType; - private: -}; - -/** - * Codec for encoding/decoding a list of Variants using the AMQP 0-10 - * list encoding. - */ -class QPID_COMMON_CLASS_EXTERN ListCodec -{ - public: - typedef qpid::types::Variant::List ObjectType; - static void QPID_COMMON_EXTERN encode(const ObjectType&, std::string&); - static void QPID_COMMON_EXTERN decode(const std::string&, ObjectType&); - static size_t QPID_COMMON_EXTERN encodedSize(const ObjectType&); - static const QPID_COMMON_EXTERN std::string contentType; - private: -}; - -/** - * @internal - * - * Conversion functions between qpid::types:Variant::Map and the - * deprecated qpid::framing::FieldTable. - * - */ -QPID_COMMON_EXTERN void translate(const qpid::types::Variant::Map& from, - qpid::framing::FieldTable& to); -QPID_COMMON_EXTERN void translate(const qpid::types::Variant::Map& from, const std::string& efield, const qpid::types::Variant& evalue, - qpid::framing::FieldTable& to); -QPID_COMMON_EXTERN void translate(const qpid::framing::FieldTable& from, - qpid::types::Variant::Map& to); - -QPID_COMMON_EXTERN void translate(const boost::shared_ptr<qpid::framing::FieldValue> from, - qpid::types::Variant& to); -QPID_COMMON_EXTERN void translate(const types::Variant& from, - boost::shared_ptr<qpid::framing::FieldValue> to); - -}} // namespace qpid::amqp_0_10 - -#endif /*!QPID_AMQP_0_10_CODECS_H*/ diff --git a/qpid/cpp/include/qpid/client/AsyncSession.h b/qpid/cpp/include/qpid/client/AsyncSession.h deleted file mode 100644 index d91efeb4f1..0000000000 --- a/qpid/cpp/include/qpid/client/AsyncSession.h +++ /dev/null @@ -1,38 +0,0 @@ -#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 deleted file mode 100644 index 2a3a5a52e9..0000000000 --- a/qpid/cpp/include/qpid/client/ClientImportExport.h +++ /dev/null @@ -1,35 +0,0 @@ -#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. - */ - -#include "qpid/ImportExport.h" - -#if defined(CLIENT_EXPORT) || defined (qpidclient_EXPORTS) -# 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 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 deleted file mode 100644 index 9546db9258..0000000000 --- a/qpid/cpp/include/qpid/client/Completion.h +++ /dev/null @@ -1,71 +0,0 @@ -#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 <string> - -namespace qpid { -namespace client { - -class CompletionImpl; -template <class T> 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 QPID_CLIENT_CLASS_EXTERN Completion : public Handle<CompletionImpl> -{ -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<Completion>; -}; - -}} - - -#endif /*!QPID_CLIENT_COMPLETION_H*/ diff --git a/qpid/cpp/include/qpid/client/Connection.h b/qpid/cpp/include/qpid/client/Connection.h deleted file mode 100644 index c0db0f301d..0000000000 --- a/qpid/cpp/include/qpid/client/Connection.h +++ /dev/null @@ -1,228 +0,0 @@ -#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 <map> -#include <string> -#include "qpid/client/Session.h" -#include "qpid/client/ClientImportExport.h" -#include "qpid/client/ConnectionSettings.h" -#include "qpid/framing/ProtocolVersion.h" - -#include "boost/function.hpp" - -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 - * - * 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 = <as per http://www.ietf.org/rfc/rfc3986.txt> - * port = number]]> - * - */ - -class QPID_CLIENT_CLASS_EXTERN Connection -{ - framing::ProtocolVersion version; - - boost::function<void ()> failureCallback; - - - protected: - boost::shared_ptr<ConnectionImpl> impl; - - - public: - /** - * 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(); - - /** - * 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 = "", - const std::string& pwd = "", - 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 = "", - const std::string& pwd = "", - 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 <qpid/client/AsyncSession.h> - * 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; - - /** In a cluster, returns the initial set of known broker URLs - * at the time of connection. - */ - QPID_CLIENT_EXTERN std::vector<Url> getInitialBrokers(); - - QPID_CLIENT_EXTERN void registerFailureCallback ( boost::function<void ()> fn ); - - /** - * Return the set of client negotiated settings - */ - QPID_CLIENT_EXTERN const ConnectionSettings& getNegotiatedSettings(); - - friend struct 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 deleted file mode 100644 index a0c209badf..0000000000 --- a/qpid/cpp/include/qpid/client/ConnectionSettings.h +++ /dev/null @@ -1,140 +0,0 @@ -#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/client/ClientImportExport.h" -#include "qpid/framing/FieldTable.h" -#include "qpid/sys/IntegerTypes.h" -#include <string> - -namespace qpid { - -namespace sys { -class Socket; -} - -namespace client { - -/** - * Settings for a Connection. - */ -struct QPID_CLIENT_CLASS_EXTERN 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. - */ - 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; - /** - * SSL cert-name for the connection. Overrides global SSL - * settings. Used only when a client connects to the broker. - */ - std::string sslCertName; - - /** - * Passed as client-propreties on opening the connecction. - */ - framing::FieldTable clientProperties; -}; - -}} // namespace qpid::client - -#endif /*!QPID_CLIENT_CONNECTIONSETTINGS_H*/ diff --git a/qpid/cpp/include/qpid/client/FailoverListener.h b/qpid/cpp/include/qpid/client/FailoverListener.h deleted file mode 100644 index 53c7c26211..0000000000 --- a/qpid/cpp/include/qpid/client/FailoverListener.h +++ /dev/null @@ -1,88 +0,0 @@ -#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 <vector> - -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 QPID_CLIENT_CLASS_EXTERN 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<Url> getKnownBrokers(const Message& m); - - /** 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. */ - QPID_CLIENT_EXTERN std::vector<Url> getKnownBrokers() const; - - private: - void received(Message& msg); - void run(); - void init(bool); - - mutable sys::Mutex lock; - Connection connection; - Session session; - SubscriptionManager subscriptions; - sys::Thread thread; - std::vector<Url> 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 deleted file mode 100644 index bc739fd0f5..0000000000 --- a/qpid/cpp/include/qpid/client/FailoverManager.h +++ /dev/null @@ -1,138 +0,0 @@ -#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/Exception.h" -#include "qpid/client/AsyncSession.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 <vector> - -namespace qpid { -namespace client { - -struct CannotConnectException : qpid::Exception -{ - CannotConnectException(const std::string& m) : qpid::Exception(m) {} -}; - -/** - * Utility to manage failover. - */ -class QPID_CLIENT_CLASS_EXTERN 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<Url>& 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); - QPID_CLIENT_EXTERN ~FailoverManager(); - /** - * 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<Url> brokers = std::vector<Url>()); - /** - * 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; - std::auto_ptr<FailoverListener> failoverListener; - ConnectionSettings settings; - ReconnectionStrategy* strategy; - State state; - - void attempt(Connection&, ConnectionSettings settings, std::vector<Url> 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 deleted file mode 100644 index bff7071b3b..0000000000 --- a/qpid/cpp/include/qpid/client/FlowControl.h +++ /dev/null @@ -1,75 +0,0 @@ -#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 <qpid/sys/IntegerTypes.h> - -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 deleted file mode 100644 index 630a7e03c0..0000000000 --- a/qpid/cpp/include/qpid/client/Future.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -#ifndef _Future_ -#define _Future_ - -#include <boost/bind.hpp> -#include <boost/shared_ptr.hpp> -#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 QPID_CLIENT_CLASS_EXTERN Future -{ - framing::SequenceNumber command; - boost::shared_ptr<FutureResult> 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<FutureResult> r); -}; - -}} - -#endif diff --git a/qpid/cpp/include/qpid/client/FutureCompletion.h b/qpid/cpp/include/qpid/client/FutureCompletion.h deleted file mode 100644 index 0970f494b7..0000000000 --- a/qpid/cpp/include/qpid/client/FutureCompletion.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -#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 deleted file mode 100644 index ead4929571..0000000000 --- a/qpid/cpp/include/qpid/client/FutureResult.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -#ifndef _FutureResult_ -#define _FutureResult_ - -#include <string> - -#include "qpid/client/ClientImportExport.h" -#include "qpid/framing/amqp_framing.h" -#include "qpid/client/FutureCompletion.h" - -namespace qpid { -namespace client { - -class SessionImpl; - -///@internal -class QPID_CLIENT_CLASS_EXTERN 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 deleted file mode 100644 index b8315481a9..0000000000 --- a/qpid/cpp/include/qpid/client/Handle.h +++ /dev/null @@ -1,71 +0,0 @@ -#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> 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 T> class Handle { - public: - - /**@return true if handle is valid, i.e. not null. */ - 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_INLINE_EXTERN bool isNull() const { return !impl; } - - /** Conversion to bool supports idiom if (handle) { handle->... } */ - QPID_CLIENT_INLINE_EXTERN operator bool() const { return impl; } - - /** Operator ! supports idiom if (!handle) { do_if_handle_is_null(); } */ - QPID_CLIENT_INLINE_EXTERN bool operator !() const { return !impl; } - - void swap(Handle<T>& h) { T* t = h.impl; h.impl = impl; impl = t; } - - protected: - typedef T Impl; - QPID_CLIENT_INLINE_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<T>; // 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 deleted file mode 100644 index 1a19a8499d..0000000000 --- a/qpid/cpp/include/qpid/client/LocalQueue.h +++ /dev/null @@ -1,120 +0,0 @@ -#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 T> 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 - * - * <pre> - * 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; - * } - * </pre> - * - * <h2>Getting Messages</h2> - * - * <ul><li> - * <p>get()</p> - * <pre>Message message = local_queue.get();</pre> - * <pre>// Specifying timeouts (TIME_SEC, TIME_MSEC, TIME_USEC, TIME_NSEC) - *#include <qpid/sys/Time.h> - *Message message; - *local_queue.get(message, 5*sys::TIME_SEC);</pre></li></ul> - * - * <h2>Checking size</h2> - * <ul><li> - * <p>empty()</p> - * <pre>if (local_queue.empty()) { ... }</pre></li> - * <li><p>size()</p> - * <pre>std::cout << local_queue.size();</pre></li> - * </ul> - */ - -class QPID_CLIENT_CLASS_EXTERN LocalQueue : public Handle<LocalQueueImpl> { - 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<LocalQueue>; -}; - -}} // 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 deleted file mode 100644 index ba50dda9ba..0000000000 --- a/qpid/cpp/include/qpid/client/Message.h +++ /dev/null @@ -1,175 +0,0 @@ -#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 <string> - -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 - * - * <h2>Getting and setting message contents</h2> - * - * <ul> - * <li> - * <p>getData()</p> - * <pre>std::cout << "Response: " << message.getData() << std::endl;</pre> - * </li> - * <li> - * <p>setData()</p> - * <pre>message.setData("That's all, folks!");</pre></li> - * <li> - * <p>appendData()</p> - * <pre>message.appendData(" ... let's add a bit more ...");</pre></li> - * </ul> - * - * <h2>Getting and Setting Delivery Properties</h2> - * - * <ul> - * <li> - * <p>getDeliveryProperties()</p> - * <pre>message.getDeliveryProperties().setRoutingKey("control");</pre> - * <pre>message.getDeliveryProperties().setDeliveryMode(PERSISTENT);</pre> - * <pre>message.getDeliveryProperties().setPriority(9);</pre> - * <pre>message.getDeliveryProperties().setTtl(100);</pre></li> - * - * <li> - * <p>hasDeliveryProperties()</p> - * <pre>if (! message.hasDeliveryProperties()) { - * ... - *}</pre></li> - * </ul> - * - * <h2>Getting and Setting Message Properties</h2> - * - * <ul> - * <li> - * <p>getMessageProperties()</p> - * <pre> - *request.getMessageProperties().setReplyTo(ReplyTo("amq.direct", response_queue.str())); - * </pre> - * <pre> - *routingKey = request.getMessageProperties().getReplyTo().getRoutingKey(); - *exchange = request.getMessageProperties().getReplyTo().getExchange(); - * </pre> - * <pre>message.getMessageProperties().setContentType("text/plain");</pre> - * <pre>message.getMessageProperties().setContentEncoding("text/plain");</pre> - * </li> - * <li> - * <p>hasMessageProperties()</p> - * <pre>request.getMessageProperties().hasReplyTo();</pre> - * </li> - * </ul> - * - * <h2>Getting and Setting Application Headers</h2> - * - * <ul> - * <li> - * <p>getHeaders()</p> - * <pre> - *message.getHeaders().getString("control"); - * </pre> - * <pre> - *message.getHeaders().setString("control","continue"); - * </pre></li> - * </ul> - * - * - */ -class QPID_CLIENT_CLASS_EXTERN 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 deleted file mode 100644 index 3ca2fa964a..0000000000 --- a/qpid/cpp/include/qpid/client/MessageListener.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -#include <string> -#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 - * - * <h2>Using a MessageListener</h2> - * - * <ul> - * <li> - * <p>The received() function is called when a message arrives:</p> - * <pre>virtual void received(Message& message)=0;</pre> - * </li> - * <li> - * <p>Derive your own listener, implement the received() function:</p> - * <pre> - * 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()); - * } - * } - *</pre> - * <pre> - * 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(); - * </pre> - * </li> - * </ul> - * - */ - - class QPID_CLIENT_CLASS_EXTERN 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 deleted file mode 100644 index 06a3f29c7d..0000000000 --- a/qpid/cpp/include/qpid/client/MessageReplayTracker.h +++ /dev/null @@ -1,73 +0,0 @@ -#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 <list> -#include <string> - -namespace qpid { -namespace client { - -/** - * Utility to track messages sent asynchronously, allowing those that - * are indoubt to be replayed over a new session. - */ -class QPID_CLIENT_CLASS_EXTERN 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 <class F> void foreach(F& f) { - for (std::list<ReplayRecord>::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<ReplayRecord> 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 deleted file mode 100644 index 3984b63fdd..0000000000 --- a/qpid/cpp/include/qpid/client/QueueOptions.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -#include "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 QPID_CLIENT_CLASS_EXTERN 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. - * - * 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; - 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 deleted file mode 100644 index c40549bbc5..0000000000 --- a/qpid/cpp/include/qpid/client/Session.h +++ /dev/null @@ -1,39 +0,0 @@ -#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 deleted file mode 100644 index 630987c11d..0000000000 --- a/qpid/cpp/include/qpid/client/SessionBase_0_10.h +++ /dev/null @@ -1,109 +0,0 @@ -#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 <string> - -namespace qpid { -namespace client { - -class Connection; -class SessionImpl; - -using qpid::framing::Content; -using qpid::framing::FieldTable; -using qpid::framing::SequenceNumber; -using qpid::framing::SequenceSet; -using qpid::framing::SequenceNumberSet; -using qpid::SessionId; -using qpid::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 QPID_CLIENT_CLASS_EXTERN 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; - - QPID_CLIENT_EXTERN Connection getConnection(); - protected: - boost::shared_ptr<SessionImpl> 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 deleted file mode 100644 index bb9b98e8ff..0000000000 --- a/qpid/cpp/include/qpid/client/Subscription.h +++ /dev/null @@ -1,123 +0,0 @@ -#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> 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 QPID_CLIENT_CLASS_EXTERN Subscription : public Handle<SubscriptionImpl> { - 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_INLINE_EXTERN void acquire(const Message& m) { acquire(SequenceSet(m.getId())); } - - /* Accept a single message */ - QPID_CLIENT_INLINE_EXTERN void accept(const Message& m) { accept(SequenceSet(m.getId())); } - - /* Release a single message */ - 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; - - /** 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<Subscription>; - 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 deleted file mode 100644 index 404a9c6eb9..0000000000 --- a/qpid/cpp/include/qpid/client/SubscriptionManager.h +++ /dev/null @@ -1,292 +0,0 @@ -#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 <string> - -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 - * - * <h2>Subscribing and canceling subscriptions</h2> - * - * <ul> - * <li> - * <p>subscribe()</p> - * <pre> SubscriptionManager subscriptions(session); - * Listener listener(subscriptions); - * subscriptions.subscribe(listener, myQueue);</pre> - * <pre> SubscriptionManager subscriptions(session); - * LocalQueue local_queue; - * subscriptions.subscribe(local_queue, string("message_queue"));</pre></li> - * <li> - * <p>cancel()</p> - * <pre>subscriptions.cancel();</pre></li> - * </ul> - * - * <h2>Waiting for messages (and returning)</h2> - * - * <ul> - * <li> - * <p>run()</p> - * <pre> // Give up control to receive messages - * subscriptions.run();</pre></li> - * <li> - * <p>stop()</p> - * <pre>.// Use this code in a listener to return from run() - * subscriptions.stop();</pre></li> - * <li> - * <p>setAutoStop()</p> - * <pre>.// Return from subscriptions.run() when last subscription is cancelled - *.subscriptions.setAutoStop(true); - *.subscriptons.run(); - * </pre></li> - * <li> - * <p>Ending a subscription in a listener</p> - * <pre> - * void Listener::received(Message& message) { - * - * if (message.getData() == "That's all, folks!") { - * subscriptions.cancel(message.getDestination()); - * } - * } - * </pre> - * </li> - * </ul> - * - */ -class QPID_CLIENT_CLASS_EXTERN SubscriptionManager : public sys::Runnable, public Handle<SubscriptionManagerImpl> -{ - 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. - * (Note: this currently uses a subscription per invocation and is - * thus relatively expensive. The subscription is cancelled as - * part of each call which can trigger auto-deletion). - *@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. - * (Note: this currently uses a subscription per invocation and is - * thus relatively expensive. The subscription is cancelled as - * part of each call which can trigger auto-deletion). - *@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<void ()> fh ); - - QPID_CLIENT_EXTERN Session getSession() const; - - SubscriptionManager(SubscriptionManagerImpl*); ///<@internal - - private: - typedef SubscriptionManagerImpl Impl; - friend class PrivateImplRef<SubscriptionManager>; -}; - -/** AutoCancel cancels a subscription in its destructor */ -class AutoCancel { - public: - AutoCancel(SubscriptionManager&, const std::string& tag); - ~AutoCancel(); - 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 deleted file mode 100644 index bee39f6816..0000000000 --- a/qpid/cpp/include/qpid/client/SubscriptionSettings.h +++ /dev/null @@ -1,135 +0,0 @@ -#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 qpid::framing::message::AcceptMode; -using qpid::framing::message::AcquireMode; -using qpid::framing::message::ACCEPT_MODE_EXPLICIT; -using qpid::framing::message::ACCEPT_MODE_NONE; -using qpid::framing::message::ACQUIRE_MODE_NOT_ACQUIRED; -using qpid::framing::message::ACQUIRE_MODE_PRE_ACQUIRED; -using qpid::framing::message::CREDIT_UNIT_BYTE; -using qpid::framing::message::CREDIT_UNIT_MESSAGE; -using qpid::framing::message::DELIVERY_MODE_NON_PERSISTENT; -using qpid::framing::message::DELIVERY_MODE_PERSISTENT; -using qpid::framing::message::FLOW_MODE_CREDIT; -using qpid::framing::message::FLOW_MODE_WINDOW; - - -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 - /** - * 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 - - /** - * 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 - * 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 deleted file mode 100644 index 8e1a16580c..0000000000 --- a/qpid/cpp/include/qpid/client/TypedResult.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -#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 T> 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/framing/Array.h b/qpid/cpp/include/qpid/framing/Array.h deleted file mode 100644 index 6254f6271a..0000000000 --- a/qpid/cpp/include/qpid/framing/Array.h +++ /dev/null @@ -1,99 +0,0 @@ -#ifndef QPID_FRAMING_ARRAY_H -#define QPID_FRAMING_ARRAY_H - -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -#include "qpid/framing/amqp_types.h" -#include "qpid/framing/TypeCode.h" - -#include <boost/shared_ptr.hpp> - -#include <iostream> -#include <vector> - -#include "qpid/CommonImportExport.h" - -namespace qpid { -namespace framing { - -class Buffer; -class FieldValue; - -class QPID_COMMON_CLASS_EXTERN Array -{ - public: - typedef boost::shared_ptr<FieldValue> ValuePtr; - typedef std::vector<ValuePtr> 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<std::string>& in); - - QPID_COMMON_INLINE_EXTERN TypeCode getType() const { return type; } - - // std collection interface. - 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_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_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_INLINE_EXTERN void add(ValuePtr value) { push_back(value); } - - // For use in standard algorithms - template <typename R, typename V> - static R get(const V& v) { - return v->template get<R>(); - } - - 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 deleted file mode 100644 index 166b524e3c..0000000000 --- a/qpid/cpp/include/qpid/framing/Buffer.h +++ /dev/null @@ -1,115 +0,0 @@ -#ifndef QPID_FRAMING_BUFFER_H -#define QPID_FRAMING_BUFFER_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/CommonImportExport.h" -#include "qpid/sys/IntegerTypes.h" - -#include <string> - -namespace qpid { -namespace framing { - -struct QPID_COMMON_CLASS_EXTERN OutOfBounds : qpid::Exception { - OutOfBounds() : qpid::Exception(std::string("Out of Bounds")) {} -}; - -class Content; -class FieldTable; - -class QPID_COMMON_CLASS_EXTERN Buffer -{ - uint32_t size; - char* data; - uint32_t position; - - public: - void checkAvailable(size_t count) { if (count > size - position) throw OutOfBounds(); } - - QPID_COMMON_EXTERN Buffer(char* data=0, uint32_t size=0); - - QPID_COMMON_EXTERN void reset(); - - QPID_COMMON_INLINE_EXTERN uint32_t available() const{ return size - position; } - QPID_COMMON_INLINE_EXTERN uint32_t getSize() const { return size; } - QPID_COMMON_INLINE_EXTERN uint32_t getPosition() const { return position; } - QPID_COMMON_INLINE_EXTERN void setPosition(uint32_t p) { position = p; } - QPID_COMMON_INLINE_EXTERN const char * getPointer() const { return data; } - QPID_COMMON_INLINE_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 <int n> - QPID_COMMON_EXTERN uint64_t getUInt(); - - template <int n> - QPID_COMMON_EXTERN void putUInt(uint64_t); - - 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 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); - - template <class T> void put(const T& data) { data.encode(*this); } - template <class T> 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 deleted file mode 100644 index 1986a72d10..0000000000 --- a/qpid/cpp/include/qpid/framing/FieldTable.h +++ /dev/null @@ -1,139 +0,0 @@ -#ifndef _FieldTable_ -#define _FieldTable_ - -/* - * - * 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/sys/Mutex.h" - -#include <boost/shared_ptr.hpp> -#include <boost/shared_array.hpp> - -#include <iosfwd> -#include <map> - -#include "qpid/CommonImportExport.h" - -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<FieldValue> ValuePtr; - typedef std::map<std::string, ValuePtr> 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; - - QPID_COMMON_EXTERN FieldTable(); - QPID_COMMON_EXTERN FieldTable(const FieldTable&); - QPID_COMMON_EXTERN FieldTable& operator=(const FieldTable&); - // Compiler default destructor fine - 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_INLINE_EXTERN size_t size() const { return values.size(); } - QPID_COMMON_INLINE_EXTERN bool empty() { return size() == 0; } - QPID_COMMON_EXTERN void set(const std::string& name, const ValuePtr& value); - QPID_COMMON_EXTERN ValuePtr get(const std::string& name) const; - 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); - 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; - //QPID_COMMON_EXTERN bool getTimestamp(const std::string& name, uint64_t& value) const; - //QPID_COMMON_EXTERN 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. - QPID_COMMON_EXTERN ValueMap::const_iterator begin() const; - QPID_COMMON_EXTERN ValueMap::const_iterator end() const; - QPID_COMMON_EXTERN ValueMap::const_iterator find(const std::string& s) const; - - QPID_COMMON_EXTERN ValueMap::iterator begin(); - QPID_COMMON_EXTERN ValueMap::iterator end(); - QPID_COMMON_EXTERN ValueMap::iterator find(const std::string& s); - - QPID_COMMON_EXTERN std::pair <ValueMap::iterator, bool> insert(const ValueMap::value_type&); - QPID_COMMON_EXTERN ValueMap::iterator insert(ValueMap::iterator, const ValueMap::value_type&); - QPID_COMMON_EXTERN void clear(); - - private: - void realDecode() const; - void flushRawCache(); - - mutable qpid::sys::Mutex lock; - mutable ValueMap values; - mutable boost::shared_array<uint8_t> cachedBytes; - mutable uint32_t cachedSize; // if = 0 then non cached size as 0 is not a legal size - mutable bool newBytes; - - 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 deleted file mode 100644 index 1adcb2fa07..0000000000 --- a/qpid/cpp/include/qpid/framing/FieldValue.h +++ /dev/null @@ -1,484 +0,0 @@ -#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 <iostream> -#include <memory> -#include <vector> - -#include <assert.h> - -namespace qpid { -namespace framing { - -/** - * Exception that is the base exception for all field table errors. - * - * \ingroup clientapi - */ -class QPID_COMMON_CLASS_EXTERN FieldValueException : public qpid::Exception {}; - -/** - * Exception thrown when we can't perform requested conversion - * - * \ingroup clientapi - */ -struct QPID_COMMON_CLASS_EXTERN InvalidConversionException : public FieldValueException { - InvalidConversionException() {} -}; - -class List; - -/** - * Value that can appear in an AMQP field table - * - * \ingroup clientapi - */ -class QPID_COMMON_CLASS_EXTERN 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); - 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; } - void encode(Buffer& buffer); - void decode(Buffer& buffer); - QPID_COMMON_EXTERN bool operator==(const FieldValue&) const; - QPID_COMMON_INLINE_EXTERN bool operator!=(const FieldValue& v) const { return !(*this == v); } - - QPID_COMMON_EXTERN void print(std::ostream& out) const; - - template <typename T> bool convertsTo() const { return false; } - template <typename T> T get() const { throw InvalidConversionException(); } - - template <class T, int W> T getIntegerValue() const; - template <class T> T getIntegerValue() const; - template <class T, int W> T getFloatingPointValue() const; - template <int W> void getFixedWidthValue(unsigned char*) const; - template <class T> bool get(T&) const; - - protected: - FieldValue(uint8_t t, Data* d): typeOctet(t), data(d) {} - - QPID_COMMON_EXTERN static uint8_t* convertIfRequired(uint8_t* const octets, int width); - - private: - uint8_t typeOctet; - std::auto_ptr<Data> data; - -}; - -template <> -inline bool FieldValue::convertsTo<int>() const { return data->convertsToInt(); } - -template <> -inline bool FieldValue::convertsTo<int64_t>() const { return data->convertsToInt(); } - -template <> -inline bool FieldValue::convertsTo<std::string>() const { return data->convertsToString(); } - -template <> -inline int FieldValue::get<int>() const { return static_cast<int>(data->getInt()); } - -template <> -inline int64_t FieldValue::get<int64_t>() const { return data->getInt(); } - -template <> -inline std::string FieldValue::get<std::string>() const { return data->getString(); } - -inline std::ostream& operator<<(std::ostream& out, const FieldValue& v) { - v.print(out); - return out; -} - -template <int width> -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<width>* rhs = dynamic_cast< const FixedWidthValue<width>* >(&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; } - const uint8_t* rawOctets() const { return octets; } - - void print(std::ostream& o) const { o << "F" << width << ":"; }; -}; - -class UuidData : public FixedWidthValue<16> { - public: - UuidData(); - UuidData(const unsigned char* bytes); - bool convertsToString() const; - std::string getString() const; -}; - -template <class T, int W> -inline T FieldValue::getIntegerValue() const -{ - FixedWidthValue<W>* const fwv = dynamic_cast< FixedWidthValue<W>* 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 <class T> -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 <class T, int W> -inline T FieldValue::getFloatingPointValue() const { - FixedWidthValue<W>* const fwv = dynamic_cast< FixedWidthValue<W>* const>(data.get()); - if (fwv) { - T value; - uint8_t* const octets = convertIfRequired(fwv->rawOctets(), W); - uint8_t* const target = reinterpret_cast<uint8_t*>(&value); - for (size_t i = 0; i < W; ++i) target[i] = octets[i]; - return value; - } else { - throw InvalidConversionException(); - } -} - -template <int W> void FieldValue::getFixedWidthValue(unsigned char* value) const -{ - FixedWidthValue<W>* const fwv = dynamic_cast< FixedWidthValue<W>* const>(data.get()); - if (fwv) { - for (size_t i = 0; i < W; ++i) value[i] = fwv->rawOctets()[i]; - } else { - throw InvalidConversionException(); - } -} - -template <> -inline float FieldValue::get<float>() const { - return getFloatingPointValue<float, 4>(); -} - -template <> -inline double FieldValue::get<double>() const { - return getFloatingPointValue<double, 8>(); -} - -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 <int lenwidth> -class VariableWidthValue : public FieldValue::Data { - std::vector<uint8_t> octets; - - public: - VariableWidthValue() {} - VariableWidthValue(const std::vector<uint8_t>& 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<lenwidth>(octets.size()); - if (octets.size() > 0) - buffer.putRawData(&octets[0], octets.size()); - }; - void decode(Buffer& buffer) { - uint32_t len = buffer.getUInt<lenwidth>(); - buffer.checkAvailable(len); - octets.resize(len); - if (len > 0) - buffer.getRawData(&octets[0], len); - } - bool operator==(const Data& d) const { - const VariableWidthValue<lenwidth>* rhs = dynamic_cast< const VariableWidthValue<lenwidth>* >(&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 T> -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<T>* rhs = dynamic_cast< const EncodedValue<T>* >(&d); - if (rhs == 0) return false; - else return value==rhs->value; - } - - void print(std::ostream& o) const { o << "[" << value << "]"; }; -}; - -/** - * Accessor that can be used to get values of type FieldTable, Array - * and List. - */ -template <class T> -inline bool FieldValue::get(T& t) const -{ - const EncodedValue<T>* v = dynamic_cast< EncodedValue<T>* >(data.get()); - if (v != 0) { - t = v->getValue(); - return true; - } else { - try { - t = get<T>(); - return true; - } catch (const InvalidConversionException&) { - return false; - } - } -} - -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 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); -}; - -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: - typedef FieldTable ValueType; - QPID_COMMON_EXTERN FieldTableValue(const FieldTable&); -}; - -class ArrayValue : public FieldValue { - public: - 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&); -}; - -class UuidValue : public FieldValue { - public: - QPID_COMMON_EXTERN UuidValue(); - QPID_COMMON_EXTERN UuidValue(const unsigned char*); -}; - -template <class T> -bool getEncodedValue(FieldTable::ValuePtr vptr, T& value) -{ - if (vptr) { - const EncodedValue<T>* ev = dynamic_cast< EncodedValue<T>* >(&(vptr->getData())); - if (ev != 0) { - value = ev->getValue(); - return true; - } - } - return false; -} - -}} // qpid::framing - -#endif diff --git a/qpid/cpp/include/qpid/framing/List.h b/qpid/cpp/include/qpid/framing/List.h deleted file mode 100644 index 681445947c..0000000000 --- a/qpid/cpp/include/qpid/framing/List.h +++ /dev/null @@ -1,78 +0,0 @@ -#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 <iostream> -#include <list> -#include <boost/shared_ptr.hpp> - -namespace qpid { -namespace framing { - -class Buffer; -class FieldValue; - -/** - * Representation of an AMQP 0-10 list - */ -class QPID_COMMON_CLASS_EXTERN List -{ - public: - typedef boost::shared_ptr<FieldValue> ValuePtr; - typedef ValuePtr value_type; - typedef std::list<ValuePtr> Values; - 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; - QPID_COMMON_EXTERN void decode(Buffer& buffer); - - QPID_COMMON_EXTERN bool operator==(const List& other) const; - - // std collection interface. - 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_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_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; - - friend QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& out, const List& list); -}; -}} // namespace qpid::framing - -#endif /*!QPID_FRAMING_LIST_H*/ diff --git a/qpid/cpp/include/qpid/framing/ProtocolVersion.h b/qpid/cpp/include/qpid/framing/ProtocolVersion.h deleted file mode 100644 index 309e543516..0000000000 --- a/qpid/cpp/include/qpid/framing/ProtocolVersion.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -#ifndef _ProtocolVersion_ -#define _ProtocolVersion_ - -#include "qpid/framing/amqp_types.h" -#include "qpid/CommonImportExport.h" - -#include <string> - -namespace qpid -{ -namespace framing -{ - -class QPID_COMMON_CLASS_EXTERN ProtocolVersion -{ -private: - uint8_t major_; - uint8_t minor_; - uint8_t protocol_; - -public: - explicit ProtocolVersion(uint8_t _major=0, uint8_t _minor=0, uint8_t _protocol=0) - : major_(_major), minor_(_minor), protocol_(_protocol) {} - - 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_INLINE_EXTERN uint8_t getProtocol() const { return protocol_; } - QPID_COMMON_INLINE_EXTERN void setProtocol(uint8_t protocol) { protocol_ = protocol; } - 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_INLINE_EXTERN bool operator!=(ProtocolVersion p) const { return ! (*this == p); } - QPID_COMMON_EXTERN static uint8_t AMQP; - QPID_COMMON_EXTERN static uint8_t LEGACY_AMQP; - QPID_COMMON_EXTERN static uint8_t TLS; - QPID_COMMON_EXTERN static uint8_t SASL; -}; - -} // 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 deleted file mode 100644 index 00fa2469c8..0000000000 --- a/qpid/cpp/include/qpid/framing/SequenceNumber.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -#ifndef _framing_SequenceNumber_h -#define _framing_SequenceNumber_h - -#include "qpid/framing/amqp_types.h" -#include <boost/operators.hpp> -#include <iosfwd> -#include "qpid/CommonImportExport.h" - -namespace qpid { -namespace framing { - -class Buffer; - -/** - * 4-byte sequence number that 'wraps around'. - */ -class QPID_COMMON_CLASS_EXTERN SequenceNumber : public -boost::equality_comparable< - SequenceNumber, boost::less_than_comparable< - SequenceNumber, boost::incrementable< - SequenceNumber, boost::decrementable<SequenceNumber> > > > -{ - 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); } - - QPID_COMMON_EXTERN void encode(Buffer& buffer) const; - QPID_COMMON_EXTERN void decode(Buffer& buffer); - QPID_COMMON_EXTERN uint32_t encodedSize() const; - - template <class S> void serialize(S& s) { s(value); } -}; - -inline int32_t operator-(const SequenceNumber& a, const SequenceNumber& b) { - return int32_t(a.getValue() - b.getValue()); -} - -inline SequenceNumber operator+(const SequenceNumber& a, int32_t n) { - return SequenceNumber(a.getValue() + n); -} - -inline SequenceNumber operator-(const SequenceNumber& a, int32_t n) { - return SequenceNumber(a.getValue() - n); -} - -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 deleted file mode 100644 index 827c8999b3..0000000000 --- a/qpid/cpp/include/qpid/framing/SequenceSet.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -#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 QPID_COMMON_CLASS_EXTERN SequenceSet : public RangeSet<SequenceNumber> { - public: - SequenceSet() {} - SequenceSet(const RangeSet<SequenceNumber>& r) - : RangeSet<SequenceNumber>(r) {} - SequenceSet(const SequenceNumber& s) { add(s); } - SequenceSet(const SequenceNumber& start, const SequenceNumber finish) { add(start,finish); } - - - QPID_COMMON_EXTERN void encode(Buffer& buffer) const; - QPID_COMMON_EXTERN void decode(Buffer& buffer); - QPID_COMMON_EXTERN 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 <class T> void for_each(T& t) const { - for (RangeIterator i = rangesBegin(); i != rangesEnd(); i++) - t(i->first(), i->last()); - } - - template <class T> 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 deleted file mode 100644 index fe2fa64ce7..0000000000 --- a/qpid/cpp/include/qpid/framing/StructHelper.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -#ifndef _StructHelper_ -#define _StructHelper_ - -#include "qpid/Exception.h" -#include "qpid/CommonImportExport.h" -#include "qpid/framing/Buffer.h" - -#include <stdlib.h> // For alloca - -namespace qpid { -namespace framing { - -class QPID_COMMON_CLASS_EXTERN StructHelper -{ -public: - - template <class T> void encode(const T& t, std::string& data) { - uint32_t size = t.bodySize() + 2/*type*/; - data.resize(size); - Buffer wbuffer(const_cast<char*>(data.data()), size); - wbuffer.putShort(T::TYPE); - t.encodeStructBody(wbuffer); - } - - template <class T> void decode(T& t, const std::string& data) { - Buffer rbuffer(const_cast<char*>(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 deleted file mode 100644 index e9e56ed7c9..0000000000 --- a/qpid/cpp/include/qpid/framing/Uuid.h +++ /dev/null @@ -1,94 +0,0 @@ -#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/IntegerTypes.h" - -#include <boost/array.hpp> - -#include <ostream> -#include <istream> - -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. - * - * TODO: change this implementation as it leaks boost into the - * client API - */ -struct Uuid : public boost::array<uint8_t, 16> { - /** If unique is true, generate a unique ID else a null ID. */ - QPID_COMMON_EXTERN Uuid(bool unique=false); - - /** Copy from 16 bytes of data. */ - QPID_COMMON_EXTERN Uuid(const uint8_t* data); - - /** Parse format 1b4e28ba-2fa1-11d2-883f-b9a761bde3fb. */ - QPID_COMMON_EXTERN Uuid(const std::string&); - - // Default op= and copy ctor are fine. - // boost::array gives us ==, < etc. - - /** Copy from 16 bytes of 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. */ - QPID_COMMON_EXTERN void clear(); - - /** Test for null (all zeros). */ - QPID_COMMON_EXTERN bool isNull() const; - 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_INLINE_EXTERN uint32_t encodedSize() const - { return static_cast<uint32_t>(size()); } - - /** String value in format 1b4e28ba-2fa1-11d2-883f-b9a761bde3fb. */ - QPID_COMMON_EXTERN std::string str() const; - - template <class S> 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 deleted file mode 100644 index 2072a83904..0000000000 --- a/qpid/cpp/include/qpid/framing/amqp_types.h +++ /dev/null @@ -1,64 +0,0 @@ -#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" - -namespace qpid { -namespace framing { - -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 deleted file mode 100644 index c5d84dedea..0000000000 --- a/qpid/cpp/include/qpid/framing/amqp_types_full.h +++ /dev/null @@ -1,38 +0,0 @@ -#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 deleted file mode 100644 index 8c4beb0785..0000000000 --- a/qpid/cpp/include/qpid/log/Logger.h +++ /dev/null @@ -1,122 +0,0 @@ -#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 <boost/ptr_container/ptr_vector.hpp> -#include <boost/noncopyable.hpp> -#include <set> -#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 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, CATEGORY=128}; - - /** - * 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); - - /** Reset the log selectors */ - QPID_COMMON_EXTERN void reconfigure(const std::vector<std::string>& selectors); - - /** 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<Output> 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_INLINE_EXTERN const Options& getOptions() const { return options; } - - /** Get the hires timestamp setting */ - QPID_COMMON_EXTERN bool getHiresTimestamp(); - - /** Set the hires timestamp setting */ - QPID_COMMON_EXTERN void setHiresTimestamp(bool setting); - - private: - typedef boost::ptr_vector<Output> Outputs; - typedef std::set<Statement*> 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 deleted file mode 100644 index 42a8fb40fe..0000000000 --- a/qpid/cpp/include/qpid/log/Options.h +++ /dev/null @@ -1,51 +0,0 @@ -#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 <iosfwd> -#include <memory> - -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<std::string> selectors; - std::vector<std::string> deselectors; - bool time, level, thread, source, function, hiresTs, category; - bool trace; - std::string prefix; - std::auto_ptr<SinkOptions> 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 deleted file mode 100644 index 1d025e9646..0000000000 --- a/qpid/cpp/include/qpid/log/Selector.h +++ /dev/null @@ -1,99 +0,0 @@ -#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 <vector> - -namespace qpid { -namespace log { -struct Options; - -/** - * SelectorElement parses a cli/mgmt enable/disable entry into usable fields - * where cliEntry = [!]LEVEL[+-][:PATTERN] - */ -struct SelectorElement { - QPID_COMMON_EXTERN SelectorElement(const std::string cliEntry); - std::string levelStr; - std::string patternStr; - Level level; - Category category; - bool isDisable; - bool isCategory; - bool isLevelAndAbove; - bool isLevelAndBelow; -}; - -/** - * A selector identifies the set of log messages to enable. - * - * Thread object unsafe, pass-by-value type. - */ -class Selector { - public: - /** Empty selector selects nothing */ - QPID_COMMON_EXTERN Selector(); - - /** Set selector from Options */ - QPID_COMMON_EXTERN Selector(const Options&); - - /** Equavlient to: Selector s; s.enable(l, s) */ - QPID_COMMON_EXTERN Selector(Level l, const std::string& s=std::string()); - - /** Selector from string */ - QPID_COMMON_EXTERN Selector(const std::string& selector); - - /** push option settings into runtime lookup structs */ - QPID_COMMON_EXTERN void enable(const std::string& enableStr); - QPID_COMMON_EXTERN void disable(const std::string& disableStr); - - /** - * Enable/disable messages with level in levels where the file - * name contains substring. Empty string matches all. - */ - QPID_COMMON_EXTERN void enable(Level level, const std::string& substring=std::string()); - QPID_COMMON_EXTERN void disable(Level level, const std::string& substring=std::string()); - - /** Tests to determine if function names are in enable/disable tables */ - QPID_COMMON_EXTERN bool isEnabled(Level level, const char* function); - QPID_COMMON_EXTERN bool isDisabled(Level level, const char* function); - - /** Test to determine if log Statement is enabled */ - QPID_COMMON_EXTERN bool isEnabled(Level level, const char* function, Category category); - - private: - typedef std::vector<std::string> FunctionNameTable [LevelTraits::COUNT]; - FunctionNameTable enabledFunctions; // log function names explicitly enabled - FunctionNameTable disabledFunctions; // log function names explicitly disabled - bool enableFlags[LevelTraits::COUNT][CategoryTraits::COUNT]; - bool disableFlags[LevelTraits::COUNT][CategoryTraits::COUNT]; - - bool lookupFuncName(Level level, const char* function, FunctionNameTable& table); - /** Reset the category enable flags */ - QPID_COMMON_EXTERN void reset(); -}; - - -}} // namespace qpid::log - - -#endif /*!SELECTOR_H*/ diff --git a/qpid/cpp/include/qpid/log/SinkOptions.h b/qpid/cpp/include/qpid/log/SinkOptions.h deleted file mode 100644 index 7ec2cfbc17..0000000000 --- a/qpid/cpp/include/qpid/log/SinkOptions.h +++ /dev/null @@ -1,64 +0,0 @@ -#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 <string> - -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 deleted file mode 100644 index e928e19f22..0000000000 --- a/qpid/cpp/include/qpid/log/Statement.h +++ /dev/null @@ -1,242 +0,0 @@ -#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 <boost/current_function.hpp> - -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); -}; - -/** Formal message categories - * https://issues.apache.org/jira/browse/QPID-3902 - * - * Category Source code directory - * -------- --------------------- - * Security acl ssl gssapi sasl cyrus - * Broker broker - * Management agent console qmf - * Protocol amqp_0_10 framing - * System log sys types xml thread mutex fork pipe time ... - * HA cluster ha replication - * Messaging messaging - * Client client - * Store store - * Network tcp rdma AsynchIO socket epoll - * Test - * Model <not related to a directory> - * Unspecified <must be last in enum> - */ -enum Category { security, broker, management, protocol, system, ha, messaging, - store, network, test, client, model, unspecified }; -struct CategoryTraits { - static const int COUNT=unspecified+1; - - /** Test if given name is a Category name - */ - static bool isCategory(const std::string& name); - - /** Get category from string name - * @exception if name invalid. - */ - static Category category(const char* name); - - /** Get category from string name. - * @exception if name invalid. - */ - static Category category(const std::string& name) { - return category(name.c_str()); - } - - /** String name of category */ - static const char* name(Category); -}; - - /** POD struct representing a logging statement in source code. */ -struct Statement { - bool enabled; - const char* file; - int line; - const char* function; - Level level; - Category category; - - QPID_COMMON_EXTERN void log(const std::string& message); - QPID_COMMON_EXTERN static void categorize(Statement& s); - - struct Initializer { - QPID_COMMON_EXTERN Initializer(Statement& s); - Statement& statement; - }; -}; - -///@internal static initializer for a Statement. -#define QPID_LOG_STATEMENT_INIT_CAT(LEVEL, CATEGORY) \ -{ 0, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, (::qpid::log::LEVEL), \ -(::qpid::log::CATEGORY) } - - -///@internal static initializer for a Statement with unspecified category -#define QPID_LOG_STATEMENT_INIT(LEVEL) \ -QPID_LOG_STATEMENT_INIT_CAT ( LEVEL , unspecified ) - -/** - * 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) - -/** - * Line QPID_LOG_IF but with the additional specification of a category. - * @param CATEGORY message category. - */ -#define QPID_LOG_IF_CAT(LEVEL, CATEGORY, TEST, MESSAGE) \ - do { \ - using ::qpid::log::Statement; \ - static Statement stmt_= QPID_LOG_STATEMENT_INIT_CAT(LEVEL, CATEGORY); \ - static Statement::Initializer init_(stmt_); \ - if (stmt_.enabled && (TEST)) \ - 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(warning, 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) - - /** - * 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_CAT(warning, System, logWarning); - * if (logWarning) { do stuff needed for warning log messages } - */ - #define QPID_LOG_TEST_CAT(LEVEL, CATEGORY, FLAG) \ - do { \ - using ::qpid::log::Statement; \ - static Statement stmt_= QPID_LOG_STATEMENT_INIT_CAT(LEVEL, CATEGORY); \ - static Statement::Initializer init_(stmt_); \ - FLAG = stmt_.enabled; \ - } 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 - * Using QPID_LOG implies a category of Unspecified. - * - * 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); - -/** - * Macro for log statements. Example of use: - * @code - * QPID_LOG_CAT(debug, System, "There are " << foocount << " foos in the bar."); - * QPID_LOG_CAT(error, System, boost::format("Dohickey %s exploded") % dohicky.name()); - * @endcode - * Using QPID_LOG_CAT requires the specification of a category. - * - * 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 CATEGORY basic Category for the message. - *@param MESSAGE any object with an @eostream operator<<, or a sequence - * like of ostreamable objects separated by @e<<. - */ -#define QPID_LOG_CAT(LEVEL, CATEGORY, MESSAGE) QPID_LOG_IF_CAT(LEVEL, CATEGORY, 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 deleted file mode 100644 index 5d1cb7e01d..0000000000 --- a/qpid/cpp/include/qpid/management/Args.h +++ /dev/null @@ -1,44 +0,0 @@ -#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/Buffer.h b/qpid/cpp/include/qpid/management/Buffer.h deleted file mode 100644 index 1ac52bf276..0000000000 --- a/qpid/cpp/include/qpid/management/Buffer.h +++ /dev/null @@ -1,105 +0,0 @@ -#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/CommonImportExport.h" -#include "qpid/types/Exception.h" -#include "qpid/types/Variant.h" -#include <string> - -namespace qpid { -namespace framing { - class Buffer; -} - -namespace management { - -struct OutOfBounds : qpid::types::Exception { - OutOfBounds() : qpid::types::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 reset(); - - QPID_COMMON_EXTERN uint32_t available(); - QPID_COMMON_EXTERN uint32_t getSize(); - QPID_COMMON_EXTERN uint32_t getPosition(); - QPID_COMMON_EXTERN void setPosition(uint32_t); - 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 diff --git a/qpid/cpp/include/qpid/management/ConnectionSettings.h b/qpid/cpp/include/qpid/management/ConnectionSettings.h deleted file mode 100644 index b631ffa658..0000000000 --- a/qpid/cpp/include/qpid/management/ConnectionSettings.h +++ /dev/null @@ -1,118 +0,0 @@ -#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 <string> - -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 - diff --git a/qpid/cpp/include/qpid/management/Manageable.h b/qpid/cpp/include/qpid/management/Manageable.h deleted file mode 100644 index ede5c29e43..0000000000 --- a/qpid/cpp/include/qpid/management/Manageable.h +++ /dev/null @@ -1,81 +0,0 @@ -#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 <string> -#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_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; - 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. - // -#ifdef _IN_QPID_BROKER - virtual ManagementObject::shared_ptr GetManagementObject() const = 0; -#else - virtual ManagementObject* GetManagementObject() const = 0; -#endif - - // 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); - - // 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) {} - -}} - -#endif /*!_Manageable_*/ diff --git a/qpid/cpp/include/qpid/management/ManagementEvent.h b/qpid/cpp/include/qpid/management/ManagementEvent.h deleted file mode 100644 index e80175096f..0000000000 --- a/qpid/cpp/include/qpid/management/ManagementEvent.h +++ /dev/null @@ -1,53 +0,0 @@ -#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 "qpid/types/Variant.h" -#include <string> - -namespace qpid { -namespace management { - -class ManagementAgent; - -class ManagementEvent : public ManagementItem { - 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(std::string&) const = 0; - virtual void mapEncode(qpid::types::Variant::Map&) const = 0; -}; - -}} - -#endif /*!_ManagementEvent_*/ diff --git a/qpid/cpp/include/qpid/management/ManagementObject.h b/qpid/cpp/include/qpid/management/ManagementObject.h deleted file mode 100644 index 93fbec7bc7..0000000000 --- a/qpid/cpp/include/qpid/management/ManagementObject.h +++ /dev/null @@ -1,246 +0,0 @@ -#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/CommonImportExport.h" - -#include "qpid/management/Mutex.h" -#include "qpid/types/Variant.h" -#include <map> -#include <vector> - -#ifdef _IN_QPID_BROKER -#include <boost/shared_ptr.hpp> -#endif - -namespace qpid { -namespace management { - -class Manageable; -class ObjectId; -class ManagementObject; - - -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; - uint64_t agentEpoch; - std::string v2Key; - std::string agentName; - void fromString(const std::string&); -public: - 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_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) {} - - // 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_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_INLINE_EXTERN void setV2Key(const std::string& _key) { v2Key = _key; } - QPID_COMMON_EXTERN void setV2Key(const ManagementObject& object); - 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&); -}; - -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 TYPE_LIST = 21; - - 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 QPID_COMMON_CLASS_EXTERN ManagementObject : public ManagementItem -{ -protected: - - uint64_t createTime; - uint64_t destroyTime; - uint64_t updateTime; - ObjectId objectId; - mutable bool configChanged; - mutable bool instChanged; - bool deleted; - Manageable* coreObject; - mutable Mutex accessLock; - uint32_t flags; - - static int nextThreadIndex; - bool forcePublish; - - QPID_COMMON_EXTERN int getThreadIndex(); - QPID_COMMON_EXTERN void writeTimestamps(std::string& buf) const; - QPID_COMMON_EXTERN void readTimestamps(const std::string& buf); - QPID_COMMON_EXTERN uint32_t writeTimestampsSize() const; - - public: -#ifdef _IN_QPID_BROKER - typedef boost::shared_ptr<ManagementObject> shared_ptr; -#endif - - 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) (std::string&); - - QPID_COMMON_EXTERN ManagementObject(Manageable* _core); - virtual ~ManagementObject() {} - - virtual writeSchemaCall_t getWriteSchemaCall() = 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, - 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); - - /** - * 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&, const std::string&) {} - - 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; } - 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; } - bool isSameClass(ManagementObject& other) { - 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(); } - - // 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); -}; - -#ifdef _IN_QPID_BROKER -typedef std::map<ObjectId, ManagementObject::shared_ptr> ManagementObjectMap; -typedef std::vector<ManagementObject::shared_ptr> ManagementObjectVector; -#endif - -}} - - - -#endif /*!_ManagementObject_*/ diff --git a/qpid/cpp/include/qpid/management/Mutex.h b/qpid/cpp/include/qpid/management/Mutex.h deleted file mode 100644 index 67ae04bae9..0000000000 --- a/qpid/cpp/include/qpid/management/Mutex.h +++ /dev/null @@ -1,67 +0,0 @@ -#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. - * - */ - -#include "qpid/CommonImportExport.h" - -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 L> class ScopedLockTemplate { - public: - ScopedLockTemplate(L& l) : mutex(l) { mutex.lock(); } - ~ScopedLockTemplate() { mutex.unlock(); } - private: - L& mutex; - }; - - template <class L> class ScopedUnlockTemplate { - public: - ScopedUnlockTemplate(L& l) : mutex(l) { mutex.unlock(); } - ~ScopedUnlockTemplate() { mutex.lock(); } - private: - L& mutex; - }; - - class Mutex { - public: - typedef ScopedLockTemplate<Mutex> ScopedLock; - typedef ScopedUnlockTemplate<Mutex> ScopedUnlock; - - QPID_COMMON_EXTERN Mutex(); - QPID_COMMON_EXTERN ~Mutex(); - QPID_COMMON_EXTERN void lock(); - QPID_COMMON_EXTERN void unlock(); - private: - sys::Mutex* impl; - }; - } -} - -#endif - diff --git a/qpid/cpp/include/qpid/sys/Condition.h b/qpid/cpp/include/qpid/sys/Condition.h deleted file mode 100644 index 9be4b357fe..0000000000 --- a/qpid/cpp/include/qpid/sys/Condition.h +++ /dev/null @@ -1,33 +0,0 @@ -#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/ExceptionHolder.h b/qpid/cpp/include/qpid/sys/ExceptionHolder.h deleted file mode 100644 index 4bc934cf75..0000000000 --- a/qpid/cpp/include/qpid/sys/ExceptionHolder.h +++ /dev/null @@ -1,71 +0,0 @@ -#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 <boost/shared_ptr.hpp> - - -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 <class Ex> ExceptionHolder(Ex* ex) { wrap(ex); } - template <class Ex> ExceptionHolder& operator=(Ex* ex) { wrap(ex); 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 <class Ex> struct Wrapper : public Raisable { - Wrapper(Ex* ptr) : exception(ptr) {} - void raise() const { throw *exception; } - std::string what() const { return exception->what(); } - boost::shared_ptr<Ex> exception; - }; - template <class Ex> void wrap(Ex* ex) { wrapper.reset(new Wrapper<Ex>(ex)); } - boost::shared_ptr<Raisable> wrapper; -}; - - -}} // namespace qpid::sys - - -#endif /*!QPID_EXCEPTIONHOLDER_H*/ diff --git a/qpid/cpp/include/qpid/sys/IOHandle.h b/qpid/cpp/include/qpid/sys/IOHandle.h deleted file mode 100644 index 06ae65f879..0000000000 --- a/qpid/cpp/include/qpid/sys/IOHandle.h +++ /dev/null @@ -1,36 +0,0 @@ -#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. - * - */ - -namespace qpid { -namespace sys { - -/** - * This is a class intended to abstract the Unix concept of file descriptor - * or the Windows concept of HANDLE - */ -class IOHandle; - -}} - -#endif // _sys_IOHandle_h diff --git a/qpid/cpp/include/qpid/sys/Monitor.h b/qpid/cpp/include/qpid/sys/Monitor.h deleted file mode 100644 index 123bf92dcb..0000000000 --- a/qpid/cpp/include/qpid/sys/Monitor.h +++ /dev/null @@ -1,49 +0,0 @@ -#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 deleted file mode 100644 index e718586a39..0000000000 --- a/qpid/cpp/include/qpid/sys/Mutex.h +++ /dev/null @@ -1,91 +0,0 @@ -#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 L> -class ScopedLock -{ - public: - ScopedLock(L& l) : mutex(l) { mutex.lock(); } - ~ScopedLock() { mutex.unlock(); } - private: - L& mutex; -}; - -template <class L> -class ScopedUnlock -{ - public: - ScopedUnlock(L& l) : mutex(l) { mutex.unlock(); } - ~ScopedUnlock() { mutex.lock(); } - private: - L& mutex; -}; - -template <class L> -class ScopedRlock -{ - public: - ScopedRlock(L& l) : mutex(l) { mutex.rlock(); } - ~ScopedRlock() { mutex.unlock(); } - private: - L& mutex; -}; - -template <class L> -class ScopedWlock -{ - public: - ScopedWlock(L& l) : mutex(l) { mutex.wlock(); } - ~ScopedWlock() { mutex.unlock(); } - private: - L& mutex; -}; - -template <class L> -class ConditionalScopedLock -{ - public: - ConditionalScopedLock(L& l) : mutex(l) { acquired = mutex.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 deleted file mode 100644 index fed7663cb6..0000000000 --- a/qpid/cpp/include/qpid/sys/Runnable.h +++ /dev/null @@ -1,51 +0,0 @@ -#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 <boost/function.hpp> -#include "qpid/CommonImportExport.h" - -namespace qpid { -namespace sys { - -/** - * Interface for objects that can be run, e.g. in a thread. - */ -class QPID_COMMON_CLASS_EXTERN Runnable -{ - public: - /** Type to represent a runnable as a Functor */ - typedef boost::function0<void> 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 deleted file mode 100644 index 36489dd0fc..0000000000 --- a/qpid/cpp/include/qpid/sys/StrError.h +++ /dev/null @@ -1,36 +0,0 @@ -#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 <string> -#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 deleted file mode 100644 index 1b5720a5f0..0000000000 --- a/qpid/cpp/include/qpid/sys/SystemInfo.h +++ /dev/null @@ -1,109 +0,0 @@ -#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" -#include <vector> - -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. - * Returns false if it can't be obtained and sets errno to any error value. - */ -QPID_COMMON_EXTERN bool getLocalHostname (Address &address); - -/** - * Get the names of all the network interfaces connected to - * this host. - * @param names Receives the list of interface names - */ -QPID_COMMON_EXTERN void getInterfaceNames(std::vector<std::string>& names ); - -/** - * Get strings for each of the IP addresses associated with a named network - * interface. - * If there is no interface of that name an empty list will be returned. - * - * @param interface The name of the network interface - * @param addresses The list of the strings for the IP addresses are pushed on the back of this parameter - * to get just the list you need to clear the vector before using it. - * @return true if an interface of the correct name was found, false otherwise - */ -QPID_COMMON_EXTERN bool getInterfaceAddresses(const std::string& interface, std::vector<std::string>& addresses); - -/** - * 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(); - -/** - * Can thread related primitives be trusted during runtime house-cleaning? - * (i.e. static destructors, atexit()). - */ -QPID_COMMON_EXTERN bool threadSafeShutdown(); - - -}}} // 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 deleted file mode 100644 index f556612908..0000000000 --- a/qpid/cpp/include/qpid/sys/Thread.h +++ /dev/null @@ -1,71 +0,0 @@ -#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 <boost/shared_ptr.hpp> -#include "qpid/CommonImportExport.h" - -#ifdef _WIN32 -# 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) -# 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<ThreadPrivate> 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 operator bool(); - QPID_COMMON_EXTERN bool operator==(const Thread&) const; - QPID_COMMON_EXTERN bool operator!=(const Thread&) const; - - QPID_COMMON_EXTERN void join(); - - QPID_COMMON_EXTERN static Thread current(); - - /** ID of current thread for logging. - * Workaround for broken Thread::current() in APR - */ - QPID_COMMON_EXTERN static unsigned long logId(); -}; - -}} -#endif /*!_sys_Thread_h*/ diff --git a/qpid/cpp/include/qpid/sys/Time.h b/qpid/cpp/include/qpid/sys/Time.h deleted file mode 100644 index 2ccff92e7c..0000000000 --- a/qpid/cpp/include/qpid/sys/Time.h +++ /dev/null @@ -1,176 +0,0 @@ -#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 <limits> -#include <iosfwd> - -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 = now(); - * ... - * when = AbsTime(when, 2*TIME_SEC); // Advance timer 2 secs - * - * 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: - * - * 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 - * 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; - friend class Condition; - - TimePrivate timepoint; - -public: - - 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(); - - bool operator==(const AbsTime& t) const { return t.timepoint == 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<int64_t>::max(); } - int64_t nanosecs; - - friend class AbsTime; - -public: - 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; -}; - -QPID_COMMON_EXTERN std::ostream& operator << (std::ostream&, const Duration&); -QPID_COMMON_EXTERN std::istream& operator >> (std::istream&, 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<int64_t>::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(); - -/** 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&); - -/** Output unformatted nanosecond-resolution time for now */ -void outputHiresNow(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 deleted file mode 100644 index 36e7557ffd..0000000000 --- a/qpid/cpp/include/qpid/sys/posix/Condition.h +++ /dev/null @@ -1,86 +0,0 @@ -#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 <time.h> -#include <sys/errno.h> -#include <boost/noncopyable.hpp> - -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(EPOCH, 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/Mutex.h b/qpid/cpp/include/qpid/sys/posix/Mutex.h deleted file mode 100644 index e2b21b5a56..0000000000 --- a/qpid/cpp/include/qpid/sys/posix/Mutex.h +++ /dev/null @@ -1,158 +0,0 @@ -#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 <pthread.h> -#include <boost/noncopyable.hpp> - -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<Mutex> ScopedLock; - typedef ::qpid::sys::ScopedUnlock<Mutex> 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<RWlock> ScopedRlock; - typedef ::qpid::sys::ScopedWlock<RWlock> 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<PODMutex> 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 deleted file mode 100644 index 0f59fe3176..0000000000 --- a/qpid/cpp/include/qpid/sys/posix/PrivatePosix.h +++ /dev/null @@ -1,65 +0,0 @@ -#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" - -struct timespec; -struct timeval; -struct addrinfo; - -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 SocketAddress details -class SocketAddress; -const struct addrinfo& getAddrInfo(const SocketAddress&); - -// Posix fd as an IOHandle -class IOHandle { -public: - IOHandle(int fd0 = -1) : - fd(fd0) - {} - - int 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() - {} -}; - -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 deleted file mode 100755 index 62d734c816..0000000000 --- a/qpid/cpp/include/qpid/sys/posix/Time.h +++ /dev/null @@ -1,34 +0,0 @@ -#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 deleted file mode 100644 index 1bfe5d6d78..0000000000 --- a/qpid/cpp/include/qpid/sys/posix/check.h +++ /dev/null @@ -1,53 +0,0 @@ -#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 "qpid/Msg.h" - -#include <cerrno> -#include <assert.h> -#include <stdio.h> -#include <stdlib.h> - -#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/windows/Condition.h b/qpid/cpp/include/qpid/sys/windows/Condition.h deleted file mode 100755 index cd5aebbf09..0000000000 --- a/qpid/cpp/include/qpid/sys/windows/Condition.h +++ /dev/null @@ -1,77 +0,0 @@ -#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 <time.h> -#include <boost/noncopyable.hpp> -#include <boost/thread/condition.hpp> -#include <boost/thread/thread_time.hpp> -#include <windows.h> - -namespace qpid { -namespace sys { - -/** - * 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.timepoint); -} - -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 deleted file mode 100755 index 5dcc69e836..0000000000 --- a/qpid/cpp/include/qpid/sys/windows/Mutex.h +++ /dev/null @@ -1,188 +0,0 @@ -#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 <boost/version.hpp> -#if (BOOST_VERSION < 103500) -#error The Windows port requires Boost version 1.35.0 or later -#endif - -#include <boost/noncopyable.hpp> -#include <boost/thread/recursive_mutex.hpp> -#include <boost/thread/shared_mutex.hpp> -#include <boost/thread/thread_time.hpp> -#include <boost/thread/tss.hpp> - -namespace qpid { -namespace sys { - -class Condition; - -/** - * Mutex lock. - */ -class Mutex : private boost::noncopyable { - friend class Condition; - -public: - typedef ::qpid::sys::ScopedLock<Mutex> ScopedLock; - typedef ::qpid::sys::ScopedUnlock<Mutex> 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<RWlock> ScopedRlock; - typedef ::qpid::sys::ScopedWlock<RWlock> 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<bool> 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<PODMutex> 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 deleted file mode 100644 index 2987b1c8b2..0000000000 --- a/qpid/cpp/include/qpid/sys/windows/Time.h +++ /dev/null @@ -1,36 +0,0 @@ -#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 <boost/date_time/posix_time/posix_time_types.hpp> - -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*/ diff --git a/qpid/cpp/include/qpid/sys/windows/check.h b/qpid/cpp/include/qpid/sys/windows/check.h deleted file mode 100755 index 2a8e439bed..0000000000 --- a/qpid/cpp/include/qpid/sys/windows/check.h +++ /dev/null @@ -1,49 +0,0 @@ -#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/Msg.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*/ |
