// Copyright (C) 2016 Jochen Becher // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #pragma once #include "objectid.h" #include #include #include namespace qark { namespace impl { class SavingRefMap { public: template bool hasRef(const T *object) { return hasRef(reinterpret_cast(object), typeid(*object).name()); } template bool hasDefinedRef(const T *object) { return hasDefinedRef(reinterpret_cast(object), typeid(*object).name()); } template ObjectId ref(const T *object, bool define = false) { return ref(reinterpret_cast(object), typeid(*object).name(), define); } int countDanglingReferences(); private: bool hasRef(const void *address, const char *typeName); bool hasDefinedRef(const void *address, const char *typeName); ObjectId ref(const void *address, const char *typeName, bool define); typedef QPair KeyType; typedef QPair ValueType; typedef QMap MapType; MapType m_references; ObjectId m_nextRef = ObjectId(1); }; } // namespace impl } // namespace qark