| 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 "CSuccessorIndividualATMOSTReactivationData.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Reasoner { |
| 27 |
|
| 28 |
namespace Kernel { |
| 29 |
|
| 30 |
namespace Process { |
| 31 |
|
| 32 |
|
| 33 |
CSuccessorIndividualATMOSTReactivationData::CSuccessorIndividualATMOSTReactivationData(CProcessContext* processContext) { |
| 34 |
mProcessContext = processContext; |
| 35 |
} |
| 36 |
|
| 37 |
CSuccessorIndividualATMOSTReactivationData* CSuccessorIndividualATMOSTReactivationData::initSuccessorIndividualATMOSTReactivationData(CSuccessorIndividualATMOSTReactivationData* data) { |
| 38 |
mDirectReactivationConDes = nullptr; |
| 39 |
mLastDirectIndiReactivationLinker = nullptr; |
| 40 |
mReactivationConDesIndiLinkerHash = nullptr; |
| 41 |
if (data) { |
| 42 |
if (data->mReactivationConDesIndiLinkerHash) { |
| 43 |
mReactivationConDesIndiLinkerHash = CObjectParameterizingAllocator< CPROCESSHASH< CConceptDescriptor*,CXLinker<CIndividualLinkEdge*>* >,CContext* >::allocateAndConstructAndParameterize(mProcessContext->getMemoryAllocationManager(),mProcessContext); |
| 44 |
*mReactivationConDesIndiLinkerHash = *data->mReactivationConDesIndiLinkerHash; |
| 45 |
} |
| 46 |
mLastDirectIndiReactivationLinker = data->mLastDirectIndiReactivationLinker; |
| 47 |
mDirectReactivationConDes = data->mDirectReactivationConDes; |
| 48 |
} |
| 49 |
return this; |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
CXLinker<CIndividualLinkEdge*>* CSuccessorIndividualATMOSTReactivationData::getReactivationSuccessorIndividualLinkLinker(CConceptDescriptor* atmostConDes) { |
| 56 |
if (mDirectReactivationConDes == atmostConDes) { |
| 57 |
return mLastDirectIndiReactivationLinker; |
| 58 |
} |
| 59 |
if (mReactivationConDesIndiLinkerHash) { |
| 60 |
return mReactivationConDesIndiLinkerHash->operator[](atmostConDes); |
| 61 |
} |
| 62 |
return nullptr; |
| 63 |
} |
| 64 |
|
| 65 |
bool CSuccessorIndividualATMOSTReactivationData::hasNewReactivationSuccessorIndividualLinkTriggered(CConceptDescriptor* atmostConDes, CXLinker<CIndividualLinkEdge*>* lastDirectIndiReactivationLinker) { |
| 66 |
return getReactivationSuccessorIndividualLinkLinker(atmostConDes) == lastDirectIndiReactivationLinker; |
| 67 |
} |
| 68 |
|
| 69 |
|
| 70 |
CSuccessorIndividualATMOSTReactivationData* CSuccessorIndividualATMOSTReactivationData::addReactivationSuccessorIIndividualLinkLinker(CConceptDescriptor* atmostConDes, CXLinker<CIndividualLinkEdge*>* indiProcNodeLinker) { |
| 71 |
if (!mDirectReactivationConDes || mDirectReactivationConDes == atmostConDes) { |
| 72 |
mLastDirectIndiReactivationLinker = indiProcNodeLinker->append(mLastDirectIndiReactivationLinker); |
| 73 |
mDirectReactivationConDes = atmostConDes; |
| 74 |
} else { |
| 75 |
if (!mReactivationConDesIndiLinkerHash) { |
| 76 |
mReactivationConDesIndiLinkerHash = CObjectParameterizingAllocator< CPROCESSHASH< CConceptDescriptor*,CXLinker<CIndividualLinkEdge*>* >,CContext* >::allocateAndConstructAndParameterize(mProcessContext->getMemoryAllocationManager(),mProcessContext); |
| 77 |
} |
| 78 |
CXLinker<CIndividualLinkEdge*>*& prevIndiLinker = mReactivationConDesIndiLinkerHash->operator[](atmostConDes); |
| 79 |
prevIndiLinker = indiProcNodeLinker->append(prevIndiLinker); |
| 80 |
} |
| 81 |
return this; |
| 82 |
} |
| 83 |
|
| 84 |
CSuccessorIndividualATMOSTReactivationData* CSuccessorIndividualATMOSTReactivationData::addReactivationSuccessorIndividualLink(CConceptDescriptor* atmostConDes, CIndividualLinkEdge* indiProcNode) { |
| 85 |
CXLinker<CIndividualLinkEdge*>* indiLinker = CObjectAllocator< CXLinker<CIndividualLinkEdge*> >::allocateAndConstruct(mProcessContext->getMemoryAllocationManager()); |
| 86 |
indiLinker->initLinker(indiProcNode); |
| 87 |
return addReactivationSuccessorIIndividualLinkLinker(atmostConDes,indiLinker); |
| 88 |
} |
| 89 |
|
| 90 |
|
| 91 |
}; // end namespace Process |
| 92 |
|
| 93 |
}; // end namespace Kernel |
| 94 |
|
| 95 |
}; // end namespace Reasoner |
| 96 |
|
| 97 |
}; // end namespace Konclude |