Debian Codegraph @

Source/Reasoner/Kernel/Cache/COccurrenceUnsatisfiableCacheUpdateSlotItem.cpp

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 */
20
21 #include "COccurrenceUnsatisfiableCacheUpdateSlotItem.h"
22
23
24 namespace Konclude {
25
26 namespace Reasoner {
27
28 namespace Kernel {
29
30 namespace Cache {
31
32
33 COccurrenceUnsatisfiableCacheUpdateSlotItem::COccurrenceUnsatisfiableCacheUpdateSlotItem(qint64 updateSlotIndex) {
34 slotIndex = updateSlotIndex;
35 mReaderUsing = false;
36 }
37
38
39 COccurrenceUnsatisfiableCacheUpdateSlotItem::~COccurrenceUnsatisfiableCacheUpdateSlotItem() {
40 cleanSlotUpdateItems();
41 }
42
43
44 bool COccurrenceUnsatisfiableCacheUpdateSlotItem::incReader() {
45 if (mReaderSharingCount.ref()) {
46 mReaderUsing = true;
47 }
48 return true;
49 }
50
51
52 bool COccurrenceUnsatisfiableCacheUpdateSlotItem::incReader(cint64 incCount) {
53 for (cint64 i = 0; i < incCount; ++i) {
54 incReader();
55 }
56 return mReaderUsing;
57 }
58
59
60 bool COccurrenceUnsatisfiableCacheUpdateSlotItem::decReader() {
61 if (!mReaderSharingCount.deref()) {
62 mReaderUsing = false;
63 }
64 return mReaderUsing;
65 }
66
67
68 void COccurrenceUnsatisfiableCacheUpdateSlotItem::addCacheEntry(COccurrenceUnsatisfiableCacheEntry *cacheEntry) {
69 updatedEntrySet.insert(cacheEntry);
70 }
71
72 void COccurrenceUnsatisfiableCacheUpdateSlotItem::addCacheEntriesHash(COccurrenceUnsatisfiableCacheEntriesHash *prevDelHash) {
73 updatedHashesList.append(prevDelHash);
74 }
75
76
77 void COccurrenceUnsatisfiableCacheUpdateSlotItem::activateSlotUpdateItems() {
78 foreach (COccurrenceUnsatisfiableCacheEntry *entry, updatedEntrySet) {
79 entry->setActiveSlot(slotIndex);
80 }
81 }
82
83
84 void COccurrenceUnsatisfiableCacheUpdateSlotItem::cleanSlotUpdateItems() {
85 foreach (COccurrenceUnsatisfiableCacheEntriesHash *hash, updatedHashesList) {
86 if (hash->decReferenceCountReturnHasToBeDeleted()) {
87 delete hash;
88 }
89 }
90 updatedHashesList.clear();
91 updatedEntrySet.clear();
92 }
93
94
95 qint64 COccurrenceUnsatisfiableCacheUpdateSlotItem::getSlotIndex() {
96 return slotIndex;
97 }
98
99 bool COccurrenceUnsatisfiableCacheUpdateSlotItem::hasCacheReaders() {
100 return mReaderUsing;
101 }
102
103
104
105 }; // end namespace Cache
106
107 }; // end namespace Kernel
108
109 }; // end namespace Reasoner
110
111 }; // end namespace Konclude