diff options
author | Kim van der Riet <kpvdr@apache.org> | 2012-08-03 12:13:32 +0000 |
---|---|---|
committer | Kim van der Riet <kpvdr@apache.org> | 2012-08-03 12:13:32 +0000 |
commit | d43d1912b376322e27fdcda551a73f9ff5487972 (patch) | |
tree | ce493e10baa95f44be8beb5778ce51783463196d /cpp/include/qpid | |
parent | 04877fec0c6346edec67072d7f2d247740cf2af5 (diff) | |
download | qpid-python-d43d1912b376322e27fdcda551a73f9ff5487972.tar.gz |
QPID-3858: Updated branch - merged from trunk r.1368650
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/asyncstore@1368910 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/include/qpid')
-rw-r--r-- | cpp/include/qpid/Options.h | 9 | ||||
-rw-r--r-- | cpp/include/qpid/RangeSet.h | 10 | ||||
-rw-r--r-- | cpp/include/qpid/amqp_0_10/Codecs.h | 2 | ||||
-rw-r--r-- | cpp/include/qpid/client/SessionBase_0_10.h | 13 | ||||
-rw-r--r-- | cpp/include/qpid/client/SubscriptionSettings.h | 14 | ||||
-rw-r--r-- | cpp/include/qpid/framing/Array.h | 2 | ||||
-rw-r--r-- | cpp/include/qpid/framing/Buffer.h | 50 | ||||
-rw-r--r-- | cpp/include/qpid/framing/ProtocolVersion.h | 2 | ||||
-rw-r--r-- | cpp/include/qpid/framing/SequenceNumber.h | 12 | ||||
-rw-r--r-- | cpp/include/qpid/framing/StructHelper.h | 2 | ||||
-rw-r--r-- | cpp/include/qpid/framing/Uuid.h | 3 | ||||
-rw-r--r-- | cpp/include/qpid/framing/amqp_types.h | 2 | ||||
-rw-r--r-- | cpp/include/qpid/log/Logger.h | 2 | ||||
-rw-r--r-- | cpp/include/qpid/log/Options.h | 2 | ||||
-rw-r--r-- | cpp/include/qpid/log/Selector.h | 27 | ||||
-rw-r--r-- | cpp/include/qpid/log/Statement.h | 170 | ||||
-rw-r--r-- | cpp/include/qpid/management/Buffer.h | 3 | ||||
-rw-r--r-- | cpp/include/qpid/sys/SystemInfo.h | 88 |
18 files changed, 302 insertions, 111 deletions
diff --git a/cpp/include/qpid/Options.h b/cpp/include/qpid/Options.h index 9860076195..0bbe7b704f 100644 --- a/cpp/include/qpid/Options.h +++ b/cpp/include/qpid/Options.h @@ -81,13 +81,12 @@ po::value_semantic* optValue(T& value, const char* name) { */ template <class T> po::value_semantic* optValue(std::vector<T>& value, const char* name) { - using namespace std; - ostringstream os; - copy(value.begin(), value.end(), ostream_iterator<T>(os, " ")); - string val=os.str(); + 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<vector<T> >(value, prettyArg(name, val))); + return (new OptionValue<std::vector<T> >(value, prettyArg(name, val))); } /** Create a boolean switch value. Presence of the option sets the value. */ diff --git a/cpp/include/qpid/RangeSet.h b/cpp/include/qpid/RangeSet.h index 36991fd784..ef0ad032da 100644 --- a/cpp/include/qpid/RangeSet.h +++ b/cpp/include/qpid/RangeSet.h @@ -224,17 +224,15 @@ bool RangeSet<T>::contains(const Range<T>& r) const { 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); + typename Ranges::iterator i = std::lower_bound(ranges.begin(), ranges.end(), r); if (i == ranges.end() || !i->touching(r)) - ranges.insert(i, r); + ranges.insert(i, r); // No overlap else { i->merge(r); typename Ranges::iterator j = i; - if (++j != ranges.end() && i->touching(*j)) { + while (++j != ranges.end() && i->touching(*j)) i->merge(*j); - ranges.erase(j); - } + ranges.erase(i+1,j); } } diff --git a/cpp/include/qpid/amqp_0_10/Codecs.h b/cpp/include/qpid/amqp_0_10/Codecs.h index 73846f33a8..d632a9f20a 100644 --- a/cpp/include/qpid/amqp_0_10/Codecs.h +++ b/cpp/include/qpid/amqp_0_10/Codecs.h @@ -69,6 +69,8 @@ class QPID_COMMON_CLASS_EXTERN ListCodec */ 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); diff --git a/cpp/include/qpid/client/SessionBase_0_10.h b/cpp/include/qpid/client/SessionBase_0_10.h index ea50ab32f7..630987c11d 100644 --- a/cpp/include/qpid/client/SessionBase_0_10.h +++ b/cpp/include/qpid/client/SessionBase_0_10.h @@ -36,14 +36,13 @@ namespace client { class Connection; class SessionImpl; -using std::string; -using framing::Content; -using framing::FieldTable; -using framing::SequenceNumber; -using framing::SequenceSet; -using framing::SequenceNumberSet; +using qpid::framing::Content; +using qpid::framing::FieldTable; +using qpid::framing::SequenceNumber; +using qpid::framing::SequenceSet; +using qpid::framing::SequenceNumberSet; using qpid::SessionId; -using framing::Xid; +using qpid::framing::Xid; /** Unit of message credit: messages or bytes */ enum CreditUnit { MESSAGE_CREDIT=0, BYTE_CREDIT=1, UNLIMITED_CREDIT=0xFFFFFFFF }; diff --git a/cpp/include/qpid/client/SubscriptionSettings.h b/cpp/include/qpid/client/SubscriptionSettings.h index b4cb302b56..bee39f6816 100644 --- a/cpp/include/qpid/client/SubscriptionSettings.h +++ b/cpp/include/qpid/client/SubscriptionSettings.h @@ -28,7 +28,19 @@ namespace qpid { namespace client { /** Bring AMQP enum definitions for message class into this namespace. */ -using namespace qpid::framing::message; +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, diff --git a/cpp/include/qpid/framing/Array.h b/cpp/include/qpid/framing/Array.h index 4f82d4dbf0..6254f6271a 100644 --- a/cpp/include/qpid/framing/Array.h +++ b/cpp/include/qpid/framing/Array.h @@ -82,7 +82,7 @@ class QPID_COMMON_CLASS_EXTERN Array // For use in standard algorithms template <typename R, typename V> static R get(const V& v) { - return v->get<R>(); + return v->template get<R>(); } private: diff --git a/cpp/include/qpid/framing/Buffer.h b/cpp/include/qpid/framing/Buffer.h index 8b08e60762..2ccad3bd57 100644 --- a/cpp/include/qpid/framing/Buffer.h +++ b/cpp/include/qpid/framing/Buffer.h @@ -1,3 +1,6 @@ +#ifndef QPID_FRAMING_BUFFER_H +#define QPID_FRAMING_BUFFER_H + /* * * Licensed to the Apache Software Foundation (ASF) under one @@ -18,13 +21,12 @@ * under the License. * */ -#include "qpid/framing/amqp_types.h" + #include "qpid/Exception.h" #include "qpid/CommonImportExport.h" -#include <boost/iterator/iterator_facade.hpp> +#include "qpid/sys/IntegerTypes.h" -#ifndef _Buffer_ -#define _Buffer_ +#include <string> namespace qpid { namespace framing { @@ -41,42 +43,18 @@ class QPID_COMMON_CLASS_EXTERN Buffer uint32_t size; char* data; uint32_t position; - uint32_t r_position; public: void checkAvailable(uint32_t count) { if (position + count > size) throw OutOfBounds(); } - /** Buffer input/output iterator. - * Supports using an amqp_0_10::Codec with a framing::Buffer. - */ - class Iterator : public boost::iterator_facade< - Iterator, char, boost::random_access_traversal_tag> - { - public: - Iterator(Buffer& b) : buffer(&b) {} - - private: - friend class boost::iterator_core_access; - char& dereference() const { return buffer->data[buffer->position]; } - void increment() { ++buffer->position; } - bool equal(const Iterator& x) const { return buffer == x.buffer; } - - Buffer* buffer; - }; - - friend class Iterator; - QPID_COMMON_EXTERN Buffer(char* data=0, uint32_t size=0); - QPID_COMMON_EXTERN void record(); - QPID_COMMON_EXTERN void restore(bool reRecord = false); QPID_COMMON_EXTERN void reset(); QPID_COMMON_INLINE_EXTERN uint32_t available() { return size - position; } QPID_COMMON_INLINE_EXTERN uint32_t getSize() { return size; } QPID_COMMON_INLINE_EXTERN uint32_t getPosition() { return position; } QPID_COMMON_INLINE_EXTERN void setPosition(uint32_t p) { position = p; } - QPID_COMMON_INLINE_EXTERN Iterator getIterator() { return Iterator(*this); } QPID_COMMON_INLINE_EXTERN char* getPointer() { return data; } QPID_COMMON_EXTERN void putOctet(uint8_t i); @@ -108,16 +86,16 @@ class QPID_COMMON_CLASS_EXTERN Buffer template <int n> QPID_COMMON_EXTERN void putUInt(uint64_t); - QPID_COMMON_EXTERN void putShortString(const string& s); - QPID_COMMON_EXTERN void putMediumString(const string& s); - QPID_COMMON_EXTERN void putLongString(const string& s); - QPID_COMMON_EXTERN void getShortString(string& s); - QPID_COMMON_EXTERN void getMediumString(string& s); - QPID_COMMON_EXTERN void getLongString(string& s); + QPID_COMMON_EXTERN void 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 string& s); - QPID_COMMON_EXTERN void getRawData(string& s, uint32_t size); + 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); diff --git a/cpp/include/qpid/framing/ProtocolVersion.h b/cpp/include/qpid/framing/ProtocolVersion.h index 30094c165d..26d628e41c 100644 --- a/cpp/include/qpid/framing/ProtocolVersion.h +++ b/cpp/include/qpid/framing/ProtocolVersion.h @@ -24,6 +24,8 @@ #include "qpid/framing/amqp_types.h" #include "qpid/CommonImportExport.h" +#include <string> + namespace qpid { namespace framing diff --git a/cpp/include/qpid/framing/SequenceNumber.h b/cpp/include/qpid/framing/SequenceNumber.h index dd85d97a52..00fa2469c8 100644 --- a/cpp/include/qpid/framing/SequenceNumber.h +++ b/cpp/include/qpid/framing/SequenceNumber.h @@ -57,12 +57,18 @@ boost::equality_comparable< QPID_COMMON_EXTERN uint32_t encodedSize() const; template <class S> void serialize(S& s) { s(value); } - - friend inline int32_t operator-(const SequenceNumber& a, const SequenceNumber& b); }; inline int32_t operator-(const SequenceNumber& a, const SequenceNumber& b) { - return int32_t(a.value - b.value); + 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 diff --git a/cpp/include/qpid/framing/StructHelper.h b/cpp/include/qpid/framing/StructHelper.h index 21f9b91fa9..fe2fa64ce7 100644 --- a/cpp/include/qpid/framing/StructHelper.h +++ b/cpp/include/qpid/framing/StructHelper.h @@ -34,7 +34,7 @@ class QPID_COMMON_CLASS_EXTERN StructHelper { public: - template <class T> void encode(const T t, std::string& data) { + 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); diff --git a/cpp/include/qpid/framing/Uuid.h b/cpp/include/qpid/framing/Uuid.h index ccfd7e9534..e9e56ed7c9 100644 --- a/cpp/include/qpid/framing/Uuid.h +++ b/cpp/include/qpid/framing/Uuid.h @@ -48,6 +48,9 @@ struct Uuid : public boost::array<uint8_t, 16> { /** 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. diff --git a/cpp/include/qpid/framing/amqp_types.h b/cpp/include/qpid/framing/amqp_types.h index d9088b7a12..2072a83904 100644 --- a/cpp/include/qpid/framing/amqp_types.h +++ b/cpp/include/qpid/framing/amqp_types.h @@ -27,12 +27,10 @@ */ #include "qpid/sys/IntegerTypes.h" -#include <string> namespace qpid { namespace framing { -using std::string; typedef uint8_t FrameType; typedef uint16_t ChannelId; typedef uint32_t BatchOffset; diff --git a/cpp/include/qpid/log/Logger.h b/cpp/include/qpid/log/Logger.h index d255b7e150..9464fa52dd 100644 --- a/cpp/include/qpid/log/Logger.h +++ b/cpp/include/qpid/log/Logger.h @@ -36,7 +36,7 @@ namespace log { 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}; + enum FormatFlag { FILE=1, LINE=2, FUNCTION=4, LEVEL=8, TIME=16, THREAD=32, HIRES=64, CATEGORY=128}; /** * Logging output sink. diff --git a/cpp/include/qpid/log/Options.h b/cpp/include/qpid/log/Options.h index 17cbfde9bc..819f2c85f1 100644 --- a/cpp/include/qpid/log/Options.h +++ b/cpp/include/qpid/log/Options.h @@ -39,7 +39,7 @@ struct Options : public qpid::Options { std::string argv0; std::string name; std::vector<std::string> selectors; - bool time, level, thread, source, function, hiresTs; + bool time, level, thread, source, function, hiresTs, category; bool trace; std::string prefix; std::auto_ptr<SinkOptions> sinkOptions; diff --git a/cpp/include/qpid/log/Selector.h b/cpp/include/qpid/log/Selector.h index 061152d7e2..498d4a7342 100644 --- a/cpp/include/qpid/log/Selector.h +++ b/cpp/include/qpid/log/Selector.h @@ -35,17 +35,24 @@ struct Options; class Selector { public: /** Empty selector selects nothing */ - Selector() {} + Selector() { + reset(); + } /** Set selector from Options */ QPID_COMMON_EXTERN Selector(const Options&); /** Equavlient to: Selector s; s.enable(l, s) */ Selector(Level l, const std::string& s=std::string()) { + reset(); enable(l,s); } - Selector(const std::string& enableStr) { enable(enableStr); } + Selector(const std::string& enableStr) { + reset(); + enable(enableStr); + } + /** * Enable messages with level in levels where the file * name contains substring. Empty string matches all. @@ -54,14 +61,30 @@ class Selector { substrings[level].push_back(substring); } + /** + * Enable messages at this level for this category + */ + void enable(Level level, Category category) { + catFlags[level][category] = true; + } + /** Enable based on a 'level[+]:file' string */ QPID_COMMON_EXTERN void enable(const std::string& enableStr); /** True if level is enabled for file. */ QPID_COMMON_EXTERN bool isEnabled(Level level, const char* function); + QPID_COMMON_EXTERN bool isEnabled(Level level, const char* function, Category category); + + /** Reset the category enable flags */ + QPID_COMMON_EXTERN void reset() { + for (int lt = 0; lt < LevelTraits::COUNT; ++lt) + for (int ct = 0; ct < CategoryTraits::COUNT; ++ct) + catFlags[lt][ct] = false; + } private: std::vector<std::string> substrings[LevelTraits::COUNT]; + bool catFlags[LevelTraits::COUNT][CategoryTraits::COUNT]; }; diff --git a/cpp/include/qpid/log/Statement.h b/cpp/include/qpid/log/Statement.h index 7b3ab60b81..ad84d66db6 100644 --- a/cpp/include/qpid/log/Statement.h +++ b/cpp/include/qpid/log/Statement.h @@ -22,6 +22,7 @@ #include "qpid/Msg.h" #include "qpid/CommonImportExport.h" #include <boost/current_function.hpp> +#include <list> namespace qpid { namespace log { @@ -55,15 +56,119 @@ struct LevelTraits { static const char* name(Level); }; -/** POD struct representing a logging statement in source code. */ +/** 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); +}; + + +class CategoryFileNameHints { +public: + CategoryFileNameHints(){ + hintList.push_back(std::make_pair("AsynchIo", network)); + hintList.push_back(std::make_pair("TCP", network)); + hintList.push_back(std::make_pair("epoll", network)); + hintList.push_back(std::make_pair("Pollable", network)); + hintList.push_back(std::make_pair("Socket", network)); + + hintList.push_back(std::make_pair("Sasl", security)); + hintList.push_back(std::make_pair("Ssl", security)); + hintList.push_back(std::make_pair("Acl", security)); + hintList.push_back(std::make_pair("acl", security)); + hintList.push_back(std::make_pair("cyrus", security)); + + hintList.push_back(std::make_pair("amqp_", protocol)); + hintList.push_back(std::make_pair("framing", protocol)); + + hintList.push_back(std::make_pair("management", management)); + hintList.push_back(std::make_pair("qmf", management)); + hintList.push_back(std::make_pair("console", management)); + hintList.push_back(std::make_pair("Management", management)); + + hintList.push_back(std::make_pair("cluster", ha)); + hintList.push_back(std::make_pair("qpid/ha", ha)); + hintList.push_back(std::make_pair("qpid\\ha", ha)); + hintList.push_back(std::make_pair("replication", ha)); + hintList.push_back(std::make_pair("ClusterSafe", ha)); + + hintList.push_back(std::make_pair("broker", broker)); + hintList.push_back(std::make_pair("SessionState",broker)); + hintList.push_back(std::make_pair("DataDir", broker)); + hintList.push_back(std::make_pair("qpidd", broker)); + hintList.push_back(std::make_pair("xml", broker)); + hintList.push_back(std::make_pair("QpidBroker", broker)); + + hintList.push_back(std::make_pair("store", store)); + + hintList.push_back(std::make_pair("assert", system)); + hintList.push_back(std::make_pair("Exception", system)); + hintList.push_back(std::make_pair("sys", system)); + hintList.push_back(std::make_pair("SCM", system)); + + hintList.push_back(std::make_pair("tests", test)); + + hintList.push_back(std::make_pair("messaging", messaging)); + hintList.push_back(std::make_pair("types", messaging)); + + hintList.push_back(std::make_pair("client", client)); + } + + static Category categoryOf(const char*const fName); + +private: + std::list<std::pair<const char* const, Category> > hintList; +}; + + /** 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); @@ -72,8 +177,14 @@ struct Statement { }; ///@internal static initializer for a Statement. -#define QPID_LOG_STATEMENT_INIT(level) \ - { 0, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, (::qpid::log::level) } +#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 @@ -96,13 +207,26 @@ struct Statement { } 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(LEVEL, logWarning); + * QPID_LOG_TEST(warning, logWarning); * if (logWarning) { do stuff needed for warning log messages } */ #define QPID_LOG_TEST(LEVEL, FLAG) \ @@ -113,12 +237,31 @@ struct Statement { 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. @@ -130,6 +273,25 @@ struct Statement { */ #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 diff --git a/cpp/include/qpid/management/Buffer.h b/cpp/include/qpid/management/Buffer.h index c32494b8c0..1ac52bf276 100644 --- a/cpp/include/qpid/management/Buffer.h +++ b/cpp/include/qpid/management/Buffer.h @@ -46,13 +46,12 @@ public: QPID_COMMON_EXTERN Buffer(char* data=0, uint32_t size=0); QPID_COMMON_EXTERN ~Buffer(); - QPID_COMMON_EXTERN void record(); - QPID_COMMON_EXTERN void restore(bool reRecord = false); QPID_COMMON_EXTERN void reset(); QPID_COMMON_EXTERN uint32_t available(); QPID_COMMON_EXTERN uint32_t getSize(); QPID_COMMON_EXTERN uint32_t getPosition(); + QPID_COMMON_EXTERN void setPosition(uint32_t); QPID_COMMON_EXTERN char* getPointer(); QPID_COMMON_EXTERN void putOctet(uint8_t i); diff --git a/cpp/include/qpid/sys/SystemInfo.h b/cpp/include/qpid/sys/SystemInfo.h index 23594cf650..24bc099d75 100644 --- a/cpp/include/qpid/sys/SystemInfo.h +++ b/cpp/include/qpid/sys/SystemInfo.h @@ -34,51 +34,61 @@ namespace sys { * 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(); +/** + * 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 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); - QPID_COMMON_EXTERN void getLocalIpAddresses (uint16_t port, std::vector<Address> &addrList); +/** + * Get the (possibly multiple) local IP addresses of this host + * using the specified port. + */ +QPID_COMMON_EXTERN void getLocalIpAddresses (uint16_t port, std::vector<Address> &addrList); + +/** + * Return true if host names an address of the local host. + *@param host host name or IP address. + */ +QPID_COMMON_EXTERN bool isLocalHost(const std::string& host); - /** - * 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); +/** + * 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 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 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(); +/** + * Get the name of the current process (i.e. the name of the executable) + */ +QPID_COMMON_EXTERN std::string getProcessName(); }}} // namespace qpid::sys::SystemInfo |