From b377462185d9f7bafe87acea8319ea07434ced2b Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Mon, 5 Aug 2013 16:35:13 +0000 Subject: NO-JIRA: Corrected use of boost_hash, failing to build on some compilers. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1510597 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/include/qpid/types/Uuid.h | 3 +++ cpp/src/qpid/ha/BrokerInfo.h | 4 +++- cpp/src/qpid/ha/Primary.h | 4 ++-- cpp/src/qpid/ha/QueueGuard.h | 4 ++-- cpp/src/qpid/ha/QueueReplicator.h | 4 ++-- cpp/src/qpid/ha/QueueSnapshots.h | 10 +++++----- cpp/src/qpid/ha/RemoteBackup.h | 4 ++-- cpp/src/qpid/ha/hash.h | 42 --------------------------------------- 8 files changed, 19 insertions(+), 56 deletions(-) delete mode 100644 cpp/src/qpid/ha/hash.h diff --git a/cpp/include/qpid/types/Uuid.h b/cpp/include/qpid/types/Uuid.h index b931670d97..eb9cf33693 100644 --- a/cpp/include/qpid/types/Uuid.h +++ b/cpp/include/qpid/types/Uuid.h @@ -82,6 +82,9 @@ class QPID_TYPES_CLASS_EXTERN Uuid unsigned char bytes[16]; }; +/** Hash value function for use with boots::hash or std::hash */ +inline size_t hash_value(const Uuid& uuid) { return uuid.hash(); } + /** Returns true if the uuids are equal, false otherwise. **/ QPID_TYPES_EXTERN bool operator==(const Uuid&, const Uuid&); /** Returns true if the uuids are NOT equal, false if they are. **/ diff --git a/cpp/src/qpid/ha/BrokerInfo.h b/cpp/src/qpid/ha/BrokerInfo.h index bd1ad86392..8e62665088 100644 --- a/cpp/src/qpid/ha/BrokerInfo.h +++ b/cpp/src/qpid/ha/BrokerInfo.h @@ -28,6 +28,7 @@ #include "qpid/types/Uuid.h" #include "qpid/types/Variant.h" #include "qpid/sys/unordered_map.h" +#include #include #include #include @@ -42,7 +43,8 @@ class BrokerInfo { public: typedef std::set Set; - typedef qpid::sys::unordered_map Map; + typedef qpid::sys::unordered_map > Map; BrokerInfo(); BrokerInfo(const types::Uuid& id, BrokerStatus, const Address& = Address()); diff --git a/cpp/src/qpid/ha/Primary.h b/cpp/src/qpid/ha/Primary.h index a34f8f5a30..c13d60991e 100644 --- a/cpp/src/qpid/ha/Primary.h +++ b/cpp/src/qpid/ha/Primary.h @@ -29,9 +29,9 @@ #include "qpid/sys/Mutex.h" #include "qpid/sys/unordered_map.h" #include +#include #include #include -#include namespace qpid { @@ -105,7 +105,7 @@ class Primary : public Role private: typedef sys::unordered_map< - types::Uuid, RemoteBackupPtr, types::Uuid::Hasher > BackupMap; + types::Uuid, RemoteBackupPtr, boost::hash > BackupMap; typedef std::set BackupSet; diff --git a/cpp/src/qpid/ha/QueueGuard.h b/cpp/src/qpid/ha/QueueGuard.h index e41a92c74f..5a5f80996d 100644 --- a/cpp/src/qpid/ha/QueueGuard.h +++ b/cpp/src/qpid/ha/QueueGuard.h @@ -23,12 +23,12 @@ */ #include "types.h" -#include "hash.h" #include "qpid/types/Uuid.h" #include "qpid/sys/Mutex.h" #include "qpid/sys/unordered_map.h" #include #include +#include #include #include @@ -89,7 +89,7 @@ class QueueGuard { class QueueObserver; typedef qpid::sys::unordered_map, - TrivialHasher > Delayed; + boost::hash > Delayed; bool complete(ReplicationId, sys::Mutex::ScopedLock &); void complete(Delayed::iterator, sys::Mutex::ScopedLock &); diff --git a/cpp/src/qpid/ha/QueueReplicator.h b/cpp/src/qpid/ha/QueueReplicator.h index cbc950d4bc..24baeb9a89 100644 --- a/cpp/src/qpid/ha/QueueReplicator.h +++ b/cpp/src/qpid/ha/QueueReplicator.h @@ -23,9 +23,9 @@ */ #include "BrokerInfo.h" -#include "hash.h" #include "qpid/broker/Exchange.h" #include +#include #include #include @@ -106,7 +106,7 @@ class QueueReplicator : public broker::Exchange, private: typedef qpid::sys::unordered_map< - ReplicationId, QueuePosition, TrivialHasher > PositionMap; + ReplicationId, QueuePosition, boost::hash > PositionMap; class ErrorListener; class QueueObserver; diff --git a/cpp/src/qpid/ha/QueueSnapshots.h b/cpp/src/qpid/ha/QueueSnapshots.h index e28bcd95a8..c12ee743e8 100644 --- a/cpp/src/qpid/ha/QueueSnapshots.h +++ b/cpp/src/qpid/ha/QueueSnapshots.h @@ -24,7 +24,6 @@ #include "QueueSnapshot.h" -#include "hash.h" #include "qpid/assert.h" #include "qpid/broker/BrokerObserver.h" @@ -32,6 +31,7 @@ #include "qpid/sys/Mutex.h" #include +#include namespace qpid { namespace ha { @@ -67,10 +67,10 @@ class QueueSnapshots : public broker::BrokerObserver } private: - typedef qpid::sys::unordered_map, - boost::shared_ptr, - SharedPtrHasher - > SnapshotMap; + typedef qpid::sys::unordered_map< + boost::shared_ptr, boost::shared_ptr, + boost::hash > > SnapshotMap; + SnapshotMap snapshots; mutable sys::Mutex lock; }; diff --git a/cpp/src/qpid/ha/RemoteBackup.h b/cpp/src/qpid/ha/RemoteBackup.h index 1d0a129c82..d2533e8b5c 100644 --- a/cpp/src/qpid/ha/RemoteBackup.h +++ b/cpp/src/qpid/ha/RemoteBackup.h @@ -25,8 +25,8 @@ #include "ReplicationTest.h" #include "BrokerInfo.h" #include "types.h" -#include "hash.h" #include "qpid/sys/unordered_map.h" +#include #include namespace qpid { @@ -97,7 +97,7 @@ class RemoteBackup private: typedef qpid::sys::unordered_map > GuardMap; + boost::hash > GuardMap; typedef std::set QueueSet; std::string logPrefix; diff --git a/cpp/src/qpid/ha/hash.h b/cpp/src/qpid/ha/hash.h deleted file mode 100644 index a513673cce..0000000000 --- a/cpp/src/qpid/ha/hash.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef QPID_HA_HASH_H -#define QPID_HA_HASH_H - -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -#include - -namespace qpid { -namespace ha { - -template struct TrivialHasher { - size_t operator()(T value) const { return static_cast(value); } -}; - -template struct SharedPtrHasher { - size_t operator()(const boost::shared_ptr& ptr) const { - return reinterpret_cast(ptr.get()); - } -}; - -}} // namespace qpid::ha - -#endif /*!QPID_HA_HASH_H*/ -- cgit v1.2.1