| 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_CANSWERINGMANAGERTHREAD_H |
| 22 |
#define KONCLUDE_REASONER_ANSWERER_CANSWERINGMANAGERTHREAD_H |
| 23 |
|
| 24 |
// Libraries includes |
| 25 |
#include <QLinkedList> |
| 26 |
|
| 27 |
// Namespace includes |
| 28 |
#include "AnswererSettings.h" |
| 29 |
#include "CAnsweringManager.h" |
| 30 |
#include "CAnswererThread.h" |
| 31 |
#include "CFirstQueuedAnsweringHandlerProvider.h" |
| 32 |
#include "CAnsweringManagerQueryData.h" |
| 33 |
#include "CConfigurationAnsweringHandlerFactory.h" |
| 34 |
#include "CAnsweringStatisticsCollectionStrings.h" |
| 35 |
|
| 36 |
|
| 37 |
// Other includes |
| 38 |
#include "Reasoner/Answerer/Events/CAnsweringComplexQueryCompletedEvent.h" |
| 39 |
#include "Reasoner/Answerer/Events/CAnswerComplexQueryEvent.h" |
| 40 |
#include "Reasoner/Answerer/Events/CAnsweringOntologyPreparationEvent.h" |
| 41 |
#include "Reasoner/Answerer/Events/CAnsweringPreparedEvent.h" |
| 42 |
|
| 43 |
#include "Reasoner/Query/CComplexAnsweringQuery.h" |
| 44 |
|
| 45 |
#include "Reasoner/Kernel/Manager/CReasonerManager.h" |
| 46 |
|
| 47 |
|
| 48 |
#include "Concurrent/CThread.h" |
| 49 |
|
| 50 |
|
| 51 |
// Logger includes |
| 52 |
#include "Logger/CLogger.h" |
| 53 |
#include "Logger/CLogIdentifier.h" |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
namespace Konclude { |
| 60 |
|
| 61 |
namespace Reasoner { |
| 62 |
|
| 63 |
using namespace Query; |
| 64 |
using namespace Kernel::Manager; |
| 65 |
|
| 66 |
namespace Answerer { |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
/*! |
| 71 |
* |
| 72 |
* \class CAnsweringManagerThread |
| 73 |
* \author Andreas Steigmiller |
| 74 |
* \version 0.1 |
| 75 |
* \brief TODO |
| 76 |
* |
| 77 |
*/ |
| 78 |
class CAnsweringManagerThread : public CAnsweringManager, public CThread { |
| 79 |
// public methods |
| 80 |
public: |
| 81 |
//! Constructor |
| 82 |
CAnsweringManagerThread(CReasonerManager* reasonerManager, CConfiguration* config); |
| 83 |
|
| 84 |
//! Destructor |
| 85 |
virtual ~CAnsweringManagerThread(); |
| 86 |
|
| 87 |
virtual CAnsweringManager* answerComplexQuery(CComplexAnsweringQuery* complexAnsweringQuery, CCallbackData* callback = nullptr); |
| 88 |
|
| 89 |
virtual CAnsweringProgress* getAnsweringProgress(); |
| 90 |
|
| 91 |
|
| 92 |
virtual CAnsweringStatistics* getAnsweringStatistics(CConcreteOntology* ontology); |
| 93 |
|
| 94 |
virtual CAnsweringManager* prepareAnswering(CConcreteOntology* ontology, CCallbackData* callback = nullptr); |
| 95 |
|
| 96 |
|
| 97 |
// protected methods |
| 98 |
protected: |
| 99 |
CAnsweringManager* queueComplexQueryAnswering(CComplexAnsweringQuery* complexAnsweringQuery, CCallbackData* callback); |
| 100 |
CAnsweringManager* finishComplexQueryAnswering(CAnsweringHandler* answeringHandler, CAnsweringManagerQueryData* queryData); |
| 101 |
|
| 102 |
virtual CAnsweringManager* manageComplexQueryAnswering(); |
| 103 |
|
| 104 |
virtual bool processCustomsEvents(QEvent::Type type, CCustomEvent *event); |
| 105 |
|
| 106 |
void createQueuedAnswererThread(); |
| 107 |
|
| 108 |
// protected variables |
| 109 |
protected: |
| 110 |
CConfiguration* mConfig; |
| 111 |
CFirstQueuedAnsweringHandlerProvider mHandlerProvider; |
| 112 |
|
| 113 |
|
| 114 |
CReasonerManager* mReasonerManager; |
| 115 |
|
| 116 |
|
| 117 |
QList<CAnswererThread*> mAnswererThreadContainer; |
| 118 |
QList<CAnswererThread*> mQueuedThreadList; |
| 119 |
QSet<CAnswererThread*> mProcessingThreadSet; |
| 120 |
cint64 mCurrentThreadCount; |
| 121 |
cint64 mConfMaxThreadCount; |
| 122 |
|
| 123 |
|
| 124 |
QList<CAnsweringManagerQueryData*> mQueuedExpressionQueryList; |
| 125 |
QList<CAnsweringManagerQueryData*> mQueuedCompositionQueryList; |
| 126 |
cint64 mCompositionQueryProcessingCount; |
| 127 |
cint64 mMaxCompositionQueryProcessingCount; |
| 128 |
QSet<CAnsweringManagerQueryData*> mProcessingQuerySet; |
| 129 |
|
| 130 |
QReadWriteLock mReadWriteLock; |
| 131 |
CAnsweringProgress mAnsweringProgress; |
| 132 |
|
| 133 |
|
| 134 |
// private methods |
| 135 |
private: |
| 136 |
|
| 137 |
// private variables |
| 138 |
private: |
| 139 |
|
| 140 |
}; |
| 141 |
|
| 142 |
}; // end namespace Answerer |
| 143 |
|
| 144 |
}; // end namespace Reasoner |
| 145 |
|
| 146 |
}; // end namespace Konclude |
| 147 |
|
| 148 |
#endif // KONCLUDE_REASONER_ANSWERER_CANSWERINGMANAGERTHREAD_H |