Debian Codegraph @

Source/Reasoner/Kernel/Process/CLinkedNeighbourRoleAssertionSaturationHash.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 "CLinkedNeighbourRoleAssertionSaturationHash.h"
22 #include "CIndividualSaturationProcessNode.h"
23
24
25 namespace Konclude {
26
27 namespace Reasoner {
28
29 namespace Kernel {
30
31 namespace Process {
32
33
34 CLinkedNeighbourRoleAssertionSaturationHash::CLinkedNeighbourRoleAssertionSaturationHash(CProcessContext* context) : mContext(context),mNeighbourRoleAssertionDataHash(context) {
35 }
36
37
38 CLinkedNeighbourRoleAssertionSaturationHash* CLinkedNeighbourRoleAssertionSaturationHash::initNeighbourRoleAssertionHash() {
39 mNeighbourRoleAssertionDataHash.clear();
40 return this;
41 }
42
43 CLinkedNeighbourRoleAssertionSaturationHash* CLinkedNeighbourRoleAssertionSaturationHash::copyNeighbourRoleAssertionHash(CLinkedNeighbourRoleAssertionSaturationHash* copyNeighbourRoleAssertionHash) {
44 mNeighbourRoleAssertionDataHash = copyNeighbourRoleAssertionHash->mNeighbourRoleAssertionDataHash;
45 return this;
46 }
47
48
49
50 CLinkedNeighbourRoleAssertionSaturationHash* CLinkedNeighbourRoleAssertionSaturationHash::addNeighbourRoleAssertion(cint64 sourceIndiId, cint64 targetIndiId, CRole* assertedRole, bool roleInversed, CIndividualSaturationProcessNode* connectedSatNode) {
51 CLinkedNeighbourRoleAssertionSaturationNodeLinker* linker = CObjectAllocator<CLinkedNeighbourRoleAssertionSaturationNodeLinker>::allocateAndConstruct(mContext->getMemoryAllocationManager());
52 linker->initLinkedNeighbourRoleAssertionLinker(assertedRole, roleInversed, connectedSatNode);
53 CLinkedNeighbourRoleAssertionSaturationData* neighbourSatData = getNeighbourRoleAssertionData(targetIndiId, true);
54 neighbourSatData->addLinkedRoleAssertedLinker(linker);
55 return this;
56 }
57
58
59 CLinkedNeighbourRoleAssertionSaturationData* CLinkedNeighbourRoleAssertionSaturationHash::getNeighbourRoleAssertionData(cint64 neighbourIndiId, bool createIfNotExists) {
60 if (createIfNotExists) {
61 CLinkedNeighbourRoleAssertionSaturationData*& data = mNeighbourRoleAssertionDataHash[neighbourIndiId];
62 if (!data) {
63 data = CObjectAllocator<CLinkedNeighbourRoleAssertionSaturationData>::allocateAndConstruct(mContext->getMemoryAllocationManager());
64 }
65 return data;
66 } else {
67 return mNeighbourRoleAssertionDataHash.value(neighbourIndiId);
68 }
69 }
70
71
72 CLinkedNeighbourRoleAssertionSaturationNodeLinker* CLinkedNeighbourRoleAssertionSaturationHash::getNeighbourRoleAssertionLinker(cint64 neighbourIndiId) {
73 CLinkedNeighbourRoleAssertionSaturationData* neighbourSatData = getNeighbourRoleAssertionData(neighbourIndiId, false);
74 if (neighbourSatData) {
75 return neighbourSatData->getLinkedRoleAssertedLinker();
76 }
77 return nullptr;
78 }
79
80
81 CPROCESSHASH<cint64, CLinkedNeighbourRoleAssertionSaturationData*>* CLinkedNeighbourRoleAssertionSaturationHash::getNeighbourRoleAssertionDataHash() {
82 return &mNeighbourRoleAssertionDataHash;
83 }
84
85
86 }; // end namespace Process
87
88 }; // end namespace Kernel
89
90 }; // end namespace Reasoner
91
92 }; // end namespace Konclude