12 KiB
12 KiB
t20024 - Switch statement sequence diagram test case
Config
compilation_database_dir: ..
output_directory: puml
diagrams:
t20024_sequence:
type: sequence
glob:
- ../../tests/t20024/t20024.cc
include:
namespaces:
- clanguml::t20024
using_namespace:
- clanguml::t20024
start_from:
- function: "clanguml::t20024::tmain()"
Source code
File t20024.cc
namespace clanguml {
namespace t20024 {
enum enum_a { zero = 0, one = 1, two = 2, three = 3 };
enum class colors { red, orange, green };
struct A {
int select(enum_a v)
{
switch (v) {
case zero:
return a0();
case one:
return a1();
case two:
return a2();
default:
return a3();
}
}
int a0() { return 0; }
int a1() { return 1; }
int a2() { return 2; }
int a3() { return 3; }
};
struct B {
void select(colors c)
{
switch (c) {
case colors::red:
red();
break;
case colors::orange:
orange();
break;
case colors::green:
green();
break;
default:
grey();
}
}
void red() { }
void orange() { }
void green() { }
void grey() { }
};
int tmain()
{
A a;
B b;
a.select(enum_a::two);
b.select(colors::green);
return 0;
}
}
}
Generated UML diagrams
Generated JSON models
{
"diagram_type": "sequence",
"metadata": {
"clang_uml_version": "0.3.6-11-g75d1daa",
"llvm_version": "Ubuntu clang version 15.0.6",
"schema_version": 1
},
"name": "t20024_sequence",
"participants": [
{
"id": "1919714441225983014",
"name": "clanguml::t20024::tmain()",
"source_location": {
"file": "../../tests/t20024/t20024.cc",
"line": 53
},
"type": "function"
},
{
"id": "40786919835708828",
"name": "clanguml::t20024::A",
"source_location": {
"file": "../../tests/t20024/t20024.cc",
"line": 8
},
"type": "class"
},
{
"id": "933287014626440872",
"name": "clanguml::t20024::B",
"source_location": {
"file": "../../tests/t20024/t20024.cc",
"line": 29
},
"type": "class"
}
],
"sequences": [
{
"messages": [
{
"from": {
"activity_id": "1919714441225983014",
"activity_name": "clanguml::t20024::tmain()",
"participant_id": "1919714441225983014",
"participant_name": "clanguml::t20024::tmain()"
},
"name": "select(enum_a)",
"return_type": "int",
"scope": "normal",
"source_location": {
"file": "../../tests/t20024/t20024.cc",
"line": 58
},
"to": {
"activity_id": "1200587047701031901",
"activity_name": "clanguml::t20024::A::select(enum_a)",
"participant_id": "40786919835708828"
},
"type": "message"
},
{
"activity_id": "1200587047701031901",
"branches": [
{
"messages": [
{
"from": {
"activity_id": "1200587047701031901",
"activity_name": "clanguml::t20024::A::select(enum_a)",
"participant_id": "40786919835708828"
},
"name": "a0()",
"return_type": "int",
"scope": "normal",
"source_location": {
"file": "../../tests/t20024/t20024.cc",
"line": 13
},
"to": {
"activity_id": "1859614580641799156",
"activity_name": "clanguml::t20024::A::a0()",
"participant_id": "40786919835708828"
},
"type": "message"
}
],
"name": "zero",
"type": "case"
},
{
"messages": [
{
"from": {
"activity_id": "1200587047701031901",
"activity_name": "clanguml::t20024::A::select(enum_a)",
"participant_id": "40786919835708828"
},
"name": "a1()",
"return_type": "int",
"scope": "normal",
"source_location": {
"file": "../../tests/t20024/t20024.cc",
"line": 15
},
"to": {
"activity_id": "501598940454911460",
"activity_name": "clanguml::t20024::A::a1()",
"participant_id": "40786919835708828"
},
"type": "message"
}
],
"name": "one",
"type": "case"
},
{
"messages": [
{
"from": {
"activity_id": "1200587047701031901",
"activity_name": "clanguml::t20024::A::select(enum_a)",
"participant_id": "40786919835708828"
},
"name": "a2()",
"return_type": "int",
"scope": "normal",
"source_location": {
"file": "../../tests/t20024/t20024.cc",
"line": 17
},
"to": {
"activity_id": "1698866541173753340",
"activity_name": "clanguml::t20024::A::a2()",
"participant_id": "40786919835708828"
},
"type": "message"
}
],
"name": "two",
"type": "case"
},
{
"messages": [
{
"from": {
"activity_id": "1200587047701031901",
"activity_name": "clanguml::t20024::A::select(enum_a)",
"participant_id": "40786919835708828"
},
"name": "a3()",
"return_type": "int",
"scope": "normal",
"source_location": {
"file": "../../tests/t20024/t20024.cc",
"line": 19
},
"to": {
"activity_id": "490376438551958259",
"activity_name": "clanguml::t20024::A::a3()",
"participant_id": "40786919835708828"
},
"type": "message"
}
],
"name": "default",
"type": "case"
}
],
"name": "switch",
"type": "alt"
},
{
"from": {
"activity_id": "1919714441225983014",
"activity_name": "clanguml::t20024::tmain()",
"participant_id": "1919714441225983014",
"participant_name": "clanguml::t20024::tmain()"
},
"name": "select(colors)",
"return_type": "void",
"scope": "normal",
"source_location": {
"file": "../../tests/t20024/t20024.cc",
"line": 60
},
"to": {
"activity_id": "286108218156977422",
"activity_name": "clanguml::t20024::B::select(colors)",
"participant_id": "933287014626440872"
},
"type": "message"
},
{
"activity_id": "286108218156977422",
"branches": [
{
"messages": [
{
"from": {
"activity_id": "286108218156977422",
"activity_name": "clanguml::t20024::B::select(colors)",
"participant_id": "933287014626440872"
},
"name": "red()",
"return_type": "void",
"scope": "normal",
"source_location": {
"file": "../../tests/t20024/t20024.cc",
"line": 34
},
"to": {
"activity_id": "112014563206084467",
"activity_name": "clanguml::t20024::B::red()",
"participant_id": "933287014626440872"
},
"type": "message"
}
],
"name": "enum colors::red",
"type": "case"
},
{
"messages": [
{
"from": {
"activity_id": "286108218156977422",
"activity_name": "clanguml::t20024::B::select(colors)",
"participant_id": "933287014626440872"
},
"name": "orange()",
"return_type": "void",
"scope": "normal",
"source_location": {
"file": "../../tests/t20024/t20024.cc",
"line": 37
},
"to": {
"activity_id": "2222823236498505185",
"activity_name": "clanguml::t20024::B::orange()",
"participant_id": "933287014626440872"
},
"type": "message"
}
],
"name": "enum colors::orange",
"type": "case"
},
{
"messages": [
{
"from": {
"activity_id": "286108218156977422",
"activity_name": "clanguml::t20024::B::select(colors)",
"participant_id": "933287014626440872"
},
"name": "green()",
"return_type": "void",
"scope": "normal",
"source_location": {
"file": "../../tests/t20024/t20024.cc",
"line": 40
},
"to": {
"activity_id": "519021723720658376",
"activity_name": "clanguml::t20024::B::green()",
"participant_id": "933287014626440872"
},
"type": "message"
}
],
"name": "enum colors::green",
"type": "case"
},
{
"messages": [
{
"from": {
"activity_id": "286108218156977422",
"activity_name": "clanguml::t20024::B::select(colors)",
"participant_id": "933287014626440872"
},
"name": "grey()",
"return_type": "void",
"scope": "normal",
"source_location": {
"file": "../../tests/t20024/t20024.cc",
"line": 43
},
"to": {
"activity_id": "1813557671878544737",
"activity_name": "clanguml::t20024::B::grey()",
"participant_id": "933287014626440872"
},
"type": "message"
}
],
"name": "default",
"type": "case"
}
],
"name": "switch",
"type": "alt"
}
],
"start_from": {
"id": 1919714441225983014,
"location": "clanguml::t20024::tmain()"
}
}
],
"using_namespace": "clanguml::t20024"
}