| 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 "CSaturationNodeAssociatedConceptExpansion.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Reasoner { |
| 27 |
|
| 28 |
namespace Kernel { |
| 29 |
|
| 30 |
namespace Cache { |
| 31 |
|
| 32 |
|
| 33 |
CSaturationNodeAssociatedConceptExpansion::CSaturationNodeAssociatedConceptExpansion(CSaturationNodeAssociatedExpansionCacheContext* context) : mContext(context),mConceptExpansionHash(context) { |
| 34 |
} |
| 35 |
|
| 36 |
CSaturationNodeAssociatedConceptExpansion* CSaturationNodeAssociatedConceptExpansion::initConceptExpansion() { |
| 37 |
mConceptExpansionLinker = nullptr; |
| 38 |
mHasTightCardinalityRestriction = false; |
| 39 |
mConceptExpansionCount = 0; |
| 40 |
mDependentNominalSet = nullptr; |
| 41 |
mConceptSetSignature = 0; |
| 42 |
mTotalConceptCount = 0; |
| 43 |
return this; |
| 44 |
} |
| 45 |
|
| 46 |
CCACHINGHASH<CCacheValueHasher,CSaturationNodeAssociatedConceptLinker*>* CSaturationNodeAssociatedConceptExpansion::getConceptExpansionHash() { |
| 47 |
return &mConceptExpansionHash; |
| 48 |
} |
| 49 |
|
| 50 |
|
| 51 |
CSaturationNodeAssociatedConceptExpansion* CSaturationNodeAssociatedConceptExpansion::addConceptExpansionLinker(CSaturationNodeAssociatedConceptLinker* conceptLinker) { |
| 52 |
if (conceptLinker) { |
| 53 |
mConceptExpansionCount += conceptLinker->getCount(); |
| 54 |
mConceptExpansionLinker = conceptLinker->append(mConceptExpansionLinker); |
| 55 |
mConceptExpansionHash.insert(CCacheValueHasher(conceptLinker->getCacheValue()),conceptLinker); |
| 56 |
} |
| 57 |
return this; |
| 58 |
} |
| 59 |
|
| 60 |
|
| 61 |
CSaturationNodeAssociatedConceptLinker* CSaturationNodeAssociatedConceptExpansion::getConceptExpansionLinker(CCacheValue* cacheValue) { |
| 62 |
CSaturationNodeAssociatedConceptLinker* linker = mConceptExpansionHash.value(CCacheValueHasher(cacheValue),nullptr); |
| 63 |
return linker; |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
bool CSaturationNodeAssociatedConceptExpansion::hasConceptExpansionLinker(CCacheValue* cacheValue) { |
| 68 |
return mConceptExpansionHash.contains(CCacheValueHasher(cacheValue)); |
| 69 |
} |
| 70 |
|
| 71 |
|
| 72 |
CSaturationNodeAssociatedConceptLinker* CSaturationNodeAssociatedConceptExpansion::getConceptExpansionLinker() { |
| 73 |
return mConceptExpansionLinker; |
| 74 |
} |
| 75 |
|
| 76 |
|
| 77 |
cint64 CSaturationNodeAssociatedConceptExpansion::getConceptExpansionCount() { |
| 78 |
return mConceptExpansionCount; |
| 79 |
} |
| 80 |
|
| 81 |
CSaturationNodeAssociatedConceptExpansion* CSaturationNodeAssociatedConceptExpansion::setConceptExpansionCount(cint64 count) { |
| 82 |
mConceptExpansionCount = count; |
| 83 |
return this; |
| 84 |
} |
| 85 |
|
| 86 |
CSaturationNodeAssociatedDependentNominalSet* CSaturationNodeAssociatedConceptExpansion::getDependentNominalSet(bool create) { |
| 87 |
if (!mDependentNominalSet && create) { |
| 88 |
mDependentNominalSet = CObjectParameterizingAllocator< CSaturationNodeAssociatedDependentNominalSet,CSaturationNodeAssociatedExpansionCacheContext* >::allocateAndConstructAndParameterize(mContext->getMemoryAllocationManager(),mContext); |
| 89 |
} |
| 90 |
return mDependentNominalSet; |
| 91 |
} |
| 92 |
|
| 93 |
bool CSaturationNodeAssociatedConceptExpansion::getHasTightAtMostRestriction() { |
| 94 |
return mHasTightCardinalityRestriction; |
| 95 |
} |
| 96 |
|
| 97 |
|
| 98 |
CSaturationNodeAssociatedConceptExpansion* CSaturationNodeAssociatedConceptExpansion::setHasTightCardinalityRestriction(bool tightAtMostRestrictions) { |
| 99 |
mHasTightCardinalityRestriction = tightAtMostRestrictions; |
| 100 |
return this; |
| 101 |
} |
| 102 |
|
| 103 |
|
| 104 |
cint64 CSaturationNodeAssociatedConceptExpansion::getConceptSetSignature() { |
| 105 |
return mConceptSetSignature; |
| 106 |
} |
| 107 |
|
| 108 |
CSaturationNodeAssociatedConceptExpansion* CSaturationNodeAssociatedConceptExpansion::setConceptSetSignature(cint64 signature) { |
| 109 |
mConceptSetSignature = signature; |
| 110 |
return this; |
| 111 |
} |
| 112 |
|
| 113 |
|
| 114 |
cint64 CSaturationNodeAssociatedConceptExpansion::getTotalConceptCount() { |
| 115 |
return mTotalConceptCount; |
| 116 |
} |
| 117 |
|
| 118 |
CSaturationNodeAssociatedConceptExpansion* CSaturationNodeAssociatedConceptExpansion::setTotalConceptCount(cint64 totalConceptCount) { |
| 119 |
mTotalConceptCount = totalConceptCount; |
| 120 |
return this; |
| 121 |
} |
| 122 |
|
| 123 |
|
| 124 |
}; // end namespace Cache |
| 125 |
|
| 126 |
}; // end namespace Kernel |
| 127 |
|
| 128 |
}; // end namespace Reasoner |
| 129 |
|
| 130 |
}; // end namespace Konclude |