Debian Codegraph @

Source/Reasoner/Kernel/Process/CMarkerIndividualNodeHash.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 "CMarkerIndividualNodeHash.h"
22
23
24 namespace Konclude {
25
26 namespace Reasoner {
27
28 namespace Kernel {
29
30 namespace Process {
31
32
33 CMarkerIndividualNodeHash::CMarkerIndividualNodeHash(CProcessContext* context) : mContext(context) {
34 }
35
36
37 CMarkerIndividualNodeHash* CMarkerIndividualNodeHash::initMarkerIndividualNodeHash(CMarkerIndividualNodeHash* prevMarkerIndiNodeHash) {
38 if (prevMarkerIndiNodeHash) {
39 CPROCESSHASH< CConcept*, CMarkerIndividualNodeData >::operator=(*prevMarkerIndiNodeHash);
40 } else {
41 CPROCESSHASH< CConcept*, CMarkerIndividualNodeData >::clear();
42 }
43 return this;
44 }
45
46 CXNegLinker<CIndividualProcessNode*>* CMarkerIndividualNodeHash::getMarkerIndividualNodeLinker(CConcept* markerConcept) {
47 CMarkerIndividualNodeData data = value(markerConcept);
48 return data.getMarkerIndividualNodeLinker();
49 }
50
51 CMarkerIndividualNodeHash* CMarkerIndividualNodeHash::addMarkerIndividualNodeLinker(CConcept* markerConcept, CXNegLinker<CIndividualProcessNode*>* indiNodeLinker) {
52 CMarkerIndividualNodeData& data = this->operator [](markerConcept);
53 CPROCESSSET< QPair<cint64, bool> >* indiNondetSet = data.getIndividualNondeterminismSet(false);
54 cint64 indiId = indiNodeLinker->getData()->getIndividualNodeID();
55 bool nonDet = indiNodeLinker->isNegated();
56 if (!indiNondetSet || !indiNondetSet->contains(QPair<cint64, bool>(indiId, nonDet))) {
57 CPROCESSSET< QPair<cint64, bool> >* localNondetSet = data.getIndividualNondeterminismSet(true);
58 if (!localNondetSet) {
59 localNondetSet = CObjectParameterizingAllocator< CPROCESSSET< QPair<cint64, bool> >, CContext* >::allocateAndConstructAndParameterize(mContext->getMemoryAllocationManager(), mContext);
60 if (indiNondetSet) {
61 *localNondetSet = *indiNondetSet;
62 }
63 data.setIndividualNondeterminismSet(true, localNondetSet);
64 data.setIndividualNondeterminismSet(false, localNondetSet);
65 }
66 localNondetSet->insert(QPair<cint64, bool>(indiId, nonDet));
67 data.addMarkerIndividualNodeLinker(indiNodeLinker);
68 }
69 return this;
70 }
71
72 CMarkerIndividualNodeHash* CMarkerIndividualNodeHash::addMarkerIndividualNode(CConcept* markerConcept, CIndividualProcessNode* indiNode, bool nondeterministicallyAdded) {
73 CXNegLinker<CIndividualProcessNode*>* indiNodeLinker = CObjectAllocator< CXNegLinker<CIndividualProcessNode*> >::allocateAndConstruct(mContext->getMemoryAllocationManager());
74 indiNodeLinker->initNegLinker(indiNode,nondeterministicallyAdded);
75 addMarkerIndividualNodeLinker(markerConcept,indiNodeLinker);
76 return this;
77 }
78
79 }; // end namespace Process
80
81 }; // end namespace Kernel
82
83 }; // end namespace Reasoner
84
85 }; // end namespace Konclude