| 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 "CRepresentativePropagationSet.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Reasoner { |
| 27 |
|
| 28 |
namespace Kernel { |
| 29 |
|
| 30 |
namespace Process { |
| 31 |
|
| 32 |
|
| 33 |
CRepresentativePropagationSet::CRepresentativePropagationSet(CProcessContext* processContext) : mProcessContext(processContext),mRepPropMap(processContext) { |
| 34 |
} |
| 35 |
|
| 36 |
CRepresentativePropagationSet* CRepresentativePropagationSet::initRepresentativePropagationSet(CRepresentativePropagationSet* prevSet) { |
| 37 |
if (prevSet) { |
| 38 |
mRepPropMap.initRepresentativePropagationMap(&prevSet->mRepPropMap); |
| 39 |
mIncomingRepPropSignature.initSignature(&prevSet->mIncomingRepPropSignature); |
| 40 |
mConceptDescriptor = prevSet->mConceptDescriptor; |
| 41 |
mIncomingRepPropDesLinker = prevSet->mIncomingRepPropDesLinker; |
| 42 |
mOutgoingRepPropDesLinker = prevSet->mOutgoingRepPropDesLinker; |
| 43 |
mLastProcessedIncomingRepPropDesLinker = prevSet->mLastProcessedIncomingRepPropDesLinker; |
| 44 |
} else { |
| 45 |
mRepPropMap.initRepresentativePropagationMap(nullptr); |
| 46 |
mIncomingRepPropSignature.initSignature(nullptr); |
| 47 |
mConceptDescriptor = nullptr; |
| 48 |
mIncomingRepPropDesLinker = nullptr; |
| 49 |
mOutgoingRepPropDesLinker = nullptr; |
| 50 |
mLastProcessedIncomingRepPropDesLinker = nullptr; |
| 51 |
} |
| 52 |
return this; |
| 53 |
} |
| 54 |
|
| 55 |
bool CRepresentativePropagationSet::containsRepresentativePropagation(CRepresentativeVariableBindingPathSetData* repVarBindPathSetData) { |
| 56 |
return mRepPropMap.contains(repVarBindPathSetData->getRepresentativeID()); |
| 57 |
} |
| 58 |
|
| 59 |
bool CRepresentativePropagationSet::containsRepresentativePropagation(cint64 repID) { |
| 60 |
return mRepPropMap.contains(repID); |
| 61 |
} |
| 62 |
|
| 63 |
CRepresentativePropagationDescriptor* CRepresentativePropagationSet::getRepresentativePropagationDescriptor(CRepresentativeVariableBindingPathSetData* repVarBindPathSetData) { |
| 64 |
return mRepPropMap.value(repVarBindPathSetData->getRepresentativeID()).getRepresentativePropagationDescriptor(); |
| 65 |
} |
| 66 |
|
| 67 |
|
| 68 |
CRepresentativePropagationMap* CRepresentativePropagationSet::getRepresentativePropagationMap() { |
| 69 |
return &mRepPropMap; |
| 70 |
} |
| 71 |
|
| 72 |
CRepresentativePropagationSet* CRepresentativePropagationSet::addIncomingRepresentativePropagation(CRepresentativePropagationDescriptor* repPropDes) { |
| 73 |
CRepresentativePropagationMapData& data = mRepPropMap[repPropDes->getRepresentativeVariableBindingPathSetData()->getRepresentativeID()]; |
| 74 |
if (!data.hasRepresentativePropagationDescriptor()) { |
| 75 |
data.setRepresentativePropagationDescriptor(repPropDes); |
| 76 |
if (mIncomingRepPropDesLinker) { |
| 77 |
mIncomingRepPropSignature.addKey(repPropDes->getRepresentativeVariableBindingPathSetData()->getRepresentativeKey()); |
| 78 |
} else { |
| 79 |
mIncomingRepPropSignature.initSignature(repPropDes->getRepresentativeVariableBindingPathSetData()->getKeySignature()); |
| 80 |
} |
| 81 |
mIncomingRepPropDesLinker = repPropDes->append(mIncomingRepPropDesLinker); |
| 82 |
} |
| 83 |
return this; |
| 84 |
} |
| 85 |
|
| 86 |
|
| 87 |
CRepresentativePropagationSet* CRepresentativePropagationSet::copyRepresentativePropagations(CRepresentativePropagationMap* repPropMap) { |
| 88 |
if (repPropMap) { |
| 89 |
mRepPropMap = *repPropMap; |
| 90 |
} |
| 91 |
return this; |
| 92 |
} |
| 93 |
|
| 94 |
CConceptDescriptor* CRepresentativePropagationSet::getConceptDescriptor() { |
| 95 |
return mConceptDescriptor; |
| 96 |
} |
| 97 |
|
| 98 |
CRepresentativePropagationSet* CRepresentativePropagationSet::setConceptDescriptor(CConceptDescriptor* conDes) { |
| 99 |
mConceptDescriptor = conDes; |
| 100 |
return this; |
| 101 |
} |
| 102 |
|
| 103 |
|
| 104 |
CRepresentativePropagationSet* CRepresentativePropagationSet::addIncomingRepresentativePropagationDescriptorLinker(CRepresentativePropagationDescriptor* repPropDesLinker) { |
| 105 |
for (CRepresentativePropagationDescriptor* repPropDesLinkerIt = repPropDesLinker; repPropDesLinkerIt; repPropDesLinkerIt = repPropDesLinkerIt->getNext()) { |
| 106 |
mIncomingRepPropSignature.addKey(repPropDesLinkerIt->getRepresentativeVariableBindingPathSetData()->getRepresentativeKey()); |
| 107 |
} |
| 108 |
mIncomingRepPropDesLinker = repPropDesLinker->append(mIncomingRepPropDesLinker); |
| 109 |
return this; |
| 110 |
} |
| 111 |
|
| 112 |
|
| 113 |
CRepresentativePropagationDescriptor* CRepresentativePropagationSet::getIncomingRepresentativePropagationDescriptorLinker() { |
| 114 |
return mIncomingRepPropDesLinker; |
| 115 |
} |
| 116 |
|
| 117 |
CRepresentativePropagationSet* CRepresentativePropagationSet::setOutgoingRepresentativePropagationDescriptorLinker(CRepresentativePropagationDescriptor* repPropDesLinker) { |
| 118 |
mOutgoingRepPropDesLinker = repPropDesLinker; |
| 119 |
return this; |
| 120 |
} |
| 121 |
|
| 122 |
CRepresentativePropagationSet* CRepresentativePropagationSet::addOutgoingRepresentativePropagationDescriptorLinker(CRepresentativePropagationDescriptor* repPropDesLinker) { |
| 123 |
mOutgoingRepPropDesLinker = repPropDesLinker->append(mOutgoingRepPropDesLinker); |
| 124 |
return this; |
| 125 |
} |
| 126 |
|
| 127 |
CRepresentativePropagationDescriptor* CRepresentativePropagationSet::getOutgoingRepresentativePropagationDescriptorLinker() { |
| 128 |
return mOutgoingRepPropDesLinker; |
| 129 |
} |
| 130 |
|
| 131 |
cint64 CRepresentativePropagationSet::getIncomingRepresentativePropagationSignatureKey() { |
| 132 |
return mIncomingRepPropSignature.getSignatureValue(); |
| 133 |
} |
| 134 |
|
| 135 |
CRepresentativePropagationDescriptor* CRepresentativePropagationSet::getLastProcessedIncomingRepresentativePropagationDescriptorLinker() { |
| 136 |
return mLastProcessedIncomingRepPropDesLinker; |
| 137 |
} |
| 138 |
|
| 139 |
CRepresentativePropagationSet* CRepresentativePropagationSet::setLastProcessedIncomingRepresentativePropagationDescriptorLinker(CRepresentativePropagationDescriptor* descriptor) { |
| 140 |
mLastProcessedIncomingRepPropDesLinker = descriptor; |
| 141 |
return this; |
| 142 |
} |
| 143 |
|
| 144 |
|
| 145 |
}; // end namespace Process |
| 146 |
|
| 147 |
}; // end namespace Kernel |
| 148 |
|
| 149 |
}; // end namespace Reasoner |
| 150 |
|
| 151 |
}; // end namespace Konclude |