Debian Codegraph @

Source/Reasoner/Query/CIsConsistentQuery.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 "CIsConsistentQuery.h"
22
23
24 namespace Konclude {
25
26 namespace Reasoner {
27
28 namespace Query {
29
30
31 CIsConsistentQuery::CIsConsistentQuery(CConcreteOntology* ontology, CConfigurationBase* configuration, const QString& consistentQueryName)
32 : CConsistencePremisingQuery(ontology,configuration) {
33
34 queryName = consistentQueryName;
35 queryString = QString("Is ontology consistent?");
36 mResult = nullptr;
37 }
38
39 CIsConsistentQuery::~CIsConsistentQuery() {
40 if (mResult) {
41 delete mResult;
42 }
43 }
44
45
46 CQueryResult* CIsConsistentQuery::getQueryResult() {
47 return mResult;
48 }
49
50
51 CQueryResult *CIsConsistentQuery::constructResult(CConsistence* consistence) {
52 return constructConsistenceResult(consistence);
53 }
54
55
56 CBooleanQueryResult* CIsConsistentQuery::constructConsistenceResult(CConsistence* consistence) {
57 if (consistence) {
58 mResult = new CBooleanQueryResult(consistence->isOntologyConsistent());
59 }
60 return mResult;
61 }
62
63
64 QString CIsConsistentQuery::getQueryName() {
65 return queryName;
66 }
67
68 QString CIsConsistentQuery::getQueryString() {
69 return queryString;
70 }
71
72 bool CIsConsistentQuery::hasAnswer() {
73 return mResult != 0;
74 }
75
76
77 CQuery* CIsConsistentQuery::addQueryError(CQueryError* queryError) {
78 if (CQueryInconsitentOntologyError::hasInconsistentOntologyError(queryError)) {
79 mResult = new CBooleanQueryResult(false);
80 }
81 return CQuery::addQueryError(queryError);
82 }
83
84
85 QString CIsConsistentQuery::getAnswerString() {
86 if (!mResult) {
87 return QString("Consistency Unknown");
88 } else {
89 return mResult->getQueryResultString();
90 }
91 }
92
93 }; // end namespace Query
94
95 }; // end namespace Reasoner
96
97 }; // end namespace Konclude