Added '--print-to' cli option to print all possible 'to' constraints in sequence diagrams

This commit is contained in:
Bartek Kryza
2023-08-31 22:28:25 +02:00
parent 1bd60b71ec
commit 51e0275db3
5 changed files with 63 additions and 20 deletions

View File

@@ -193,18 +193,41 @@ bool diagram::should_include(
dynamic_cast<const common::model::source_location &>(p));
}
std::vector<std::string> diagram::list_start_from_values() const
std::vector<std::string> diagram::list_from_values() const
{
std::vector<std::string> result;
for (const auto &[from_id, act] : sequences_) {
const auto &from_activity = *(participants_.at(from_id));
result.push_back(from_activity.full_name(false));
const auto &full_name = from_activity.full_name(false);
if (!full_name.empty())
result.push_back(full_name);
}
std::sort(result.begin(), result.end());
result.erase(std::unique(result.begin(), result.end()), result.end());
return result;
}
std::vector<std::string> diagram::list_to_values() const
{
std::vector<std::string> result;
for (const auto &[from_id, act] : sequences_) {
for (const auto &m : act.messages()) {
if (participants_.count(m.to()) > 0) {
const auto &to_activity = *(participants_.at(m.to()));
const auto &full_name = to_activity.full_name(false);
if (!full_name.empty())
result.push_back(full_name);
}
}
}
std::sort(result.begin(), result.end());
result.erase(std::unique(result.begin(), result.end()), result.end());
return result;
}

View File

@@ -232,11 +232,18 @@ public:
bool should_include(const sequence_diagram::model::participant &p) const;
/**
* @brief Get list of all possible 'start_from' values in the model
* @brief Get list of all possible 'from' values in the model
*
* @return List of all possible 'start_from' values
* @return List of all possible 'from' values
*/
std::vector<std::string> list_start_from_values() const;
std::vector<std::string> list_from_values() const;
/**
* @brief Get list of all possible 'to' values in the model
*
* @return List of all possible 'to' values
*/
std::vector<std::string> list_to_values() const;
/**
* @brief Generate a list of message chains matching a from_to constraint