Refactored relationship and scope filter types
This commit is contained in:
@@ -165,9 +165,10 @@ struct subclass_filter : public filter_visitor {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct relationship_filter : public filter_visitor {
|
struct relationship_filter : public filter_visitor {
|
||||||
relationship_filter(filter_t type, std::vector<std::string> relationships)
|
relationship_filter(
|
||||||
|
filter_t type, std::vector<relationship_t> relationships)
|
||||||
: filter_visitor{type}
|
: filter_visitor{type}
|
||||||
, relationships_{relationships}
|
, relationships_{std::move(relationships)}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,19 +179,16 @@ struct relationship_filter : public filter_visitor {
|
|||||||
return {};
|
return {};
|
||||||
|
|
||||||
return std::any_of(relationships_.begin(), relationships_.end(),
|
return std::any_of(relationships_.begin(), relationships_.end(),
|
||||||
[&r](const auto &rel) {
|
[&r](const auto &rel) { return r == rel; });
|
||||||
bool res = to_string(r) == rel;
|
|
||||||
return res;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> relationships_;
|
std::vector<relationship_t> relationships_;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct scope_filter : public filter_visitor {
|
struct scope_filter : public filter_visitor {
|
||||||
scope_filter(filter_t type, std::vector<std::string> scopes)
|
scope_filter(filter_t type, std::vector<scope_t> scopes)
|
||||||
: filter_visitor{type}
|
: filter_visitor{type}
|
||||||
, scopes_{scopes}
|
, scopes_{std::move(scopes)}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,14 +197,11 @@ struct scope_filter : public filter_visitor {
|
|||||||
if (scopes_.empty())
|
if (scopes_.empty())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
return std::any_of(
|
return std::any_of(scopes_.begin(), scopes_.end(),
|
||||||
scopes_.begin(), scopes_.end(), [&s](const auto &rel) {
|
[&s](const auto &scope) { return s == scope; });
|
||||||
bool res = to_string(s) == rel;
|
|
||||||
return res;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> scopes_;
|
std::vector<scope_t> scopes_;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct context_filter : public filter_visitor {
|
struct context_filter : public filter_visitor {
|
||||||
|
|||||||
@@ -151,6 +151,7 @@ template <> void append_value<plantuml>(plantuml &l, const plantuml &r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace YAML {
|
namespace YAML {
|
||||||
|
using clanguml::common::model::relationship_t;
|
||||||
using clanguml::common::model::scope_t;
|
using clanguml::common::model::scope_t;
|
||||||
using clanguml::config::class_diagram;
|
using clanguml::config::class_diagram;
|
||||||
using clanguml::config::config;
|
using clanguml::config::config;
|
||||||
@@ -464,6 +465,53 @@ template <> struct convert<layout_hint> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// config relationship_t decoder
|
||||||
|
//
|
||||||
|
template <> struct convert<relationship_t> {
|
||||||
|
static bool decode(const Node &node, relationship_t &rhs)
|
||||||
|
{
|
||||||
|
assert(node.Type() == NodeType::Scalar);
|
||||||
|
|
||||||
|
auto relationship_name = node.as<std::string>();
|
||||||
|
if (relationship_name == "extension" ||
|
||||||
|
relationship_name == "inheritance") {
|
||||||
|
rhs = relationship_t::kExtension;
|
||||||
|
}
|
||||||
|
else if (relationship_name == "composition") {
|
||||||
|
rhs = relationship_t::kComposition;
|
||||||
|
}
|
||||||
|
else if (relationship_name == "aggregation") {
|
||||||
|
rhs = relationship_t::kAggregation;
|
||||||
|
}
|
||||||
|
else if (relationship_name == "containment") {
|
||||||
|
rhs = relationship_t::kContainment;
|
||||||
|
}
|
||||||
|
else if (relationship_name == "ownership") {
|
||||||
|
rhs = relationship_t::kOwnership;
|
||||||
|
}
|
||||||
|
else if (relationship_name == "association") {
|
||||||
|
rhs = relationship_t::kAssociation;
|
||||||
|
}
|
||||||
|
else if (relationship_name == "instantiation") {
|
||||||
|
rhs = relationship_t::kInstantiation;
|
||||||
|
}
|
||||||
|
else if (relationship_name == "friendship") {
|
||||||
|
rhs = relationship_t::kFriendship;
|
||||||
|
}
|
||||||
|
else if (relationship_name == "dependency") {
|
||||||
|
rhs = relationship_t::kDependency;
|
||||||
|
}
|
||||||
|
else if (relationship_name == "none") {
|
||||||
|
rhs = relationship_t::kNone;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
// config Yaml decoder
|
// config Yaml decoder
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -51,16 +51,16 @@ struct filter {
|
|||||||
std::vector<std::string> elements;
|
std::vector<std::string> elements;
|
||||||
|
|
||||||
// E.g.:
|
// E.g.:
|
||||||
// - inheritance
|
// - inheritance/extension
|
||||||
// - dependency
|
// - dependency
|
||||||
// - instantiation
|
// - instantiation
|
||||||
std::vector<std::string> relationships;
|
std::vector<common::model::relationship_t> relationships;
|
||||||
|
|
||||||
// E.g.:
|
// E.g.:
|
||||||
// - public
|
// - public
|
||||||
// - protected
|
// - protected
|
||||||
// - private
|
// - private
|
||||||
std::vector<std::string> scopes;
|
std::vector<common::model::scope_t> scopes;
|
||||||
|
|
||||||
std::vector<std::string> subclasses;
|
std::vector<std::string> subclasses;
|
||||||
|
|
||||||
|
|||||||
@@ -12,4 +12,4 @@ diagrams:
|
|||||||
subclasses:
|
subclasses:
|
||||||
- clanguml::t00039::A
|
- clanguml::t00039::A
|
||||||
relationships:
|
relationships:
|
||||||
- extension
|
- inheritance
|
||||||
Reference in New Issue
Block a user