#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 */