std::size_t annotation_hasher::hash(const annotation& v) { std::size_t seed(0); combine(seed, hash_std_unordered_map_std_string_boost_shared_ptr_dogen_annotations_value(v.entries())); combine(seed, v.scope()); return seed; }
bool function_annotation::operator==(annotation const& o) const { bool is_equal = false; annotation_visitor av(true); av._([&](function_annotation const* fa) { is_equal = (this->name == fa->name) && equals(this->args, fa->args); }); o.accept(av); return is_equal; }
annotation annotation_groups_factory:: handle_profiles(const type_group& tg, const std::unordered_map<std::string, annotation>& profiles, const std::vector<std::string>& candidate_labels, const annotation& original) const { BOOST_LOG_SEV(lg, debug) << "Started handling profiles. Original: " << original; /* * If a profile name was specified via the meta-data, it must * exist on our profile collection. Locate it, merge it with the * original annotation and return that. */ const auto profn(obtain_profile_name(tg, original)); if (!profn.empty()) { BOOST_LOG_SEV(lg, debug) << "Configured profile: " << profn; const auto i(profiles.find(profn)); if (i == profiles.end()) { BOOST_LOG_SEV(lg, error) << missing_profile << profn; BOOST_THROW_EXCEPTION(building_error(missing_profile + profn)); } merger mg; const auto annotation_profile(i->second); const annotation r(mg.merge(original, annotation_profile)); BOOST_LOG_SEV(lg, debug) << "Merged profile: " << r; return r; } else BOOST_LOG_SEV(lg, debug) << "Profile not set in meta-data."; /* * Lets try each of the candidate labels instead and see if any of * them bind to a profile. */ const auto bound_labels(get_bound_labels(profiles, candidate_labels)); if (bound_labels.size() > 1) { BOOST_LOG_SEV(lg, error) << too_many_binds << bound_labels; BOOST_THROW_EXCEPTION(building_error(too_many_binds)); } for (const auto& bl : bound_labels) { BOOST_LOG_SEV(lg, debug) << "Bound label: " << bl; const auto i(profiles.find(bl)); if (i == profiles.end()) { BOOST_LOG_SEV(lg, error) << missing_profile << bl; BOOST_THROW_EXCEPTION(building_error(missing_profile + bl)); } merger mg; const auto annotation_profile(i->second); const annotation r(mg.merge(original, annotation_profile)); BOOST_LOG_SEV(lg, debug) << "Merged profile: " << r; return r; } /* * If no profile name was found by now, we need to try looking for * the well-known default profiles, based on the scope of the * annotation. Not all scope types have a mapping, and the default * profiles do not necessarily exist. */ const auto def_profn(get_default_profile_name_for_scope(original.scope())); if (!def_profn.empty()) { BOOST_LOG_SEV(lg, debug) << "Looking for default profile; " << def_profn; const auto i(profiles.find(def_profn)); if (i != profiles.end()) { merger mg; const auto annotation_profile(i->second); const annotation r(mg.merge(original, annotation_profile)); BOOST_LOG_SEV(lg, debug) << "Merged profile: " << r; return r; } } else BOOST_LOG_SEV(lg, debug) << "Scope does not have a default profile."; /* * If we could find nothing suitable, just return the original. */ BOOST_LOG_SEV(lg, debug) << "No profiles found, using original."; return original; }