Debian Codegraph @

Source/Utilities/Container/CQtManagedRestrictedModificationHashData.h

raw
1 /*
2 * Copyright (C) 2013-2015, 2019 by the Konclude Developer Team.
3 *
4 * This file is part of the reasoning system Konclude.
5 * For details and support, see <http://konclude.com/>.
6 *
7 * Konclude is free software: you can redistribute it and/or modify
8 * it under the terms of version 3 of the GNU Lesser General Public
9 * License (LGPLv3) as published by the Free Software Foundation.
10 *
11 * Konclude is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU (Lesser) General Public License for more details.
15 *
16 * You should have received a copy of the GNU (Lesser) General Public
17 * License along with Konclude. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * This file incorporates work covered by the following copyright and
20 * permission notice (to be compatible with LGPLv2.1,
21 * this code is available/released under GPLv3,
22 * see https://www.gnu.org/licenses/gpl-faq.html#AllCompatibility):
23 *
24 *
25 * Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
26 * Contact: http://www.qt-project.org/legal
27 *
28 * This file is part of the QtCore module of the Qt Toolkit.
29 *
30 * $QT_BEGIN_LICENSE:LGPL$
31 * Commercial License Usage
32 * Licensees holding valid commercial Qt licenses may use this file in
33 * accordance with the commercial license agreement provided with the
34 * Software or, alternatively, in accordance with the terms contained in
35 * a written agreement between you and Digia. For licensing terms and
36 * conditions see http://qt.digia.com/licensing. For further information
37 * use the contact form at http://qt.digia.com/contact-us.
38 *
39 * GNU Lesser General Public License Usage
40 * Alternatively, this file may be used under the terms of the GNU Lesser
41 * General Public License version 2.1 as published by the Free Software
42 * Foundation and appearing in the file LICENSE.LGPL included in the
43 * packaging of this file. Please review the following information to
44 * ensure the GNU Lesser General Public License version 2.1 requirements
45 * will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
46 *
47 * In addition, as a special exception, Digia gives you certain additional
48 * rights. These rights are described in the Digia Qt LGPL Exception
49 * version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
50 *
51 * GNU General Public License Usage
52 * Alternatively, this file may be used under the terms of the GNU
53 * General Public License version 3.0 as published by the Free Software
54 * Foundation and appearing in the file LICENSE.GPL included in the
55 * packaging of this file. Please review the following information to
56 * ensure the GNU General Public License version 3.0 requirements will be
57 * met: http://www.gnu.org/copyleft/gpl.html.
58 *
59 *
60 * $QT_END_LICENSE$
61 *
62 *
63 */
64
65 #ifndef KONCLUDE_UTILITIES_CONTAINER_CQTMANAGEDRESTRICTEDMODIFICATIONHASHDATA_H
66 #define KONCLUDE_UTILITIES_CONTAINER_CQTMANAGEDRESTRICTEDMODIFICATIONHASHDATA_H
67
68 // Namespace includes
69 #include "ContainerSettings.h"
70 #include "CQtManagedRestrictedModificationHashBase.h"
71
72 #ifdef KONCLUDE_EMPLOY_QT_MANAGED_RESTRICTED_MODIFICATION_HASH_CONTAINER
73
74 // Library includes
75 #include <QHash>
76
77 // Other includes
78 #include "Utilities/Memory/CMemoryAllocationManager.h"
79 #include "Utilities/Memory/CObjectAllocator.h"
80 #include "Utilities/Memory/CMemoryAllocator.h"
81
82 // Logger includes
83 #include "Logger/CLogger.h"
84
85
86 namespace Konclude {
87
88 namespace Utilities {
89
90 using namespace Memory;
91
92 namespace Container {
93
94
95 /*!
96 *
97 * \class CQtManagedRestrictedModificationHashData
98 * \author Andreas Steigmiller
99 * \version 0.1
100 * \brief TODO
101 *
102 */
103
104 struct CQtManagedRestrictedModificationHashData
105 {
106 struct Node {
107 Node *next;
108 uint h;
109 };
110
111 Node *fakeNext;
112 Node **buckets;
113 //QBasicAtomicInt ref;
114 CQtManagedRestrictedModificationHashBase *refHash;
115 int size;
116 int nodeSize;
117 short userNumBits;
118 short numBits;
119 int numBuckets;
120 uint sharable : 1;
121 uint strictAlignment : 1;
122 uint reserved : 30;
123
124 void *allocateNode(CMemoryAllocationManager* memMan); // ### Qt5 remove me
125 void *allocateNode(int nodeAlign, CMemoryAllocationManager* memMan);
126 void freeNode(void *node, CMemoryAllocationManager* memMan);
127 CQtManagedRestrictedModificationHashData *detach_helper(void (*node_duplicate)(Node *, void *), int nodeSize); // ### Qt5 remove me
128 CQtManagedRestrictedModificationHashData *detach_helper2(void (*node_duplicate)(Node *, void *), void (*node_delete)(Node *),
129 int nodeSize, int nodeAlign, CQtManagedRestrictedModificationHashBase* referencedHash, CMemoryAllocationManager* memMan);
130 CQtManagedRestrictedModificationHashData *restricted_detach_helper2(bool (*copy_restricted)(Node *, void *), void* assistValue, void (*node_duplicate)(Node *, void *), void (*node_delete)(Node *),
131 int nodeSize, int nodeAlign, CQtManagedRestrictedModificationHashBase* referencedHash, CMemoryAllocationManager* memMan);
132 void mightGrow(CMemoryAllocationManager* memMan);
133 bool willGrow(CMemoryAllocationManager* memMan) {
134 if (size >= numBuckets) {
135 rehash(numBits + 1,memMan);
136 return true;
137 } else {
138 return false;
139 }
140 }
141 void hasShrunk(CMemoryAllocationManager* memMan);
142 void rehash(int hint, CMemoryAllocationManager* memMan);
143 void free_helper(void (*node_delete)(Node *), CMemoryAllocationManager* memMan);
144 void destroyAndFree(CMemoryAllocationManager* memMan); // ### Qt5 remove me
145 Node *firstNode();
146 #ifdef KONCLUDE_CQTMANAGEDRESTRICTEDMODIFICATIONHASH_DEBUG
147 void dump();
148 void checkSanity();
149 #endif
150 static Node *nextNode(Node *node);
151 static Node *previousNode(Node *node);
152
153 static CQtManagedRestrictedModificationHashData shared_null;
154 };
155
156
157
158 }; // end namespace Container
159
160 }; // end namespace Utilities
161
162 }; // end namespace Konclude
163
164
165 #endif // KONCLUDE_EMPLOY_QT_MANAGED_RESTRICTED_MODIFICATION_HASH_CONTAINER
166
167 #endif // KONCLUDE_UTILITIES_CONTAINER_CQTMANAGEDRESTRICTEDMODIFICATIONHASHDATA_H