Debian Codegraph @

Source/Reasoner/Consistiser/CPrecomputationThread.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_CONSISTISER_CPRECOMPUTATIONTHREAD_H
22 #define KONCLUDE_REASONER_CONSISTISER_CPRECOMPUTATIONTHREAD_H
23
24 // Libraries includes
25
26
27 // Namespace includes
28 #include "ConsistiserSettings.h"
29 #include "CPrecomputator.h"
30 #include "CConsistiser.h"
31 #include "CPrecomputationContext.h"
32 #include "COntologyPrecomputationItem.h"
33 #include "CPrecomputationCallbackDataContext.h"
34 #include "CPrecomputationTestingItem.h"
35
36 // Other includes
37 #include "Reasoner/Consistiser/Events/CCallbackPrecomputedOntologyEvent.h"
38 #include "Reasoner/Consistiser/Events/CPrecomputeOntologyEvent.h"
39 #include "Reasoner/Consistiser/Events/CPrecomputationCalculatedCallbackEvent.h"
40 #include "Reasoner/Consistiser/Events/CSaturationPrecomputationCalculatedCallbackEvent.h"
41 #include "Reasoner/Consistiser/Events/CRetrievedPrecomputationIndividualsCallbackEvent.h"
42 #include "Reasoner/Consistiser/Events/CRescheduleJobCreationEvent.h"
43
44
45 #include "Reasoner/Ontology/CConcept.h"
46
47 #include "Reasoner/Kernel/Manager/CReasonerManager.h"
48
49 #include "Concurrent/CThread.h"
50
51 #include "Concurrent/Callback/CBlockingCallbackData.h"
52
53 // Logger includes
54 #include "Logger/CLogger.h"
55
56
57 namespace Konclude {
58
59 using namespace Concurrent;
60 using namespace Concurrent::Callback;
61
62 namespace Reasoner {
63
64 using namespace Ontology;
65 using namespace Kernel::Manager;
66 using namespace Kernel::Calculation;
67
68 namespace Consistiser {
69
70 using namespace Events;
71
72
73 /*!
74 *
75 * \class CPrecomputationThread
76 * \author Andreas Steigmiller
77 * \version 0.1
78 * \brief TODO
79 *
80 */
81 class CPrecomputationThread : public CPrecomputator, public CConsistiser, public CThread {
82 // public methods
83 public:
84 //! Constructor
85 CPrecomputationThread(CReasonerManager* reasonerManager);
86
87 //! Destructor
88 virtual ~CPrecomputationThread();
89
90 virtual bool precompute(CConcreteOntology* ontology, CConfigurationBase* config, const QList<COntologyProcessingRequirement*>& requirementList, CCallbackData* callback);
91 virtual bool precompute(CConcreteOntology* ontology, CConfigurationBase* config, const QList<COntologyProcessingRequirement*>& requirementList);
92 virtual bool callbackPrecomputed(CConcreteOntology* ontology, CCallbackData* callback);
93
94
95 // protected methods
96 protected:
97 virtual bool processCustomsEvents(QEvent::Type type, CCustomEvent *event);
98
99
100 virtual bool createNextTest() = 0;
101
102 virtual bool canProcessMoreTests();
103 virtual bool doNextPendingTests();
104
105 virtual COntologyPrecomputationItem* initializeOntologyPrecomputionItem(CConcreteOntology* ontology, CConfigurationBase* config);
106 virtual bool addOntologyPrecomputionCallback(COntologyPrecomputationItem* item, CCallbackData* callback);
107 virtual bool addOntologyPrecomputionRequirements(COntologyPrecomputationItem* item, COntologyProcessingRequirement* requirement);
108
109 CPrecomputationThread* processCalculationJob(CSatisfiableCalculationJob* job, COntologyPrecomputationItem* preCompItem, CPrecomputationTestingItem* preTestItem);
110 CPrecomputationThread* processCalculationJob(CApproximatedSaturationCalculationJob* job, COntologyPrecomputationItem* preCompItem, CPrecomputationTestingItem* preTestItem);
111
112 virtual bool precomputationTested(COntologyPrecomputationItem* ontPreCompItem, CPrecomputationTestingItem* preTestItem, CPrecomputationCalculatedCallbackEvent* pcce) = 0;
113 virtual bool precomputationTested(COntologyPrecomputationItem* ontPreCompItem, CPrecomputationTestingItem* preTestItem, CSaturationPrecomputationCalculatedCallbackEvent* pcce) = 0;
114
115
116 virtual bool precomputationIndividualsRetrieved(COntologyPrecomputationItem* ontPreCompItem, CRetrievedPrecomputationIndividualsCallbackEvent* pcce) = 0;
117
118
119 // protected variables
120 protected:
121 qint64 mConfMaxTestParallelCount;
122 qint64 mConfMaxTestBatchCreationCount;
123
124 qint64 mCurrRunningTestParallelCount;
125
126 QSet<COntologyPrecomputationItem*> mActiveOntItemSet;
127 QSet<COntologyPrecomputationItem*> mInactiveOntItemSet;
128 QList<COntologyPrecomputationItem*> mProcessingOntItemList;
129 QHash<CConcreteOntology*,COntologyPrecomputationItem*> mOntItemHash;
130 cint64 mPrecomputationCount;
131
132 CReasonerManager* mReasoner;
133 CCalculationManager* mCalculationManager;
134
135
136 cint64 mStatCalculatingJobs;
137 CPrecomputationContext mContext;
138
139
140
141 // private methods
142 private:
143
144 // private variables
145 private:
146
147 };
148
149 }; // end namespace Consistiser
150
151 }; // end namespace Reasoner
152
153 }; // end namespace Konclude
154
155 #endif // KONCLUDE_REASONER_CONSISTISER_CPRECOMPUTATIONTHREAD_H