Menu

[r45]: / trunk / libtop_engine / top_class.cpp  Maximize  Restore  History

Download this file

190 lines (137 with data), 7.4 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#include "top_class.h"
namespace model {
/////////////////////////////////////////////////////////////////////////////////////////
// top_class::get_asserted_inherited_property_membership
//
/////////////////////////////////////////////////////////////////////////////////////////
top_property_lookup_const_iterator
top_class::get_asserted_inherited_property_membership()const
{
m_asserted_inherited_properties.clear();
rdf_graph::index_iterator base_classes = m_model.find_asserted_objects(m_index, m_model.m_owl.rdfs_subClassOf);
while(!base_classes.is_end()) {
rdf_graph::index_iterator properties = m_model.find_asserted_subjects(m_model.m_owl.rdfs_domain, base_classes.get_triple().get_object());
while(!properties.is_end()) {
m_asserted_inherited_properties.push_back(properties.get_triple().get_subject());
properties.next();
}
base_classes.next();
}
return top_property_lookup_const_iterator(m_asserted_inherited_properties.begin(), m_asserted_inherited_properties.end(), top_property_lookup(m_model));
};
/////////////////////////////////////////////////////////////////////////////////////////
// top_class::get_inferred_inherited_property_membership
//
/////////////////////////////////////////////////////////////////////////////////////////
top_property_lookup_const_iterator
top_class::get_inferred_inherited_property_membership()const
{
m_inferred_inherited_property.clear();
rdf_session::index_iterator base_classes = m_model.find_objects(m_index, m_model.m_owl.rdfs_subClassOf);
while(!base_classes.is_end()) {
rdf_session::index_iterator properties = m_model.find_subjects(m_model.m_owl.rdfs_domain, base_classes.get_triple().get_object());
while(!properties.is_end()) {
m_inferred_inherited_property.push_back(properties.get_triple().get_subject());
properties.next();
}
base_classes.next();
}
return top_property_lookup_const_iterator(m_inferred_inherited_property.begin(), m_inferred_inherited_property.end(), top_property_lookup(m_model));
};
/////////////////////////////////////////////////////////////////////////////////////////
// top_class::get_asserted_necessary_criteria
//
/////////////////////////////////////////////////////////////////////////////////////////
top_class_lookup_const_iterator
top_class::get_asserted_necessary_criteria()const
{
m_asserted_necessary_criteria.clear();
top_class_const_iterator direct_base_classes = get_asserted_direct_base_classes();
while(!direct_base_classes.is_end()) {
index_type direct_base_class_index = direct_base_classes.get_value()->get_index();
// keep this if it is of type restriction
if(m_model.contains_asserted(direct_base_class_index, m_model.m_owl.rdf_type, m_model.m_owl.owl_Restriction)) {
m_asserted_necessary_criteria.push_back(direct_base_class_index);
}
direct_base_classes.next();
}
return top_class_lookup_const_iterator(m_asserted_necessary_criteria.begin(), m_asserted_necessary_criteria.end(), top_class_lookup(m_model));
};
/////////////////////////////////////////////////////////////////////////////////////////
// top_class::get_asserted_inherited_necessary_criteria
//
/////////////////////////////////////////////////////////////////////////////////////////
top_class_lookup_const_iterator
top_class::get_asserted_inherited_necessary_criteria()const
{
m_asserted_inherited_necessary_criteria.clear();
rdf_graph::index_iterator base_classes = m_model.find_asserted_objects(m_index, m_model.m_owl.rdfs_subClassOf);
while(!base_classes.is_end()) {
index_type base_class_index = base_classes.get_triple().get_object();
// keep this base class if it is not a direct base and is of type Restriction
if(m_asserted_base_classes.find(base_class_index) == m_asserted_base_classes.end() and
m_model.contains_asserted(base_class_index, m_model.m_owl.rdf_type, m_model.m_owl.owl_Restriction)) {
m_asserted_inherited_necessary_criteria.push_back(base_class_index);
}
// keep any equivalent classes to the base class excluding self!
rdf_graph::index_iterator eq_to_base = m_model.find_asserted_objects(base_class_index, m_model.m_owl.owl_equivalentClass);
while(!eq_to_base.is_end()) {
index_type eq_to_base_index = eq_to_base.get_triple().get_object();
if(m_index != eq_to_base_index) {
m_asserted_inherited_necessary_criteria.push_back(eq_to_base_index);
}
eq_to_base.next();
}
base_classes.next();
}
return top_class_lookup_const_iterator(m_asserted_inherited_necessary_criteria.begin(), m_asserted_inherited_necessary_criteria.end(), top_class_lookup(m_model));
};
/////////////////////////////////////////////////////////////////////////////////////////
// top_class::get_inferred_necessary_criteria
//
/////////////////////////////////////////////////////////////////////////////////////////
top_class_lookup_const_iterator
top_class::get_inferred_necessary_criteria()const
{
m_inferred_necessary_criteria.clear();
top_class_const_iterator direct_base_classes = get_inferred_direct_base_classes();
while(!direct_base_classes.is_end()) {
index_type direct_base_class_index = direct_base_classes.get_value()->get_index();
// keep this if it is of type restriction
if(m_model.contains(direct_base_class_index, m_model.m_owl.rdf_type, m_model.m_owl.owl_Restriction)) {
m_inferred_necessary_criteria.push_back(direct_base_class_index);
}
direct_base_classes.next();
}
return top_class_lookup_const_iterator(m_inferred_necessary_criteria.begin(), m_inferred_necessary_criteria.end(), top_class_lookup(m_model));
};
/////////////////////////////////////////////////////////////////////////////////////////
// top_class::get_inferred_inherited_necessary_criteria
//
/////////////////////////////////////////////////////////////////////////////////////////
top_class_lookup_const_iterator
top_class::get_inferred_inherited_necessary_criteria()const
{
m_inferred_inherited_necessary_criteria.clear();
rdf_session::index_iterator base_classes = m_model.find_objects(m_index, m_model.m_owl.rdfs_subClassOf);
while(!base_classes.is_end()) {
index_type base_class_index = base_classes.get_triple().get_object();
// keep this base class if it is not a direct base and is of type Restriction
if(m_inferred_base_classes.find(base_class_index) == m_inferred_base_classes.end() and
m_model.contains(base_class_index, m_model.m_owl.rdf_type, m_model.m_owl.owl_Restriction)) {
m_inferred_inherited_necessary_criteria.push_back(base_class_index);
}
// keep any equivalent classes to the base class except self!
rdf_session::index_iterator eq_to_base = m_model.find_objects(base_class_index, m_model.m_owl.owl_equivalentClass);
while(!eq_to_base.is_end()) {
index_type eq_base_class_index = eq_to_base.get_triple().get_object();
if(m_index != eq_base_class_index) {
m_inferred_inherited_necessary_criteria.push_back(eq_base_class_index);
}
eq_to_base.next();
}
base_classes.next();
}
return top_class_lookup_const_iterator(m_inferred_inherited_necessary_criteria.begin(), m_inferred_inherited_necessary_criteria.end(), top_class_lookup(m_model));
};
}; /* model namespace */
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.