forked from qt-creator/qt-creator
Utils: Make TreeStorageBase related qHash and comparison hidden friends
Also, inline the hashing. Change-Id: I75859ad5481ab673d6c6f233c6fe67a96f9cda45 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -14,11 +14,6 @@ bool TreeStorageBase::isValid() const
|
|||||||
return m_storageData && m_storageData->m_constructor && m_storageData->m_destructor;
|
return m_storageData && m_storageData->m_constructor && m_storageData->m_destructor;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t TreeStorageBase::hash(uint seed) const
|
|
||||||
{
|
|
||||||
return size_t(m_storageData.get()) ^ seed;
|
|
||||||
}
|
|
||||||
|
|
||||||
TreeStorageBase::TreeStorageBase(StorageConstructor ctor, StorageDestructor dtor)
|
TreeStorageBase::TreeStorageBase(StorageConstructor ctor, StorageDestructor dtor)
|
||||||
: m_storageData(new StorageData{ctor, dtor}) { }
|
: m_storageData(new StorageData{ctor, dtor}) { }
|
||||||
|
|
||||||
|
@@ -33,11 +33,6 @@ class QTCREATOR_UTILS_EXPORT TreeStorageBase
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
friend bool operator==(const TreeStorageBase &first, const TreeStorageBase &second)
|
|
||||||
{ return first.m_storageData == second.m_storageData; }
|
|
||||||
friend bool operator!=(const TreeStorageBase &first, const TreeStorageBase &second)
|
|
||||||
{ return first.m_storageData != second.m_storageData; }
|
|
||||||
size_t hash(uint seed) const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
using StorageConstructor = std::function<void *(void)>;
|
using StorageConstructor = std::function<void *(void)>;
|
||||||
@@ -51,6 +46,15 @@ private:
|
|||||||
void deleteStorage(int id);
|
void deleteStorage(int id);
|
||||||
void activateStorage(int id);
|
void activateStorage(int id);
|
||||||
|
|
||||||
|
friend bool operator==(const TreeStorageBase &first, const TreeStorageBase &second)
|
||||||
|
{ return first.m_storageData == second.m_storageData; }
|
||||||
|
|
||||||
|
friend bool operator!=(const TreeStorageBase &first, const TreeStorageBase &second)
|
||||||
|
{ return first.m_storageData != second.m_storageData; }
|
||||||
|
|
||||||
|
friend size_t qHash(const TreeStorageBase &storage, uint seed = 0)
|
||||||
|
{ return size_t(storage.m_storageData.get()) ^ seed; }
|
||||||
|
|
||||||
struct StorageData {
|
struct StorageData {
|
||||||
~StorageData();
|
~StorageData();
|
||||||
StorageConstructor m_constructor = {};
|
StorageConstructor m_constructor = {};
|
||||||
@@ -64,11 +68,6 @@ private:
|
|||||||
friend TaskTreePrivate;
|
friend TaskTreePrivate;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline size_t qHash(const TreeStorageBase &storage, uint seed = 0)
|
|
||||||
{
|
|
||||||
return storage.hash(seed);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename StorageStruct>
|
template <typename StorageStruct>
|
||||||
class TreeStorage : public TreeStorageBase
|
class TreeStorage : public TreeStorageBase
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user