void generalization_indexer:: populate(const generalization_details& d, model& m) const { for (const auto& pair : d.leaves) { const auto& n(pair.first); auto i(m.objects().find(n)); if (i == m.objects().end()) { const auto qn(n.qualified()); BOOST_LOG_SEV(lg, error) << object_not_found << qn; BOOST_THROW_EXCEPTION(indexing_error(object_not_found + qn)); } const auto rt(relationship_types::leaves); i->second.relationships()[rt] = pair.second; i->second.relationships()[rt].sort(); const auto omn(m.name().location().original_model_name()); for (const auto& l : pair.second) { if (l.location().original_model_name() == omn) m.leaves().insert(l); } } for (const auto& pair : d.original_parents) { const auto& n(pair.first); auto i(m.objects().find(n)); if (i == m.objects().end()) { const auto qn(n.qualified()); BOOST_LOG_SEV(lg, error) << object_not_found << qn; BOOST_THROW_EXCEPTION(indexing_error(object_not_found + qn)); } auto& o(i->second); if (!o.is_child()) { // a bit of a hack, top-level types have themselves as the // original parent of the container just to make our life easier BOOST_LOG_SEV(lg, debug) << "Type has parents but is not a child: " << n.qualified(); continue; } const auto rt(relationship_types::original_parents); o.relationships()[rt] = pair.second; for (const auto& opn : pair.second) { const auto j(m.objects().find(opn)); if (j == m.objects().end()) { const auto qn(opn.qualified()); BOOST_LOG_SEV(lg, error) << object_not_found << qn; BOOST_THROW_EXCEPTION(indexing_error(object_not_found + qn)); } o.is_original_parent_visitable(j->second.is_visitable()); } } }
void generalization_indexer:: populate(const generalization_details& d, intermediate_model& m) const { for (const auto& pair : d.leaves) { const auto& n(pair.first); auto i(m.objects().find(n.qualified())); if (i == m.objects().end()) { const auto qn(n.qualified()); BOOST_LOG_SEV(lg, error) << object_not_found << qn; BOOST_THROW_EXCEPTION(indexing_error(object_not_found + qn)); } auto& o(i->second); o.leaves(pair.second); o.leaves().sort(); for (const auto& leaf : pair.second) { if (leaf.location().model_modules() == m.name().location().model_modules()) m.leaves().insert(leaf); } } for (const auto& pair : d.root_parents) { const auto& n(pair.first); auto i(m.objects().find(n.qualified())); if (i == m.objects().end()) { const auto qn(n.qualified()); BOOST_LOG_SEV(lg, error) << object_not_found << qn; BOOST_THROW_EXCEPTION(indexing_error(object_not_found + qn)); } auto& o(i->second); if (!o.is_child()) { /* Top-level types have themselves as the original parent * of the container just to make our life easier, so we * have to ignore them here. */ BOOST_LOG_SEV(lg, debug) << "Type has parents but is not a child: " << n.qualified(); continue; } o.root_parents(pair.second); for (const auto& opn : pair.second) { const auto j(m.objects().find(opn.qualified())); if (j == m.objects().end()) { const auto qn(opn.qualified()); BOOST_LOG_SEV(lg, error) << object_not_found << qn; BOOST_THROW_EXCEPTION(indexing_error(object_not_found + qn)); } o.is_root_parent_visitable(j->second.is_visitable()); } } }
std::list<name> generalization_indexer:: recurse_generalization(const model& m, const name& leaf, const object& o, generalization_details& d) const { if (!o.is_child()) return std::list<name> { o.name() }; const auto i(o.relationships().find(relationship_types::parents)); if (i == o.relationships().end() || i->second.empty()) { const auto qn(o.name().qualified()); BOOST_LOG_SEV(lg, error) << child_with_no_parents << qn; BOOST_THROW_EXCEPTION(indexing_error(child_with_no_parents + qn)); } std::list<name> original_parents; for (const auto& parent : i->second) { auto j(m.objects().find(parent)); if (j == m.objects().end()) { const auto qn(parent.qualified()); BOOST_LOG_SEV(lg, error) << parent_not_found << qn; BOOST_THROW_EXCEPTION(indexing_error(parent_not_found + qn)); } const auto op(recurse_generalization(m, leaf, j->second, d)); if (op.empty()) { const auto qn(parent.qualified()); BOOST_LOG_SEV(lg, error) << child_with_no_original_parent << qn; BOOST_THROW_EXCEPTION( indexing_error(child_with_no_original_parent + qn)); } for (const auto qn : op) original_parents.push_back(qn); d.original_parents[parent] = op; BOOST_LOG_SEV(lg, debug) << "Type: " << parent.qualified() << " has original parents: " << op; d.leaves[parent].push_back(leaf); BOOST_LOG_SEV(lg, debug) << "Type is a leaf of: " << parent.qualified(); } d.original_parents[o.name()] = original_parents; return original_parents; }
concept& property_indexer::find_concept(const qname& qn, model& m) { auto i(m.concepts().find(qn)); if (i == m.concepts().end()) { const auto& sn(qn.simple_name()); BOOST_LOG_SEV(lg, error) << concept_not_found << sn; BOOST_THROW_EXCEPTION(indexing_error(concept_not_found + sn)); } return i->second; }
object& property_indexer::find_object(const qname& qn, model& m) { auto i(m.objects().find(qn)); if (i == m.objects().end()) { const auto n(sml::string_converter::convert(qn)); BOOST_LOG_SEV(lg, error) << object_not_found << n; BOOST_THROW_EXCEPTION(indexing_error(object_not_found + n)); } return i->second; }
concept& concept_indexer::find_concept(const qname& qn, model& m) { auto i(m.concepts().find(qn)); if (i == m.concepts().end()) { const auto n(string_converter::convert(qn)); BOOST_LOG_SEV(lg, error) << concept_not_found << n; BOOST_THROW_EXCEPTION(indexing_error(concept_not_found + n)); } return i->second; }
std::list<qname>& property_indexer:: find_relationships(const relationship_types rt, object& o) { auto i(o.relationships().find(rt)); if (i == o.relationships().end() || i->second.empty()) { const auto n(sml::string_converter::convert(o.name())); BOOST_LOG_SEV(lg, error) << relationship_not_found << n << " relationship: " << rt; BOOST_THROW_EXCEPTION(indexing_error(relationship_not_found + n)); } return i->second; }