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

Detailed Description

Match element based on whether it is a subclass of a set of base classes, or one of them.

Definition at line 343 of file diagram_filter.h.

#include <diagram_filter.h>

Public Member Functions

 subclass_filter (filter_t type, std::vector< common::string_or_regex > roots)
 
 ~subclass_filter () override=default
 
tvl::value_t match (const diagram &d, const element &e) 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)
 

Private Attributes

std::vector< common::string_or_regexroots_
 

Constructor & Destructor Documentation

◆ subclass_filter()

clanguml::common::model::subclass_filter::subclass_filter ( filter_t  type,
std::vector< common::string_or_regex roots 
)

Definition at line 805 of file diagram_filter.cc.

808 , roots_{std::move(roots)}
809{
810}

◆ ~subclass_filter()

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

Member Function Documentation

◆ match()

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

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

Definition at line 812 of file diagram_filter.cc.

813{
814 if (d.type() != diagram_t::kClass)
815 return {};
816
817 if (roots_.empty())
818 return {};
819
820 if (!d.complete())
821 return {};
822
823 const auto &cd = dynamic_cast<const class_diagram::model::diagram &>(d);
824
825 // First get all parents of element e
827
828 const auto &fn = e.full_name(false);
829 auto class_ref = cd.find<class_diagram::model::class_>(fn);
830
831 if (!class_ref.has_value())
832 return false;
833
834 parents.emplace(class_ref.value());
835
836 cd.get_parents(parents);
837
838 std::vector<std::string> parents_names;
839 for (const auto p : parents)
840 parents_names.push_back(p.get().full_name(false));
841
842 // Now check if any of the parents matches the roots specified in the
843 // filter config
844 for (const auto &root : roots_) {
845 for (const auto &parent : parents) {
846 auto full_name = parent.get().full_name(false);
847 if (root == full_name) {
848 if (type() == filter_t::kExclusive)
849 LOG_TRACE("Element {} rejected by subclass_filter",
850 e.full_name(false));
851
852 return true;
853 }
854 }
855 }
856
857 if (type() == filter_t::kInclusive)
858 LOG_TRACE("Element {} rejected by subclass_filter", e.full_name(false));
859
860 return false;
861}

Member Data Documentation

◆ roots_

std::vector<common::string_or_regex> clanguml::common::model::subclass_filter::roots_
private

Definition at line 351 of file diagram_filter.h.


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