| 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_REALIZER_COPTIMIZEDREPRESENTATIVEKPSETINDIVIDUALCANDIATESITERATOR_H |
| 22 |
#define KONCLUDE_REASONER_REALIZER_COPTIMIZEDREPRESENTATIVEKPSETINDIVIDUALCANDIATESITERATOR_H |
| 23 |
|
| 24 |
// Libraries includes |
| 25 |
|
| 26 |
|
| 27 |
// Namespace includes |
| 28 |
#include "RealizerSettings.h" |
| 29 |
#include "COptimizedKPSetRoleInstancesItem.h" |
| 30 |
#include "COptimizedKPSetIndividualComplexRoleData.h" |
| 31 |
#include "COptimizedKPSetIndividualInstantiatedItemMultiHash.h" |
| 32 |
|
| 33 |
|
| 34 |
// Other includes |
| 35 |
#include "Reasoner/Realization/CRealizationIndividualInstanceItemReferenceIterator.h" |
| 36 |
|
| 37 |
#include "Reasoner/Kernel/Cache/CBackendRepresentativeMemoryCacheReader.h" |
| 38 |
|
| 39 |
// Logger includes |
| 40 |
#include "Logger/CLogger.h" |
| 41 |
|
| 42 |
|
| 43 |
namespace Konclude { |
| 44 |
|
| 45 |
namespace Reasoner { |
| 46 |
|
| 47 |
using namespace Kernel::Cache; |
| 48 |
using namespace Realization; |
| 49 |
|
| 50 |
namespace Realizer { |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
/*! |
| 55 |
* |
| 56 |
* \class COptimizedRepresentativeKPSetIndividualCandiatesIterator |
| 57 |
* \author Andreas Steigmiller |
| 58 |
* \version 0.1 |
| 59 |
* \brief TODO |
| 60 |
* |
| 61 |
*/ |
| 62 |
class COptimizedRepresentativeKPSetIndividualCandiatesIterator : public CRealizationIndividualInstanceItemReferenceIterator { |
| 63 |
// public methods |
| 64 |
public: |
| 65 |
//! Constructor |
| 66 |
COptimizedRepresentativeKPSetIndividualCandiatesIterator(const QMap<cint64, IndividualIdCandidateData>& candidateIndiIdsMap, CBackendRepresentativeMemoryCacheReader* backendAssocCacheReader, COptimizedKPSetIndividualInstantiatedItemMultiHash* individualInstantiatedItemHash, CIndividualVector* individualVector, const CRealizationIndividualSorting& sorting, const CRealizationIndividualInstanceItemReference& indiInstItemRefCursor, bool moveOverCursor = true); |
| 67 |
|
| 68 |
|
| 69 |
virtual bool requiresInitialization(); |
| 70 |
virtual bool begin(); |
| 71 |
|
| 72 |
|
| 73 |
virtual bool atEnd(); |
| 74 |
virtual CRealizationRemainingInstancesEstimation remainingInstancesEstimation(); |
| 75 |
|
| 76 |
virtual bool moveNext(); |
| 77 |
virtual bool moveTo(const CRealizationIndividualInstanceItemReference& indiInstItemRef, bool moveOver = true); |
| 78 |
|
| 79 |
virtual CRealizationIndividualInstanceItemReference currentIndividualInstanceItemReference(); |
| 80 |
virtual bool isCurrentInstancePossible(); |
| 81 |
virtual bool isCurrentInstanceCertain(); |
| 82 |
|
| 83 |
virtual CRealizationIndividualInstanceItemReferenceIterator* getCopy(); |
| 84 |
|
| 85 |
virtual CRealizationIndividualSorting getSorting(); |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
// protected methods |
| 90 |
protected: |
| 91 |
|
| 92 |
|
| 93 |
COptimizedRepresentativeKPSetIndividualCandiatesIterator* loadIteratorIndividualItemData(QMap<cint64, IndividualIdCandidateData>::const_iterator currentIndiIdsMapIt); |
| 94 |
|
| 95 |
|
| 96 |
// protected variables |
| 97 |
protected: |
| 98 |
CBackendRepresentativeMemoryCacheReader* mBackendAssocCacheReader; |
| 99 |
COptimizedKPSetIndividualInstantiatedItemMultiHash* mIndividualInstantiatedItemHash; |
| 100 |
CIndividualVector* mIndividualVector; |
| 101 |
CRealizationIndividualSorting mSorting; |
| 102 |
CRealizationIndividualInstanceItemReference mIndiInstItemRefCursor; |
| 103 |
bool mMoveOverCursor; |
| 104 |
|
| 105 |
bool mIterateAscending; |
| 106 |
|
| 107 |
COptimizedKPSetIndividualComplexRoleData** mComplexRoleDataPointer; |
| 108 |
bool mInitializationRequired; |
| 109 |
bool mMapInitialized; |
| 110 |
|
| 111 |
QMap<cint64, IndividualIdCandidateData> mCandidateIndiIdsMap; |
| 112 |
|
| 113 |
QMap<cint64, IndividualIdCandidateData>::const_iterator mCandidateIndiIdsMapItBegin; |
| 114 |
QMap<cint64, IndividualIdCandidateData>::const_iterator mCandidateIndiIdsMapItEnd; |
| 115 |
QMap<cint64, IndividualIdCandidateData>::const_iterator mCandidateIndiIdsMapIt; |
| 116 |
cint64 mCurrentIndiId; |
| 117 |
bool mHasCurrentIndiId; |
| 118 |
COptimizedKPSetIndividualItem* mCurrentIndividualItem; |
| 119 |
CIndividual* mCurentIndividual; |
| 120 |
CRealizationIndividualInstanceItemReference mCurrentIndiInstItemRef; |
| 121 |
|
| 122 |
cint64 mMinIndiId; |
| 123 |
cint64 mMaxIndiId; |
| 124 |
|
| 125 |
cint64 mLastIndiId; |
| 126 |
cint64 mAverageIterationIncrementSize; |
| 127 |
cint64 mIterationCount; |
| 128 |
bool mIterationMoved; |
| 129 |
|
| 130 |
const static cint64 MAX_ITERTION_BEFORE_MOVE_LIMIT = 10; |
| 131 |
|
| 132 |
|
| 133 |
// private methods |
| 134 |
private: |
| 135 |
|
| 136 |
// private variables |
| 137 |
private: |
| 138 |
|
| 139 |
}; |
| 140 |
|
| 141 |
}; // end namespace Realizer |
| 142 |
|
| 143 |
}; // end namespace Reasoner |
| 144 |
|
| 145 |
}; // end namespace Konclude |
| 146 |
|
| 147 |
#endif // KONCLUDE_REASONER_REALIZER_COPTIMIZEDREPRESENTATIVEKPSETINDIVIDUALCANDIATESITERATOR_H |