| 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 |
#ifndef KONCLUDE_REASONER_KERNEL_PROCESS_CNODESWITCHHISTORY_H |
| 22 |
#define KONCLUDE_REASONER_KERNEL_PROCESS_CNODESWITCHHISTORY_H |
| 23 |
|
| 24 |
// Libraries includes |
| 25 |
|
| 26 |
|
| 27 |
// Namespace includes |
| 28 |
#include "ProcessSettings.h" |
| 29 |
#include "CProcessContext.h" |
| 30 |
#include "CIndividualProcessNode.h" |
| 31 |
|
| 32 |
|
| 33 |
// Other includes |
| 34 |
|
| 35 |
|
| 36 |
// Logger includes |
| 37 |
#include "Logger/CLogger.h" |
| 38 |
|
| 39 |
#include <limits> |
| 40 |
|
| 41 |
namespace Konclude { |
| 42 |
|
| 43 |
namespace Reasoner { |
| 44 |
|
| 45 |
namespace Kernel { |
| 46 |
|
| 47 |
namespace Process { |
| 48 |
|
| 49 |
/*! |
| 50 |
* |
| 51 |
* \class CNodeSwitchHistory |
| 52 |
* \author Andreas Steigmiller |
| 53 |
* \version 0.1 |
| 54 |
* \brief TODO |
| 55 |
* |
| 56 |
*/ |
| 57 |
class CNodeSwitchHistory { |
| 58 |
// public methods |
| 59 |
public: |
| 60 |
//! Constructor |
| 61 |
CNodeSwitchHistory(CProcessContext* processContext = nullptr); |
| 62 |
|
| 63 |
//! Destructor |
| 64 |
virtual ~CNodeSwitchHistory(); |
| 65 |
|
| 66 |
CNodeSwitchHistory* initSwitchHistory(CNodeSwitchHistory* prevSwitchHistory); |
| 67 |
CNodeSwitchHistory* addIndividualProcessNodeSwitch(CIndividualProcessNode* individual, cint64 indiSwitchTag); |
| 68 |
CNodeSwitchHistory* addIndividualProcessNodeSwitch(cint64 indiAncDepth, cint64 indiID, cint64 indiSwitchTag); |
| 69 |
|
| 70 |
CNodeSwitchHistory* updateLastIndividualProcessNodeSwitch(cint64 indiAncDepth, cint64 indiID); |
| 71 |
|
| 72 |
|
| 73 |
cint64 getMinIndividualAncestorDepth(cint64 indiSwitchTag); |
| 74 |
cint64 getMinIndividualNodeID(cint64 indiSwitchTag); |
| 75 |
|
| 76 |
bool getMinIndividualAncestorDepthAndNodeID(cint64 indiSwitchTag, cint64& indiAncDepth, cint64& indiNodeID); |
| 77 |
|
| 78 |
|
| 79 |
// protected methods |
| 80 |
protected: |
| 81 |
|
| 82 |
// protected variables |
| 83 |
protected: |
| 84 |
class CNodeSwitchHistoryLinkData { |
| 85 |
public: |
| 86 |
inline CNodeSwitchHistoryLinkData() { |
| 87 |
mNextData = nullptr; |
| 88 |
mUpData = nullptr; |
| 89 |
mDownData = nullptr; |
| 90 |
mLevelCount = 0; |
| 91 |
mNodeSwitchTag = 0; |
| 92 |
mNodeAncestorDepth = 0; |
| 93 |
mNodeIndividualID = 0; |
| 94 |
} |
| 95 |
|
| 96 |
inline CNodeSwitchHistoryLinkData* initCopy(CNodeSwitchHistoryLinkData* prevData) { |
| 97 |
mNextData = prevData->mNextData; |
| 98 |
mUpData = nullptr; |
| 99 |
mDownData = prevData->mDownData; |
| 100 |
mLevelCount = prevData->mLevelCount; |
| 101 |
mNodeSwitchTag = prevData->mNodeSwitchTag; |
| 102 |
mNodeAncestorDepth = prevData->mNodeAncestorDepth; |
| 103 |
mNodeIndividualID = prevData->mNodeIndividualID; |
| 104 |
return this; |
| 105 |
} |
| 106 |
|
| 107 |
CNodeSwitchHistoryLinkData* mNextData; |
| 108 |
CNodeSwitchHistoryLinkData* mUpData; |
| 109 |
CNodeSwitchHistoryLinkData* mDownData; |
| 110 |
cint64 mLevelCount; |
| 111 |
cint64 mNodeSwitchTag; |
| 112 |
cint64 mNodeAncestorDepth; |
| 113 |
cint64 mNodeIndividualID; |
| 114 |
}; |
| 115 |
|
| 116 |
CProcessContext* mContext; |
| 117 |
CNodeSwitchHistoryLinkData* mDownData; |
| 118 |
cint64 mLevelingCount; |
| 119 |
|
| 120 |
// private methods |
| 121 |
private: |
| 122 |
CNodeSwitchHistory* updateUpperData(CNodeSwitchHistoryLinkData* data, cint64 indiSwitchTag); |
| 123 |
|
| 124 |
// private variables |
| 125 |
private: |
| 126 |
|
| 127 |
}; |
| 128 |
|
| 129 |
}; // end namespace Process |
| 130 |
|
| 131 |
}; // end namespace Kernel |
| 132 |
|
| 133 |
}; // end namespace Reasoner |
| 134 |
|
| 135 |
}; // end namespace Konclude |
| 136 |
|
| 137 |
#endif // KONCLUDE_REASONER_KERNEL_PROCESS_CNODESWITCHHISTORY_H |