| 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 "CNominalCachingLossReactivationHash.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Reasoner { |
| 27 |
|
| 28 |
namespace Kernel { |
| 29 |
|
| 30 |
namespace Process { |
| 31 |
|
| 32 |
|
| 33 |
CNominalCachingLossReactivationHash::CNominalCachingLossReactivationHash(CProcessContext* processContext) : mNominalReactivationDataHash(processContext),mProcessContext(processContext) { |
| 34 |
} |
| 35 |
|
| 36 |
CNominalCachingLossReactivationHash* CNominalCachingLossReactivationHash::initNominalDependentNodeHash(CNominalCachingLossReactivationHash* nominalDependentHash) { |
| 37 |
if (nominalDependentHash) { |
| 38 |
mNominalReactivationDataHash = nominalDependentHash->mNominalReactivationDataHash; |
| 39 |
} else { |
| 40 |
mNominalReactivationDataHash.clear(); |
| 41 |
} |
| 42 |
return this; |
| 43 |
} |
| 44 |
|
| 45 |
|
| 46 |
CNominalCachingLossReactivationData* CNominalCachingLossReactivationHash::getNominalCachingLossReactivationData(CIndividualProcessNode* nominalIndiNode, bool create) { |
| 47 |
return getNominalCachingLossReactivationData(nominalIndiNode->getIndividualNodeID(),create); |
| 48 |
} |
| 49 |
|
| 50 |
|
| 51 |
CNominalCachingLossReactivationData* CNominalCachingLossReactivationHash::getNominalCachingLossReactivationData(cint64 nominalID, bool create) { |
| 52 |
CNominalCachingLossReactivationData* nominalNodeReactData = nullptr; |
| 53 |
if (!create) { |
| 54 |
const CNominalCachingLossReactivationHashData& hashData = mNominalReactivationDataHash.value(nominalID); |
| 55 |
nominalNodeReactData = hashData.mPrevReactivationData; |
| 56 |
} else { |
| 57 |
CNominalCachingLossReactivationHashData& hashData = mNominalReactivationDataHash[nominalID]; |
| 58 |
nominalNodeReactData = hashData.mReactivationData; |
| 59 |
if (!nominalNodeReactData) { |
| 60 |
nominalNodeReactData = CObjectParameterizingAllocator< CNominalCachingLossReactivationData,CProcessContext* >::allocateAndConstructAndParameterize(mProcessContext->getUsedMemoryAllocationManager(),mProcessContext); |
| 61 |
nominalNodeReactData->initNominalCachingLossReactivationData(nominalID,hashData.mPrevReactivationData); |
| 62 |
hashData.mReactivationData = nominalNodeReactData; |
| 63 |
hashData.mPrevReactivationData = nominalNodeReactData; |
| 64 |
} |
| 65 |
} |
| 66 |
return nominalNodeReactData; |
| 67 |
} |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
}; // end namespace Process |
| 73 |
|
| 74 |
}; // end namespace Kernel |
| 75 |
|
| 76 |
}; // end namespace Reasoner |
| 77 |
|
| 78 |
}; // end namespace Konclude |