0.6.1
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
clanguml::common::model::element_filter Struct Reference

Detailed Description

Match element's name to a set of names or regex patterns.

Definition at line 273 of file diagram_filter.h.

#include <diagram_filter.h>

Public Member Functions

 element_filter (filter_t type, std::vector< config::element_filter_t > elements)
 
 ~element_filter () override=default
 
tvl::value_t match (const diagram &d, const element &e) const override
 
tvl::value_t match (const diagram &d, const class_diagram::model::class_method &m) const override
 
tvl::value_t match (const diagram &d, const class_diagram::model::class_member &m) const override
 
tvl::value_t match (const diagram &d, const class_diagram::model::objc_method &m) const override
 
tvl::value_t match (const diagram &d, const class_diagram::model::objc_member &m) const override
 
tvl::value_t match (const diagram &d, const sequence_diagram::model::participant &p) const override
 
- Public Member Functions inherited from clanguml::common::model::filter_visitor
 filter_visitor (filter_t type)
 
virtual ~filter_visitor ()=default
 
virtual tvl::value_t match (const diagram &d, const common::model::element &e) const
 
virtual tvl::value_t match (const diagram &d, const common::model::relationship &r) const
 
virtual tvl::value_t match (const diagram &d, const common::model::relationship_t &r) const
 
virtual tvl::value_t match (const diagram &d, const common::model::access_t &a) const
 
virtual tvl::value_t match (const diagram &d, const common::model::namespace_ &ns) const
 
virtual tvl::value_t match (const diagram &d, const common::model::source_file &f) const
 
virtual tvl::value_t match (const diagram &d, const common::model::source_location &f) const
 
virtual tvl::value_t match (const diagram &d, const class_diagram::model::class_method &m) const
 
virtual tvl::value_t match (const diagram &d, const class_diagram::model::class_member &m) const
 
virtual tvl::value_t match (const diagram &d, const class_diagram::model::objc_method &m) const
 
virtual tvl::value_t match (const diagram &d, const class_diagram::model::objc_member &m) const
 
virtual tvl::value_t match (const diagram &d, const sequence_diagram::model::participant &p) const
 
bool is_inclusive () const
 
bool is_exclusive () const
 
filter_t type () const
 
filter_mode_t mode () const
 
void set_mode (filter_mode_t mode)
 
virtual void reset ()
 

Private Attributes

std::vector< config::element_filter_telements_
 

Constructor & Destructor Documentation

◆ element_filter()

clanguml::common::model::element_filter::element_filter ( filter_t  type,
std::vector< config::element_filter_t elements 
)

Definition at line 493 of file diagram_filter.cc.

496 , elements_{std::move(elements)}
497{
498}

◆ ~element_filter()

clanguml::common::model::element_filter::~element_filter ( )
overridedefault

Member Function Documentation

◆ match() [1/6]

tvl::value_t clanguml::common::model::element_filter::match ( const diagram d,
const class_diagram::model::class_member m 
) const
overridevirtual

Reimplemented from clanguml::common::model::filter_visitor.

Definition at line 548 of file diagram_filter.cc.

550{
551 auto res = tvl::any_of(elements_.begin(), elements_.end(),
552 [&m](const auto &ef) -> tvl::value_t {
553 // Apply this filter only if it had `member` type, do not apply
554 // `any` filters to methods for backward compatibility
555 if (ef.type != config::element_filter_t::filtered_type::member)
556 return {};
557
558 return ef.name == m.qualified_name();
559 });
560
561 if ((type() == filter_t::kInclusive && tvl::is_false(res)) ||
562 (type() == filter_t::kExclusive && tvl::is_true(res))) {
563 LOG_TRACE(
564 "Class member {} rejected by element_filter", m.qualified_name());
565 }
566
567 return res;
568}

◆ match() [2/6]

tvl::value_t clanguml::common::model::element_filter::match ( const diagram d,
const class_diagram::model::class_method m 
) const
overridevirtual

Reimplemented from clanguml::common::model::filter_visitor.

Definition at line 526 of file diagram_filter.cc.

528{
529 auto res = tvl::any_of(elements_.begin(), elements_.end(),
530 [&m](const auto &ef) -> tvl::value_t {
531 // Apply this filter only if it had `method` type, do not apply
532 // `any` filters to methods for backward compatibility
533 if (ef.type != config::element_filter_t::filtered_type::method)
534 return {};
535
536 return ef.name == m.qualified_name();
537 });
538
539 if ((type() == filter_t::kInclusive && tvl::is_false(res)) ||
540 (type() == filter_t::kExclusive && tvl::is_true(res))) {
541 LOG_TRACE(
542 "Class method {} rejected by element_filter", m.display_name());
543 }
544
545 return res;
546}

◆ match() [3/6]

tvl::value_t clanguml::common::model::element_filter::match ( const diagram d,
const class_diagram::model::objc_member m 
) const
overridevirtual

Reimplemented from clanguml::common::model::filter_visitor.

Definition at line 592 of file diagram_filter.cc.

594{
595 auto res = tvl::any_of(elements_.begin(), elements_.end(),
596 [&m](const auto &ef) -> tvl::value_t {
597 // Apply this filter only if it had `method` type, do not apply
598 // `any` filters to methods for backward compatibility
599 if (ef.type != config::element_filter_t::filtered_type::objc_member)
600 return {};
601
602 return ef.name == m.qualified_name();
603 });
604
605 if ((type() == filter_t::kInclusive && tvl::is_false(res)) ||
606 (type() == filter_t::kExclusive && tvl::is_true(res))) {
607 LOG_TRACE(
608 "ObjC member {} rejected by element_filter", m.qualified_name());
609 }
610
611 return res;
612}

◆ match() [4/6]

tvl::value_t clanguml::common::model::element_filter::match ( const diagram d,
const class_diagram::model::objc_method m 
) const
overridevirtual

Reimplemented from clanguml::common::model::filter_visitor.

Definition at line 570 of file diagram_filter.cc.

572{
573 auto res = tvl::any_of(elements_.begin(), elements_.end(),
574 [&m](const auto &ef) -> tvl::value_t {
575 // Apply this filter only if it had `objc_method` type, do not apply
576 // `any` filters to methods for backward compatibility
577 if (ef.type != config::element_filter_t::filtered_type::objc_method)
578 return {};
579
580 return ef.name == m.qualified_name();
581 });
582
583 if ((type() == filter_t::kInclusive && tvl::is_false(res)) ||
584 (type() == filter_t::kExclusive && tvl::is_true(res))) {
585 LOG_TRACE(
586 "ObjC method {} rejected by element_filter", m.qualified_name());
587 }
588
589 return res;
590}

◆ match() [5/6]

tvl::value_t clanguml::common::model::element_filter::match ( const diagram d,
const element e 
) const
overridevirtual

Reimplemented from clanguml::common::model::filter_visitor.

Definition at line 500 of file diagram_filter.cc.

501{
502 // Do not apply element filter to packages in class diagrams
503 if (d.type() == diagram_t::kClass && e.type_name() == "package")
504 return std::nullopt;
505
506 auto res =
507 tvl::any_of(elements_.begin(), elements_.end(), [&e](const auto &el) {
508 // First check if elements type matches the filter
509 if ((el.type != config::element_filter_t::filtered_type::any) &&
510 (config::to_string(el.type) != e.type_name())) {
511 return false;
512 }
513
514 return ((el.name == e.full_name(false)) ||
515 (el.name == fmt::format("::{}", e.full_name(false))));
516 });
517
518 if ((type() == filter_t::kInclusive && tvl::is_false(res)) ||
519 (type() == filter_t::kExclusive && tvl::is_true(res))) {
520 LOG_TRACE("Element {} rejected by element_filter", e.full_name(false));
521 }
522
523 return res;
524}

◆ match() [6/6]

tvl::value_t clanguml::common::model::element_filter::match ( const diagram d,
const sequence_diagram::model::participant p 
) const
overridevirtual

Reimplemented from clanguml::common::model::filter_visitor.

Definition at line 614 of file diagram_filter.cc.

616{
617 using sequence_diagram::model::method;
618 using sequence_diagram::model::participant;
619
620 if (d.type() != diagram_t::kSequence)
621 return {};
622
623 const auto &sequence_model =
624 dynamic_cast<const sequence_diagram::model::diagram &>(d);
625 auto res = tvl::any_of(elements_.begin(), elements_.end(),
626 [&sequence_model, &p](const auto &el) {
627 // First check if elements type matches the filter
628 if (el.type != config::element_filter_t::filtered_type::any &&
629 config::to_string(el.type) != p.type_name()) {
630 return false;
631 }
632
633 if (p.type_name() == "method") {
634 const auto &m = dynamic_cast<const method &>(p);
635 const auto class_id = m.class_id();
636 const auto &class_participant =
637 sequence_model.get_participant<participant>(class_id)
638 .value();
639
640 return (el.name == p.name_and_ns()) ||
641 (el.name == p.full_name(false)) ||
642 (el.name == class_participant.full_name(false));
643 }
644
645 if (p.type_name() == "objc_method") {
646 const auto &m =
647 dynamic_cast<const sequence_diagram::model::objc_method &>(
648 p);
649 const auto class_id = m.class_id();
650 const auto &class_participant =
651 sequence_model.get_participant<participant>(class_id)
652 .value();
653
654 return (el.name == p.name_and_ns()) ||
655 (el.name == p.full_name(false)) ||
656 (el.name == class_participant.full_name(false));
657 }
658
659 return el.name == p.full_name(false);
660 });
661
662 if ((type() == filter_t::kInclusive && tvl::is_false(res)) ||
663 (type() == filter_t::kExclusive && tvl::is_true(res))) {
664 LOG_TRACE(
665 "Participant {} rejected by element_filter", p.full_name(false));
666 }
667
668 return res;
669}

Member Data Documentation

◆ elements_

std::vector<config::element_filter_t> clanguml::common::model::element_filter::elements_
private

Definition at line 297 of file diagram_filter.h.


The documentation for this struct was generated from the following files: