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