Refactored common diagram elements to clanguml::common:model namespace
This commit is contained in:
@@ -18,7 +18,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "class_diagram/model/class.h"
|
#include "class_diagram/model/class.h"
|
||||||
#include "class_diagram/model/class_relationship.h"
|
#include "common/model/relationship.h"
|
||||||
#include "class_diagram/model/diagram.h"
|
#include "class_diagram/model/diagram.h"
|
||||||
#include "class_diagram/model/enum.h"
|
#include "class_diagram/model/enum.h"
|
||||||
#include "class_diagram/visitor/translation_unit_visitor.h"
|
#include "class_diagram/visitor/translation_unit_visitor.h"
|
||||||
@@ -44,8 +44,8 @@ using diagram_config = clanguml::class_diagram::model::diagram;
|
|||||||
using diagram_model = clanguml::class_diagram::model::diagram;
|
using diagram_model = clanguml::class_diagram::model::diagram;
|
||||||
using clanguml::class_diagram::model::class_;
|
using clanguml::class_diagram::model::class_;
|
||||||
using clanguml::class_diagram::model::enum_;
|
using clanguml::class_diagram::model::enum_;
|
||||||
using clanguml::class_diagram::model::relationship_t;
|
using clanguml::common::model::relationship_t;
|
||||||
using clanguml::class_diagram::model::scope_t;
|
using clanguml::common::model::scope_t;
|
||||||
using namespace clanguml::util;
|
using namespace clanguml::util;
|
||||||
|
|
||||||
std::string relative_to(std::string n, std::string c);
|
std::string relative_to(std::string n, std::string c);
|
||||||
|
|||||||
@@ -21,9 +21,9 @@
|
|||||||
#include "class_method.h"
|
#include "class_method.h"
|
||||||
#include "class_parent.h"
|
#include "class_parent.h"
|
||||||
#include "class_template.h"
|
#include "class_template.h"
|
||||||
#include "element.h"
|
#include "common/model/element.h"
|
||||||
#include "enums.h"
|
#include "common/model/enums.h"
|
||||||
#include "stylable_element.h"
|
#include "common/model/stylable_element.h"
|
||||||
#include "type_alias.h"
|
#include "type_alias.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -31,7 +31,8 @@
|
|||||||
|
|
||||||
namespace clanguml::class_diagram::model {
|
namespace clanguml::class_diagram::model {
|
||||||
|
|
||||||
class class_ : public element, public stylable_element {
|
class class_ : public common::model::element,
|
||||||
|
public common::model::stylable_element {
|
||||||
public:
|
public:
|
||||||
class_(const std::vector<std::string> &using_namespaces);
|
class_(const std::vector<std::string> &using_namespaces);
|
||||||
|
|
||||||
|
|||||||
@@ -20,15 +20,15 @@
|
|||||||
|
|
||||||
namespace clanguml::class_diagram::model {
|
namespace clanguml::class_diagram::model {
|
||||||
|
|
||||||
class_element::class_element(
|
class_element::class_element(common::model::scope_t scope,
|
||||||
scope_t scope, const std::string &name, const std::string &type)
|
const std::string &name, const std::string &type)
|
||||||
: scope_{scope}
|
: scope_{scope}
|
||||||
, name_{name}
|
, name_{name}
|
||||||
, type_{type}
|
, type_{type}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
scope_t class_element::scope() const { return scope_; }
|
common::model::scope_t class_element::scope() const { return scope_; }
|
||||||
|
|
||||||
std::string class_element::name() const { return name_; }
|
std::string class_element::name() const { return name_; }
|
||||||
|
|
||||||
|
|||||||
@@ -17,23 +17,23 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "decorated_element.h"
|
#include "common/model/decorated_element.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace clanguml::class_diagram::model {
|
namespace clanguml::class_diagram::model {
|
||||||
|
|
||||||
class class_element : public decorated_element {
|
class class_element : public common::model::decorated_element {
|
||||||
public:
|
public:
|
||||||
class_element(
|
class_element(common::model::scope_t scope, const std::string &name,
|
||||||
scope_t scope, const std::string &name, const std::string &type);
|
const std::string &type);
|
||||||
|
|
||||||
scope_t scope() const;
|
common::model::scope_t scope() const;
|
||||||
std::string name() const;
|
std::string name() const;
|
||||||
std::string type() const;
|
std::string type() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
scope_t scope_;
|
common::model::scope_t scope_;
|
||||||
std::string name_;
|
std::string name_;
|
||||||
std::string type_;
|
std::string type_;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,8 +20,8 @@
|
|||||||
|
|
||||||
namespace clanguml::class_diagram::model {
|
namespace clanguml::class_diagram::model {
|
||||||
|
|
||||||
class_member::class_member(
|
class_member::class_member(common::model::scope_t scope,
|
||||||
scope_t scope, const std::string &name, const std::string &type)
|
const std::string &name, const std::string &type)
|
||||||
: class_element{scope, name, type}
|
: class_element{scope, name, type}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ namespace clanguml::class_diagram::model {
|
|||||||
|
|
||||||
class class_member : public class_element {
|
class class_member : public class_element {
|
||||||
public:
|
public:
|
||||||
class_member(
|
class_member(common::model::scope_t scope, const std::string &name,
|
||||||
scope_t scope, const std::string &name, const std::string &type);
|
const std::string &type);
|
||||||
|
|
||||||
bool is_relationship() const;
|
bool is_relationship() const;
|
||||||
void is_relationship(bool is_relationship);
|
void is_relationship(bool is_relationship);
|
||||||
|
|||||||
@@ -20,8 +20,8 @@
|
|||||||
|
|
||||||
namespace clanguml::class_diagram::model {
|
namespace clanguml::class_diagram::model {
|
||||||
|
|
||||||
class_method::class_method(
|
class_method::class_method(common::model::scope_t scope,
|
||||||
scope_t scope, const std::string &name, const std::string &type)
|
const std::string &name, const std::string &type)
|
||||||
: class_element{scope, name, type}
|
: class_element{scope, name, type}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ namespace clanguml::class_diagram::model {
|
|||||||
|
|
||||||
class class_method : public class_element {
|
class class_method : public class_element {
|
||||||
public:
|
public:
|
||||||
class_method(
|
class_method(common::model::scope_t scope, const std::string &name,
|
||||||
scope_t scope, const std::string &name, const std::string &type);
|
const std::string &type);
|
||||||
|
|
||||||
bool is_pure_virtual() const;
|
bool is_pure_virtual() const;
|
||||||
void is_pure_virtual(bool is_pure_virtual);
|
void is_pure_virtual(bool is_pure_virtual);
|
||||||
|
|||||||
@@ -28,8 +28,11 @@ void class_parent::is_virtual(bool is_virtual) { is_virtual_ = is_virtual; }
|
|||||||
|
|
||||||
bool class_parent::is_virtual() const { return is_virtual_; }
|
bool class_parent::is_virtual() const { return is_virtual_; }
|
||||||
|
|
||||||
void class_parent::set_access(access_t access) { access_ = access; }
|
void class_parent::set_access(common::model::access_t access)
|
||||||
|
{
|
||||||
|
access_ = access;
|
||||||
|
}
|
||||||
|
|
||||||
access_t class_parent::access() const { return access_; }
|
common::model::access_t class_parent::access() const { return access_; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "enums.h"
|
#include "common/model/enums.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@@ -31,12 +31,12 @@ public:
|
|||||||
void is_virtual(bool is_virtual);
|
void is_virtual(bool is_virtual);
|
||||||
bool is_virtual() const;
|
bool is_virtual() const;
|
||||||
|
|
||||||
void set_access(access_t access);
|
void set_access(common::model::access_t access);
|
||||||
access_t access() const;
|
common::model::access_t access() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string name_;
|
std::string name_;
|
||||||
bool is_virtual_{false};
|
bool is_virtual_{false};
|
||||||
access_t access_;
|
common::model::access_t access_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,8 @@
|
|||||||
|
|
||||||
namespace clanguml::class_diagram::model {
|
namespace clanguml::class_diagram::model {
|
||||||
|
|
||||||
class enum_ : public element, public stylable_element {
|
class enum_ : public common::model::element,
|
||||||
|
public common::model::stylable_element {
|
||||||
public:
|
public:
|
||||||
enum_(const std::vector<std::string> &using_namespaces);
|
enum_(const std::vector<std::string> &using_namespaces);
|
||||||
|
|
||||||
|
|||||||
@@ -17,14 +17,14 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "decorated_element.h"
|
#include "common/model/decorated_element.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace clanguml::class_diagram::model {
|
namespace clanguml::class_diagram::model {
|
||||||
|
|
||||||
class method_parameter : public decorated_element {
|
class method_parameter : public common::model::decorated_element {
|
||||||
public:
|
public:
|
||||||
void set_type(const std::string &type);
|
void set_type(const std::string &type);
|
||||||
std::string type() const;
|
std::string type() const;
|
||||||
|
|||||||
@@ -36,19 +36,20 @@
|
|||||||
|
|
||||||
namespace clanguml::class_diagram::visitor {
|
namespace clanguml::class_diagram::visitor {
|
||||||
|
|
||||||
using clanguml::class_diagram::model::access_t;
|
using clanguml::common::model::access_t;
|
||||||
using clanguml::class_diagram::model::class_;
|
using clanguml::class_diagram::model::class_;
|
||||||
using clanguml::class_diagram::model::class_member;
|
using clanguml::class_diagram::model::class_member;
|
||||||
using clanguml::class_diagram::model::class_method;
|
using clanguml::class_diagram::model::class_method;
|
||||||
using clanguml::class_diagram::model::class_parent;
|
using clanguml::class_diagram::model::class_parent;
|
||||||
using clanguml::class_diagram::model::class_relationship;
|
using clanguml::class_diagram::model::class_template;
|
||||||
using clanguml::class_diagram::model::class_template;
|
using clanguml::class_diagram::model::class_template;
|
||||||
using clanguml::class_diagram::model::diagram;
|
using clanguml::class_diagram::model::diagram;
|
||||||
using clanguml::class_diagram::model::enum_;
|
using clanguml::class_diagram::model::enum_;
|
||||||
using clanguml::class_diagram::model::method_parameter;
|
using clanguml::class_diagram::model::method_parameter;
|
||||||
using clanguml::class_diagram::model::relationship_t;
|
using clanguml::common::model::relationship_t;
|
||||||
using clanguml::class_diagram::model::scope_t;
|
using clanguml::common::model::scope_t;
|
||||||
using clanguml::class_diagram::model::type_alias;
|
using clanguml::class_diagram::model::type_alias;
|
||||||
|
using clanguml::common::model::relationship;
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
scope_t cpp_access_specifier_to_scope(
|
scope_t cpp_access_specifier_to_scope(
|
||||||
@@ -551,12 +552,12 @@ bool translation_unit_visitor::process_field_with_template_instantiation(
|
|||||||
else
|
else
|
||||||
relationship_type = relationship_t::kAggregation;
|
relationship_type = relationship_t::kAggregation;
|
||||||
|
|
||||||
class_relationship rr{relationship_type, tinst.full_name(),
|
relationship rr{relationship_type, tinst.full_name(),
|
||||||
detail::cpp_access_specifier_to_scope(as), mv.name()};
|
detail::cpp_access_specifier_to_scope(as), mv.name()};
|
||||||
rr.set_style(m.style_spec());
|
rr.set_style(m.style_spec());
|
||||||
|
|
||||||
// Process field decorators
|
// Process field decorators
|
||||||
auto [decorator_rtype, decorator_rmult] = m.relationship();
|
auto [decorator_rtype, decorator_rmult] = m.get_relationship();
|
||||||
if (decorator_rtype != relationship_t::kNone) {
|
if (decorator_rtype != relationship_t::kNone) {
|
||||||
rr.set_type(decorator_rtype);
|
rr.set_type(decorator_rtype);
|
||||||
auto mult = util::split(decorator_rmult, ":");
|
auto mult = util::split(decorator_rmult, ":");
|
||||||
@@ -569,7 +570,7 @@ bool translation_unit_visitor::process_field_with_template_instantiation(
|
|||||||
if (ctx.config().should_include(tinst.name())) {
|
if (ctx.config().should_include(tinst.name())) {
|
||||||
LOG_DBG("Adding field instantiation relationship {} {} {} : {}",
|
LOG_DBG("Adding field instantiation relationship {} {} {} : {}",
|
||||||
rr.destination(),
|
rr.destination(),
|
||||||
clanguml::class_diagram::model::to_string(rr.type()), c.full_name(),
|
clanguml::common::model::to_string(rr.type()), c.full_name(),
|
||||||
rr.label());
|
rr.label());
|
||||||
|
|
||||||
c.add_relationship(std::move(rr));
|
c.add_relationship(std::move(rr));
|
||||||
@@ -632,11 +633,11 @@ void translation_unit_visitor::process_field(
|
|||||||
|
|
||||||
for (const auto &[type, relationship_type] : relationships) {
|
for (const auto &[type, relationship_type] : relationships) {
|
||||||
if (relationship_type != relationship_t::kNone) {
|
if (relationship_type != relationship_t::kNone) {
|
||||||
class_relationship r{
|
relationship r{
|
||||||
relationship_type, type, m.scope(), m.name()};
|
relationship_type, type, m.scope(), m.name()};
|
||||||
r.set_style(m.style_spec());
|
r.set_style(m.style_spec());
|
||||||
|
|
||||||
auto [decorator_rtype, decorator_rmult] = m.relationship();
|
auto [decorator_rtype, decorator_rmult] = m.get_relationship();
|
||||||
if (decorator_rtype != relationship_t::kNone) {
|
if (decorator_rtype != relationship_t::kNone) {
|
||||||
r.set_type(decorator_rtype);
|
r.set_type(decorator_rtype);
|
||||||
auto mult = util::split(decorator_rmult, ":");
|
auto mult = util::split(decorator_rmult, ":");
|
||||||
@@ -648,7 +649,7 @@ void translation_unit_visitor::process_field(
|
|||||||
|
|
||||||
LOG_DBG("Adding field relationship {} {} {} : {}",
|
LOG_DBG("Adding field relationship {} {} {} : {}",
|
||||||
r.destination(),
|
r.destination(),
|
||||||
clanguml::class_diagram::model::to_string(r.type()),
|
clanguml::common::model::to_string(r.type()),
|
||||||
c.full_name(), r.label());
|
c.full_name(), r.label());
|
||||||
|
|
||||||
c.add_relationship(std::move(r));
|
c.add_relationship(std::move(r));
|
||||||
@@ -874,11 +875,11 @@ void translation_unit_visitor::process_function_parameter(
|
|||||||
for (const auto &[type, relationship_type] : relationships) {
|
for (const auto &[type, relationship_type] : relationships) {
|
||||||
if ((relationship_type != relationship_t::kNone) &&
|
if ((relationship_type != relationship_t::kNone) &&
|
||||||
(type != c.name())) {
|
(type != c.name())) {
|
||||||
class_relationship r{relationship_t::kDependency, type};
|
relationship r{relationship_t::kDependency, type};
|
||||||
|
|
||||||
LOG_DBG("Adding field relationship {} {} {} : {}",
|
LOG_DBG("Adding field relationship {} {} {} : {}",
|
||||||
r.destination(),
|
r.destination(),
|
||||||
clanguml::class_diagram::model::to_string(r.type()),
|
clanguml::common::model::to_string(r.type()),
|
||||||
c.full_name(), r.label());
|
c.full_name(), r.label());
|
||||||
|
|
||||||
c.add_relationship(std::move(r));
|
c.add_relationship(std::move(r));
|
||||||
@@ -940,14 +941,14 @@ void translation_unit_visitor::process_function_parameter(
|
|||||||
"only adding reference to template {}",
|
"only adding reference to template {}",
|
||||||
cx::util::full_name(cppast::remove_cv(t),
|
cx::util::full_name(cppast::remove_cv(t),
|
||||||
ctx.entity_index(), false));
|
ctx.entity_index(), false));
|
||||||
class_relationship rr{relationship_t::kDependency,
|
relationship rr{relationship_t::kDependency,
|
||||||
cx::util::full_name(cppast::remove_cv(t),
|
cx::util::full_name(cppast::remove_cv(t),
|
||||||
ctx.entity_index(), false)};
|
ctx.entity_index(), false)};
|
||||||
LOG_DBG("Adding field template dependency relationship "
|
LOG_DBG("Adding field template dependency relationship "
|
||||||
"{} {} {} "
|
"{} {} {} "
|
||||||
": {}",
|
": {}",
|
||||||
rr.destination(),
|
rr.destination(),
|
||||||
clanguml::class_diagram::model::to_string(
|
clanguml::common::model::to_string(
|
||||||
rr.type()),
|
rr.type()),
|
||||||
c.full_name(), rr.label());
|
c.full_name(), rr.label());
|
||||||
c.add_relationship(std::move(rr));
|
c.add_relationship(std::move(rr));
|
||||||
@@ -957,13 +958,13 @@ void translation_unit_visitor::process_function_parameter(
|
|||||||
class_ tinst = build_template_instantiation(
|
class_ tinst = build_template_instantiation(
|
||||||
template_instantiation_type);
|
template_instantiation_type);
|
||||||
|
|
||||||
class_relationship rr{
|
relationship rr{
|
||||||
relationship_t::kDependency, tinst.full_name()};
|
relationship_t::kDependency, tinst.full_name()};
|
||||||
|
|
||||||
LOG_DBG("Adding field dependency relationship {} {} {} "
|
LOG_DBG("Adding field dependency relationship {} {} {} "
|
||||||
": {}",
|
": {}",
|
||||||
rr.destination(),
|
rr.destination(),
|
||||||
clanguml::class_diagram::model::to_string(
|
clanguml::common::model::to_string(
|
||||||
rr.type()),
|
rr.type()),
|
||||||
c.full_name(), rr.label());
|
c.full_name(), rr.label());
|
||||||
|
|
||||||
@@ -1008,7 +1009,7 @@ void translation_unit_visitor::process_friend(
|
|||||||
cppast::cpp_entity_kind::class_template_t))
|
cppast::cpp_entity_kind::class_template_t))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
class_relationship r{
|
relationship r{
|
||||||
relationship_t::kFriendship, "", scope_t::kNone, "<<friend>>"};
|
relationship_t::kFriendship, "", scope_t::kNone, "<<friend>>"};
|
||||||
|
|
||||||
if (f.comment().has_value())
|
if (f.comment().has_value())
|
||||||
@@ -1355,7 +1356,7 @@ class_ translation_unit_visitor::build_template_instantiation(
|
|||||||
? std::make_optional(&tinst)
|
? std::make_optional(&tinst)
|
||||||
: parent);
|
: parent);
|
||||||
|
|
||||||
class_relationship tinst_dependency{
|
relationship tinst_dependency{
|
||||||
relationship_t::kDependency, nested_tinst.full_name()};
|
relationship_t::kDependency, nested_tinst.full_name()};
|
||||||
|
|
||||||
auto nested_tinst_full_name = nested_tinst.full_name();
|
auto nested_tinst_full_name = nested_tinst.full_name();
|
||||||
@@ -1392,7 +1393,7 @@ class_ translation_unit_visitor::build_template_instantiation(
|
|||||||
}
|
}
|
||||||
else if (targ.type().value().kind() ==
|
else if (targ.type().value().kind() ==
|
||||||
cppast::cpp_type_kind::user_defined_t) {
|
cppast::cpp_type_kind::user_defined_t) {
|
||||||
class_relationship tinst_dependency{
|
relationship tinst_dependency{
|
||||||
relationship_t::kDependency,
|
relationship_t::kDependency,
|
||||||
cx::util::full_name(
|
cx::util::full_name(
|
||||||
cppast::remove_cv(
|
cppast::remove_cv(
|
||||||
@@ -1478,7 +1479,7 @@ class_ translation_unit_visitor::build_template_instantiation(
|
|||||||
// Otherwise point to the base template
|
// Otherwise point to the base template
|
||||||
destination = tinst.base_template();
|
destination = tinst.base_template();
|
||||||
}
|
}
|
||||||
class_relationship r{relationship_t::kInstantiation, destination};
|
relationship r{relationship_t::kInstantiation, destination};
|
||||||
tinst.add_relationship(std::move(r));
|
tinst.add_relationship(std::move(r));
|
||||||
|
|
||||||
return tinst;
|
return tinst;
|
||||||
|
|||||||
@@ -100,9 +100,9 @@ public:
|
|||||||
|
|
||||||
bool find_relationships(const cppast::cpp_type &t,
|
bool find_relationships(const cppast::cpp_type &t,
|
||||||
std::vector<std::pair<std::string,
|
std::vector<std::pair<std::string,
|
||||||
clanguml::class_diagram::model::relationship_t>> &relationships,
|
clanguml::common::model::relationship_t>> &relationships,
|
||||||
clanguml::class_diagram::model::relationship_t relationship_hint =
|
clanguml::common::model::relationship_t relationship_hint =
|
||||||
clanguml::class_diagram::model::relationship_t::kNone);
|
clanguml::common::model::relationship_t::kNone);
|
||||||
|
|
||||||
void process_template_type_parameter(
|
void process_template_type_parameter(
|
||||||
const cppast::cpp_template_type_parameter &t,
|
const cppast::cpp_template_type_parameter &t,
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#include "decorated_element.h"
|
#include "decorated_element.h"
|
||||||
|
|
||||||
namespace clanguml::class_diagram::model {
|
namespace clanguml::common::model {
|
||||||
|
|
||||||
bool decorated_element::skip() const
|
bool decorated_element::skip() const
|
||||||
{
|
{
|
||||||
@@ -38,7 +38,7 @@ bool decorated_element::skip_relationship() const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<relationship_t, std::string> decorated_element::relationship() const
|
std::pair<relationship_t, std::string> decorated_element::get_relationship() const
|
||||||
{
|
{
|
||||||
for (auto &d : decorators_)
|
for (auto &d : decorators_)
|
||||||
if (std::dynamic_pointer_cast<decorators::association>(d))
|
if (std::dynamic_pointer_cast<decorators::association>(d))
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace clanguml::class_diagram::model {
|
namespace clanguml::common::model {
|
||||||
|
|
||||||
class decorated_element {
|
class decorated_element {
|
||||||
public:
|
public:
|
||||||
@@ -33,7 +33,7 @@ public:
|
|||||||
|
|
||||||
bool skip_relationship() const;
|
bool skip_relationship() const;
|
||||||
|
|
||||||
std::pair<relationship_t, std::string> relationship() const;
|
std::pair<relationship_t, std::string> get_relationship() const;
|
||||||
|
|
||||||
std::string style_spec();
|
std::string style_spec();
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include "util/util.h"
|
#include "util/util.h"
|
||||||
|
|
||||||
namespace clanguml::class_diagram::model {
|
namespace clanguml::common::model {
|
||||||
|
|
||||||
std::atomic_uint64_t element::m_nextId = 1;
|
std::atomic_uint64_t element::m_nextId = 1;
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ element::element(const std::vector<std::string> &using_namespaces)
|
|||||||
|
|
||||||
std::string element::alias() const { return fmt::format("C_{:010}", m_id); }
|
std::string element::alias() const { return fmt::format("C_{:010}", m_id); }
|
||||||
|
|
||||||
void element::add_relationship(class_relationship &&cr)
|
void element::add_relationship(relationship &&cr)
|
||||||
{
|
{
|
||||||
if (cr.destination().empty()) {
|
if (cr.destination().empty()) {
|
||||||
LOG_WARN("Skipping relationship '{}' - {} - '{}' due empty "
|
LOG_WARN("Skipping relationship '{}' - {} - '{}' due empty "
|
||||||
@@ -56,12 +56,12 @@ const std::vector<std::string> &element::using_namespaces() const
|
|||||||
return using_namespaces_;
|
return using_namespaces_;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<class_relationship> &element::relationships()
|
std::vector<relationship> &element::relationships()
|
||||||
{
|
{
|
||||||
return relationships_;
|
return relationships_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<class_relationship> &element::relationships() const
|
const std::vector<relationship> &element::relationships() const
|
||||||
{
|
{
|
||||||
return relationships_;
|
return relationships_;
|
||||||
}
|
}
|
||||||
@@ -17,14 +17,15 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "class_relationship.h"
|
#include "relationship.h"
|
||||||
#include "decorated_element.h"
|
#include "decorated_element.h"
|
||||||
|
#include "relationship.h"
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace clanguml::class_diagram::model {
|
namespace clanguml::common::model {
|
||||||
|
|
||||||
class element : public decorated_element {
|
class element : public decorated_element {
|
||||||
public:
|
public:
|
||||||
@@ -46,11 +47,11 @@ public:
|
|||||||
|
|
||||||
const std::vector<std::string> &using_namespaces() const;
|
const std::vector<std::string> &using_namespaces() const;
|
||||||
|
|
||||||
std::vector<class_relationship> &relationships();
|
std::vector<relationship> &relationships();
|
||||||
|
|
||||||
const std::vector<class_relationship> &relationships() const;
|
const std::vector<relationship> &relationships() const;
|
||||||
|
|
||||||
void add_relationship(class_relationship &&cr);
|
void add_relationship(relationship &&cr);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const uint64_t m_id{0};
|
const uint64_t m_id{0};
|
||||||
@@ -59,7 +60,7 @@ private:
|
|||||||
std::string name_;
|
std::string name_;
|
||||||
std::vector<std::string> namespace_;
|
std::vector<std::string> namespace_;
|
||||||
std::vector<std::string> using_namespaces_;
|
std::vector<std::string> using_namespaces_;
|
||||||
std::vector<class_relationship> relationships_;
|
std::vector<relationship> relationships_;
|
||||||
|
|
||||||
static std::atomic_uint64_t m_nextId;
|
static std::atomic_uint64_t m_nextId;
|
||||||
};
|
};
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace clanguml::class_diagram::model {
|
namespace clanguml::common::model {
|
||||||
|
|
||||||
enum class access_t { kPublic, kProtected, kPrivate };
|
enum class access_t { kPublic, kProtected, kPrivate };
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* src/class_diagram/model/class_relationship.cc
|
* src/common/model/class_relationship.cc
|
||||||
*
|
*
|
||||||
* Copyright (c) 2021-2022 Bartek Kryza <bkryza@gmail.com>
|
* Copyright (c) 2021-2022 Bartek Kryza <bkryza@gmail.com>
|
||||||
*
|
*
|
||||||
@@ -16,9 +16,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "class_relationship.h"
|
#include "relationship.h"
|
||||||
|
|
||||||
namespace clanguml::class_diagram::model {
|
namespace clanguml::common::model {
|
||||||
|
|
||||||
std::string to_string(relationship_t r)
|
std::string to_string(relationship_t r)
|
||||||
{
|
{
|
||||||
@@ -48,7 +48,7 @@ std::string to_string(relationship_t r)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class_relationship::class_relationship(relationship_t type,
|
relationship::relationship(relationship_t type,
|
||||||
const std::string &destination, scope_t scope, const std::string &label,
|
const std::string &destination, scope_t scope, const std::string &label,
|
||||||
const std::string &multiplicity_source,
|
const std::string &multiplicity_source,
|
||||||
const std::string &multiplicity_destination)
|
const std::string &multiplicity_destination)
|
||||||
@@ -61,51 +61,51 @@ class_relationship::class_relationship(relationship_t type,
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void class_relationship::set_type(relationship_t type) noexcept
|
void relationship::set_type(relationship_t type) noexcept
|
||||||
{
|
{
|
||||||
type_ = type;
|
type_ = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
relationship_t class_relationship::type() const noexcept { return type_; }
|
relationship_t relationship::type() const noexcept { return type_; }
|
||||||
|
|
||||||
void class_relationship::set_destination(const std::string &destination)
|
void relationship::set_destination(const std::string &destination)
|
||||||
{
|
{
|
||||||
destination_ = destination;
|
destination_ = destination;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string class_relationship::destination() const { return destination_; }
|
std::string relationship::destination() const { return destination_; }
|
||||||
|
|
||||||
void class_relationship::set_multiplicity_source(
|
void relationship::set_multiplicity_source(
|
||||||
const std::string &multiplicity_source)
|
const std::string &multiplicity_source)
|
||||||
{
|
{
|
||||||
multiplicity_source_ = multiplicity_source;
|
multiplicity_source_ = multiplicity_source;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string class_relationship::multiplicity_source() const
|
std::string relationship::multiplicity_source() const
|
||||||
{
|
{
|
||||||
return multiplicity_source_;
|
return multiplicity_source_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void class_relationship::set_multiplicity_destination(
|
void relationship::set_multiplicity_destination(
|
||||||
const std::string &multiplicity_destination)
|
const std::string &multiplicity_destination)
|
||||||
{
|
{
|
||||||
multiplicity_destination_ = multiplicity_destination;
|
multiplicity_destination_ = multiplicity_destination;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string class_relationship::multiplicity_destination() const
|
std::string relationship::multiplicity_destination() const
|
||||||
{
|
{
|
||||||
return multiplicity_destination_;
|
return multiplicity_destination_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void class_relationship::set_label(const std::string &label) { label_ = label; }
|
void relationship::set_label(const std::string &label) { label_ = label; }
|
||||||
|
|
||||||
std::string class_relationship::label() const { return label_; }
|
std::string relationship::label() const { return label_; }
|
||||||
|
|
||||||
void class_relationship::set_scope(scope_t scope) noexcept { scope_ = scope; }
|
void relationship::set_scope(scope_t scope) noexcept { scope_ = scope; }
|
||||||
|
|
||||||
scope_t class_relationship::scope() const noexcept { return scope_; }
|
scope_t relationship::scope() const noexcept { return scope_; }
|
||||||
|
|
||||||
bool operator==(const class_relationship &l, const class_relationship &r)
|
bool operator==(const relationship &l, const relationship &r)
|
||||||
{
|
{
|
||||||
return l.type() == r.type() && l.destination() == r.destination() &&
|
return l.type() == r.type() && l.destination() == r.destination() &&
|
||||||
l.label() == r.label();
|
l.label() == r.label();
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* src/class_diagram/model/class_relationship.h
|
* src/common/model/relationship.h
|
||||||
*
|
*
|
||||||
* Copyright (c) 2021-2022 Bartek Kryza <bkryza@gmail.com>
|
* Copyright (c) 2021-2022 Bartek Kryza <bkryza@gmail.com>
|
||||||
*
|
*
|
||||||
@@ -17,23 +17,24 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "decorated_element.h"
|
#include "common/model/decorated_element.h"
|
||||||
#include "stylable_element.h"
|
#include "common/model/stylable_element.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace clanguml::class_diagram::model {
|
namespace clanguml::common::model {
|
||||||
|
|
||||||
std::string to_string(relationship_t r);
|
std::string to_string(relationship_t r);
|
||||||
|
|
||||||
class class_relationship : public decorated_element, public stylable_element {
|
class relationship : public common::model::decorated_element,
|
||||||
|
public common::model::stylable_element {
|
||||||
public:
|
public:
|
||||||
class_relationship(relationship_t type, const std::string &destination,
|
relationship(relationship_t type, const std::string &destination,
|
||||||
scope_t scope = scope_t::kNone, const std::string &label = "",
|
scope_t scope = scope_t::kNone, const std::string &label = "",
|
||||||
const std::string &multiplicity_source = "",
|
const std::string &multiplicity_source = "",
|
||||||
const std::string &multiplicity_destination = "");
|
const std::string &multiplicity_destination = "");
|
||||||
|
|
||||||
virtual ~class_relationship() = default;
|
virtual ~relationship() = default;
|
||||||
|
|
||||||
void set_type(relationship_t type) noexcept;
|
void set_type(relationship_t type) noexcept;
|
||||||
relationship_t type() const noexcept;
|
relationship_t type() const noexcept;
|
||||||
@@ -55,7 +56,7 @@ public:
|
|||||||
scope_t scope() const noexcept;
|
scope_t scope() const noexcept;
|
||||||
|
|
||||||
friend bool operator==(
|
friend bool operator==(
|
||||||
const class_relationship &l, const class_relationship &r);
|
const relationship &l, const relationship &r);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
relationship_t type_{relationship_t::kAssociation};
|
relationship_t type_{relationship_t::kAssociation};
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#include "stylable_element.h"
|
#include "stylable_element.h"
|
||||||
|
|
||||||
namespace clanguml::class_diagram::model {
|
namespace clanguml::common::model {
|
||||||
|
|
||||||
void stylable_element::set_style(const std::string &style) { style_ = style; }
|
void stylable_element::set_style(const std::string &style) { style_ = style; }
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace clanguml::class_diagram::model {
|
namespace clanguml::common::model {
|
||||||
|
|
||||||
class stylable_element {
|
class stylable_element {
|
||||||
public:
|
public:
|
||||||
@@ -90,7 +90,7 @@ bool diagram::should_include(const std::string &name_) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool diagram::should_include(
|
bool diagram::should_include(
|
||||||
const clanguml::class_diagram::model::scope_t scope) const
|
const clanguml::common::model::scope_t scope) const
|
||||||
{
|
{
|
||||||
for (const auto &s : exclude.scopes) {
|
for (const auto &s : exclude.scopes) {
|
||||||
if (s == scope)
|
if (s == scope)
|
||||||
@@ -128,7 +128,7 @@ bool class_diagram::has_class(std::string clazz)
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace YAML {
|
namespace YAML {
|
||||||
using clanguml::class_diagram::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;
|
||||||
using clanguml::config::filter;
|
using clanguml::config::filter;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "class_diagram/model/diagram.h"
|
#include "class_diagram/model/diagram.h"
|
||||||
#include "class_diagram/model/enums.h"
|
#include "common/model/enums.h"
|
||||||
#include "util/util.h"
|
#include "util/util.h"
|
||||||
|
|
||||||
#include <spdlog/spdlog.h>
|
#include <spdlog/spdlog.h>
|
||||||
@@ -56,7 +56,7 @@ struct filter {
|
|||||||
// E.g.:
|
// E.g.:
|
||||||
// - public
|
// - public
|
||||||
// - private
|
// - private
|
||||||
std::vector<class_diagram::model::scope_t> scopes;
|
std::vector<common::model::scope_t> scopes;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct diagram {
|
struct diagram {
|
||||||
@@ -77,7 +77,7 @@ struct diagram {
|
|||||||
|
|
||||||
bool should_include(const std::string &name_) const;
|
bool should_include(const std::string &name_) const;
|
||||||
|
|
||||||
bool should_include(const class_diagram::model::scope_t scope) const;
|
bool should_include(const common::model::scope_t scope) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct source_location {
|
struct source_location {
|
||||||
|
|||||||
10
src/main.cc
10
src/main.cc
@@ -19,28 +19,19 @@
|
|||||||
#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_DEBUG
|
#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_DEBUG
|
||||||
|
|
||||||
#include "class_diagram/generators/plantuml/class_diagram_generator.h"
|
#include "class_diagram/generators/plantuml/class_diagram_generator.h"
|
||||||
#include "class_diagram/model/diagram.h"
|
|
||||||
#include "class_diagram/visitor/translation_unit_visitor.h"
|
|
||||||
#include "config/config.h"
|
#include "config/config.h"
|
||||||
#include "cx/compilation_database.h"
|
#include "cx/compilation_database.h"
|
||||||
#include "sequence_diagram/generators/plantuml/sequence_diagram_generator.h"
|
#include "sequence_diagram/generators/plantuml/sequence_diagram_generator.h"
|
||||||
#include "sequence_diagram/visitor/translation_unit_context.h"
|
|
||||||
#include "util/util.h"
|
#include "util/util.h"
|
||||||
|
|
||||||
#include <cli11/CLI11.hpp>
|
#include <cli11/CLI11.hpp>
|
||||||
#include <cppast/libclang_parser.hpp>
|
#include <cppast/libclang_parser.hpp>
|
||||||
#include <glob/glob.hpp>
|
|
||||||
#include <spdlog/spdlog.h>
|
#include <spdlog/spdlog.h>
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <limits.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
using namespace clanguml;
|
using namespace clanguml;
|
||||||
using config::config;
|
using config::config;
|
||||||
@@ -112,7 +103,6 @@ int main(int argc, const char *argv[])
|
|||||||
dynamic_cast<clanguml::config::sequence_diagram &>(*diagram),
|
dynamic_cast<clanguml::config::sequence_diagram &>(*diagram),
|
||||||
model);
|
model);
|
||||||
}
|
}
|
||||||
|
|
||||||
ofs.close();
|
ofs.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user