| 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_ANSWERER_COPTIMIZEDCOMPLEXVARIABLEJOININGBINDINGPOSITIONMAPPING_H |
| 22 |
#define KONCLUDE_REASONER_ANSWERER_COPTIMIZEDCOMPLEXVARIABLEJOININGBINDINGPOSITIONMAPPING_H |
| 23 |
|
| 24 |
// Libraries includes |
| 25 |
|
| 26 |
|
| 27 |
// Namespace includes |
| 28 |
#include "AnswererSettings.h" |
| 29 |
|
| 30 |
|
| 31 |
// Other includes |
| 32 |
#include "Utilities/UtilitiesSettings.h" |
| 33 |
|
| 34 |
|
| 35 |
// Logger includes |
| 36 |
#include "Logger/CLogger.h" |
| 37 |
|
| 38 |
|
| 39 |
namespace Konclude { |
| 40 |
|
| 41 |
using namespace Utilities; |
| 42 |
|
| 43 |
namespace Reasoner { |
| 44 |
|
| 45 |
namespace Answerer { |
| 46 |
|
| 47 |
|
| 48 |
/*! |
| 49 |
* |
| 50 |
* \class COptimizedComplexVariableCompositionItemVariableExpressionBinding |
| 51 |
* \author Andreas Steigmiller |
| 52 |
* \version 0.1 |
| 53 |
* \brief TODO |
| 54 |
* |
| 55 |
*/ |
| 56 |
class COptimizedComplexVariableJoiningBindingPositionMapping { |
| 57 |
// public methods |
| 58 |
public: |
| 59 |
//! Constructor |
| 60 |
COptimizedComplexVariableJoiningBindingPositionMapping(COptimizedComplexVariableCompositionItem* joiningVarItem, cint64 leftSize, cint64 rightSize); |
| 61 |
~COptimizedComplexVariableJoiningBindingPositionMapping(); |
| 62 |
|
| 63 |
|
| 64 |
COptimizedComplexVariableJoiningBindingPositionMapping(const COptimizedComplexVariableJoiningBindingPositionMapping& mapping); |
| 65 |
|
| 66 |
COptimizedComplexVariableCompositionItem* getJoiningVariableItem(); |
| 67 |
|
| 68 |
COptimizedComplexVariableJoiningBindingPositionMapping* addBindingPositionMapping(bool left, cint64 varIdx, cint64 mappedVarIdx); |
| 69 |
cint64 getMappedBindingPosition(bool left, cint64 varIdx); |
| 70 |
|
| 71 |
bool isSelfSameVariableReduction(); |
| 72 |
COptimizedComplexVariableJoiningBindingPositionMapping* setSelfSameVariableReduction(bool selfSameVariableReduction); |
| 73 |
|
| 74 |
bool isVariableReduction(); |
| 75 |
COptimizedComplexVariableJoiningBindingPositionMapping* setVariableReduction(bool variableReduction); |
| 76 |
|
| 77 |
|
| 78 |
cint64 getHashValue() const; |
| 79 |
bool operator==(const COptimizedComplexVariableJoiningBindingPositionMapping& mapping) const; |
| 80 |
|
| 81 |
|
| 82 |
CXLinker<cint64>* getLeftKeyBindingLinker(); |
| 83 |
CXLinker<cint64>* getRightKeyBindingLinker(); |
| 84 |
|
| 85 |
COptimizedComplexVariableJoiningBindingPositionMapping* setLeftKeyBindingLinker(CXLinker<cint64>* linker); |
| 86 |
COptimizedComplexVariableJoiningBindingPositionMapping* setRightKeyBindingLinker(CXLinker<cint64>* linker); |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
CXLinker<cint64>* getLeftRemainingBindingLinker(); |
| 91 |
CXLinker<cint64>* getRightRemainingBindingLinker(); |
| 92 |
|
| 93 |
COptimizedComplexVariableJoiningBindingPositionMapping* setLeftRemainingBindingLinker(CXLinker<cint64>* linker); |
| 94 |
COptimizedComplexVariableJoiningBindingPositionMapping* setRightRemainingBindingLinker(CXLinker<cint64>* linker); |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
cint64* getRightPosMapArray(); |
| 99 |
cint64* getLeftPosMapArray(); |
| 100 |
|
| 101 |
|
| 102 |
// protected methods |
| 103 |
protected: |
| 104 |
void deleteKeyBindingLinker(CXLinker<cint64>* keyBindingLinkerIt); |
| 105 |
CXLinker<cint64>* copyKeyBindingLinker(CXLinker<cint64>* originalKeyBindingLinker); |
| 106 |
|
| 107 |
// protected variables |
| 108 |
protected: |
| 109 |
bool mSelfSameVariableReduction; |
| 110 |
bool mVariableReduction; |
| 111 |
mutable bool mHashValueCaluclated; |
| 112 |
mutable cint64 mHashValue; |
| 113 |
COptimizedComplexVariableCompositionItem* mJoiningVarItem; |
| 114 |
CXLinker<cint64>* mLeftKeyBindingLinker; |
| 115 |
CXLinker<cint64>* mRightKeyBindingLinker; |
| 116 |
CXLinker<cint64>* mLeftRemainingBindingLinker; |
| 117 |
CXLinker<cint64>* mRightRemainingBindingLinker; |
| 118 |
cint64* mRightPosMapArray; |
| 119 |
cint64* mLeftPosMapArray; |
| 120 |
cint64 mLeftMapSize; |
| 121 |
cint64 mRightMapSize; |
| 122 |
|
| 123 |
|
| 124 |
// private methods |
| 125 |
private: |
| 126 |
|
| 127 |
// private variables |
| 128 |
private: |
| 129 |
|
| 130 |
}; |
| 131 |
|
| 132 |
|
| 133 |
inline uint qHash(const COptimizedComplexVariableJoiningBindingPositionMapping& hasher) { |
| 134 |
qint64 key = (qint64)hasher.getHashValue(); |
| 135 |
if (sizeof(quint64) > sizeof(uint)) { |
| 136 |
return uint((key >> (8 * sizeof(uint) - 1)) ^ key); |
| 137 |
} else { |
| 138 |
return uint(key); |
| 139 |
} |
| 140 |
} |
| 141 |
|
| 142 |
|
| 143 |
}; // end namespace Answerer |
| 144 |
|
| 145 |
}; // end namespace Reasoner |
| 146 |
|
| 147 |
}; // end namespace Konclude |
| 148 |
|
| 149 |
#endif // KONCLUDE_REASONER_ANSWERER_COPTIMIZEDCOMPLEXVARIABLEJOININGBINDINGPOSITIONMAPPING_H |