0.6.0
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
Classes | Typedefs | Functions
clanguml::sequence_diagram::model Namespace Reference

Classes

class  activity
 Model of a sequence diagram activity. More...
 
struct  class_
 Sequence diagram participant representing a class. More...
 
class  diagram
 Model of a sequence diagram. More...
 
struct  function
 Participant mode representing a free function. More...
 
struct  function_template
 Participant model representing a function template. More...
 
class  message
 Model of a sequence diagram message. More...
 
struct  method
 Participant model representing a method. More...
 
struct  objc_method
 
struct  participant
 Base class for various types of sequence diagram participants. More...
 
struct  reverse_call_graph_activity_node
 

Typedefs

using message_chain_t = std::vector< sequence_diagram::model::message >
 

Functions

void to_json (nlohmann::json &j, const participant &c)
 
void to_json (nlohmann::json &j, const activity &c)
 
std::vector< std::vector< eid_t > > find_reverse_message_chains (const reverse_call_graph_activity_node &root)
 Convert reverse call graph into a list of activity id chains.
 
bool operator== (const class_ &l, const class_ &r)
 

Typedef Documentation

◆ message_chain_t

Definition at line 31 of file diagram.h.

Function Documentation

◆ find_reverse_message_chains()

std::vector< std::vector< eid_t > > clanguml::sequence_diagram::model::find_reverse_message_chains ( const reverse_call_graph_activity_node root)

Convert reverse call graph into a list of activity id chains.

Parameters
rootRoot of the reverse call graph tree
Returns

Definition at line 28 of file diagram.cc.

30{
31 std::vector<std::vector<eid_t>> all_message_chains;
32 std::vector<eid_t> current_chain;
33
34 // Depth first search lambda function to traverse reverse call graph
35 std::function<void(const reverse_call_graph_activity_node &)> dfs =
36 [&](const reverse_call_graph_activity_node &node) {
37 // Add the current node’s activity ID to the path
38 current_chain.push_back(node.activity_id);
39
40 if (node.callers.empty()) {
41 auto reversed = current_chain;
42 std::reverse(reversed.begin(), reversed.end());
43 all_message_chains.emplace_back(std::move(reversed));
44 }
45 else {
46 for (const auto &child : node.callers) {
47 dfs(child);
48 }
49 }
50
51 // Backtrack
52 current_chain.pop_back();
53 };
54
55 // Start depth first search
56 dfs(root);
57
58 return all_message_chains;
59}

◆ operator==()

bool clanguml::sequence_diagram::model::operator== ( const class_ l,
const class_ r 
)

Definition at line 113 of file participant.cc.

113{ return l.id() == r.id(); }

◆ to_json() [1/2]

void clanguml::sequence_diagram::model::to_json ( nlohmann::json &  j,
const activity c 
)

Definition at line 48 of file sequence_diagram_generator.cc.

49{
50 j["participant_id"] = std::to_string(c.from().value());
51}

◆ to_json() [2/2]

void clanguml::sequence_diagram::model::to_json ( nlohmann::json &  j,
const participant c 
)

Definition at line 25 of file sequence_diagram_generator.cc.

26{
27 to_json(j, dynamic_cast<const participant::element &>(c));
28 j["type"] = c.type_name();
29
30 if (c.type_name() == "method") {
31 j["name"] = dynamic_cast<const method &>(c).method_name();
32 }
33 else if (c.type_name() == "objc_method") {
34 j["name"] = dynamic_cast<const objc_method &>(c).method_name();
35 }
36
37 j["full_name"] = display_name_adapter(c).full_name(false);
38
39 if (c.type_name() == "function" || c.type_name() == "function_template") {
40 const auto &f = dynamic_cast<const function &>(c);
41 if (f.is_cuda_kernel())
42 j["is_cuda_kernel"] = true;
43 if (f.is_cuda_device())
44 j["is_cuda_device"] = true;
45 }
46}