Debian Codegraph @

Source/Reasoner/Kernel/Cache/CSaturationNodeAssociatedExpansionCacheContext.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 "CSaturationNodeAssociatedExpansionCacheContext.h"
22
23
24 namespace Konclude {
25
26 namespace Reasoner {
27
28 namespace Kernel {
29
30 namespace Cache {
31
32
33 CSaturationNodeAssociatedExpansionCacheContext::CSaturationNodeAssociatedExpansionCacheContext() {
34 mMemoryPoolProvider = new CNewAllocationMemoryPoolProvider();
35 mMemMan = new CLimitedReserveMemoryPoolAllocationManager(mMemoryPoolProvider);
36 mAddRelMemory = 0;
37 mConSatUpdateLinker = nullptr;
38 }
39
40
41 CSaturationNodeAssociatedExpansionCacheContext::~CSaturationNodeAssociatedExpansionCacheContext() {
42 delete mMemMan;
43 delete mMemoryPoolProvider;
44 }
45
46
47 CMemoryPoolAllocationManager* CSaturationNodeAssociatedExpansionCacheContext::getMemoryPoolAllocationManager() {
48 return mMemMan;
49 }
50
51
52 CMemoryAllocationManager* CSaturationNodeAssociatedExpansionCacheContext::getMemoryAllocationManager() {
53 return mMemMan;
54 }
55
56 CMemoryPoolProvider* CSaturationNodeAssociatedExpansionCacheContext::getMemoryPoolProvider() {
57 return mMemoryPoolProvider;
58 }
59
60 cint64 CSaturationNodeAssociatedExpansionCacheContext::getMemoryConsumption() {
61 return mAddRelMemory + mMemoryPoolProvider->getAllocatedReleaseDifferencePoolSize();
62 }
63
64 CSaturationNodeAssociatedExpansionCacheContext* CSaturationNodeAssociatedExpansionCacheContext::releaseTemporaryMemoryPools(CMemoryPool* memoryPools) {
65 CMemoryPool* memoryPoolIt = memoryPools;
66 while (memoryPoolIt) {
67 mAddRelMemory += memoryPoolIt->getMemoryBlockSize();
68 memoryPoolIt = memoryPoolIt->getNext();
69 }
70 mMemMan->releaseTemporaryMemoryPools(memoryPools);
71 return this;
72 }
73
74
75 CIndividualSaturationProcessNodeStatusUpdateLinker* CSaturationNodeAssociatedExpansionCacheContext::getIndividualSaturationUpdateLinker(bool create) {
76 CIndividualSaturationProcessNodeStatusUpdateLinker* conSatUpdateLinker = mConSatUpdateLinker;
77 if (!conSatUpdateLinker && create) {
78 conSatUpdateLinker = CObjectAllocator<CIndividualSaturationProcessNodeStatusUpdateLinker>::allocateAndConstruct(mMemMan);
79 }
80 conSatUpdateLinker->clearNext();
81 if (mConSatUpdateLinker) {
82 mConSatUpdateLinker = mConSatUpdateLinker->getNext();
83 }
84 return conSatUpdateLinker;
85 }
86
87
88 CSaturationNodeAssociatedExpansionCacheContext* CSaturationNodeAssociatedExpansionCacheContext::addIndividualSaturationUpdateLinker(CIndividualSaturationProcessNodeStatusUpdateLinker* linker) {
89 if (linker) {
90 linker->clearNext();
91 linker = linker->append(mConSatUpdateLinker);
92 }
93 return this;
94 }
95
96
97 }; // end namespace Cache
98
99 }; // end namespace Kernel
100
101 }; // end namespace Reasoner
102
103 }; // end namespace Konclude