Debian Codegraph @

Source/Reasoner/Preprocess/CDataLiteralNormalizerPreProcess.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_CDATALITERALNORMALIZERPREPROCESS_H
22 #define KONCLUDE_REASONER_PREPROCESS_CDATALITERALNORMALIZERPREPROCESS_H
23
24 // Libraries includes
25 #include <QSet>
26 #include <QDomDocument>
27
28 // Namespace includes
29 #include "CConcreteOntologyContinuablePreProcess.h"
30 #include "CConceptRoleIndividualLocator.h"
31
32
33 // Other includes
34 #include "Reasoner/Ontology/CBoxContext.h"
35 #include "Reasoner/Ontology/CConcept.h"
36 #include "Reasoner/Ontology/CMBox.h"
37
38
39 // Logger includes
40 #include "Logger/CLogger.h"
41
42
43
44 namespace Konclude {
45
46 namespace Reasoner {
47
48 using namespace Ontology;
49
50 namespace Preprocess {
51
52 /*!
53 *
54 * \class CDataLiteralNormalizerPreProcess
55 * \author Andreas Steigmiller
56 * \version 0.1
57 * \brief TODO
58 *
59 */
60 class CDataLiteralNormalizerPreProcess : public CConcreteOntologyContinuablePreProcess {
61 // public methods
62 public:
63 //! Constructor
64 CDataLiteralNormalizerPreProcess();
65
66 //! Destructor
67 virtual ~CDataLiteralNormalizerPreProcess();
68
69
70 virtual CConcreteOntology *preprocess(CConcreteOntology *ontology, CPreProcessContext* context);
71
72 virtual CConcept *preprocessDataConcept(CConcept* dataConcept, CConcreteOntology *ontology, CPreProcessContext* context);
73 virtual CConcreteOntology* continuePreprocessing();
74
75 CDataLiteralValue* createPreprocessedDataLiteralValue(CDataLiteral* dataLiteral, CPreProcessContext* context, CContext* boxContext);
76
77
78 // protected methods
79 protected:
80 CDataLiteralValue* createDataLiteralValue(CDataLiteral* dataLiteral, CPreProcessContext* context);
81
82 bool normalizeDataLiteral(CConcept* dataLiteralConcept, CPreProcessContext* context);
83 bool normalizeDatatypeRestriction(CConcept* datatypeRestrictionConcept, CPreProcessContext* context);
84 CDataLiteral* getNormalizedDataLiteralForLengthRestriction(CDatatype* datatype, CDataLiteral* dataLiteral, bool roundUp, CPreProcessContext* context);
85
86 CConcept* createConcept();
87 CConcept* addConceptOperand(CConcept* concept, CConcept* operand, bool negated);
88
89
90 CDataLiteralValue* parseIntegerValue(const QString& valueString, CPreProcessContext* context);
91 CDataLiteralValue* parseDecimalValue(const QString& valueString, CPreProcessContext* context);
92 CDataLiteralValue* parseRationalValue(const QString& valueString, CPreProcessContext* context);
93 CDataLiteralValue* parseRealValue(const QString& valueString, CPreProcessContext* context);
94
95 CDataLiteralValue* parseStringValue(const QString& valueString, bool parseLanguageString, CPreProcessContext* context);
96 CDataLiteralValue* parseDateTimeValue(const QString& valueString, CPreProcessContext* context);
97 CDataLiteralValue* parseBooleanValue(const QString& valueString, CPreProcessContext* context);
98 CDataLiteralValue* parseDoubleValue(const QString& valueString, CPreProcessContext* context);
99 CDataLiteralValue* parseFloatValue(const QString& valueString, CPreProcessContext* context);
100 CDataLiteralValue* parseIRIValue(const QString& valueString, CPreProcessContext* context);
101 CDataLiteralValue* parseXMLValue(const QString& valueString, CPreProcessContext* context);
102 CDataLiteralValue* parseBinaryHexValue(const QString& valueString, CPreProcessContext* context);
103 CDataLiteralValue* parseBinaryBase64Value(const QString& valueString, CPreProcessContext* context);
104
105
106 cint64 getBinaryFromHex(QChar character);
107 cint64 getBinaryFromBase64(QChar character);
108
109 // private methods
110 private:
111
112 // private variables
113 private:
114 CABox* mABox = nullptr;
115 CTBox* mTBox = nullptr;
116 CRBox* mRBox = nullptr;
117 CMBox* mMBox = nullptr;
118 CContext* mBoxContext = nullptr;
119 CIndividualVector* mIndiVec = nullptr;
120 CRoleVector* mRolesVector = nullptr;
121 CConceptVector* mConceptVector = nullptr;
122 CConcreteOntology* mOntology = nullptr;
123
124 CMemoryAllocationManager* mMemMan = nullptr;
125
126 static bool mConvArraysInitialized;
127 static cint64* mHexStringBinaryDataConvArray;
128 static cint64* mBase64StringBinaryDataConvArray;
129
130
131 CPreProcessContext* mContext = nullptr;
132 cint64 mLastConceptId = 0;
133 cint64 mLastIndiId = 0;
134
135 };
136
137 }; // end namespace Preprocess
138
139 }; // end namespace Reasoner
140
141 }; // end namespace Konclude
142
143 #endif // KONCLUDE_REASONER_PREPROCESS_CDATALITERALNORMALIZERPREPROCESS_H