Debian Codegraph @

Source/Reasoner/Classifier/CSubsumptionClassifierThread.h

raw
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_CLASSIFIER_CSUBSUMPTIONCLASSIFIERTHREAD_H
22 #define KONCLUDE_REASONER_CLASSIFIER_CSUBSUMPTIONCLASSIFIERTHREAD_H
23
24 // Libraries includes
25
26
27 // Namespace includes
28 #include "ClassifierSettings.h"
29 #include "CSubsumptionClassifier.h"
30 #include "COntologyClassificationItem.h"
31 #include "CClassifyingCallbackDataContext.h"
32 #include "CClassSubsumptionClassifierContext.h"
33
34 // Other includes
35 #include "Reasoner/Classifier/Events/CClassifyOntologyEvent.h"
36 #include "Reasoner/Classifier/Events/CTestCalculatedCallbackEvent.h"
37 #include "Reasoner/Classifier/Events/CCallbackClassifiedOntologyEvent.h"
38 #include "Reasoner/Classifier/Events/COntologyTellClassificationMessageEvent.h"
39
40 #include "Reasoner/Ontology/CConcept.h"
41
42 #include "Reasoner/Kernel/Manager/CReasonerManager.h"
43
44
45 #include "Concurrent/CThread.h"
46
47 #include "Concurrent/Callback/CBlockingCallbackData.h"
48
49 // Logger includes
50 #include "Logger/CLogger.h"
51
52
53 namespace Konclude {
54
55 using namespace Concurrent;
56 using namespace Concurrent::Callback;
57
58 namespace Reasoner {
59
60 using namespace Ontology;
61 using namespace Kernel::Manager;
62 using namespace Kernel::Calculation;
63
64 namespace Classifier {
65
66 using namespace Events;
67
68
69 /*!
70 *
71 * \class CSubsumptionClassifierThread
72 * \author Andreas Steigmiller
73 * \version 0.1
74 * \brief TODO
75 *
76 */
77 class CSubsumptionClassifierThread : public CSubsumptionClassifier, public CThread {
78 // public methods
79 public:
80 //! Constructor
81 CSubsumptionClassifierThread(CReasonerManager *reasonerManager);
82
83 //! Destructor
84 virtual ~CSubsumptionClassifierThread();
85
86 virtual bool classify(CConcreteOntology *ontology, CConfigurationBase *config, const QList<COntologyProcessingRequirement*>& requirementList, CCallbackData* callback);
87 virtual bool classify(CConcreteOntology *ontology, CConfigurationBase *config, const QList<COntologyProcessingRequirement*>& requirementList);
88 virtual bool callbackClassified(CConcreteOntology *ontology, CCallbackData *callback);
89
90
91 virtual CClassifierStatistics *getClassificationStatistics();
92
93 virtual CClassificationProgress* getClassificationProgress();
94
95 virtual CClassificationMessageDataObserver* tellClassificationMessage(CConcreteOntology *ontology, CClassificationMessageData* messageData, CMemoryPool* memoryPool);
96
97 virtual bool isClassifierActive();
98
99 // protected methods
100 protected:
101 virtual bool processCustomsEvents(QEvent::Type type, CCustomEvent *event);
102
103
104 virtual bool isOntologyClassificationScheduled(CConcreteOntology *ontology);
105 virtual CSubsumptionClassifierThread* scheduleOntologyClassification(CConcreteOntology *ontology, CClassificationCalculationSupport *classificationSupport, CConfigurationBase *config);
106 virtual CSubsumptionClassifierThread* rescheduleOntologyClassification(CConcreteOntology *ontology);
107 virtual CSubsumptionClassifierThread* addOntologyClassifiedCallback(CConcreteOntology *ontology, CCallbackData *callback);
108 virtual CSubsumptionClassifierThread* addOntologyClassifyRequirements(CConcreteOntology *ontology, const QList<COntologyProcessingRequirement*>& requirementList);
109
110 virtual bool createNextSubsumtionTest() = 0;
111
112 virtual CSubsumptionClassifierThread* processCalculationJob(CSatisfiableCalculationJob* job, COntologyClassificationItem *ontClassItem, CCallbackData* callback, bool directlySubmit = true);
113 virtual CSubsumptionClassifierThread* submitCalculationJobs();
114
115 virtual bool interpreteTestResults(CTestCalculatedCallbackEvent *testResult) = 0;
116
117 virtual bool startProcessMoreTests();
118 virtual bool canProcessMoreTests();
119 virtual bool doNextPendingTests();
120
121
122 virtual bool processToldClassificationMessage(COntologyClassificationItem *ontClassItem, CClassificationMessageData* messageData, CMemoryPool* memoryPools);
123
124 // protected variables
125 protected:
126 qint64 confMaxTestParallelCount;
127 qint64 confMinTestParallelCount;
128
129 qint64 currRunningTestParallelCount;
130
131 QList<COntologyClassificationItem*> ontItemList;
132 QList<COntologyClassificationItem*> processingOntItemList;
133 QHash<CConcreteOntology*,COntologyClassificationItem*> ontItemHash;
134 cint64 mClassificationCount;
135
136 CReasonerManager* reasoner;
137 CCalculationManager* calculationManager;
138 QList< QPair<CCalculationJob*,CCallbackData*> > mJobCallbackList;
139
140 CClassifierStatistics* statistics;
141
142 cint64 mStatCalculatingJobs;
143
144 CClassSubsumptionClassifierContext mContext;
145
146 bool mClassifierActive;
147
148
149 // private methods
150 private:
151
152 // private variables
153 private:
154
155 };
156
157 }; // end namespace Classifier
158
159 }; // end namespace Reasoner
160
161 }; // end namespace Konclude
162
163 #endif // KONCLUDE_REASONER_CLASSIFIER_CSUBSUMPTIONCLASSIFIERTHREAD_H