Debian Codegraph @

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