| 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 "CNodeEdge.h" |
| 22 |
#include "CIndividualProcessNode.h" |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
namespace Konclude { |
| 27 |
|
| 28 |
namespace Reasoner { |
| 29 |
|
| 30 |
namespace Kernel { |
| 31 |
|
| 32 |
namespace Process { |
| 33 |
|
| 34 |
|
| 35 |
CNodeEdge::CNodeEdge(CProcessContext* processContext) { |
| 36 |
mSourceIndividual = nullptr; |
| 37 |
mDestinationIndividual = nullptr; |
| 38 |
initLocalizationTag(processContext->getUsedProcessTagger()); |
| 39 |
} |
| 40 |
|
| 41 |
CNodeEdge* CNodeEdge::initNodeEdge(CNodeEdge* nodeEdge) { |
| 42 |
mSourceIndividual = nodeEdge->mSourceIndividual; |
| 43 |
mDestinationIndividual = nodeEdge->mDestinationIndividual; |
| 44 |
initDependencyTracker(nodeEdge->mDependencyTrackPoint); |
| 45 |
return this; |
| 46 |
} |
| 47 |
|
| 48 |
CNodeEdge* CNodeEdge::initNodeEdge(CIndividualProcessNode* sourceIndividual, CIndividualProcessNode* destinationIndividual, CDependencyTrackPoint* depTrackPoint) { |
| 49 |
mSourceIndividual = sourceIndividual; |
| 50 |
mDestinationIndividual = destinationIndividual; |
| 51 |
initDependencyTracker(depTrackPoint); |
| 52 |
return this; |
| 53 |
} |
| 54 |
|
| 55 |
|
| 56 |
CIndividualProcessNode* CNodeEdge::getSourceIndividual() { |
| 57 |
return mSourceIndividual; |
| 58 |
} |
| 59 |
|
| 60 |
CIndividualProcessNode* CNodeEdge::getDestinationIndividual() { |
| 61 |
return mDestinationIndividual; |
| 62 |
} |
| 63 |
|
| 64 |
cint64 CNodeEdge::getSourceIndividualID() { |
| 65 |
cint64 indiID = 0; |
| 66 |
if (mSourceIndividual) { |
| 67 |
indiID = mSourceIndividual->getIndividualNodeID(); |
| 68 |
} |
| 69 |
return indiID; |
| 70 |
} |
| 71 |
|
| 72 |
cint64 CNodeEdge::getDestinationIndividualID() { |
| 73 |
cint64 indiID = 0; |
| 74 |
if (mDestinationIndividual) { |
| 75 |
indiID = mDestinationIndividual->getIndividualNodeID(); |
| 76 |
} |
| 77 |
return indiID; |
| 78 |
} |
| 79 |
|
| 80 |
|
| 81 |
CNodeEdge* CNodeEdge::setSourceIndividual(CIndividualProcessNode* sourceIndi) { |
| 82 |
mSourceIndividual = sourceIndi; |
| 83 |
return this; |
| 84 |
} |
| 85 |
|
| 86 |
CNodeEdge* CNodeEdge::setDestinationIndividual(CIndividualProcessNode* destinationIndi) { |
| 87 |
mDestinationIndividual = destinationIndi; |
| 88 |
return this; |
| 89 |
} |
| 90 |
|
| 91 |
CIndividualProcessNode* CNodeEdge::getOppositeIndividual(CIndividualProcessNode* indi) { |
| 92 |
if (indi) { |
| 93 |
return getOppositeIndividual(indi->getIndividualNodeID()); |
| 94 |
} |
| 95 |
return nullptr; |
| 96 |
} |
| 97 |
|
| 98 |
CIndividualProcessNode* CNodeEdge::getOppositeIndividual(cint64 indiID) { |
| 99 |
if (mSourceIndividual->getIndividualNodeID() == indiID) { |
| 100 |
return mDestinationIndividual; |
| 101 |
} |
| 102 |
return mSourceIndividual; |
| 103 |
} |
| 104 |
|
| 105 |
cint64 CNodeEdge::getOppositeIndividualID(CIndividualProcessNode* indi) { |
| 106 |
if (indi) { |
| 107 |
return getOppositeIndividualID(indi->getIndividualNodeID()); |
| 108 |
} |
| 109 |
return 0; |
| 110 |
} |
| 111 |
|
| 112 |
|
| 113 |
cint64 CNodeEdge::getOppositeIndividualID(cint64 indiID) { |
| 114 |
if (mSourceIndividual->getIndividualNodeID() == indiID) { |
| 115 |
return mDestinationIndividual->getIndividualNodeID(); |
| 116 |
} |
| 117 |
return mSourceIndividual->getIndividualNodeID(); |
| 118 |
} |
| 119 |
|
| 120 |
|
| 121 |
bool CNodeEdge::isDestinationIndividual(CIndividualProcessNode* indi) { |
| 122 |
return mDestinationIndividual == indi; |
| 123 |
} |
| 124 |
|
| 125 |
bool CNodeEdge::isDestinationIndividualID(CIndividualProcessNode* indi) { |
| 126 |
return mDestinationIndividual->getIndividualNodeID() == indi->getIndividualNodeID(); |
| 127 |
} |
| 128 |
|
| 129 |
bool CNodeEdge::isDestinationIndividualID(cint64 indiID) { |
| 130 |
return mDestinationIndividual->getIndividualNodeID() == indiID; |
| 131 |
} |
| 132 |
|
| 133 |
bool CNodeEdge::isSourceIndividual(CIndividualProcessNode* indi) { |
| 134 |
return mSourceIndividual == indi; |
| 135 |
} |
| 136 |
|
| 137 |
bool CNodeEdge::isSourceIndividualID(CIndividualProcessNode* indi) { |
| 138 |
return mSourceIndividual->getIndividualNodeID() == indi->getIndividualNodeID(); |
| 139 |
} |
| 140 |
|
| 141 |
bool CNodeEdge::isSourceIndividualID(cint64 indiID) { |
| 142 |
return mSourceIndividual->getIndividualNodeID() == indiID; |
| 143 |
} |
| 144 |
|
| 145 |
cint64 CNodeEdge::getCoupledIndividualID() { |
| 146 |
return mSourceIndividual->getIndividualNodeID() + mDestinationIndividual->getIndividualNodeID(); |
| 147 |
} |
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
}; // end namespace Process |
| 152 |
|
| 153 |
}; // end namespace Kernel |
| 154 |
|
| 155 |
}; // end namespace Reasoner |
| 156 |
|
| 157 |
}; // end namespace Konclude |