563 lines
14 KiB
Markdown
563 lines
14 KiB
Markdown
# t00059 - Non-virtual abstract factory pattern using concepts test case
|
|
## Config
|
|
```yaml
|
|
compilation_database_dir: ..
|
|
output_directory: puml
|
|
diagrams:
|
|
t00059_class:
|
|
type: class
|
|
glob:
|
|
- ../../tests/t00059/t00059.cc
|
|
include:
|
|
namespaces:
|
|
- clanguml::t00059
|
|
using_namespace:
|
|
- clanguml::t00059
|
|
```
|
|
## Source code
|
|
File t00059.cc
|
|
```cpp
|
|
#include <string>
|
|
|
|
namespace clanguml {
|
|
namespace t00059 {
|
|
|
|
template <typename T>
|
|
concept fruit_c = requires(T t) {
|
|
T{};
|
|
t.get_name();
|
|
};
|
|
|
|
template <typename T>
|
|
concept apple_c = fruit_c<T> && requires(T t) { t.get_sweetness(); };
|
|
|
|
template <typename T>
|
|
concept orange_c = fruit_c<T> && requires(T t) { t.get_bitterness(); };
|
|
|
|
class gala_apple {
|
|
public:
|
|
auto get_name() const -> std::string { return "gala"; }
|
|
auto get_sweetness() const -> float { return 0.8; }
|
|
};
|
|
|
|
class empire_apple {
|
|
public:
|
|
auto get_name() const -> std::string { return "empire"; }
|
|
auto get_sweetness() const -> float { return 0.6; }
|
|
};
|
|
|
|
class lima_orange {
|
|
public:
|
|
auto get_name() const -> std::string { return "lima"; }
|
|
auto get_bitterness() const -> float { return 0.8; }
|
|
};
|
|
|
|
class valencia_orange {
|
|
public:
|
|
auto get_name() const -> std::string { return "valencia"; }
|
|
auto get_bitterness() const -> float { return 0.6; }
|
|
};
|
|
|
|
template <apple_c TA, orange_c TO> class fruit_factory {
|
|
public:
|
|
auto create_apple() const -> TA { return TA{}; }
|
|
auto create_orange() const -> TO { return TO{}; }
|
|
};
|
|
|
|
using fruit_factory_1 = fruit_factory<gala_apple, valencia_orange>;
|
|
using fruit_factory_2 = fruit_factory<empire_apple, lima_orange>;
|
|
|
|
struct R {
|
|
fruit_factory_1 factory_1;
|
|
fruit_factory_2 factory_2;
|
|
};
|
|
}
|
|
}
|
|
```
|
|
## Generated UML diagrams
|
|

|
|
## Generated JSON models
|
|
```json
|
|
{
|
|
"diagram_type": "class",
|
|
"elements": [
|
|
{
|
|
"display_name": "clanguml::t00059::fruit_c<T>",
|
|
"id": "1926201868069460340",
|
|
"name": "fruit_c",
|
|
"namespace": "clanguml::t00059",
|
|
"parameters": [
|
|
{
|
|
"name": "clanguml::t00059::t",
|
|
"type": "T"
|
|
}
|
|
],
|
|
"source_location": {
|
|
"file": "../../tests/t00059/t00059.cc",
|
|
"line": 7
|
|
},
|
|
"statements": [
|
|
"T{}",
|
|
"t.get_name()"
|
|
],
|
|
"type": "concept"
|
|
},
|
|
{
|
|
"display_name": "clanguml::t00059::apple_c<T>",
|
|
"id": "1932582371736186409",
|
|
"name": "apple_c",
|
|
"namespace": "clanguml::t00059",
|
|
"parameters": [
|
|
{
|
|
"name": "clanguml::t00059::t",
|
|
"type": "T"
|
|
}
|
|
],
|
|
"source_location": {
|
|
"file": "../../tests/t00059/t00059.cc",
|
|
"line": 13
|
|
},
|
|
"statements": [
|
|
"t.get_sweetness()"
|
|
],
|
|
"type": "concept"
|
|
},
|
|
{
|
|
"display_name": "clanguml::t00059::orange_c<T>",
|
|
"id": "1483904441065806133",
|
|
"name": "orange_c",
|
|
"namespace": "clanguml::t00059",
|
|
"parameters": [
|
|
{
|
|
"name": "clanguml::t00059::t",
|
|
"type": "T"
|
|
}
|
|
],
|
|
"source_location": {
|
|
"file": "../../tests/t00059/t00059.cc",
|
|
"line": 16
|
|
},
|
|
"statements": [
|
|
"t.get_bitterness()"
|
|
],
|
|
"type": "concept"
|
|
},
|
|
{
|
|
"bases": [],
|
|
"display_name": "clanguml::t00059::gala_apple",
|
|
"id": "399997161214328320",
|
|
"is_abstract": false,
|
|
"is_nested": false,
|
|
"is_struct": false,
|
|
"is_template": false,
|
|
"is_union": false,
|
|
"members": [],
|
|
"methods": [
|
|
{
|
|
"access": "public",
|
|
"is_const": true,
|
|
"is_defaulted": false,
|
|
"is_implicit": false,
|
|
"is_pure_virtual": false,
|
|
"is_static": false,
|
|
"is_virtual": false,
|
|
"name": "get_name",
|
|
"parameters": [],
|
|
"type": "std::string"
|
|
},
|
|
{
|
|
"access": "public",
|
|
"is_const": true,
|
|
"is_defaulted": false,
|
|
"is_implicit": false,
|
|
"is_pure_virtual": false,
|
|
"is_static": false,
|
|
"is_virtual": false,
|
|
"name": "get_sweetness",
|
|
"parameters": [],
|
|
"type": "float"
|
|
}
|
|
],
|
|
"name": "gala_apple",
|
|
"namespace": "clanguml::t00059",
|
|
"source_location": {
|
|
"file": "../../tests/t00059/t00059.cc",
|
|
"line": 18
|
|
},
|
|
"template_parameters": [],
|
|
"type": "class"
|
|
},
|
|
{
|
|
"bases": [],
|
|
"display_name": "clanguml::t00059::empire_apple",
|
|
"id": "660406972347773654",
|
|
"is_abstract": false,
|
|
"is_nested": false,
|
|
"is_struct": false,
|
|
"is_template": false,
|
|
"is_union": false,
|
|
"members": [],
|
|
"methods": [
|
|
{
|
|
"access": "public",
|
|
"is_const": true,
|
|
"is_defaulted": false,
|
|
"is_implicit": false,
|
|
"is_pure_virtual": false,
|
|
"is_static": false,
|
|
"is_virtual": false,
|
|
"name": "get_name",
|
|
"parameters": [],
|
|
"type": "std::string"
|
|
},
|
|
{
|
|
"access": "public",
|
|
"is_const": true,
|
|
"is_defaulted": false,
|
|
"is_implicit": false,
|
|
"is_pure_virtual": false,
|
|
"is_static": false,
|
|
"is_virtual": false,
|
|
"name": "get_sweetness",
|
|
"parameters": [],
|
|
"type": "float"
|
|
}
|
|
],
|
|
"name": "empire_apple",
|
|
"namespace": "clanguml::t00059",
|
|
"source_location": {
|
|
"file": "../../tests/t00059/t00059.cc",
|
|
"line": 24
|
|
},
|
|
"template_parameters": [],
|
|
"type": "class"
|
|
},
|
|
{
|
|
"bases": [],
|
|
"display_name": "clanguml::t00059::lima_orange",
|
|
"id": "1649295452510454080",
|
|
"is_abstract": false,
|
|
"is_nested": false,
|
|
"is_struct": false,
|
|
"is_template": false,
|
|
"is_union": false,
|
|
"members": [],
|
|
"methods": [
|
|
{
|
|
"access": "public",
|
|
"is_const": true,
|
|
"is_defaulted": false,
|
|
"is_implicit": false,
|
|
"is_pure_virtual": false,
|
|
"is_static": false,
|
|
"is_virtual": false,
|
|
"name": "get_name",
|
|
"parameters": [],
|
|
"type": "std::string"
|
|
},
|
|
{
|
|
"access": "public",
|
|
"is_const": true,
|
|
"is_defaulted": false,
|
|
"is_implicit": false,
|
|
"is_pure_virtual": false,
|
|
"is_static": false,
|
|
"is_virtual": false,
|
|
"name": "get_bitterness",
|
|
"parameters": [],
|
|
"type": "float"
|
|
}
|
|
],
|
|
"name": "lima_orange",
|
|
"namespace": "clanguml::t00059",
|
|
"source_location": {
|
|
"file": "../../tests/t00059/t00059.cc",
|
|
"line": 30
|
|
},
|
|
"template_parameters": [],
|
|
"type": "class"
|
|
},
|
|
{
|
|
"bases": [],
|
|
"display_name": "clanguml::t00059::valencia_orange",
|
|
"id": "802727760415733923",
|
|
"is_abstract": false,
|
|
"is_nested": false,
|
|
"is_struct": false,
|
|
"is_template": false,
|
|
"is_union": false,
|
|
"members": [],
|
|
"methods": [
|
|
{
|
|
"access": "public",
|
|
"is_const": true,
|
|
"is_defaulted": false,
|
|
"is_implicit": false,
|
|
"is_pure_virtual": false,
|
|
"is_static": false,
|
|
"is_virtual": false,
|
|
"name": "get_name",
|
|
"parameters": [],
|
|
"type": "std::string"
|
|
},
|
|
{
|
|
"access": "public",
|
|
"is_const": true,
|
|
"is_defaulted": false,
|
|
"is_implicit": false,
|
|
"is_pure_virtual": false,
|
|
"is_static": false,
|
|
"is_virtual": false,
|
|
"name": "get_bitterness",
|
|
"parameters": [],
|
|
"type": "float"
|
|
}
|
|
],
|
|
"name": "valencia_orange",
|
|
"namespace": "clanguml::t00059",
|
|
"source_location": {
|
|
"file": "../../tests/t00059/t00059.cc",
|
|
"line": 36
|
|
},
|
|
"template_parameters": [],
|
|
"type": "class"
|
|
},
|
|
{
|
|
"bases": [],
|
|
"display_name": "clanguml::t00059::fruit_factory<clanguml::t00059::apple_c TA,clanguml::t00059::orange_c TO>",
|
|
"id": "2301786483822933456",
|
|
"is_abstract": false,
|
|
"is_nested": false,
|
|
"is_struct": false,
|
|
"is_template": true,
|
|
"is_union": false,
|
|
"members": [],
|
|
"methods": [
|
|
{
|
|
"access": "public",
|
|
"is_const": true,
|
|
"is_defaulted": false,
|
|
"is_implicit": false,
|
|
"is_pure_virtual": false,
|
|
"is_static": false,
|
|
"is_virtual": false,
|
|
"name": "create_apple",
|
|
"parameters": [],
|
|
"type": "TA"
|
|
},
|
|
{
|
|
"access": "public",
|
|
"is_const": true,
|
|
"is_defaulted": false,
|
|
"is_implicit": false,
|
|
"is_pure_virtual": false,
|
|
"is_static": false,
|
|
"is_virtual": false,
|
|
"name": "create_orange",
|
|
"parameters": [],
|
|
"type": "TO"
|
|
}
|
|
],
|
|
"name": "fruit_factory",
|
|
"namespace": "clanguml::t00059",
|
|
"source_location": {
|
|
"file": "../../tests/t00059/t00059.cc",
|
|
"line": 42
|
|
},
|
|
"template_parameters": [
|
|
{
|
|
"is_variadic": false,
|
|
"kind": "template_type",
|
|
"name": "TA",
|
|
"template_parameters": []
|
|
},
|
|
{
|
|
"is_variadic": false,
|
|
"kind": "template_type",
|
|
"name": "TO",
|
|
"template_parameters": []
|
|
}
|
|
],
|
|
"type": "class"
|
|
},
|
|
{
|
|
"bases": [],
|
|
"display_name": "clanguml::t00059::fruit_factory<clanguml::t00059::gala_apple,clanguml::t00059::valencia_orange>",
|
|
"id": "551278102444647278",
|
|
"is_abstract": false,
|
|
"is_nested": false,
|
|
"is_struct": false,
|
|
"is_template": true,
|
|
"is_union": false,
|
|
"members": [],
|
|
"methods": [],
|
|
"name": "fruit_factory",
|
|
"namespace": "clanguml::t00059",
|
|
"template_parameters": [
|
|
{
|
|
"is_variadic": false,
|
|
"kind": "argument",
|
|
"template_parameters": [],
|
|
"type": "clanguml::t00059::gala_apple"
|
|
},
|
|
{
|
|
"is_variadic": false,
|
|
"kind": "argument",
|
|
"template_parameters": [],
|
|
"type": "clanguml::t00059::valencia_orange"
|
|
}
|
|
],
|
|
"type": "class"
|
|
},
|
|
{
|
|
"bases": [],
|
|
"display_name": "clanguml::t00059::fruit_factory<clanguml::t00059::empire_apple,clanguml::t00059::lima_orange>",
|
|
"id": "536390279563541226",
|
|
"is_abstract": false,
|
|
"is_nested": false,
|
|
"is_struct": false,
|
|
"is_template": true,
|
|
"is_union": false,
|
|
"members": [],
|
|
"methods": [],
|
|
"name": "fruit_factory",
|
|
"namespace": "clanguml::t00059",
|
|
"template_parameters": [
|
|
{
|
|
"is_variadic": false,
|
|
"kind": "argument",
|
|
"template_parameters": [],
|
|
"type": "clanguml::t00059::empire_apple"
|
|
},
|
|
{
|
|
"is_variadic": false,
|
|
"kind": "argument",
|
|
"template_parameters": [],
|
|
"type": "clanguml::t00059::lima_orange"
|
|
}
|
|
],
|
|
"type": "class"
|
|
},
|
|
{
|
|
"bases": [],
|
|
"display_name": "clanguml::t00059::R",
|
|
"id": "1128300671453354325",
|
|
"is_abstract": false,
|
|
"is_nested": false,
|
|
"is_struct": true,
|
|
"is_template": false,
|
|
"is_union": false,
|
|
"members": [
|
|
{
|
|
"access": "public",
|
|
"is_static": false,
|
|
"name": "factory_1",
|
|
"source_location": {
|
|
"file": "../../tests/t00059/t00059.cc",
|
|
"line": 52
|
|
},
|
|
"type": "clanguml::t00059::fruit_factory_1"
|
|
},
|
|
{
|
|
"access": "public",
|
|
"is_static": false,
|
|
"name": "factory_2",
|
|
"source_location": {
|
|
"file": "../../tests/t00059/t00059.cc",
|
|
"line": 53
|
|
},
|
|
"type": "clanguml::t00059::fruit_factory_2"
|
|
}
|
|
],
|
|
"methods": [],
|
|
"name": "R",
|
|
"namespace": "clanguml::t00059",
|
|
"source_location": {
|
|
"file": "../../tests/t00059/t00059.cc",
|
|
"line": 51
|
|
},
|
|
"template_parameters": [],
|
|
"type": "class"
|
|
}
|
|
],
|
|
"name": "t00059_class",
|
|
"relationships": [
|
|
{
|
|
"destination": "1926201868069460340",
|
|
"label": "T",
|
|
"source": "1932582371736186409",
|
|
"type": "constraint"
|
|
},
|
|
{
|
|
"destination": "1926201868069460340",
|
|
"label": "T",
|
|
"source": "1483904441065806133",
|
|
"type": "constraint"
|
|
},
|
|
{
|
|
"destination": "1932582371736186409",
|
|
"label": "TA",
|
|
"source": "2301786483822933456",
|
|
"type": "constraint"
|
|
},
|
|
{
|
|
"destination": "1483904441065806133",
|
|
"label": "TO",
|
|
"source": "2301786483822933456",
|
|
"type": "constraint"
|
|
},
|
|
{
|
|
"access": "public",
|
|
"destination": "399997161214328320",
|
|
"source": "551278102444647278",
|
|
"type": "dependency"
|
|
},
|
|
{
|
|
"access": "public",
|
|
"destination": "802727760415733923",
|
|
"source": "551278102444647278",
|
|
"type": "dependency"
|
|
},
|
|
{
|
|
"access": "public",
|
|
"destination": "2301786483822933456",
|
|
"source": "551278102444647278",
|
|
"type": "instantiation"
|
|
},
|
|
{
|
|
"access": "public",
|
|
"destination": "660406972347773654",
|
|
"source": "536390279563541226",
|
|
"type": "dependency"
|
|
},
|
|
{
|
|
"access": "public",
|
|
"destination": "1649295452510454080",
|
|
"source": "536390279563541226",
|
|
"type": "dependency"
|
|
},
|
|
{
|
|
"access": "public",
|
|
"destination": "2301786483822933456",
|
|
"source": "536390279563541226",
|
|
"type": "instantiation"
|
|
},
|
|
{
|
|
"access": "public",
|
|
"destination": "551278102444647278",
|
|
"label": "factory_1",
|
|
"source": "1128300671453354325",
|
|
"type": "aggregation"
|
|
},
|
|
{
|
|
"access": "public",
|
|
"destination": "536390279563541226",
|
|
"label": "factory_2",
|
|
"source": "1128300671453354325",
|
|
"type": "aggregation"
|
|
}
|
|
],
|
|
"using_namespace": "clanguml::t00059"
|
|
}
|
|
```
|