Added class diagram test case with C++20 module partitions

This commit is contained in:
Bartek Kryza
2023-12-25 17:21:53 +01:00
parent 637112cea5
commit edfaabd4fa
20 changed files with 305 additions and 68 deletions

View File

@@ -203,6 +203,10 @@ public:
return add_with_namespace_path(std::move(e));
}
if (parent_path.type() == common::model::path_type::kModule) {
return add_with_module_path(parent_path, std::move(e));
}
return add_with_filesystem_path(parent_path, std::move(e));
}
@@ -224,8 +228,6 @@ public:
*/
void get_parents(clanguml::common::reference_set<class_> &parents) const;
friend void print_diagram_tree(const diagram &d, int level);
/**
* @brief Check if diagram contains element by id.
*
@@ -252,6 +254,10 @@ private:
template <typename ElementT>
bool add_with_namespace_path(std::unique_ptr<ElementT> &&e);
template <typename ElementT>
bool add_with_module_path(
const common::model::path &parent_path, std::unique_ptr<ElementT> &&e);
template <typename ElementT>
bool add_with_filesystem_path(
const common::model::path &parent_path, std::unique_ptr<ElementT> &&e);
@@ -317,19 +323,53 @@ bool diagram::add_with_namespace_path(std::unique_ptr<ElementT> &&e)
return false;
}
template <typename ElementT>
bool diagram::add_with_module_path(
const common::model::path &parent_path, std::unique_ptr<ElementT> &&e)
{
const auto element_type = e->type_name();
// Make sure all parent modules are already packages in the
// model
for (auto it = parent_path.begin(); it != parent_path.end(); it++) {
auto pkg = std::make_unique<common::model::package>(
e->using_namespace(), parent_path.type());
pkg->set_name(*it);
auto ns =
common::model::path(parent_path.begin(), it, parent_path.type());
// ns.pop_back();
pkg->set_namespace(ns);
pkg->set_id(common::to_id(pkg->full_name(false)));
add(ns, std::move(pkg));
}
const auto base_name = e->name();
const auto full_name = e->full_name(false);
auto &e_ref = *e;
if (add_element(parent_path, std::move(e))) {
element_view<ElementT>::add(std::ref(e_ref));
return true;
}
return false;
}
template <typename ElementT>
bool diagram::add_with_filesystem_path(
const common::model::path &parent_path, std::unique_ptr<ElementT> &&e)
{
const auto element_type = e->type_name();
// Make sure all parent directories are already packages in the
// Make sure all parent modules are already packages in the
// model
for (auto it = parent_path.begin(); it != parent_path.end(); it++) {
auto pkg =
std::make_unique<common::model::package>(e->using_namespace());
auto pkg = std::make_unique<common::model::package>(
e->using_namespace(), parent_path.type());
pkg->set_name(*it);
auto ns = common::model::path(parent_path.begin(), it);
auto ns =
common::model::path(parent_path.begin(), it, parent_path.type());
// ns.pop_back();
pkg->set_namespace(ns);
pkg->set_id(common::to_id(pkg->full_name(false)));
@@ -405,6 +445,11 @@ template <>
bool diagram::add_with_namespace_path<common::model::package>(
std::unique_ptr<common::model::package> &&p);
template <>
bool diagram::add_with_module_path<common::model::package>(
const common::model::path &parent_path,
std::unique_ptr<common::model::package> &&p);
template <>
bool diagram::add_with_filesystem_path<common::model::package>(
const common::model::path &parent_path,