Debian Codegraph @

Source/Reasoner/Realizer/CRealizerThread.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_Realizer_CREALIZERTHREAD_H
22 #define KONCLUDE_REASONER_Realizer_CREALIZERTHREAD_H
23
24 // Libraries includes
25
26
27 // Namespace includes
28 #include "RealizerSettings.h"
29 #include "CRealizer.h"
30 #include "CRealizingContext.h"
31 #include "COntologyRealizingItem.h"
32 #include "CRealizingCallbackDataContext.h"
33 #include "CRealizingTestingItem.h"
34 #include "CRealizationMessageObserver.h"
35
36 // Other includes
37 #include "Reasoner/Realizer/Events/CCallbackRealizedOntologyEvent.h"
38 #include "Reasoner/Realizer/Events/CRealizeOntologyEvent.h"
39 #include "Reasoner/Realizer/Events/CRealizingCalculatedCallbackEvent.h"
40 #include "Reasoner/Realizer/Events/CRealizationMessageEvent.h"
41
42 #include "Reasoner/Ontology/CConcept.h"
43 #include "Reasoner/Ontology/COntologyProcessingRequirement.h"
44
45 #include "Reasoner/Kernel/Manager/CReasonerManager.h"
46
47 #include "Concurrent/CThread.h"
48
49 #include "Concurrent/Callback/CBlockingCallbackData.h"
50
51 // Logger includes
52 #include "Logger/CLogger.h"
53 #include "Logger/CLogDomain.h"
54
55
56 namespace Konclude {
57
58 using namespace Logger;
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 Realizer {
69
70 using namespace Events;
71
72
73 /*!
74 *
75 * \class CRealizerThread
76 * \author Andreas Steigmiller
77 * \version 0.1
78 * \brief TODO
79 *
80 */
81 class CRealizerThread : public CRealizer, public CThread, public CRealizationMessageObserver {
82 // public methods
83 public:
84 //! Constructor
85 CRealizerThread(CReasonerManager* reasonerManager);
86
87 //! Destructor
88 virtual ~CRealizerThread();
89
90 virtual bool realize(CConcreteOntology* ontology, CConfigurationBase* config, const QList<COntologyProcessingRequirement*>& requirementList, CCallbackData* callback);
91 virtual bool realize(CConcreteOntology* ontology, CConfigurationBase* config, const QList<COntologyProcessingRequirement*>& requirementList);
92 virtual bool callbackRealized(CConcreteOntology* ontology, CCallbackData* callback);
93
94 virtual CRealizationMessageObserver* tellRealizationMessage(CConcreteOntology *ontology, CRealizationMessageData* messageData, CMemoryPool* memoryPool);
95
96 // protected methods
97 protected:
98 virtual bool processCustomsEvents(QEvent::Type type, CCustomEvent *event);
99
100
101 virtual bool createNextTest() = 0;
102
103 virtual bool canProcessMoreTests();
104 virtual bool doNextPendingTests();
105
106 virtual COntologyRealizingItem* initializeOntologyRealizingItem(CConcreteOntology* ontology, CConfigurationBase* config);
107 virtual bool addOntologyRealizingCallback(COntologyRealizingItem* item, CCallbackData* callback);
108 virtual bool addOntologyRealizingRequirements(COntologyRealizingItem* item, COntologyProcessingRequirement* requirement, COntologyRealizingDynamicRequirmentProcessingData* procData);
109
110 CRealizerThread* processCalculationJob(CSatisfiableCalculationJob* job, COntologyRealizingItem* preCompItem, CRealizingTestingItem* preTestItem);
111
112 virtual bool realizingTested(COntologyRealizingItem* ontPreCompItem, CRealizingTestingItem* preTestItem, CRealizingCalculatedCallbackEvent* pcce) = 0;
113
114 virtual bool processRealizationMessage(COntologyRealizingItem* ontRealItem, CRealizationMessageData* messageData, CMemoryPool* memoryPools) = 0;
115
116
117 // protected variables
118 protected:
119 qint64 mConfMaxTestParallelCount;
120
121 qint64 mCurrRunningTestParallelCount;
122
123 QSet<COntologyRealizingItem*> mActiveOntItemSet;
124 QSet<COntologyRealizingItem*> mInactiveOntItemSet;
125 QList<COntologyRealizingItem*> mProcessingOntItemList;
126 QHash<CConcreteOntology*,COntologyRealizingItem*> mOntItemHash;
127 cint64 mRealizingCount;
128
129 CReasonerManager* mReasoner;
130 CCalculationManager* mCalculationManager;
131
132 cint64 mStatCalculatingJobs;
133 CRealizingContext mContext;
134
135
136
137 // private methods
138 private:
139
140 // private variables
141 private:
142
143 };
144
145 }; // end namespace Realizer
146
147 }; // end namespace Reasoner
148
149 }; // end namespace Konclude
150
151 #endif // KONCLUDE_REASONER_Realizer_CREALIZERTHREAD_H