void merger::merge_model(const model& m) { const auto mn(m.name().model_name()); BOOST_LOG_SEV(lg, info) << "Merging model: '" << mn << " modules: " << m.modules().size() << " concepts: " << m.concepts().size() << " primitives: " << m.primitives().size() << " enumerations: " << m.enumerations().size() << " objects: " << m.objects().size(); for (const auto& c : m.concepts()) { check_qname(m.name().model_name(), c.first, c.second.name()); merged_model_.concepts().insert(c); } for (const auto& p : m.primitives()) { // FIXME: mega hack to handle primitive model. const auto pmn(mn == primitive_model_name ? empty : mn); check_qname(pmn, p.first, p.second.name()); merged_model_.primitives().insert(p); } for (const auto& p : m.enumerations()) { check_qname(mn, p.first, p.second.name()); merged_model_.enumerations().insert(p); } for (const auto& o : m.objects()) { check_qname(mn, o.first, o.second->name()); merged_model_.objects().insert(o); } }
void merger::add(const model& m) { require_not_has_merged(); BOOST_LOG_SEV(lg, debug) << "adding model: " << m.name().model_name(); BOOST_LOG_SEV(lg, debug) << "contents: " << m; models_.insert(std::make_pair(m.name(), m)); }
void merger::add(const model& m) { require_not_has_merged(); if (m.is_target()) add_target(m); BOOST_LOG_SEV(lg, debug) << "adding model: " << m.name().qualified(); BOOST_LOG_SEV(lg, debug) << "contents: " << m; models_.insert(std::make_pair(m.name(), m)); }
void merger::add_target(const model& target) { require_not_has_target(target.name().simple_name()); has_target_ = true; merged_model_.name(target.name()); merged_model_.documentation(target.documentation()); merged_model_.leaves(target.leaves()); merged_model_.modules(target.modules()); merged_model_.references(target.references()); add(target); BOOST_LOG_SEV(lg, debug) << "added target model: " << target.name().simple_name(); }
void merger::add_target(const model& target) { const auto qn(target.name().qualified()); require_not_has_target(qn); has_target_ = true; merged_model_.name(target.name()); merged_model_.documentation(target.documentation()); merged_model_.leaves(target.leaves()); merged_model_.modules(target.modules()); merged_model_.references(target.references()); merged_model_.extensions(target.extensions()); merged_model_.is_target(true); BOOST_LOG_SEV(lg, debug) << "added target model: " << qn; }
boost::optional<qname> containing_module(model& m, const qname& qn) { if (qn.model_name().empty() || qn.simple_name() == m.name().model_name()) { BOOST_LOG_SEV(lg, debug) << "Type has no containing module: " << string_converter::convert(qn); return boost::optional<qname>(); } qname module_qn; module_qn.model_name(qn.model_name()); if (qn.module_path().empty()) { module_qn.simple_name(qn.model_name()); } else { module_qn.simple_name(qn.module_path().back()); module_qn.module_path(qn.module_path()); module_qn.module_path().pop_back(); } const auto i(m.modules().find(module_qn)); if (i != m.modules().end()) return module_qn; BOOST_LOG_SEV(lg, debug) << "Could not find containing module: " << string_converter::convert(module_qn); return boost::optional<qname>();; }
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 merger::merge_model(const model& m) { BOOST_LOG_SEV(lg, info) << "Merging model: '" << m.name().qualified() << " modules: " << m.modules().size() << " concepts: " << m.concepts().size() << " primitives: " << m.primitives().size() << " enumerations: " << m.enumerations().size() << " objects: " << m.objects().size(); const auto mn(m.name().location().original_model_name()); for (const auto& c : m.concepts()) { check_name(mn, c.first, c.second.name()); merged_model_.concepts().insert(c); } for (const auto& pair : m.primitives()) { // FIXME: mega hack to handle primitive model. const auto pmn(mn == hardware_model_name ? empty : mn); check_name(pmn, pair.first, pair.second.name()); merged_model_.primitives().insert(pair); } for (const auto& pair : m.enumerations()) { check_name(mn, pair.first, pair.second.name()); merged_model_.enumerations().insert(pair); } for (const auto& pair : m.objects()) { check_name(mn, pair.first, pair.second.name()); merged_model_.objects().insert(pair); } for (const auto& pair : m.modules()) { if (!pair.first.simple().empty()) check_name(mn, pair.first, pair.second.name()); merged_model_.modules().insert(pair); } }
std::size_t model_hasher::hash(const model& v) { std::size_t seed(0); combine(seed, v.documentation()); combine(seed, v.extensions()); combine(seed, v.name()); combine(seed, v.generation_type()); combine(seed, v.origin_type()); combine(seed, hash_boost_optional_dogen_tack_name(v.containing_module())); combine(seed, hash_std_unordered_map_dogen_tack_name_dogen_tack_origin_types(v.references())); combine(seed, hash_std_unordered_set_dogen_tack_name(v.leaves())); combine(seed, hash_std_unordered_map_dogen_tack_name_dogen_tack_module(v.modules())); combine(seed, hash_std_unordered_map_dogen_tack_name_dogen_tack_concept(v.concepts())); combine(seed, hash_std_unordered_map_dogen_tack_name_dogen_tack_primitive(v.primitives())); combine(seed, hash_std_unordered_map_dogen_tack_name_dogen_tack_enumeration(v.enumerations())); combine(seed, hash_std_unordered_map_dogen_tack_name_dogen_tack_object(v.objects())); combine(seed, v.is_target()); combine(seed, v.has_generatable_types()); return seed; }
std::string json_hydrator::model_name(const model& m) const { if (m.name().model_name() == hardware_model_name) return empty; return m.name().model_name(); }