Add from_to config option
This commit is contained in:
@@ -542,6 +542,7 @@ struct sequence_diagram : public diagram {
|
|||||||
common::model::diagram_t type() const override;
|
common::model::diagram_t type() const override;
|
||||||
|
|
||||||
option<std::vector<source_location>> start_from{"start_from"};
|
option<std::vector<source_location>> start_from{"start_from"};
|
||||||
|
option<std::vector<std::vector<source_location>>> from_to{"from_to"};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -574,6 +574,7 @@ template <> struct convert<sequence_diagram> {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
get_option(node, rhs.start_from);
|
get_option(node, rhs.start_from);
|
||||||
|
get_option(node, rhs.from_to);
|
||||||
get_option(node, rhs.combine_free_functions_into_file_participants);
|
get_option(node, rhs.combine_free_functions_into_file_participants);
|
||||||
get_option(node, rhs.generate_return_types);
|
get_option(node, rhs.generate_return_types);
|
||||||
get_option(node, rhs.generate_condition_statements);
|
get_option(node, rhs.generate_condition_statements);
|
||||||
|
|||||||
@@ -348,6 +348,7 @@ YAML::Emitter &operator<<(YAML::Emitter &out, const sequence_diagram &c)
|
|||||||
out << YAML::BeginMap;
|
out << YAML::BeginMap;
|
||||||
out << YAML::Key << "type" << YAML::Value << c.type();
|
out << YAML::Key << "type" << YAML::Value << c.type();
|
||||||
out << c.start_from;
|
out << c.start_from;
|
||||||
|
out << c.from_to;
|
||||||
out << dynamic_cast<const inheritable_diagram_options &>(c);
|
out << dynamic_cast<const inheritable_diagram_options &>(c);
|
||||||
out << YAML::EndMap;
|
out << YAML::EndMap;
|
||||||
return out;
|
return out;
|
||||||
|
|||||||
@@ -415,7 +415,60 @@ void generator::generate_diagram(std::ostream &ostr) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto &sf : config().start_from()) {
|
for (const auto &ft : m_config.from_to()) {
|
||||||
|
// First, find the sequence of activities from 'from' location
|
||||||
|
// to 'to' location
|
||||||
|
assert(ft.size() == 2);
|
||||||
|
|
||||||
|
const auto &from_location = ft.front();
|
||||||
|
const auto &to_location = ft.back();
|
||||||
|
|
||||||
|
if (from_location.location_type == location_t::function) {
|
||||||
|
common::model::diagram_element::id_t from_activity{0};
|
||||||
|
common::model::diagram_element::id_t to_activity{0};
|
||||||
|
|
||||||
|
for (const auto &[k, v] : m_model.sequences()) {
|
||||||
|
const auto &caller = *m_model.participants().at(v.from());
|
||||||
|
std::string vfrom = caller.full_name(false);
|
||||||
|
if (vfrom == from_location.location) {
|
||||||
|
LOG_DBG("Found sequence diagram start point: {}", k);
|
||||||
|
from_activity = k;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (from_activity == 0) {
|
||||||
|
LOG_WARN("Failed to find participant with {} for start_from "
|
||||||
|
"condition",
|
||||||
|
from_location.location);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto &[k, v] : m_model.sequences()) {
|
||||||
|
const auto &caller = *m_model.participants().at(v.from());
|
||||||
|
std::string vfrom = caller.full_name(false);
|
||||||
|
if (vfrom == to_location.location) {
|
||||||
|
LOG_DBG("Found sequence diagram end point: {}", k);
|
||||||
|
to_activity = k;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (to_activity == 0) {
|
||||||
|
LOG_WARN("Failed to find participant with {} for from_to "
|
||||||
|
"condition",
|
||||||
|
to_location.location);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
call_chain_t activity_path;
|
||||||
|
activity_path.push_back(from_activity);
|
||||||
|
|
||||||
|
auto found = search_path_to(activity_path, to_activity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto &sf : m_config.start_from()) {
|
||||||
if (sf.location_type == location_t::function) {
|
if (sf.location_type == location_t::function) {
|
||||||
common::model::diagram_element::id_t start_from{0};
|
common::model::diagram_element::id_t start_from{0};
|
||||||
for (const auto &[k, v] : model().sequences()) {
|
for (const auto &[k, v] : model().sequences()) {
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ template <typename C, typename D>
|
|||||||
using common_generator =
|
using common_generator =
|
||||||
clanguml::common::generators::plantuml::generator<C, D>;
|
clanguml::common::generators::plantuml::generator<C, D>;
|
||||||
|
|
||||||
|
using call_chain_t = std::vector<common::model::diagram_element::id_t>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Sequence diagram PlantUML generator
|
* @brief Sequence diagram PlantUML generator
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user