Added package dependencies and dependants filter
This commit is contained in:
@@ -26,6 +26,8 @@
|
||||
#include "common/model/stylable_element.h"
|
||||
#include "type_alias.h"
|
||||
|
||||
#include <type_safe/reference.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -90,3 +92,17 @@ private:
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace std {
|
||||
template <>
|
||||
struct hash<
|
||||
type_safe::object_ref<const clanguml::class_diagram::model::class_>> {
|
||||
std::size_t operator()(const type_safe::object_ref<
|
||||
const clanguml::class_diagram::model::class_> &key) const
|
||||
{
|
||||
using clanguml::class_diagram::model::class_;
|
||||
|
||||
return std::hash<std::string>{}(key.get().full_name(false));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -192,3 +192,11 @@ std::string diagram::to_alias(const std::string &full_name) const
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace clanguml::common::model {
|
||||
template <>
|
||||
bool check_diagram_type<clanguml::class_diagram::model::diagram>(diagram_t t)
|
||||
{
|
||||
return t == diagram_t::kClass;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,17 +83,7 @@ private:
|
||||
};
|
||||
}
|
||||
|
||||
namespace std {
|
||||
|
||||
namespace clanguml::common::model {
|
||||
template <>
|
||||
struct hash<
|
||||
type_safe::object_ref<const clanguml::class_diagram::model::class_>> {
|
||||
std::size_t operator()(const type_safe::object_ref<
|
||||
const clanguml::class_diagram::model::class_> &key) const
|
||||
{
|
||||
using clanguml::class_diagram::model::class_;
|
||||
|
||||
return std::hash<std::string>{}(key.get().full_name(false));
|
||||
}
|
||||
};
|
||||
}
|
||||
bool check_diagram_type<clanguml::class_diagram::model::diagram>(diagram_t t);
|
||||
}
|
||||
@@ -72,4 +72,5 @@ private:
|
||||
bool complete_{false};
|
||||
};
|
||||
|
||||
template <typename DiagramT> bool check_diagram_type(diagram_t t);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
#include "diagram_filter.h"
|
||||
|
||||
#include "class_diagram/model/class.h"
|
||||
#include "common/model/package.h"
|
||||
#include "package_diagram/model/diagram.h"
|
||||
|
||||
namespace clanguml::common::model {
|
||||
|
||||
@@ -38,6 +40,13 @@ view(const class_diagram::model::diagram &d)
|
||||
return d.enums();
|
||||
}
|
||||
|
||||
template <>
|
||||
const std::vector<type_safe::object_ref<const common::model::package>> &view(
|
||||
const package_diagram::model::diagram &d)
|
||||
{
|
||||
return d.packages();
|
||||
}
|
||||
|
||||
template <>
|
||||
const type_safe::optional_ref<const class_diagram::model::class_> get(
|
||||
const class_diagram::model::diagram &d, const std::string &full_name)
|
||||
@@ -45,6 +54,13 @@ const type_safe::optional_ref<const class_diagram::model::class_> get(
|
||||
return d.get_class(full_name);
|
||||
}
|
||||
|
||||
template <>
|
||||
const type_safe::optional_ref<const common::model::package> get(
|
||||
const package_diagram::model::diagram &d, const std::string &full_name)
|
||||
{
|
||||
return d.get_package(full_name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
filter_visitor::filter_visitor(filter_t type)
|
||||
@@ -357,17 +373,22 @@ void diagram_filter::init_filters(const config::diagram &c)
|
||||
if (c.include) {
|
||||
add_inclusive_filter(std::make_unique<namespace_filter>(
|
||||
filter_t::kInclusive, c.include().namespaces));
|
||||
|
||||
add_inclusive_filter(std::make_unique<relationship_filter>(
|
||||
filter_t::kInclusive, c.include().relationships));
|
||||
|
||||
add_inclusive_filter(std::make_unique<access_filter>(
|
||||
filter_t::kInclusive, c.include().access));
|
||||
|
||||
add_inclusive_filter(std::make_unique<paths_filter>(
|
||||
filter_t::kInclusive, c.base_directory(), c.include().paths));
|
||||
|
||||
// Include any of these matches even if one them does not match
|
||||
std::vector<std::unique_ptr<filter_visitor>> element_filters;
|
||||
|
||||
element_filters.emplace_back(std::make_unique<element_filter>(
|
||||
filter_t::kInclusive, c.include().elements));
|
||||
|
||||
element_filters.emplace_back(std::make_unique<subclass_filter>(
|
||||
filter_t::kInclusive, c.include().subclasses));
|
||||
|
||||
@@ -381,11 +402,21 @@ void diagram_filter::init_filters(const config::diagram &c)
|
||||
class_diagram::model::class_>>(filter_t::kInclusive,
|
||||
relationship_t::kDependency, c.include().dependants));
|
||||
|
||||
element_filters.emplace_back(std::make_unique<tree_element_filter<
|
||||
package_diagram::model::diagram, common::model::package>>(
|
||||
filter_t::kInclusive, relationship_t::kDependency,
|
||||
c.include().dependants));
|
||||
|
||||
element_filters.emplace_back(
|
||||
std::make_unique<tree_element_filter<class_diagram::model::diagram,
|
||||
class_diagram::model::class_>>(filter_t::kInclusive,
|
||||
relationship_t::kDependency, c.include().dependencies, true));
|
||||
|
||||
element_filters.emplace_back(std::make_unique<tree_element_filter<
|
||||
package_diagram::model::diagram, common::model::package>>(
|
||||
filter_t::kInclusive, relationship_t::kDependency,
|
||||
c.include().dependencies, true));
|
||||
|
||||
element_filters.emplace_back(std::make_unique<context_filter>(
|
||||
filter_t::kInclusive, c.include().context));
|
||||
|
||||
@@ -397,28 +428,47 @@ void diagram_filter::init_filters(const config::diagram &c)
|
||||
if (c.exclude) {
|
||||
add_exclusive_filter(std::make_unique<namespace_filter>(
|
||||
filter_t::kExclusive, c.exclude().namespaces));
|
||||
|
||||
add_exclusive_filter(std::make_unique<paths_filter>(
|
||||
filter_t::kExclusive, c.base_directory(), c.exclude().paths));
|
||||
|
||||
add_exclusive_filter(std::make_unique<element_filter>(
|
||||
filter_t::kExclusive, c.exclude().elements));
|
||||
|
||||
add_exclusive_filter(std::make_unique<relationship_filter>(
|
||||
filter_t::kExclusive, c.exclude().relationships));
|
||||
|
||||
add_exclusive_filter(std::make_unique<access_filter>(
|
||||
filter_t::kExclusive, c.exclude().access));
|
||||
|
||||
add_exclusive_filter(std::make_unique<subclass_filter>(
|
||||
filter_t::kExclusive, c.exclude().subclasses));
|
||||
|
||||
add_exclusive_filter(
|
||||
std::make_unique<tree_element_filter<class_diagram::model::diagram,
|
||||
class_diagram::model::class_>>(filter_t::kExclusive,
|
||||
relationship_t::kInstantiation, c.exclude().specializations));
|
||||
|
||||
add_exclusive_filter(
|
||||
std::make_unique<tree_element_filter<class_diagram::model::diagram,
|
||||
class_diagram::model::class_>>(filter_t::kExclusive,
|
||||
relationship_t::kDependency, c.exclude().dependants));
|
||||
|
||||
add_exclusive_filter(std::make_unique<tree_element_filter<
|
||||
package_diagram::model::diagram, common::model::package>>(
|
||||
filter_t::kExclusive, relationship_t::kDependency,
|
||||
c.exclude().dependants));
|
||||
|
||||
add_exclusive_filter(
|
||||
std::make_unique<tree_element_filter<class_diagram::model::diagram,
|
||||
class_diagram::model::class_>>(filter_t::kExclusive,
|
||||
relationship_t::kDependency, c.exclude().dependencies, true));
|
||||
|
||||
add_exclusive_filter(std::make_unique<tree_element_filter<
|
||||
package_diagram::model::diagram, common::model::package>>(
|
||||
filter_t::kExclusive, relationship_t::kDependency,
|
||||
c.exclude().dependencies, true));
|
||||
|
||||
add_exclusive_filter(std::make_unique<context_filter>(
|
||||
filter_t::kExclusive, c.exclude().context));
|
||||
}
|
||||
|
||||
@@ -125,14 +125,17 @@ struct tree_element_filter : public filter_visitor {
|
||||
|
||||
tvl::value_t match(const diagram &d, const element &e) const override
|
||||
{
|
||||
if (roots_.empty())
|
||||
return {};
|
||||
|
||||
// This filter should only be run on the completely generated diagram
|
||||
// model by visitor
|
||||
if (!d.complete())
|
||||
return {};
|
||||
|
||||
if (!check_diagram_type<DiagramT>(d.type()))
|
||||
return {};
|
||||
|
||||
if (roots_.empty())
|
||||
return {};
|
||||
|
||||
const auto &cd = dynamic_cast<const DiagramT &>(d);
|
||||
|
||||
// Calculate the set of matching elements
|
||||
@@ -146,14 +149,10 @@ struct tree_element_filter : public filter_visitor {
|
||||
return false;
|
||||
|
||||
// Now check if the e element is contained in the calculated set
|
||||
const auto &e_full_name = e.full_name(false);
|
||||
bool res =
|
||||
std::find_if(matching_elements_.begin(), matching_elements_.end(),
|
||||
[&e_full_name](const auto &te) {
|
||||
return te->full_name(false) == e_full_name;
|
||||
}) != matching_elements_.end();
|
||||
|
||||
return res;
|
||||
return std::any_of(matching_elements_.begin(), matching_elements_.end(),
|
||||
[&e](const auto &te) {
|
||||
return te->full_name(false) == e.full_name(false);
|
||||
});
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -207,6 +206,27 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
if constexpr (std::is_same_v<ElementT, common::model::package>) {
|
||||
if (type() == filter_t::kInclusive) {
|
||||
// For package diagrams, add also all parents of matching
|
||||
// packages
|
||||
decltype(matching_elements_) parents;
|
||||
util::for_each(matching_elements_,
|
||||
[this, &cd, &parents](const auto &package) {
|
||||
auto parent_path = package.get().path();
|
||||
auto parent = cd.get_package(parent_path.to_string());
|
||||
while (parent.has_value()) {
|
||||
parents.emplace(type_safe::ref(parent.value()));
|
||||
parent = cd.get_package(
|
||||
parent.value().path().to_string());
|
||||
}
|
||||
});
|
||||
|
||||
matching_elements_.insert(
|
||||
std::begin(parents), std::end(parents));
|
||||
}
|
||||
}
|
||||
|
||||
initialized_ = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* src/class_diagram/model/enums.cc
|
||||
* src/common/model/enums.cc
|
||||
*
|
||||
* Copyright (c) 2021-2022 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
@@ -74,4 +74,21 @@ std::string to_string(message_t r)
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
std::string to_string(const diagram_t t)
|
||||
{
|
||||
switch (t) {
|
||||
case diagram_t::kClass:
|
||||
return "class";
|
||||
case diagram_t::kSequence:
|
||||
return "sequence";
|
||||
case diagram_t::kPackage:
|
||||
return "package";
|
||||
case diagram_t::kInclude:
|
||||
return "include";
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* src/class_diagram/model/enums.h
|
||||
* src/common/model/enums.h
|
||||
*
|
||||
* Copyright (c) 2021-2022 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
namespace clanguml::common::model {
|
||||
|
||||
enum class diagram_t { kClass, kSequence, kPackage };
|
||||
enum class diagram_t { kClass, kSequence, kPackage, kInclude };
|
||||
|
||||
enum class access_t { kPublic, kProtected, kPrivate };
|
||||
|
||||
@@ -47,4 +47,6 @@ std::string to_string(access_t r);
|
||||
|
||||
std::string to_string(message_t r);
|
||||
|
||||
std::string to_string(diagram_t r);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* src/common/model/class.h
|
||||
* src/common/model/package.cc
|
||||
*
|
||||
* Copyright (c) 2021-2022 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
@@ -18,8 +18,6 @@
|
||||
|
||||
#include "package.h"
|
||||
|
||||
#include "util/util.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
namespace clanguml::common::model {
|
||||
@@ -35,11 +33,11 @@ std::string package::full_name(bool relative) const
|
||||
return res.to_string();
|
||||
}
|
||||
|
||||
return (get_namespace().relative_to(using_namespace()) | name())
|
||||
.to_string();
|
||||
return (get_namespace() | name()).to_string();
|
||||
}
|
||||
|
||||
bool package::is_deprecated() const { return is_deprecated_; }
|
||||
|
||||
void package::set_deprecated(bool deprecated) { is_deprecated_ = deprecated; }
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* src/package_diagram/model/class.h
|
||||
* src/common/model/package.h
|
||||
*
|
||||
* Copyright (c) 2021-2022 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
@@ -54,3 +54,17 @@ private:
|
||||
bool is_deprecated_{false};
|
||||
};
|
||||
}
|
||||
|
||||
namespace std {
|
||||
template <>
|
||||
struct hash<type_safe::object_ref<const clanguml::common::model::package>> {
|
||||
std::size_t operator()(
|
||||
const type_safe::object_ref<const clanguml::common::model::package>
|
||||
&key) const
|
||||
{
|
||||
using clanguml::common::model::package;
|
||||
|
||||
return std::hash<std::string>{}(key.get().full_name(false));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* src/common/model/class_relationship.cc
|
||||
* src/common/model/relationship.cc
|
||||
*
|
||||
* Copyright (c) 2021-2022 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* src/class_diagram/model/stylable_element.cc
|
||||
* src/common/model/stylable_element.cc
|
||||
*
|
||||
* Copyright (c) 2021-2022 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* src/class_diagram/model/stylable_element.h
|
||||
* src/common/model/stylable_element.h
|
||||
*
|
||||
* Copyright (c) 2021-2022 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
|
||||
@@ -60,22 +60,6 @@ config load(const std::string &config_file)
|
||||
}
|
||||
}
|
||||
|
||||
std::string to_string(const diagram_type t)
|
||||
{
|
||||
switch (t) {
|
||||
case diagram_type::class_diagram:
|
||||
return "class";
|
||||
case diagram_type::sequence_diagram:
|
||||
return "sequence";
|
||||
case diagram_type::package_diagram:
|
||||
return "package";
|
||||
case diagram_type::include_diagram:
|
||||
return "include";
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
std::string to_string(const hint_t t)
|
||||
{
|
||||
switch (t) {
|
||||
@@ -115,7 +99,10 @@ void inheritable_diagram_options::inherit(
|
||||
relative_to.override(parent.relative_to);
|
||||
}
|
||||
|
||||
diagram_type class_diagram::type() const { return diagram_type::class_diagram; }
|
||||
common::model::diagram_t class_diagram::type() const
|
||||
{
|
||||
return common::model::diagram_t::kClass;
|
||||
}
|
||||
|
||||
bool class_diagram::has_class(std::string clazz)
|
||||
{
|
||||
@@ -133,19 +120,19 @@ bool class_diagram::has_class(std::string clazz)
|
||||
return false;
|
||||
}
|
||||
|
||||
diagram_type sequence_diagram::type() const
|
||||
common::model::diagram_t sequence_diagram::type() const
|
||||
{
|
||||
return diagram_type::sequence_diagram;
|
||||
return common::model::diagram_t::kSequence;
|
||||
}
|
||||
|
||||
diagram_type package_diagram::type() const
|
||||
common::model::diagram_t package_diagram::type() const
|
||||
{
|
||||
return diagram_type::package_diagram;
|
||||
return common::model::diagram_t::kPackage;
|
||||
}
|
||||
|
||||
diagram_type include_diagram::type() const
|
||||
common::model::diagram_t include_diagram::type() const
|
||||
{
|
||||
return diagram_type::include_diagram;
|
||||
return common::model::diagram_t::kInclude;
|
||||
}
|
||||
|
||||
template <>
|
||||
|
||||
@@ -35,13 +35,6 @@
|
||||
namespace clanguml {
|
||||
namespace config {
|
||||
|
||||
enum class diagram_type {
|
||||
class_diagram,
|
||||
sequence_diagram,
|
||||
package_diagram,
|
||||
include_diagram
|
||||
};
|
||||
|
||||
enum class method_arguments { full, abbreviated, none };
|
||||
|
||||
struct plantuml {
|
||||
@@ -102,7 +95,6 @@ struct git_config {
|
||||
std::string toplevel;
|
||||
};
|
||||
|
||||
std::string to_string(const diagram_type t);
|
||||
std::string to_string(const hint_t t);
|
||||
|
||||
struct inheritable_diagram_options {
|
||||
@@ -127,7 +119,7 @@ struct inheritable_diagram_options {
|
||||
struct diagram : public inheritable_diagram_options {
|
||||
virtual ~diagram() = default;
|
||||
|
||||
virtual diagram_type type() const = 0;
|
||||
virtual common::model::diagram_t type() const = 0;
|
||||
|
||||
std::string name;
|
||||
};
|
||||
@@ -141,7 +133,7 @@ struct source_location {
|
||||
struct class_diagram : public diagram {
|
||||
virtual ~class_diagram() = default;
|
||||
|
||||
diagram_type type() const override;
|
||||
common::model::diagram_t type() const override;
|
||||
|
||||
option<std::vector<std::string>> classes{"classes"};
|
||||
option<layout_hints> layout{"layout"};
|
||||
@@ -152,7 +144,7 @@ struct class_diagram : public diagram {
|
||||
struct sequence_diagram : public diagram {
|
||||
virtual ~sequence_diagram() = default;
|
||||
|
||||
diagram_type type() const override;
|
||||
common::model::diagram_t type() const override;
|
||||
|
||||
option<std::vector<source_location>> start_from{"start_from"};
|
||||
};
|
||||
@@ -160,7 +152,7 @@ struct sequence_diagram : public diagram {
|
||||
struct package_diagram : public diagram {
|
||||
virtual ~package_diagram() = default;
|
||||
|
||||
diagram_type type() const override;
|
||||
common::model::diagram_t type() const override;
|
||||
|
||||
option<layout_hints> layout{"layout"};
|
||||
};
|
||||
@@ -168,7 +160,7 @@ struct package_diagram : public diagram {
|
||||
struct include_diagram : public diagram {
|
||||
virtual ~include_diagram() = default;
|
||||
|
||||
diagram_type type() const override;
|
||||
common::model::diagram_t type() const override;
|
||||
|
||||
option<layout_hints> layout{"layout"};
|
||||
};
|
||||
|
||||
@@ -95,3 +95,11 @@ std::string diagram::to_alias(const std::string &full_name) const
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace clanguml::common::model {
|
||||
template <>
|
||||
bool check_diagram_type<clanguml::include_diagram::model::diagram>(diagram_t t)
|
||||
{
|
||||
return t == diagram_t::kInclude;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,3 +57,8 @@ private:
|
||||
files_;
|
||||
};
|
||||
}
|
||||
|
||||
namespace clanguml::common::model {
|
||||
template <>
|
||||
bool check_diagram_type<clanguml::include_diagram::model::diagram>(diagram_t t);
|
||||
}
|
||||
10
src/main.cc
10
src/main.cc
@@ -130,8 +130,8 @@ void generate_diagram(const std::string &od, const std::string &name,
|
||||
std::shared_ptr<clanguml::config::diagram> diagram,
|
||||
const cppast::libclang_compilation_database &db, bool verbose)
|
||||
{
|
||||
using clanguml::common::model::diagram_t;
|
||||
using clanguml::config::class_diagram;
|
||||
using clanguml::config::diagram_type;
|
||||
using clanguml::config::include_diagram;
|
||||
using clanguml::config::package_diagram;
|
||||
using clanguml::config::sequence_diagram;
|
||||
@@ -140,7 +140,7 @@ void generate_diagram(const std::string &od, const std::string &name,
|
||||
std::ofstream ofs;
|
||||
ofs.open(path, std::ofstream::out | std::ofstream::trunc);
|
||||
|
||||
if (diagram->type() == diagram_type::class_diagram) {
|
||||
if (diagram->type() == diagram_t::kClass) {
|
||||
using diagram_config = class_diagram;
|
||||
using diagram_model = clanguml::class_diagram::model::diagram;
|
||||
using diagram_visitor =
|
||||
@@ -154,7 +154,7 @@ void generate_diagram(const std::string &od, const std::string &name,
|
||||
ofs << clanguml::class_diagram::generators::plantuml::generator(
|
||||
dynamic_cast<diagram_config &>(*diagram), *model);
|
||||
}
|
||||
else if (diagram->type() == diagram_type::sequence_diagram) {
|
||||
else if (diagram->type() == diagram_t::kSequence) {
|
||||
using diagram_config = sequence_diagram;
|
||||
using diagram_model = clanguml::sequence_diagram::model::diagram;
|
||||
using diagram_visitor =
|
||||
@@ -169,7 +169,7 @@ void generate_diagram(const std::string &od, const std::string &name,
|
||||
dynamic_cast<clanguml::config::sequence_diagram &>(*diagram),
|
||||
*model);
|
||||
}
|
||||
else if (diagram->type() == diagram_type::package_diagram) {
|
||||
else if (diagram->type() == diagram_t::kPackage) {
|
||||
using diagram_config = package_diagram;
|
||||
using diagram_model = clanguml::package_diagram::model::diagram;
|
||||
using diagram_visitor =
|
||||
@@ -183,7 +183,7 @@ void generate_diagram(const std::string &od, const std::string &name,
|
||||
ofs << clanguml::package_diagram::generators::plantuml::generator(
|
||||
dynamic_cast<diagram_config &>(*diagram), *model);
|
||||
}
|
||||
else if (diagram->type() == diagram_type::include_diagram) {
|
||||
else if (diagram->type() == diagram_t::kInclude) {
|
||||
using diagram_config = include_diagram;
|
||||
using diagram_model = clanguml::include_diagram::model::diagram;
|
||||
using diagram_visitor =
|
||||
|
||||
@@ -85,7 +85,8 @@ void generator::generate(const package &p, std::ostream &ostr) const
|
||||
}
|
||||
|
||||
for (const auto &subpackage : p) {
|
||||
generate(dynamic_cast<const package &>(*subpackage), ostr);
|
||||
if (m_model.should_include(dynamic_cast<package &>(*subpackage)))
|
||||
generate(dynamic_cast<const package &>(*subpackage), ostr);
|
||||
}
|
||||
|
||||
if (!uns.starts_with(p.full_name(false))) {
|
||||
@@ -102,14 +103,14 @@ void generator::generate(std::ostream &ostr) const
|
||||
generate_plantuml_directives(ostr, m_config.puml().before);
|
||||
|
||||
for (const auto &p : m_model) {
|
||||
generate(dynamic_cast<package &>(*p), ostr);
|
||||
ostr << '\n';
|
||||
if (m_model.should_include(dynamic_cast<package &>(*p)))
|
||||
generate(dynamic_cast<package &>(*p), ostr);
|
||||
}
|
||||
|
||||
// Process package relationships
|
||||
for (const auto &p : m_model) {
|
||||
generate_relationships(dynamic_cast<package &>(*p), ostr);
|
||||
ostr << '\n';
|
||||
if (m_model.should_include(dynamic_cast<package &>(*p)))
|
||||
generate_relationships(dynamic_cast<package &>(*p), ostr);
|
||||
}
|
||||
|
||||
generate_config_layout_hints(ostr);
|
||||
|
||||
@@ -28,6 +28,12 @@ common::model::diagram_t diagram::type() const
|
||||
return common::model::diagram_t::kPackage;
|
||||
}
|
||||
|
||||
const std::vector<type_safe::object_ref<const common::model::package>> &
|
||||
diagram::packages() const
|
||||
{
|
||||
return packages_;
|
||||
}
|
||||
|
||||
void diagram::add_package(std::unique_ptr<common::model::package> &&p)
|
||||
{
|
||||
LOG_DBG("Adding package: {}, {}", p->name(), p->full_name(true));
|
||||
@@ -43,7 +49,8 @@ type_safe::optional_ref<const common::model::package> diagram::get_package(
|
||||
const std::string &name) const
|
||||
{
|
||||
for (const auto &p : packages_) {
|
||||
if (p.get().full_name(false) == name) {
|
||||
auto p_full_name = p.get().full_name(false);
|
||||
if (p_full_name == name) {
|
||||
return {p};
|
||||
}
|
||||
}
|
||||
@@ -76,3 +83,11 @@ std::string diagram::to_alias(const std::string &full_name) const
|
||||
return package.value().alias();
|
||||
}
|
||||
}
|
||||
|
||||
namespace clanguml::common::model {
|
||||
template <>
|
||||
bool check_diagram_type<clanguml::package_diagram::model::diagram>(diagram_t t)
|
||||
{
|
||||
return t == diagram_t::kPackage;
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,9 @@ public:
|
||||
|
||||
common::model::diagram_t type() const override;
|
||||
|
||||
const std::vector<type_safe::object_ref<const common::model::package>> &
|
||||
packages() const;
|
||||
|
||||
type_safe::optional_ref<const common::model::diagram_element> get(
|
||||
const std::string &full_name) const;
|
||||
|
||||
@@ -56,3 +59,8 @@ private:
|
||||
packages_;
|
||||
};
|
||||
}
|
||||
|
||||
namespace clanguml::common::model {
|
||||
template <>
|
||||
bool check_diagram_type<clanguml::package_diagram::model::diagram>(diagram_t t);
|
||||
}
|
||||
|
||||
@@ -40,3 +40,11 @@ std::string diagram::to_alias(const std::string &full_name) const
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace clanguml::common::model {
|
||||
template <>
|
||||
bool check_diagram_type<clanguml::sequence_diagram::model::diagram>(diagram_t t)
|
||||
{
|
||||
return t == diagram_t::kSequence;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,3 +47,9 @@ public:
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace clanguml::common::model {
|
||||
template <>
|
||||
bool check_diagram_type<clanguml::sequence_diagram::model::diagram>(
|
||||
diagram_t t);
|
||||
}
|
||||
Reference in New Issue
Block a user