summaryrefslogtreecommitdiffstats
path: root/src/core/resources
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2016-04-15 12:23:40 +0100
committerSean Harmer <sean.harmer@kdab.com>2016-04-17 05:38:53 +0000
commitf2e2dd73f0796c1122069e9a9738aa333ba775d9 (patch)
tree05388582785232fdb04e4d7cda6e93522989056a /src/core/resources
parente34394a63cf74cd4fdf729eac12258f2c555776b (diff)
Add debug operator for QResourceManager
Useful for dumping out the resource tables to debug issues on the backend. Change-Id: I8f140d544b208b0b6006e08da6d36e031e781b2a Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/core/resources')
-rw-r--r--src/core/resources/qresourcemanager_p.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/core/resources/qresourcemanager_p.h b/src/core/resources/qresourcemanager_p.h
index e1efb1bdb..ad337adaf 100644
--- a/src/core/resources/qresourcemanager_p.h
+++ b/src/core/resources/qresourcemanager_p.h
@@ -375,6 +375,20 @@ private:
};
+#ifndef QT_NO_DEBUG_STREAM
+template <typename ValueType, typename KeyType, uint INDEXBITS,
+ template <typename, uint> class AllocatingPolicy,
+ template <class> class LockingPolicy
+ >
+class QResourceManager;
+
+template <typename ValueType, typename KeyType, uint INDEXBITS = 16,
+ template <typename, uint> class AllocatingPolicy = ArrayAllocatingPolicy,
+ template <class> class LockingPolicy = NonLockingPolicy
+ >
+QDebug operator<<(QDebug dbg, const QResourceManager<ValueType, KeyType, INDEXBITS, AllocatingPolicy, LockingPolicy> &manager);
+#endif
+
template <typename ValueType, typename KeyType, uint INDEXBITS = 16,
template <typename, uint> class AllocatingPolicy = ArrayAllocatingPolicy,
template <class> class LockingPolicy = NonLockingPolicy
@@ -491,8 +505,31 @@ private:
m_handleManager.release(handle);
AllocatingPolicy<ValueType, INDEXBITS>::releaseResource(val);
}
+
+ friend QDebug operator<< <>(QDebug dbg, const QResourceManager<ValueType, KeyType, INDEXBITS, AllocatingPolicy, LockingPolicy> &manager);
};
+#ifndef QT_NO_DEBUG_STREAM
+template <typename ValueType, typename KeyType, uint INDEXBITS,
+ template <typename, uint> class AllocatingPolicy,
+ template <class> class LockingPolicy
+ >
+QDebug operator<<(QDebug dbg, const QResourceManager<ValueType, KeyType, INDEXBITS, AllocatingPolicy, LockingPolicy> &manager)
+{
+ QDebugStateSaver saver(dbg);
+ dbg << "Contains" << manager.count() << "items" << "of a maximum" << manager.maximumSize() << endl;
+
+ dbg << "Key to Handle Map:" << endl;
+ const auto end = manager.m_keyToHandleMap.cend();
+ for (auto it = manager.m_keyToHandleMap.cbegin(); it != end; ++it)
+ dbg << "QNodeId =" << it.key() << "Handle =" << it.value() << endl;
+
+ dbg << "Resources:" << endl;
+ dbg << manager.m_handleManager;
+ return dbg;
+}
+#endif
+
}// Qt3D
QT_END_NAMESPACE