Debian Codegraph @

Source/Reasoner/Kernel/Cache/CBackendRepresentativeMemoryLabelCacheItem.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 "CBackendRepresentativeMemoryLabelCacheItem.h"
22
23
24 namespace Konclude {
25
26 namespace Reasoner {
27
28 namespace Kernel {
29
30 namespace Cache {
31
32
33 CBackendRepresentativeMemoryLabelCacheItem::CBackendRepresentativeMemoryLabelCacheItem(CBackendRepresentativeMemoryCacheContext* context) : CLinkerBase<cint64,CBackendRepresentativeMemoryLabelCacheItem>(0,nullptr),mContext(context) {
34 }
35
36
37 CBackendRepresentativeMemoryLabelCacheItem* CBackendRepresentativeMemoryLabelCacheItem::initCacheEntry(cint64 signature, cint64 entryID, LABEL_CACHE_ITEM_TYPE type) {
38 initCachingStatusFlags();
39 setData(entryID);
40 mSignature = signature;
41 mValueLinker = nullptr;
42 mTagValueHash = nullptr;
43 mValueCount = 0;
44 mCacheItemType = type;
45
46 mIndiAssociationCount = 0;
47
48 for (cint64 i = 0; i < CBackendRepresentativeMemoryLabelCacheItemExtensionData::LABEL_CACHE_ITEM_EXTENSION_TYPE_COUNT; ++i) {
49 mExtensionData[i] = nullptr;
50 }
51
52 return this;
53 }
54
55
56 CBackendRepresentativeMemoryLabelCacheItem::LABEL_CACHE_ITEM_TYPE CBackendRepresentativeMemoryLabelCacheItem::getLabelType() {
57 return mCacheItemType;
58 }
59
60
61 cint64 CBackendRepresentativeMemoryLabelCacheItem::getCacheEntryID() {
62 return getData();
63 }
64
65 CBackendRepresentativeMemoryLabelCacheItem* CBackendRepresentativeMemoryLabelCacheItem::setCacheEntryID(cint64 entryID) {
66 setData(entryID);
67 return this;
68 }
69
70
71 cint64 CBackendRepresentativeMemoryLabelCacheItem::getSignature() {
72 return mSignature;
73 }
74
75 CBackendRepresentativeMemoryLabelCacheItem* CBackendRepresentativeMemoryLabelCacheItem::setSignature(cint64 signature) {
76 mSignature = signature;
77 return this;
78 }
79
80
81 CBackendRepresentativeMemoryLabelCacheItem* CBackendRepresentativeMemoryLabelCacheItem::addCacheValueLinker(CBackendRepresentativeMemoryLabelValueLinker* linker) {
82 mValueCount += linker->getCount();
83 mValueLinker = linker->append(mValueLinker);
84 return this;
85 }
86
87
88 CBackendRepresentativeMemoryLabelValueLinker* CBackendRepresentativeMemoryLabelCacheItem::getCacheValueLinker() {
89 return mValueLinker;
90 }
91
92
93 CCACHINGHASH<cint64,CBackendRepresentativeMemoryLabelValueLinker*>* CBackendRepresentativeMemoryLabelCacheItem::getTagCacheValueHash(bool create) {
94 if (!mTagValueHash && create) {
95 mTagValueHash = CObjectParameterizingAllocator< CCACHINGHASH<cint64,CBackendRepresentativeMemoryLabelValueLinker*>,CContext* >::allocateAndConstructAndParameterize(mContext->getMemoryAllocationManager(),mContext);
96 }
97 return mTagValueHash;
98 }
99
100
101 CBackendRepresentativeMemoryLabelCacheItem* CBackendRepresentativeMemoryLabelCacheItem::setTagCacheValueHash(CCACHINGHASH<cint64,CBackendRepresentativeMemoryLabelValueLinker*>* hash) {
102 mTagValueHash = hash;
103 return this;
104 }
105
106
107 cint64 CBackendRepresentativeMemoryLabelCacheItem::getCacheValueCount() {
108 return mValueCount;
109 }
110
111 bool CBackendRepresentativeMemoryLabelCacheItem::hasCachedTagValue(cint64 tag) {
112 if (mTagValueHash) {
113 return mTagValueHash->contains(tag);
114 }
115 return false;
116 }
117
118
119 CBackendRepresentativeMemoryLabelCacheItemExtensionData* CBackendRepresentativeMemoryLabelCacheItem::getExtensionData(cint64 extensionType) {
120 return mExtensionData[extensionType];
121 }
122
123 CBackendRepresentativeMemoryLabelCacheItem* CBackendRepresentativeMemoryLabelCacheItem::setExtensionData(cint64 extensionType, CBackendRepresentativeMemoryLabelCacheItemExtensionData* extensionData) {
124 mExtensionData[extensionType] = extensionData;
125 return this;
126 }
127
128 CBackendRepresentativeMemoryLabelCacheItem* CBackendRepresentativeMemoryLabelCacheItem::incIndividualAssociationCount(cint64 count) {
129 mIndiAssociationCount += count;
130 return this;
131 }
132 CBackendRepresentativeMemoryLabelCacheItem* CBackendRepresentativeMemoryLabelCacheItem::decIndividualAssociationCount(cint64 count) {
133 mIndiAssociationCount -= count;
134 return this;
135 }
136
137 cint64 CBackendRepresentativeMemoryLabelCacheItem::getIndividualAssociationCount() {
138 return mIndiAssociationCount;
139 }
140
141
142 }; // end namespace Cache
143
144 }; // end namespace Kernel
145
146 }; // end namespace Reasoner
147
148 }; // end namespace Konclude