Renamed common::id_t to eid_t to avoid conflicts with system id_t

This commit is contained in:
Bartek Kryza
2024-06-05 21:19:46 +02:00
parent 2cf9d2f22a
commit 420475ab64
57 changed files with 370 additions and 356 deletions

View File

@@ -70,7 +70,7 @@ public:
* @return Optional reference to a diagram element.
*/
virtual common::optional_ref<clanguml::common::model::diagram_element> get(
common::id_t id) const = 0;
eid_t id) const = 0;
/**
* Return optional reference to a diagram_element by name and namespace.
@@ -152,7 +152,7 @@ public:
// Disallow std::string overload
bool should_include(const std::string &s) const = delete;
virtual bool has_element(const common::id_t /*id*/) const { return false; }
virtual bool has_element(const eid_t /*id*/) const { return false; }
virtual bool should_include(
const namespace_ &ns, const std::string &name) const;

View File

@@ -26,16 +26,16 @@ namespace clanguml::common::model {
diagram_element::diagram_element() = default;
const common::id_t &diagram_element::id() const { return id_; }
const eid_t &diagram_element::id() const { return id_; }
void diagram_element::set_id(common::id_t id) { id_ = id; }
void diagram_element::set_id(eid_t id) { id_ = id; }
std::optional<id_t> diagram_element::parent_element_id() const
std::optional<eid_t> diagram_element::parent_element_id() const
{
return parent_element_id_;
}
void diagram_element::set_parent_element_id(common::id_t id)
void diagram_element::set_parent_element_id(eid_t id)
{
parent_element_id_ = id;
}

View File

@@ -53,28 +53,28 @@ public:
*
* @return Elements id.
*/
const common::id_t &id() const;
const eid_t &id() const;
/**
* Set elements id.
*
* @param id Elements id.
*/
void set_id(common::id_t id);
void set_id(eid_t id);
/**
* Get elements parent package id.
*
* @return Parent package id if element is nested.
*/
std::optional<id_t> parent_element_id() const;
std::optional<eid_t> parent_element_id() const;
/**
* Set elements parent package id.
*
* @param id Id of parent package.
*/
void set_parent_element_id(id_t id);
void set_parent_element_id(eid_t id);
/**
* @brief Return elements' diagram alias.
@@ -185,8 +185,8 @@ public:
void complete(bool completed);
private:
id_t id_{};
std::optional<common::id_t> parent_element_id_{};
eid_t id_{};
std::optional<eid_t> parent_element_id_{};
std::string name_;
std::vector<relationship> relationships_;
bool nested_{false};

View File

@@ -81,7 +81,7 @@ const clanguml::common::optional_ref<common::model::source_file> get(
}
template <>
clanguml::common::id_t destination_comparator<common::model::source_file>(
eid_t destination_comparator<common::model::source_file>(
const common::model::source_file &f)
{
return f.id();
@@ -690,7 +690,7 @@ void context_filter::initialize_effective_context(
// Now repeat radius times - extend the effective context with elements
// matching in direct relationship to what is in context
auto radius_counter = context.radius;
std::set<clanguml::common::id_t> current_iteration_context;
std::set<eid_t> current_iteration_context;
while (radius_counter > 0 && effective_context_extended) {
// If at any iteration the effective context was not extended - we
@@ -725,8 +725,8 @@ void context_filter::initialize_effective_context(
}
void context_filter::find_elements_inheritance_relationship(const diagram &d,
std::set<id_t> &effective_context,
std::set<clanguml::common::id_t> &current_iteration_context) const
std::set<eid_t> &effective_context,
std::set<eid_t> &current_iteration_context) const
{
const auto &cd = dynamic_cast<const class_diagram::model::diagram &>(d);

View File

@@ -37,6 +37,8 @@
namespace clanguml::common::model {
using clanguml::common::eid_t;
/**
* Diagram filters can be add in 2 modes:
* - inclusive - the elements that match are included in the diagram
@@ -55,15 +57,12 @@ template <typename ElementT, typename DiagramT>
const clanguml::common::optional_ref<ElementT> get(
const DiagramT &d, const std::string &full_name);
template <typename ElementT>
common::id_t destination_comparator(const ElementT &e)
template <typename ElementT> eid_t destination_comparator(const ElementT &e)
{
return e.id();
}
template <>
clanguml::common::id_t destination_comparator(
const common::model::source_file &f);
template <> eid_t destination_comparator(const common::model::source_file &f);
} // namespace detail
/**
@@ -493,8 +492,8 @@ private:
template <typename ElementT>
void find_elements_in_direct_relationship(const diagram &d,
std::set<id_t> &effective_context,
std::set<clanguml::common::id_t> &current_iteration_context) const
std::set<eid_t> &effective_context,
std::set<eid_t> &current_iteration_context) const
{
static_assert(std::is_same_v<ElementT, class_diagram::model::class_> ||
std::is_same_v<ElementT, class_diagram::model::enum_> ||
@@ -535,8 +534,8 @@ private:
}
void find_elements_inheritance_relationship(const diagram &d,
std::set<id_t> &effective_context,
std::set<clanguml::common::id_t> &current_iteration_context) const;
std::set<eid_t> &effective_context,
std::set<eid_t> &current_iteration_context) const;
std::vector<config::context_config> context_;
@@ -544,7 +543,7 @@ private:
* Represents all elements which should belong to the diagram based
* on this filter. It is populated by the initialize() method.
*/
mutable std::vector<std::set<clanguml::common::id_t>> effective_contexts_;
mutable std::vector<std::set<eid_t>> effective_contexts_;
/*! Flag to mark whether the filter context has been computed */
mutable bool initialized_{false};

View File

@@ -21,6 +21,8 @@
namespace clanguml::common::model {
using clanguml::common::eid_t;
/**
* Provides type based views over elements in a diagram.
*
@@ -58,7 +60,7 @@ public:
*
* @return
*/
common::optional_ref<T> get(clanguml::common::id_t id) const
common::optional_ref<T> get(eid_t id) const
{
for (const auto &e : elements_) {
if (e.get().id() == id) {

View File

@@ -89,9 +89,9 @@ struct hash<std::reference_wrapper<clanguml::common::model::package>> {
const std::reference_wrapper<clanguml::common::model::package> &key)
const
{
using clanguml::common::id_t;
using clanguml::common::eid_t;
return std::hash<id_t::type>{}(key.get().id().value());
return key.get().id().value();
}
};
} // namespace std

View File

@@ -22,7 +22,7 @@
namespace clanguml::common::model {
relationship::relationship(relationship_t type, common::id_t destination,
relationship::relationship(relationship_t type, eid_t destination,
access_t access, std::string label, std::string multiplicity_source,
std::string multiplicity_destination)
: type_{type}
@@ -38,15 +38,12 @@ void relationship::set_type(relationship_t type) noexcept { type_ = type; }
relationship_t relationship::type() const noexcept { return type_; }
void relationship::set_destination(common::id_t destination)
void relationship::set_destination(eid_t destination)
{
destination_ = destination;
}
clanguml::common::id_t relationship::destination() const
{
return destination_;
}
eid_t relationship::destination() const { return destination_; }
void relationship::set_multiplicity_source(
const std::string &multiplicity_source)

View File

@@ -25,6 +25,8 @@
namespace clanguml::common::model {
using clanguml::common::eid_t;
/**
* @brief Class representing any relationship other than inheritance
*
@@ -47,7 +49,7 @@ public:
* @param multiplicity_source Multiplicity at the source
* @param multiplicity_destination Multiplicity at the destination
*/
relationship(relationship_t type, clanguml::common::id_t destination,
relationship(relationship_t type, eid_t destination,
access_t access = access_t::kPublic, std::string label = "",
std::string multiplicity_source = "",
std::string multiplicity_destination = "");
@@ -74,14 +76,14 @@ public:
*
* @param destination Target element id.
*/
void set_destination(common::id_t destination);
void set_destination(eid_t destination);
/**
* Get the id of the target element of this relationship.
*
* @return Target element id.
*/
common::id_t destination() const;
eid_t destination() const;
/**
* Set the relationship multiplicity at the source.
@@ -144,7 +146,7 @@ public:
private:
relationship_t type_;
clanguml::common::id_t destination_;
eid_t destination_;
std::string multiplicity_source_;
std::string multiplicity_destination_;
std::string label_;

View File

@@ -210,9 +210,7 @@ struct hash<std::reference_wrapper<clanguml::common::model::source_file>> {
const std::reference_wrapper<clanguml::common::model::source_file> &key)
const
{
using clanguml::common::id_t;
return std::hash<id_t::type>{}(key.get().id().value());
return key.get().id().value();
}
};
} // namespace std

View File

@@ -505,7 +505,7 @@ std::string template_parameter::to_string(
}
bool template_parameter::find_nested_relationships(
std::vector<std::pair<common::id_t, common::model::relationship_t>>
std::vector<std::pair<eid_t, common::model::relationship_t>>
&nested_relationships,
common::model::relationship_t hint,
const std::function<bool(const std::string &full_name)> &should_include)

View File

@@ -29,6 +29,8 @@
namespace clanguml::common::model {
using clanguml::common::eid_t;
/**
* Type of template parameter or argument.
*/
@@ -166,14 +168,14 @@ public:
*
* @param id Id of parameter
*/
void set_id(const common::id_t &id) { id_ = id; }
void set_id(const eid_t &id) { id_ = id; }
/**
* Get id of the template parameter
*
* @return Id of the template parameter
*/
const std::optional<common::id_t> &id() const { return id_; }
const std::optional<eid_t> &id() const { return id_; }
/**
* Set the name of the template parameter
@@ -389,7 +391,7 @@ public:
* @return
*/
bool find_nested_relationships(
std::vector<std::pair<common::id_t, common::model::relationship_t>>
std::vector<std::pair<eid_t, common::model::relationship_t>>
&nested_relationships,
common::model::relationship_t hint,
const std::function<bool(const std::string &full_name)> &should_include)
@@ -533,7 +535,7 @@ private:
*/
std::vector<template_parameter> template_params_;
std::optional<common::id_t> id_;
std::optional<eid_t> id_;
bool is_unexposed_{false};
};