Debian Codegraph @

Source/Reasoner/Taxonomy/CRolePropertiesParentChildPredecessorHierarchyNode.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 #ifndef KONCLUDE_REASONER_TAXONOMY_CROLEPROPERTIESPARENTCHILDPREDECESSORHIERARCHYNODE_CPP
21 #define KONCLUDE_REASONER_TAXONOMY_CROLEPROPERTIESPARENTCHILDPREDECESSORHIERARCHYNODE_CPP
22
23 #include "CRolePropertiesParentChildPredecessorHierarchyNode.h"
24
25
26 namespace Konclude {
27
28 namespace Reasoner {
29
30 namespace Taxonomy {
31
32
33 template<class T>
34 CRolePropertiesParentChildPredecessorHierarchyNode<T>::CRolePropertiesParentChildPredecessorHierarchyNode(CRole* representiveRole) : CParentChildPredecessorHierarchyNode<T,CRole*>(representiveRole) {
35 }
36
37
38 template<class T>
39 T* CRolePropertiesParentChildPredecessorHierarchyNode<T>::addEquivalentRole(CRole* role) {
40 CParentChildPredecessorHierarchyNode<T,CRole*>::addEquivalentElement(role);
41 return (T*)this;
42 }
43
44
45 template<class T>
46 QList<CRole*>* CRolePropertiesParentChildPredecessorHierarchyNode<T>::getEquivalentRoleList() {
47 return CParentChildPredecessorHierarchyNode<T,CRole*>::getEquivalentElementList();
48 }
49
50
51 template<class T>
52 CRole* CRolePropertiesParentChildPredecessorHierarchyNode<T>::getOneEquivalentRole() {
53 return CParentChildPredecessorHierarchyNode<T,CRole*>::getOneEquivalentElement(0);
54 }
55
56
57 template<class T>
58 qint64 CRolePropertiesParentChildPredecessorHierarchyNode<T>::getEquivalentRoleCount() {
59 return CParentChildPredecessorHierarchyNode<T,CRole*>::getEquivalentElementCount();
60 }
61
62
63 template<class T>
64 QString CRolePropertiesParentChildPredecessorHierarchyNode<T>::getEquivalentRoleNodeString() {
65 QString string;
66 QList<CRole*>* eqList = CParentChildPredecessorHierarchyNode<T,CRole*>::getEquivalentElementList();
67 for (typename QList<CRole*>::const_iterator it = eqList->constBegin(), itEnd = eqList->constEnd(); it != itEnd; ++it) {
68 CRole* role = *it;
69 QString iriPropertyNameString = CIRIName::getRecentIRIName(role->getPropertyNameLinker());
70 if (!string.isEmpty()) {
71 string += QString(" <=> %1").arg(iriPropertyNameString);
72 } else {
73 string = iriPropertyNameString;
74 }
75 }
76 return string;
77 }
78
79
80 template<class T>
81 QString CRolePropertiesParentChildPredecessorHierarchyNode<T>::getHierarchyRolesNodeString(qint64 depth) {
82 QString string(depth,'\t');
83 string += QString("< ") + CParentChildPredecessorHierarchyNode<T,CRole*>::getEquivalentRoleNodeString() + QString(" >\n");
84 QSet<T*>* childNodeSet = CParentChildPredecessorHierarchyNode<T,CRole*>::getChildNodeSet();
85 for (typename QSet<CRole*>::const_iterator it = childNodeSet->constBegin(), itEnd = childNodeSet->constEnd(); it != itEnd; ++it) {
86 CRolePropertiesParentChildPredecessorHierarchyNode<T>* childNode = *it;
87 string += childNode->getHierarchyRolesNodeString(depth+1);
88 }
89 string += QString(depth,'\t')+QString("</ ") + getEquivalentRoleNodeString() + QString(" >\n");
90 return string;
91 }
92
93
94 template<class T>
95 QStringList CRolePropertiesParentChildPredecessorHierarchyNode<T>::getEquivalentRoleStringList(bool preferAbbreviatedNames) {
96 QStringList stringList;
97 QList<CRole*>* eqList = CParentChildPredecessorHierarchyNode<T,CRole*>::getEquivalentElementList();
98 for (typename QList<CRole*>::const_iterator it = eqList->constBegin(), itEnd = eqList->constEnd(); it != itEnd; ++it) {
99 CRole* role = *it;
100 QStringList iriClassNameStringList;
101 if (preferAbbreviatedNames) {
102 iriClassNameStringList = CAbbreviatedIRIName::getAbbreviatedPrefixWithAbbreviatedIRINames(role->getPropertyNameLinker());
103 }
104
105 if (!preferAbbreviatedNames || iriClassNameStringList.isEmpty()) {
106 iriClassNameStringList = CIRIName::getIRINames(role->getPropertyNameLinker());
107 }
108 stringList<<iriClassNameStringList;
109 }
110 return stringList;
111 }
112
113 #ifdef DEBUGHIERARCHYNODEELEMENTSTRINGS
114 template<class T>
115 void CRolePropertiesParentChildPredecessorHierarchyNode<T>::generateNodeRelationStrings() {
116 parentNodeStrings.clear();
117 foreach (CRolePropertiesParentChildPredecessorHierarchyNode<T>* node, getParentNodeList()) {
118 parentNodeStrings<<node->getEquivalentRoleNodeString();
119 }
120 childNodeStrings.clear();
121 foreach (CRolePropertiesParentChildPredecessorHierarchyNode<T>* node, getChildNodeList()) {
122 childNodeStrings<<node->getEquivalentRoleNodeString();
123 }
124 precNodeStrings.clear();
125 foreach (CRolePropertiesParentChildPredecessorHierarchyNode<T>* node, getPredecessorNodeList()) {
126 precNodeStrings<<node->getEquivalentRoleNodeString();
127 }
128 }
129 #endif
130
131 #ifdef DEBUGHIERARCHYNODEELEMENTSTRINGS
132 template<class T>
133 void CRolePropertiesParentChildPredecessorHierarchyNode<T>::generateNodeElementStrings() {
134 nodeStrings.clear();
135 nodeStrings = getEquivalentRoleStringList(true);
136 }
137 #endif
138
139 }; // end namespace Taxonomy
140
141 }; // end namespace Reasoner
142
143 }; // end namespace Konclude
144
145 #endif // KONCLUDE_REASONER_TAXONOMY_CROLEPROPERTIESPARENTCHILDPREDECESSORHIERARCHYNODE_CPP