| 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 "CVariableBindingPathSet.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Reasoner { |
| 27 |
|
| 28 |
namespace Kernel { |
| 29 |
|
| 30 |
namespace Process { |
| 31 |
|
| 32 |
|
| 33 |
CVariableBindingPathSet::CVariableBindingPathSet(CProcessContext* processContext) : mProcessContext(processContext),mVarBindPathMap(processContext) { |
| 34 |
} |
| 35 |
|
| 36 |
CVariableBindingPathSet* CVariableBindingPathSet::initVariableBindingPathSet(CVariableBindingPathSet* prevSet) { |
| 37 |
if (prevSet) { |
| 38 |
mVarBindPathMap.initVariableBindingPathMap(&prevSet->mVarBindPathMap); |
| 39 |
mConceptDescriptor = prevSet->mConceptDescriptor; |
| 40 |
mVarBindPathDesLinker = prevSet->mVarBindPathDesLinker; |
| 41 |
} else { |
| 42 |
mVarBindPathMap.initVariableBindingPathMap(nullptr); |
| 43 |
mConceptDescriptor = nullptr; |
| 44 |
mVarBindPathDesLinker = nullptr; |
| 45 |
} |
| 46 |
return this; |
| 47 |
} |
| 48 |
|
| 49 |
bool CVariableBindingPathSet::containsVariableBindingPath(CVariableBindingPath* variableBindingPath) { |
| 50 |
return mVarBindPathMap.contains(variableBindingPath->getPropagationID()); |
| 51 |
} |
| 52 |
|
| 53 |
bool CVariableBindingPathSet::containsVariableBindingPath(cint64 bindingID) { |
| 54 |
return mVarBindPathMap.contains(bindingID); |
| 55 |
} |
| 56 |
|
| 57 |
CVariableBindingPathDescriptor* CVariableBindingPathSet::getVariableBindingPathDescriptor(CVariableBindingPath* variableBindingPath) { |
| 58 |
return mVarBindPathMap.value(variableBindingPath->getPropagationID()).getVariableBindingPathDescriptor(); |
| 59 |
} |
| 60 |
|
| 61 |
|
| 62 |
CVariableBindingPathMap* CVariableBindingPathSet::getVariableBindingPathMap() { |
| 63 |
return &mVarBindPathMap; |
| 64 |
} |
| 65 |
|
| 66 |
CVariableBindingPathSet* CVariableBindingPathSet::addVariableBindingPath(CVariableBindingPathDescriptor* varBindPathDes) { |
| 67 |
CVariableBindingPathMapData& data = mVarBindPathMap[varBindPathDes->getVariableBindingPath()->getPropagationID()]; |
| 68 |
if (!data.hasVariableBindingPathDescriptor()) { |
| 69 |
data.setVariableBindingPathDescriptor(varBindPathDes); |
| 70 |
mVarBindPathDesLinker = varBindPathDes->append(mVarBindPathDesLinker); |
| 71 |
} |
| 72 |
return this; |
| 73 |
} |
| 74 |
|
| 75 |
|
| 76 |
CVariableBindingPathSet* CVariableBindingPathSet::copyVariableBindingPaths(CVariableBindingPathMap* varBindPathMap) { |
| 77 |
if (varBindPathMap) { |
| 78 |
mVarBindPathMap = *varBindPathMap; |
| 79 |
} |
| 80 |
return this; |
| 81 |
} |
| 82 |
|
| 83 |
CConceptDescriptor* CVariableBindingPathSet::getConceptDescriptor() { |
| 84 |
return mConceptDescriptor; |
| 85 |
} |
| 86 |
|
| 87 |
CVariableBindingPathSet* CVariableBindingPathSet::setConceptDescriptor(CConceptDescriptor* conDes) { |
| 88 |
mConceptDescriptor = conDes; |
| 89 |
return this; |
| 90 |
} |
| 91 |
|
| 92 |
|
| 93 |
CVariableBindingPathSet* CVariableBindingPathSet::addVariableBindingPathDescriptorLinker(CVariableBindingPathDescriptor* varBindPathDesLinker) { |
| 94 |
mVarBindPathDesLinker = varBindPathDesLinker->append(mVarBindPathDesLinker); |
| 95 |
return this; |
| 96 |
} |
| 97 |
|
| 98 |
|
| 99 |
CVariableBindingPathDescriptor* CVariableBindingPathSet::getVariableBindingPathDescriptorLinker() { |
| 100 |
return mVarBindPathDesLinker; |
| 101 |
} |
| 102 |
|
| 103 |
|
| 104 |
}; // end namespace Process |
| 105 |
|
| 106 |
}; // end namespace Kernel |
| 107 |
|
| 108 |
}; // end namespace Reasoner |
| 109 |
|
| 110 |
}; // end namespace Konclude |