Debian Codegraph @

Source/Reasoner/Ontology/COntologyProcessingStepRequirement.cpp

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 #include "COntologyProcessingStepRequirement.h"
22
23
24 namespace Konclude {
25
26 namespace Reasoner {
27
28 namespace Ontology {
29
30
31 COntologyProcessingStepRequirement::COntologyProcessingStepRequirement(COntologyProcessingStep* requiredProcessingStep, cint64 requiredProcessingFlags, cint64 forbiddenProcessingFlags, cint64 requiredErrorFlags, cint64 forbiddenErrorFlags) {
32 mRequiredProcessingStep = requiredProcessingStep;
33 mRequiredProcessingFlags = requiredProcessingFlags;
34 mForbiddenProcessingFlags = forbiddenProcessingFlags;
35 mRequiredErrorFlags = requiredErrorFlags;
36 mForbiddenErrorFlags = forbiddenErrorFlags;
37 }
38
39
40 COntologyProcessingStep* COntologyProcessingStepRequirement::getRequiredProcessingStep() {
41 return mRequiredProcessingStep;
42 }
43
44 COntologyProcessingStepRequirement* COntologyProcessingStepRequirement::setRequiredProcessingStep(COntologyProcessingStep* requiredProcessingStep) {
45 mRequiredProcessingStep = requiredProcessingStep;
46 return this;
47 }
48
49 bool COntologyProcessingStepRequirement::isRequirementSatisfied(COntology* ontology) {
50 if (ontology) {
51 CConcreteOntology* conOntology = dynamic_cast<CConcreteOntology*>(ontology);
52 if (conOntology) {
53 COntologyProcessingSteps* processingSteps = conOntology->getProcessingSteps();
54 if (processingSteps) {
55 COntologyProcessingStepDataVector* proStepDataVec = processingSteps->getOntologyProcessingStepDataVector();
56 COntologyProcessingStepData* proStepData = proStepDataVec->getProcessingStepData(mRequiredProcessingStep->getProcessingStepID());
57 if (proStepData) {
58 COntologyProcessingStatus* proStatus = proStepData->getProcessingStatus();
59 if (!proStatus->hasPartialProcessingFlags(mRequiredProcessingFlags)) {
60 return false;
61 }
62 if (proStatus->hasPartialProcessingFlags(mForbiddenProcessingFlags)) {
63 return false;
64 }
65 if (!proStatus->hasPartialErrorFlags(mRequiredErrorFlags)) {
66 return false;
67 }
68 if (proStatus->hasPartialErrorFlags(mForbiddenErrorFlags)) {
69 return false;
70 }
71 return true;
72 }
73 }
74 }
75 }
76 return false;
77 }
78
79 COntologyProcessingStepRequirement* COntologyProcessingStepRequirement::submitRequirementUpdate(cint64 processingFlags, cint64 errorFlags) {
80 return this;
81 }
82
83
84 const QString COntologyProcessingStepRequirement::getRequirementFailureString(COntology* ontology) {
85 QString failureString;
86 if (!isRequirementSatisfied(ontology)) {
87 failureString = QString("'%1' processing step failed.").arg(mRequiredProcessingStep->getProcessingStepName());
88 }
89 return failureString;
90 }
91
92
93 }; // end namespace Ontology
94
95 }; // end namespace Reasoner
96
97 }; // end namespace Konclude