351 lines
9.6 KiB
Markdown
351 lines
9.6 KiB
Markdown
# t20001 - Basic sequence diagram test case
|
|
## Config
|
|
```yaml
|
|
compilation_database_dir: ..
|
|
output_directory: diagrams
|
|
diagrams:
|
|
t20001_sequence:
|
|
type: sequence
|
|
glob:
|
|
- ../../tests/t20001/t20001.cc
|
|
include:
|
|
namespaces:
|
|
- clanguml::t20001
|
|
exclude:
|
|
namespaces:
|
|
- clanguml::t20001::detail
|
|
using_namespace:
|
|
- clanguml::t20001
|
|
from:
|
|
- function: "clanguml::t20001::tmain()"
|
|
plantuml:
|
|
before:
|
|
- "' t20001 test diagram of type {{ diagram.type }}"
|
|
after:
|
|
- '{% set e=element("clanguml::t20001::tmain()") %} note over {{ e.alias) }}: Main test function'
|
|
mermaid:
|
|
before:
|
|
- "%% t20001 test diagram of type {{ diagram.type }}"
|
|
after:
|
|
- '{% set e=element("clanguml::t20001::tmain()") %} Note over {{ e.alias) }}: Main test function'
|
|
|
|
```
|
|
## Source code
|
|
File t20001.cc
|
|
```cpp
|
|
#include <algorithm>
|
|
#include <vector>
|
|
|
|
namespace clanguml {
|
|
namespace t20001 {
|
|
|
|
namespace detail {
|
|
struct C {
|
|
auto add(int x, int y) { return x + y; }
|
|
};
|
|
}
|
|
|
|
class A {
|
|
public:
|
|
A() { }
|
|
|
|
int add(int x, int y) { return m_c.add(x, y); }
|
|
|
|
int add3(int x, int y, int z)
|
|
{
|
|
std::vector<int> v;
|
|
v.push_back(x);
|
|
v.push_back(y);
|
|
v.push_back(z);
|
|
auto res = add(v[0], v[1]) + v[2];
|
|
log_result(res);
|
|
return res;
|
|
}
|
|
|
|
static void log_result(int r) { }
|
|
|
|
private:
|
|
detail::C m_c{};
|
|
};
|
|
|
|
class B {
|
|
public:
|
|
B(A &a)
|
|
: m_a{a}
|
|
{
|
|
}
|
|
|
|
int wrap_add(int x, int y)
|
|
{
|
|
auto res = m_a.add(x, y);
|
|
m_a.log_result(res);
|
|
return res;
|
|
}
|
|
|
|
int wrap_add3(int x, int y, int z)
|
|
{
|
|
auto res = m_a.add3(x, y, z);
|
|
m_a.log_result(res);
|
|
return res;
|
|
}
|
|
|
|
private:
|
|
A &m_a;
|
|
};
|
|
|
|
int tmain()
|
|
{
|
|
A a;
|
|
B b(a);
|
|
|
|
auto tmp = a.add(1, 2);
|
|
|
|
return b.wrap_add3(tmp, 2, 3);
|
|
}
|
|
}
|
|
}
|
|
|
|
```
|
|
## Generated PlantUML diagrams
|
|

|
|
## Generated Mermaid diagrams
|
|

|
|
## Generated JSON models
|
|
```json
|
|
{
|
|
"diagram_type": "sequence",
|
|
"metadata": {
|
|
"clang_uml_version": "0.4.0",
|
|
"llvm_version": "Ubuntu clang version 16.0.1 (++20230328073357+42d1b276f779-1~exp1~20230328073502.65)",
|
|
"schema_version": 1
|
|
},
|
|
"name": "t20001_sequence",
|
|
"participants": [
|
|
{
|
|
"id": "622672604730036140",
|
|
"name": "clanguml::t20001::tmain()",
|
|
"source_location": {
|
|
"column": 5,
|
|
"file": "../../tests/t20001/t20001.cc",
|
|
"line": 61,
|
|
"translation_unit": "../../tests/t20001/t20001.cc"
|
|
},
|
|
"type": "function"
|
|
},
|
|
{
|
|
"id": "1771943546649183134",
|
|
"name": "clanguml::t20001::A",
|
|
"source_location": {
|
|
"column": 7,
|
|
"file": "../../tests/t20001/t20001.cc",
|
|
"line": 13,
|
|
"translation_unit": "../../tests/t20001/t20001.cc"
|
|
},
|
|
"type": "class"
|
|
},
|
|
{
|
|
"id": "272433898507800600",
|
|
"name": "clanguml::t20001::B",
|
|
"source_location": {
|
|
"column": 7,
|
|
"file": "../../tests/t20001/t20001.cc",
|
|
"line": 36,
|
|
"translation_unit": "../../tests/t20001/t20001.cc"
|
|
},
|
|
"type": "class"
|
|
}
|
|
],
|
|
"sequences": [
|
|
{
|
|
"messages": [
|
|
{
|
|
"from": {
|
|
"activity_id": "622672604730036140",
|
|
"activity_name": "clanguml::t20001::tmain()",
|
|
"participant_id": "622672604730036140",
|
|
"participant_name": "clanguml::t20001::tmain()"
|
|
},
|
|
"name": "A()",
|
|
"return_type": "void",
|
|
"scope": "normal",
|
|
"source_location": {
|
|
"column": 7,
|
|
"file": "../../tests/t20001/t20001.cc",
|
|
"line": 63,
|
|
"translation_unit": "../../tests/t20001/t20001.cc"
|
|
},
|
|
"to": {
|
|
"activity_id": "275353461034438145",
|
|
"activity_name": "clanguml::t20001::A::A()",
|
|
"participant_id": "1771943546649183134"
|
|
},
|
|
"type": "message"
|
|
},
|
|
{
|
|
"from": {
|
|
"activity_id": "622672604730036140",
|
|
"activity_name": "clanguml::t20001::tmain()",
|
|
"participant_id": "622672604730036140",
|
|
"participant_name": "clanguml::t20001::tmain()"
|
|
},
|
|
"name": "B(A &)",
|
|
"return_type": "void",
|
|
"scope": "normal",
|
|
"source_location": {
|
|
"column": 7,
|
|
"file": "../../tests/t20001/t20001.cc",
|
|
"line": 64,
|
|
"translation_unit": "../../tests/t20001/t20001.cc"
|
|
},
|
|
"to": {
|
|
"activity_id": "2235477658795500000",
|
|
"activity_name": "clanguml::t20001::B::B(A &)",
|
|
"participant_id": "272433898507800600"
|
|
},
|
|
"type": "message"
|
|
},
|
|
{
|
|
"from": {
|
|
"activity_id": "622672604730036140",
|
|
"activity_name": "clanguml::t20001::tmain()",
|
|
"participant_id": "622672604730036140",
|
|
"participant_name": "clanguml::t20001::tmain()"
|
|
},
|
|
"name": "add(int,int)",
|
|
"return_type": "int",
|
|
"scope": "normal",
|
|
"source_location": {
|
|
"column": 16,
|
|
"file": "../../tests/t20001/t20001.cc",
|
|
"line": 66,
|
|
"translation_unit": "../../tests/t20001/t20001.cc"
|
|
},
|
|
"to": {
|
|
"activity_id": "1131549932713395402",
|
|
"activity_name": "clanguml::t20001::A::add(int,int)",
|
|
"participant_id": "1771943546649183134"
|
|
},
|
|
"type": "message"
|
|
},
|
|
{
|
|
"from": {
|
|
"activity_id": "622672604730036140",
|
|
"activity_name": "clanguml::t20001::tmain()",
|
|
"participant_id": "622672604730036140",
|
|
"participant_name": "clanguml::t20001::tmain()"
|
|
},
|
|
"name": "wrap_add3(int,int,int)",
|
|
"return_type": "int",
|
|
"scope": "normal",
|
|
"source_location": {
|
|
"column": 12,
|
|
"file": "../../tests/t20001/t20001.cc",
|
|
"line": 68,
|
|
"translation_unit": "../../tests/t20001/t20001.cc"
|
|
},
|
|
"to": {
|
|
"activity_id": "642550151323208936",
|
|
"activity_name": "clanguml::t20001::B::wrap_add3(int,int,int)",
|
|
"participant_id": "272433898507800600"
|
|
},
|
|
"type": "message"
|
|
},
|
|
{
|
|
"from": {
|
|
"activity_id": "642550151323208936",
|
|
"activity_name": "clanguml::t20001::B::wrap_add3(int,int,int)",
|
|
"participant_id": "272433898507800600"
|
|
},
|
|
"name": "add3(int,int,int)",
|
|
"return_type": "int",
|
|
"scope": "normal",
|
|
"source_location": {
|
|
"column": 20,
|
|
"file": "../../tests/t20001/t20001.cc",
|
|
"line": 52,
|
|
"translation_unit": "../../tests/t20001/t20001.cc"
|
|
},
|
|
"to": {
|
|
"activity_id": "2090436635449419593",
|
|
"activity_name": "clanguml::t20001::A::add3(int,int,int)",
|
|
"participant_id": "1771943546649183134"
|
|
},
|
|
"type": "message"
|
|
},
|
|
{
|
|
"from": {
|
|
"activity_id": "2090436635449419593",
|
|
"activity_name": "clanguml::t20001::A::add3(int,int,int)",
|
|
"participant_id": "1771943546649183134"
|
|
},
|
|
"name": "add(int,int)",
|
|
"return_type": "int",
|
|
"scope": "normal",
|
|
"source_location": {
|
|
"column": 20,
|
|
"file": "../../tests/t20001/t20001.cc",
|
|
"line": 25,
|
|
"translation_unit": "../../tests/t20001/t20001.cc"
|
|
},
|
|
"to": {
|
|
"activity_id": "1131549932713395402",
|
|
"activity_name": "clanguml::t20001::A::add(int,int)",
|
|
"participant_id": "1771943546649183134"
|
|
},
|
|
"type": "message"
|
|
},
|
|
{
|
|
"from": {
|
|
"activity_id": "2090436635449419593",
|
|
"activity_name": "clanguml::t20001::A::add3(int,int,int)",
|
|
"participant_id": "1771943546649183134"
|
|
},
|
|
"name": "log_result(int)",
|
|
"return_type": "void",
|
|
"scope": "normal",
|
|
"source_location": {
|
|
"column": 9,
|
|
"file": "../../tests/t20001/t20001.cc",
|
|
"line": 26,
|
|
"translation_unit": "../../tests/t20001/t20001.cc"
|
|
},
|
|
"to": {
|
|
"activity_id": "1205947631808952097",
|
|
"activity_name": "clanguml::t20001::A::log_result(int)",
|
|
"participant_id": "1771943546649183134"
|
|
},
|
|
"type": "message"
|
|
},
|
|
{
|
|
"from": {
|
|
"activity_id": "642550151323208936",
|
|
"activity_name": "clanguml::t20001::B::wrap_add3(int,int,int)",
|
|
"participant_id": "272433898507800600"
|
|
},
|
|
"name": "log_result(int)",
|
|
"return_type": "void",
|
|
"scope": "normal",
|
|
"source_location": {
|
|
"column": 9,
|
|
"file": "../../tests/t20001/t20001.cc",
|
|
"line": 53,
|
|
"translation_unit": "../../tests/t20001/t20001.cc"
|
|
},
|
|
"to": {
|
|
"activity_id": "1205947631808952097",
|
|
"activity_name": "clanguml::t20001::A::log_result(int)",
|
|
"participant_id": "1771943546649183134"
|
|
},
|
|
"type": "message"
|
|
}
|
|
],
|
|
"start_from": {
|
|
"id": 622672604730036140,
|
|
"location": "clanguml::t20001::tmain()"
|
|
}
|
|
}
|
|
],
|
|
"using_namespace": "clanguml::t20001"
|
|
}
|
|
```
|