Switched default composition for aggregation
This commit is contained in:
@@ -142,6 +142,9 @@ public:
|
||||
|
||||
void generate(const class_ &c, std::ostream &ostr) const
|
||||
{
|
||||
|
||||
const auto uns = m_config.using_namespace;
|
||||
|
||||
std::string class_type{"class"};
|
||||
if (c.is_abstract())
|
||||
class_type = "abstract";
|
||||
@@ -187,7 +190,7 @@ public:
|
||||
if (m.is_defaulted)
|
||||
ostr << " = default";
|
||||
|
||||
ostr << " : " << ns_relative(m_config.using_namespace, type);
|
||||
ostr << " : " << ns_relative(uns, type);
|
||||
|
||||
ostr << std::endl;
|
||||
}
|
||||
@@ -203,7 +206,7 @@ public:
|
||||
ostr << "{static} ";
|
||||
|
||||
ostr << to_string(m.scope) << m.name << " : "
|
||||
<< ns_relative(m_config.using_namespace, m.type) << std::endl;
|
||||
<< ns_relative(uns, m.type) << std::endl;
|
||||
}
|
||||
|
||||
ostr << "}" << std::endl;
|
||||
@@ -212,11 +215,9 @@ public:
|
||||
for (const auto &b : c.bases) {
|
||||
std::stringstream relstr;
|
||||
try {
|
||||
relstr << m_model.to_alias(m_config.using_namespace,
|
||||
ns_relative(m_config.using_namespace, b.name))
|
||||
relstr << m_model.to_alias(uns, ns_relative(uns, b.name))
|
||||
<< " <|-- "
|
||||
<< m_model.to_alias(m_config.using_namespace,
|
||||
ns_relative(m_config.using_namespace, c.name))
|
||||
<< m_model.to_alias(uns, ns_relative(uns, c.name))
|
||||
<< std::endl;
|
||||
ostr << relstr.str();
|
||||
}
|
||||
@@ -237,8 +238,7 @@ public:
|
||||
try {
|
||||
if (r.destination.find("#") != std::string::npos ||
|
||||
r.destination.find("@") != std::string::npos) {
|
||||
destination = m_model.usr_to_name(
|
||||
m_config.using_namespace, r.destination);
|
||||
destination = m_model.usr_to_name(uns, r.destination);
|
||||
|
||||
// If something went wrong and we have an empty destination
|
||||
// generate the relationship but comment it out for
|
||||
@@ -252,13 +252,10 @@ public:
|
||||
destination = r.destination;
|
||||
}
|
||||
|
||||
relstr << m_model.to_alias(m_config.using_namespace,
|
||||
ns_relative(m_config.using_namespace,
|
||||
c.full_name(m_config.using_namespace)))
|
||||
relstr << m_model.to_alias(
|
||||
uns, ns_relative(uns, c.full_name(uns)))
|
||||
<< " " << to_string(r.type) << " "
|
||||
<< m_model.to_alias(m_config.using_namespace,
|
||||
ns_relative(
|
||||
m_config.using_namespace, destination));
|
||||
<< m_model.to_alias(uns, ns_relative(uns, destination));
|
||||
|
||||
if (!r.label.empty())
|
||||
relstr << " : " << r.label;
|
||||
@@ -269,8 +266,7 @@ public:
|
||||
catch (error::uml_alias_missing &e) {
|
||||
LOG_ERROR("Skipping {} relation from {} to {} due "
|
||||
"to: {}",
|
||||
to_string(r.type), c.full_name(m_config.using_namespace),
|
||||
destination, e.what());
|
||||
to_string(r.type), c.full_name(uns), destination, e.what());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -535,7 +535,7 @@ void tu_visitor::process_field_with_template_instantiation(
|
||||
mv.type().kind() == cppast::cpp_type_kind::reference_t)
|
||||
rr.type = relationship_t::kAssociation;
|
||||
else
|
||||
rr.type = relationship_t::kComposition;
|
||||
rr.type = relationship_t::kAggregation;
|
||||
rr.label = mv.name();
|
||||
LOG_DBG("Adding field instantiation relationship {} {} {} : {}",
|
||||
rr.destination, model::class_diagram::to_string(rr.type), c.usr,
|
||||
@@ -956,7 +956,7 @@ void tu_visitor::find_relationships(const cppast::cpp_type &t_,
|
||||
if (t.kind() == cppast::cpp_type_kind::array_t) {
|
||||
auto &a = static_cast<const cppast::cpp_array_type &>(t);
|
||||
find_relationships(
|
||||
a.value_type(), relationships, relationship_t::kComposition);
|
||||
a.value_type(), relationships, relationship_t::kAggregation);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -981,7 +981,7 @@ void tu_visitor::find_relationships(const cppast::cpp_type &t_,
|
||||
// container list
|
||||
if (name.find("std::unique_ptr") == 0) {
|
||||
find_relationships(args[0u].type().value(), relationships,
|
||||
relationship_t::kComposition);
|
||||
relationship_t::kAggregation);
|
||||
}
|
||||
else if (name.find("std::shared_ptr") == 0) {
|
||||
find_relationships(args[0u].type().value(), relationships,
|
||||
@@ -993,7 +993,7 @@ void tu_visitor::find_relationships(const cppast::cpp_type &t_,
|
||||
}
|
||||
else if (name.find("std::vector") == 0) {
|
||||
find_relationships(args[0u].type().value(), relationships,
|
||||
relationship_t::kComposition);
|
||||
relationship_t::kAggregation);
|
||||
}
|
||||
else {
|
||||
for (const auto &arg : args) {
|
||||
@@ -1014,7 +1014,7 @@ void tu_visitor::find_relationships(const cppast::cpp_type &t_,
|
||||
auto &r = static_cast<const cppast::cpp_reference_type &>(t_);
|
||||
auto rt = relationship_t::kAssociation;
|
||||
if (r.reference_kind() == cppast::cpp_reference::cpp_ref_rvalue) {
|
||||
rt = relationship_t::kComposition;
|
||||
rt = relationship_t::kAggregation;
|
||||
}
|
||||
if (relationship_hint == relationship_t::kDependency)
|
||||
rt = relationship_hint;
|
||||
@@ -1030,7 +1030,7 @@ void tu_visitor::find_relationships(const cppast::cpp_type &t_,
|
||||
cppast::to_string(t), relationship_type);
|
||||
else
|
||||
relationships.emplace_back(
|
||||
cppast::to_string(t), relationship_t::kComposition);
|
||||
cppast::to_string(t), relationship_t::kAggregation);
|
||||
}
|
||||
|
||||
// Check if t_ has an alias in the alias index
|
||||
|
||||
@@ -61,12 +61,12 @@ TEST_CASE("t00005", "[test-case][class]")
|
||||
REQUIRE_THAT(puml, (IsField<Public>("some_int_pointer", "int*")));
|
||||
REQUIRE_THAT(puml, (IsField<Public>("some_int_pointer_pointer", "int**")));
|
||||
|
||||
REQUIRE_THAT(puml, IsComposition(_A("R"), _A("A"), "a"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("A"), "a"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("B"), "b"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("C"), "c"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("D"), "d"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("E"), "e"));
|
||||
REQUIRE_THAT(puml, IsComposition(_A("R"), _A("F"), "f"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("F"), "f"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("G"), "g"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("H"), "h"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("I"), "i"));
|
||||
|
||||
@@ -65,22 +65,22 @@ TEST_CASE("t00006", "[test-case][class]")
|
||||
REQUIRE_THAT(puml,
|
||||
IsInstantiation(_A("custom_container<T>"), _A("custom_container<E>")));
|
||||
|
||||
REQUIRE_THAT(puml, IsComposition(_A("R"), _A("A"), "a"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("A"), "a"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("B"), "b"));
|
||||
REQUIRE_THAT(puml, IsComposition(_A("R"), _A("C"), "c"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("C"), "c"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("D"), "d"));
|
||||
REQUIRE_THAT(puml, IsComposition(_A("R"), _A("custom_container<E>"), "e"));
|
||||
REQUIRE_THAT(puml, IsComposition(_A("R"), _A("F"), "f"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("custom_container<E>"), "e"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("F"), "f"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("G"), "g"));
|
||||
REQUIRE_THAT(puml, IsComposition(_A("R"), _A("H"), "h"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("H"), "h"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("I"), "i"));
|
||||
REQUIRE_THAT(puml, IsComposition(_A("R"), _A("J"), "j"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("J"), "j"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("K"), "k"));
|
||||
REQUIRE_THAT(puml, IsComposition(_A("R"), _A("L"), "lm"));
|
||||
REQUIRE_THAT(puml, IsComposition(_A("R"), _A("M"), "lm"));
|
||||
REQUIRE_THAT(puml, IsComposition(_A("R"), _A("N"), "ns"));
|
||||
REQUIRE_THAT(puml, IsComposition(_A("R"), _A("NN"), "ns"));
|
||||
REQUIRE_THAT(puml, IsComposition(_A("R"), _A("NNN"), "ns"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("L"), "lm"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("M"), "lm"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("N"), "ns"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("NN"), "ns"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("NNN"), "ns"));
|
||||
|
||||
save_puml(
|
||||
"./" + config.output_directory + "/" + diagram->name + ".puml", puml);
|
||||
|
||||
@@ -50,7 +50,7 @@ TEST_CASE("t00007", "[test-case][class]")
|
||||
REQUIRE_THAT(puml, IsClass(_A("C")));
|
||||
REQUIRE_THAT(puml, IsClass(_A("R")));
|
||||
|
||||
REQUIRE_THAT(puml, IsComposition(_A("R"), _A("A"), "a"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("A"), "a"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("B"), "b"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("C"), "c"));
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ TEST_CASE("t00009", "[test-case][class]")
|
||||
REQUIRE_THAT(puml, IsInstantiation(_A("A<T>"), _A("A<int>")));
|
||||
REQUIRE_THAT(puml, IsInstantiation(_A("A<T>"), _A("A<std::string>")));
|
||||
|
||||
REQUIRE_THAT(puml, IsComposition(_A("B"), _A("A<int>"), "aint"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("B"), _A("A<int>"), "aint"));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("B"), _A("A<std::string>"), "astring"));
|
||||
REQUIRE_THAT(puml,
|
||||
IsAssociation(_A("B"), _A("A<std::vector<std::string>>"), "avector"));
|
||||
|
||||
@@ -52,8 +52,8 @@ TEST_CASE("t00010", "[test-case][class]")
|
||||
REQUIRE_THAT(puml, IsInstantiation(_A("B<T>"), _A("B<int>")));
|
||||
|
||||
REQUIRE_THAT(
|
||||
puml, IsComposition(_A("B<T>"), _A("A<T,std::string>"), "astring"));
|
||||
REQUIRE_THAT(puml, IsComposition(_A("C"), _A("B<int>"), "aintstring"));
|
||||
puml, IsAggregation(_A("B<T>"), _A("A<T,std::string>"), "astring"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("C"), _A("B<int>"), "aintstring"));
|
||||
|
||||
save_puml(
|
||||
"./" + config.output_directory + "/" + diagram->name + ".puml", puml);
|
||||
|
||||
@@ -56,7 +56,7 @@ TEST_CASE("t00013", "[test-case][class]")
|
||||
REQUIRE_THAT(puml, IsDependency(_A("R"), _A("E<int>")));
|
||||
REQUIRE_THAT(puml, IsInstantiation(_A("E<T>"), _A("E<int>")));
|
||||
REQUIRE_THAT(puml, IsInstantiation(_A("E<T>"), _A("E<std::string>")));
|
||||
REQUIRE_THAT(puml, IsComposition(_A("R"), _A("E<std::string>"), "estring"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("E<std::string>"), "estring"));
|
||||
REQUIRE_THAT(puml, IsDependency(_A("R"), _A("ABCD::F<T>")));
|
||||
REQUIRE_THAT(puml, IsInstantiation(_A("ABCD::F<T>"), _A("ABCD::F<int>")));
|
||||
REQUIRE_THAT(puml, IsDependency(_A("R"), _A("ABCD::F<int>")));
|
||||
|
||||
@@ -52,11 +52,11 @@ TEST_CASE("t00014", "[test-case][class]")
|
||||
REQUIRE_THAT(
|
||||
puml, IsInstantiation(_A("A<T,std::string>"), _A("AString<float>")));
|
||||
REQUIRE_THAT(
|
||||
puml, IsComposition(_A("R"), _A("A<bool,std::string>"), "boolstring"));
|
||||
puml, IsAggregation(_A("R"), _A("A<bool,std::string>"), "boolstring"));
|
||||
REQUIRE_THAT(
|
||||
puml, IsComposition(_A("R"), _A("AString<float>"), "floatstring"));
|
||||
REQUIRE_THAT(puml, IsComposition(_A("R"), _A("B"), "bs"));
|
||||
REQUIRE_THAT(puml, IsComposition(_A("R"), _A("B"), "bs2"));
|
||||
puml, IsAggregation(_A("R"), _A("AString<float>"), "floatstring"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("B"), "bs"));
|
||||
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("B"), "bs2"));
|
||||
|
||||
save_puml(
|
||||
"./" + config.output_directory + "/" + diagram->name + ".puml", puml);
|
||||
|
||||
Reference in New Issue
Block a user