320 lines
9.3 KiB
Markdown
320 lines
9.3 KiB
Markdown
# t20018 - Recursive template sequence diagram test case
|
|
## Config
|
|
```yaml
|
|
compilation_database_dir: ..
|
|
output_directory: diagrams
|
|
diagrams:
|
|
t20018_sequence:
|
|
type: sequence
|
|
glob:
|
|
- ../../tests/t20018/t20018.cc
|
|
include:
|
|
namespaces:
|
|
- clanguml::t20018
|
|
using_namespace:
|
|
- clanguml::t20018
|
|
from:
|
|
- function: "clanguml::t20018::tmain()"
|
|
```
|
|
## Source code
|
|
File t20018.cc
|
|
```cpp
|
|
#include <iostream>
|
|
|
|
namespace clanguml {
|
|
namespace t20018 {
|
|
|
|
template <int N> struct Factorial {
|
|
static const int value = N * Factorial<N - 1>::value;
|
|
|
|
static void print(int answer) { Factorial<N - 1>::print(answer); }
|
|
};
|
|
|
|
template <> struct Factorial<0> {
|
|
static const int value = 1;
|
|
|
|
static void print(int answer)
|
|
{
|
|
std::cout << "The answer is " << answer << "\n";
|
|
}
|
|
};
|
|
|
|
template <typename T, int N = T::value> struct Answer {
|
|
static void print() { T::print(N); }
|
|
};
|
|
|
|
void tmain() { Answer<Factorial<5>>::print(); }
|
|
}
|
|
}
|
|
```
|
|
## Generated UML diagrams
|
|

|
|
## Generated JSON models
|
|
```json
|
|
{
|
|
"diagram_type": "sequence",
|
|
"metadata": {
|
|
"clang_uml_version": "0.3.8-32-ge830195",
|
|
"llvm_version": "Ubuntu clang version 15.0.7",
|
|
"schema_version": 1
|
|
},
|
|
"name": "t20018_sequence",
|
|
"participants": [
|
|
{
|
|
"id": "227581758025403815",
|
|
"name": "clanguml::t20018::tmain()",
|
|
"source_location": {
|
|
"column": 6,
|
|
"file": "../../tests/t20018/t20018.cc",
|
|
"line": 25,
|
|
"translation_unit": "../../tests/t20018/t20018.cc"
|
|
},
|
|
"type": "function"
|
|
},
|
|
{
|
|
"id": "1163521725351533502",
|
|
"name": "clanguml::t20018::Answer<clanguml::t20018::Factorial<5>,120>",
|
|
"source_location": {
|
|
"column": 48,
|
|
"file": "../../tests/t20018/t20018.cc",
|
|
"line": 21,
|
|
"translation_unit": "../../tests/t20018/t20018.cc"
|
|
},
|
|
"type": "class"
|
|
},
|
|
{
|
|
"id": "1482779373563849921",
|
|
"name": "clanguml::t20018::Factorial<5>",
|
|
"source_location": {
|
|
"column": 25,
|
|
"file": "../../tests/t20018/t20018.cc",
|
|
"line": 6,
|
|
"translation_unit": "../../tests/t20018/t20018.cc"
|
|
},
|
|
"type": "class"
|
|
},
|
|
{
|
|
"id": "52416404065514823",
|
|
"name": "clanguml::t20018::Factorial<4>",
|
|
"source_location": {
|
|
"column": 25,
|
|
"file": "../../tests/t20018/t20018.cc",
|
|
"line": 6,
|
|
"translation_unit": "../../tests/t20018/t20018.cc"
|
|
},
|
|
"type": "class"
|
|
},
|
|
{
|
|
"id": "1658728078296100018",
|
|
"name": "clanguml::t20018::Factorial<3>",
|
|
"source_location": {
|
|
"column": 25,
|
|
"file": "../../tests/t20018/t20018.cc",
|
|
"line": 6,
|
|
"translation_unit": "../../tests/t20018/t20018.cc"
|
|
},
|
|
"type": "class"
|
|
},
|
|
{
|
|
"id": "969903469166760124",
|
|
"name": "clanguml::t20018::Factorial<2>",
|
|
"source_location": {
|
|
"column": 25,
|
|
"file": "../../tests/t20018/t20018.cc",
|
|
"line": 6,
|
|
"translation_unit": "../../tests/t20018/t20018.cc"
|
|
},
|
|
"type": "class"
|
|
},
|
|
{
|
|
"id": "2032621198190600516",
|
|
"name": "clanguml::t20018::Factorial<1>",
|
|
"source_location": {
|
|
"column": 25,
|
|
"file": "../../tests/t20018/t20018.cc",
|
|
"line": 6,
|
|
"translation_unit": "../../tests/t20018/t20018.cc"
|
|
},
|
|
"type": "class"
|
|
},
|
|
{
|
|
"id": "1581865799666386458",
|
|
"name": "clanguml::t20018::Factorial<0>",
|
|
"source_location": {
|
|
"column": 20,
|
|
"file": "../../tests/t20018/t20018.cc",
|
|
"line": 12,
|
|
"translation_unit": "../../tests/t20018/t20018.cc"
|
|
},
|
|
"type": "class"
|
|
}
|
|
],
|
|
"sequences": [
|
|
{
|
|
"messages": [
|
|
{
|
|
"from": {
|
|
"activity_id": "227581758025403815",
|
|
"activity_name": "clanguml::t20018::tmain()",
|
|
"participant_id": "227581758025403815",
|
|
"participant_name": "clanguml::t20018::tmain()"
|
|
},
|
|
"name": "print()",
|
|
"return_type": "void",
|
|
"scope": "normal",
|
|
"source_location": {
|
|
"column": 16,
|
|
"file": "../../tests/t20018/t20018.cc",
|
|
"line": 25,
|
|
"translation_unit": "../../tests/t20018/t20018.cc"
|
|
},
|
|
"to": {
|
|
"activity_id": "1185770766239304952",
|
|
"activity_name": "clanguml::t20018::Answer<clanguml::t20018::Factorial<5>,120>::print()",
|
|
"participant_id": "1163521725351533502"
|
|
},
|
|
"type": "message"
|
|
},
|
|
{
|
|
"from": {
|
|
"activity_id": "1185770766239304952",
|
|
"activity_name": "clanguml::t20018::Answer<clanguml::t20018::Factorial<5>,120>::print()",
|
|
"participant_id": "1163521725351533502"
|
|
},
|
|
"name": "print(int)",
|
|
"return_type": "void",
|
|
"scope": "normal",
|
|
"source_location": {
|
|
"column": 27,
|
|
"file": "../../tests/t20018/t20018.cc",
|
|
"line": 22,
|
|
"translation_unit": "../../tests/t20018/t20018.cc"
|
|
},
|
|
"to": {
|
|
"activity_id": "833100888453299461",
|
|
"activity_name": "clanguml::t20018::Factorial<5>::print(int)",
|
|
"participant_id": "1482779373563849921"
|
|
},
|
|
"type": "message"
|
|
},
|
|
{
|
|
"from": {
|
|
"activity_id": "833100888453299461",
|
|
"activity_name": "clanguml::t20018::Factorial<5>::print(int)",
|
|
"participant_id": "1482779373563849921"
|
|
},
|
|
"name": "print(int)",
|
|
"return_type": "void",
|
|
"scope": "normal",
|
|
"source_location": {
|
|
"column": 37,
|
|
"file": "../../tests/t20018/t20018.cc",
|
|
"line": 9,
|
|
"translation_unit": "../../tests/t20018/t20018.cc"
|
|
},
|
|
"to": {
|
|
"activity_id": "1782586643813991247",
|
|
"activity_name": "clanguml::t20018::Factorial<4>::print(int)",
|
|
"participant_id": "52416404065514823"
|
|
},
|
|
"type": "message"
|
|
},
|
|
{
|
|
"from": {
|
|
"activity_id": "1782586643813991247",
|
|
"activity_name": "clanguml::t20018::Factorial<4>::print(int)",
|
|
"participant_id": "52416404065514823"
|
|
},
|
|
"name": "print(int)",
|
|
"return_type": "void",
|
|
"scope": "normal",
|
|
"source_location": {
|
|
"column": 37,
|
|
"file": "../../tests/t20018/t20018.cc",
|
|
"line": 9,
|
|
"translation_unit": "../../tests/t20018/t20018.cc"
|
|
},
|
|
"to": {
|
|
"activity_id": "1238078028595736678",
|
|
"activity_name": "clanguml::t20018::Factorial<3>::print(int)",
|
|
"participant_id": "1658728078296100018"
|
|
},
|
|
"type": "message"
|
|
},
|
|
{
|
|
"from": {
|
|
"activity_id": "1238078028595736678",
|
|
"activity_name": "clanguml::t20018::Factorial<3>::print(int)",
|
|
"participant_id": "1658728078296100018"
|
|
},
|
|
"name": "print(int)",
|
|
"return_type": "void",
|
|
"scope": "normal",
|
|
"source_location": {
|
|
"column": 37,
|
|
"file": "../../tests/t20018/t20018.cc",
|
|
"line": 9,
|
|
"translation_unit": "../../tests/t20018/t20018.cc"
|
|
},
|
|
"to": {
|
|
"activity_id": "2163270950475476780",
|
|
"activity_name": "clanguml::t20018::Factorial<2>::print(int)",
|
|
"participant_id": "969903469166760124"
|
|
},
|
|
"type": "message"
|
|
},
|
|
{
|
|
"from": {
|
|
"activity_id": "2163270950475476780",
|
|
"activity_name": "clanguml::t20018::Factorial<2>::print(int)",
|
|
"participant_id": "969903469166760124"
|
|
},
|
|
"name": "print(int)",
|
|
"return_type": "void",
|
|
"scope": "normal",
|
|
"source_location": {
|
|
"column": 37,
|
|
"file": "../../tests/t20018/t20018.cc",
|
|
"line": 9,
|
|
"translation_unit": "../../tests/t20018/t20018.cc"
|
|
},
|
|
"to": {
|
|
"activity_id": "501166016325937670",
|
|
"activity_name": "clanguml::t20018::Factorial<1>::print(int)",
|
|
"participant_id": "2032621198190600516"
|
|
},
|
|
"type": "message"
|
|
},
|
|
{
|
|
"from": {
|
|
"activity_id": "501166016325937670",
|
|
"activity_name": "clanguml::t20018::Factorial<1>::print(int)",
|
|
"participant_id": "2032621198190600516"
|
|
},
|
|
"name": "print(int)",
|
|
"return_type": "void",
|
|
"scope": "normal",
|
|
"source_location": {
|
|
"column": 37,
|
|
"file": "../../tests/t20018/t20018.cc",
|
|
"line": 9,
|
|
"translation_unit": "../../tests/t20018/t20018.cc"
|
|
},
|
|
"to": {
|
|
"activity_id": "577232827352391544",
|
|
"activity_name": "clanguml::t20018::Factorial<0>::print(int)",
|
|
"participant_id": "1581865799666386458"
|
|
},
|
|
"type": "message"
|
|
}
|
|
],
|
|
"start_from": {
|
|
"id": 227581758025403815,
|
|
"location": "clanguml::t20018::tmain()"
|
|
}
|
|
}
|
|
],
|
|
"using_namespace": "clanguml::t20018"
|
|
}
|
|
```
|