| 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_CQTMANAGEDRESTRICTEDMODIFICATIONLISTDATA_H |
| 66 |
#define KONCLUDE_UTILITIES_CONTAINER_CQTMANAGEDRESTRICTEDMODIFICATIONLISTDATA_H |
| 67 |
|
| 68 |
// Namespace includes |
| 69 |
#include "ContainerSettings.h" |
| 70 |
#include "CQtManagedRestrictedModificationListBase.h" |
| 71 |
|
| 72 |
#ifdef KONCLUDE_EMPLOY_QT_MANAGED_RESTRICTED_MODIFICATION_LIST_CONTAINER |
| 73 |
|
| 74 |
// Library includes |
| 75 |
#include <QList> |
| 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 CQtManagedRestrictedModificationListData |
| 98 |
* \author Andreas Steigmiller |
| 99 |
* \version 0.1 |
| 100 |
* \brief TODO |
| 101 |
* |
| 102 |
*/ |
| 103 |
struct CQtManagedRestrictedModificationListData { |
| 104 |
struct Data { |
| 105 |
//QBasicAtomicInt ref; |
| 106 |
CQtManagedRestrictedModificationListBase* refList; |
| 107 |
int alloc, begin, end; |
| 108 |
uint sharable : 1; |
| 109 |
void *array[1]; |
| 110 |
}; |
| 111 |
enum { DataHeaderSize = sizeof(Data) - sizeof(void *) }; |
| 112 |
|
| 113 |
Data *detach(int alloc, CMemoryAllocationManager* memMan, CQtManagedRestrictedModificationListBase* listBase); |
| 114 |
Data *detach_grow(int *i, int n, CMemoryAllocationManager* memMan, CQtManagedRestrictedModificationListBase* listBase); |
| 115 |
void realloc(int alloc, CMemoryAllocationManager* memMan); |
| 116 |
static Data shared_null; |
| 117 |
Data *d; |
| 118 |
void **erase(void **xi); |
| 119 |
void **append(int n, CMemoryAllocationManager* memMan); |
| 120 |
void **append(CMemoryAllocationManager* memMan); |
| 121 |
void **append(const CQtManagedRestrictedModificationListData &l, CMemoryAllocationManager* memMan); |
| 122 |
void **append2(const CQtManagedRestrictedModificationListData &l, CMemoryAllocationManager* memMan); |
| 123 |
void **prepend(CMemoryAllocationManager* memMan); |
| 124 |
void **insert(int i, CMemoryAllocationManager* memMan); |
| 125 |
void remove(int i); |
| 126 |
void remove(int i, int n); |
| 127 |
void move(int from, int to); |
| 128 |
inline int size() const { return d->end - d->begin; } |
| 129 |
inline bool isEmpty() const { return d->end == d->begin; } |
| 130 |
inline void **at(int i) const { return d->array + d->begin + i; } |
| 131 |
inline void **begin() const { return d->array + d->begin; } |
| 132 |
inline void **end() const { return d->array + d->end; } |
| 133 |
}; |
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
}; // end namespace Container |
| 139 |
|
| 140 |
}; // end namespace Utilities |
| 141 |
|
| 142 |
}; // end namespace Konclude |
| 143 |
|
| 144 |
|
| 145 |
#endif // KONCLUDE_EMPLOY_QT_MANAGED_RESTRICTED_MODIFICATION_LIST_CONTAINER |
| 146 |
|
| 147 |
#endif // KONCLUDE_UTILITIES_CONTAINER_CQTMANAGEDRESTRICTEDMODIFICATIONLISTDATA_H |