40class diagram_filter_factory;
56template <
typename ElementT,
typename DiagramT>
59template <
typename ElementT,
typename DiagramT>
61 const DiagramT &d,
const std::string &full_name);
127 filter_mode_t
mode()
const;
132 filter_mode_t
mode_{filter_mode_t::basic};
137 filter_t type, std::vector<std::unique_ptr<filter_visitor>> filters);
169 template <
typename E>
173 [&d, &
element](
const auto &f) { return f->match(d, element); });
181 std::vector<std::unique_ptr<filter_visitor>>
filters_;
186 filter_t type, std::vector<std::unique_ptr<filter_visitor>> filters);
218 template <
typename E>
222 [&d, &
element](
const auto &f) { return f->match(d, element); });
225 std::vector<std::unique_ptr<filter_visitor>>
filters_;
234 filter_t type, std::vector<common::namespace_or_regex> namespaces);
269 filter_t type, std::vector<config::element_filter_t> elements);
313 filter_t type, std::vector<config::method_type> method_types);
351 std::vector<common::string_or_regex>
roots_;
383template <
typename DiagramT,
typename ElementT,
384 typename ConfigEntryT = std::string,
405 if (!check_diagram_type<DiagramT>(d.
type()))
411 const auto &cd =
dynamic_cast<const DiagramT &
>(d);
416 const auto &fn = e.full_name(
false);
417 auto element_ref = detail::get<ElementT>(cd, fn);
419 if (!element_ref.has_value())
425 [&e](
const auto &te) {
426 std::string tes = te.get().full_name(false);
427 std::string es = e.full_name(false);
437 template <
typename C,
typename D>
439 const std::vector<relationship_t> &relationships)
const
441 bool added_new_element{
false};
443 for (
const auto &from_el : from) {
447 for (
const auto &rel : from_el.get().relationships()) {
450 for (
const auto &to_el : to) {
451 if (rel.destination() ==
453 const auto &to_add =
forward_ ? to_el : from_el;
455 added_new_element =
true;
462 return added_new_element;
471 auto parent = detail::get<ElementT, DiagramT>(
474 while (parent.has_value()) {
475 parents.emplace(parent.value());
476 parent = detail::get<ElementT, DiagramT>(
477 cd, parent.value().path().to_string());
484 void init(
const DiagramT &cd)
const
492 for (
const auto &root_pattern :
roots_) {
493 if constexpr (std::is_same_v<ConfigEntryT,
495 auto root_refs = cd.template find<ElementT>(root_pattern);
497 for (
auto &root : root_refs) {
498 if (root.has_value())
503 auto root_ref = detail::get<ElementT>(cd, root_pattern);
504 if (root_ref.has_value()) {
511 while (keep_looking) {
512 keep_looking =
false;
546 filter_t type, std::vector<relationship_t> relationships);
602 const diagram &d,
unsigned idx)
const;
605 const diagram &d,
unsigned idx)
const;
611 template <
typename ElementT,
typename DiagramT>
614 std::set<eid_t> &effective_context,
615 std::set<eid_t> ¤t_iteration_context)
const
617 static_assert(std::is_same_v<ElementT, class_diagram::model::class_> ||
618 std::is_same_v<ElementT, class_diagram::model::enum_> ||
619 std::is_same_v<ElementT, class_diagram::model::concept_> ||
620 std::is_same_v<ElementT, common::model::package>,
621 "ElementT must be either class_ or enum_ or concept_");
623 const auto &cd =
dynamic_cast<const DiagramT &
>(d);
625 for (
const auto &el : cd.template elements<ElementT>()) {
629 for (
const relationship &rel : el.get().relationships()) {
648 for (
const auto &element_id : effective_context) {
649 if (rel.destination() == element_id)
650 current_iteration_context.emplace(el.get().id());
657 for (
const auto element_id : effective_context) {
658 const auto &maybe_element = cd.get(element_id);
664 maybe_element.value().relationships()) {
683 if (rel.destination() == el.get().id())
684 current_iteration_context.emplace(el.get().id());
711 std::filesystem::path> {
713 const std::filesystem::path &root);
727 std::vector<std::filesystem::path>
paths_;
736 std::unique_ptr<method_type_filter> mtf);
818 assert(ex.get() != nullptr);
820 return ex->match(diagram_, e);
828 assert(in.get() != nullptr);
830 return in->match(diagram_, e);
836 filter_mode_t
mode()
const;
852 filter_mode_t
mode_{filter_mode_t::basic};
855template <
typename Collection>
858 col.erase(std::remove_if(col.begin(), col.end(),
860 return !filter.should_include(element);
867 std::vector<std::reference_wrapper<T>> &col,
const diagram_filter &filter)
869 col.erase(std::remove_if(col.begin(), col.end(),
871 return !filter.should_include(element.get());
877bool diagram_filter::should_include<std::string>(
const std::string &name)
const;