Debian Codegraph @

Source/Reasoner/Kernel/Process/CConceptNominalSchemaGroundingData.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 "CConceptNominalSchemaGroundingData.h"
22
23
24 namespace Konclude {
25
26 namespace Reasoner {
27
28 namespace Kernel {
29
30 namespace Process {
31
32 CConceptNominalSchemaGroundingData::CConceptNominalSchemaGroundingData(CContext* context) : mContext(context),mBindedNomSchConList(context) {
33 mGroundedConcept = nullptr;
34 mGroundingConcept = nullptr;
35 }
36
37 CConceptNominalSchemaGroundingData* CConceptNominalSchemaGroundingData::setGroundingConcept(CConcept* concept) {
38 mGroundingConcept = concept;
39 return this;
40 }
41
42 CConceptNominalSchemaGroundingData* CConceptNominalSchemaGroundingData::setGroundedConcept(CConcept* concept) {
43 mGroundedConcept = concept;
44 return this;
45 }
46
47 CConceptNominalSchemaGroundingData* CConceptNominalSchemaGroundingData::addBindedNominalSchemaConcept(CConcept* nsConcept) {
48 mBindedNomSchConList.append(nsConcept);
49 return this;
50 }
51
52 CPROCESSLIST<CConcept*>* CConceptNominalSchemaGroundingData::getBindedNominalSchemaConceptList() {
53 return &mBindedNomSchConList;
54 }
55
56 CConcept* CConceptNominalSchemaGroundingData::getGroundedConcept() {
57 return mGroundedConcept;
58 }
59
60 CConcept* CConceptNominalSchemaGroundingData::getGroundingConcept() {
61 return mGroundingConcept;
62 }
63
64 cint64 CConceptNominalSchemaGroundingData::calculateHashValue() {
65 cint64 hashValue = (cint64)mGroundingConcept;
66 cint64 multiplier = 13;
67 for (CPROCESSLIST<CConcept*>::const_iterator it = mBindedNomSchConList.constBegin(), itEnd = mBindedNomSchConList.constEnd(); it != itEnd; ++it) {
68 CConcept* concept = *it;
69 hashValue += multiplier*(cint64)concept;
70 multiplier = multiplier*2+1;
71 }
72 return hashValue;
73 }
74
75 bool CConceptNominalSchemaGroundingData::isEquivalentTo(const CConceptNominalSchemaGroundingData& data) const {
76 if (mGroundingConcept != data.mGroundingConcept) {
77 return false;
78 }
79 CPROCESSLIST<CConcept*>::const_iterator it1 = mBindedNomSchConList.constBegin(), it1End = mBindedNomSchConList.constEnd();
80 CPROCESSLIST<CConcept*>::const_iterator it2 = data.mBindedNomSchConList.constBegin(), it2End = data.mBindedNomSchConList.constEnd();
81 while (it1 != it1End) {
82 if (it2 == it2End) {
83 return false;
84 } else {
85 CConcept* con1 = *it1;
86 CConcept* con2 = *it2;
87 if (con1 != con2) {
88 return false;
89 }
90 }
91 ++it1;
92 ++it2;
93 }
94 return true;
95 }
96
97
98
99 }; // end namespace Process
100
101 }; // end namespace Kernel
102
103 }; // end namespace Reasoner
104
105 }; // end namespace Konclude