280 lines
6.9 KiB
Markdown
280 lines
6.9 KiB
Markdown
# t20001 - Basic sequence diagram test case
|
|
## Config
|
|
```yaml
|
|
compilation_database_dir: ..
|
|
output_directory: puml
|
|
diagrams:
|
|
t20001_sequence:
|
|
type: sequence
|
|
glob:
|
|
- ../../tests/t20001/t20001.cc
|
|
include:
|
|
namespaces:
|
|
- clanguml::t20001
|
|
exclude:
|
|
namespaces:
|
|
- clanguml::t20001::detail
|
|
using_namespace:
|
|
- clanguml::t20001
|
|
start_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'
|
|
|
|
```
|
|
## 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 UML diagrams
|
|

|
|
## Generated JSON models
|
|
```json
|
|
{
|
|
"diagram_type": "sequence",
|
|
"metadata": {
|
|
"clang_uml_version": "0.3.4-45-gdec4b7b",
|
|
"llvm_version": "Ubuntu clang version 15.0.6",
|
|
"schema_version": 1
|
|
},
|
|
"name": "t20001_sequence",
|
|
"participants": [
|
|
{
|
|
"id": "622672604730036140",
|
|
"name": "clanguml::t20001::tmain()",
|
|
"source_location": {
|
|
"file": "../../tests/t20001/t20001.cc",
|
|
"line": 61
|
|
},
|
|
"type": "function"
|
|
},
|
|
{
|
|
"id": "1771943546649183134",
|
|
"name": "clanguml::t20001::A",
|
|
"source_location": {
|
|
"file": "../../tests/t20001/t20001.cc",
|
|
"line": 13
|
|
},
|
|
"type": "class"
|
|
},
|
|
{
|
|
"id": "272433898507800600",
|
|
"name": "clanguml::t20001::B",
|
|
"source_location": {
|
|
"file": "../../tests/t20001/t20001.cc",
|
|
"line": 36
|
|
},
|
|
"type": "class"
|
|
}
|
|
],
|
|
"sequences": [
|
|
{
|
|
"messages": [
|
|
{
|
|
"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": {
|
|
"file": "../../tests/t20001/t20001.cc",
|
|
"line": 66
|
|
},
|
|
"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": {
|
|
"file": "../../tests/t20001/t20001.cc",
|
|
"line": 68
|
|
},
|
|
"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": {
|
|
"file": "../../tests/t20001/t20001.cc",
|
|
"line": 52
|
|
},
|
|
"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": {
|
|
"file": "../../tests/t20001/t20001.cc",
|
|
"line": 25
|
|
},
|
|
"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": "",
|
|
"scope": "normal",
|
|
"source_location": {
|
|
"file": "../../tests/t20001/t20001.cc",
|
|
"line": 26
|
|
},
|
|
"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": "",
|
|
"scope": "normal",
|
|
"source_location": {
|
|
"file": "../../tests/t20001/t20001.cc",
|
|
"line": 53
|
|
},
|
|
"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"
|
|
}
|
|
```
|