# t00027 - Template decorator pattern
## Config
```yaml
compilation_database_dir: ..
output_directory: puml
diagrams:
  t00027_class:
    type: class
    glob:
      - ../../tests/t00027/t00027.cc
    using_namespace:
      - clanguml::t00027
    include:
      namespaces:
        - clanguml::t00027

```
## Source code
File t00027.cc
```cpp
#include <memory>
#include <tuple>
#include <type_traits>

namespace clanguml {
namespace t00027 {

class Shape {
public:
    virtual void display() = 0;
    virtual ~Shape() = default;
};

template <template <typename> class... T>
class Line : public Shape, public T<Line<>>... {
public:
    void display() override
    {
        std::apply([](auto &&...x) { (x.display(), ...); },
            std::forward_as_tuple(T<Line<>>()...));
    }
};

template <template <typename> class... T>
class Text : public Shape, public T<Text<>>... {
public:
    void display() override
    {
        std::apply([](auto &&...x) { (x.display(), ...); },
            std::forward_as_tuple(T<Text<>>()...));
    }
};

struct ShapeDecorator {
    virtual void display() = 0;
};

template <typename T> class Color : public ShapeDecorator {
public:
    void display() override { }
};

template <typename T> class Weight : public ShapeDecorator {
public:
    void display() override { }
};

struct Window {
    Line<Color, Weight> border;
    Line<Color> divider;
    Text<Color, Weight> title;
    Text<Color> description;
};
} // namespace t00027
} // namespace clanguml

```
## Generated UML diagrams
![t00027_class](./t00027_class.svg "Template decorator pattern")
## Generated JSON models
```json
{
  "diagram_type": "class",
  "elements": [
    {
      "bases": [],
      "display_name": "clanguml::t00027::Shape",
      "id": "1593092483959332221",
      "is_abstract": true,
      "is_nested": false,
      "is_struct": false,
      "is_template": false,
      "is_union": false,
      "members": [],
      "methods": [
        {
          "access": "public",
          "is_const": false,
          "is_defaulted": false,
          "is_implicit": false,
          "is_pure_virtual": true,
          "is_static": false,
          "is_virtual": true,
          "name": "display",
          "parameters": [],
          "type": "void"
        },
        {
          "access": "public",
          "is_const": false,
          "is_defaulted": true,
          "is_implicit": false,
          "is_pure_virtual": false,
          "is_static": false,
          "is_virtual": true,
          "name": "~Shape",
          "parameters": [],
          "type": "void"
        }
      ],
      "name": "Shape",
      "namespace": "clanguml::t00027",
      "source_location": {
        "file": "../../tests/t00027/t00027.cc",
        "line": 8
      },
      "template_parameters": [],
      "type": "class"
    },
    {
      "bases": [],
      "display_name": "clanguml::t00027::Line",
      "id": "1568932879061562228",
      "is_abstract": false,
      "is_nested": false,
      "is_struct": false,
      "is_template": true,
      "is_union": false,
      "members": [],
      "methods": [],
      "name": "Line",
      "namespace": "clanguml::t00027",
      "source_location": {
        "file": "../../tests/t00027/t00027.cc",
        "line": 14
      },
      "template_parameters": [],
      "type": "class"
    },
    {
      "bases": [
        {
          "access": "public",
          "id": "1593092483959332221",
          "is_virtual": false,
          "name": "clanguml::t00027::Shape"
        },
        {
          "access": "public",
          "id": "2184609081997324211",
          "is_virtual": false,
          "name": "T<Line<>>"
        }
      ],
      "display_name": "clanguml::t00027::Line<T<>...>",
      "id": "142374082478337852",
      "is_abstract": false,
      "is_nested": false,
      "is_struct": false,
      "is_template": true,
      "is_union": false,
      "members": [],
      "methods": [
        {
          "access": "public",
          "is_const": false,
          "is_defaulted": false,
          "is_implicit": false,
          "is_pure_virtual": false,
          "is_static": false,
          "is_virtual": true,
          "name": "display",
          "parameters": [],
          "type": "void"
        }
      ],
      "name": "Line",
      "namespace": "clanguml::t00027",
      "source_location": {
        "file": "../../tests/t00027/t00027.cc",
        "line": 15
      },
      "template_parameters": [
        {
          "is_variadic": true,
          "kind": "template_template_type",
          "name": "T<>...",
          "template_parameters": []
        }
      ],
      "type": "class"
    },
    {
      "bases": [],
      "display_name": "clanguml::t00027::Text",
      "id": "1833467466291294724",
      "is_abstract": false,
      "is_nested": false,
      "is_struct": false,
      "is_template": true,
      "is_union": false,
      "members": [],
      "methods": [],
      "name": "Text",
      "namespace": "clanguml::t00027",
      "source_location": {
        "file": "../../tests/t00027/t00027.cc",
        "line": 24
      },
      "template_parameters": [],
      "type": "class"
    },
    {
      "bases": [
        {
          "access": "public",
          "id": "1593092483959332221",
          "is_virtual": false,
          "name": "clanguml::t00027::Shape"
        },
        {
          "access": "public",
          "id": "2247508827463056747",
          "is_virtual": false,
          "name": "T<Text<>>"
        }
      ],
      "display_name": "clanguml::t00027::Text<T<>...>",
      "id": "1114634647721878603",
      "is_abstract": false,
      "is_nested": false,
      "is_struct": false,
      "is_template": true,
      "is_union": false,
      "members": [],
      "methods": [
        {
          "access": "public",
          "is_const": false,
          "is_defaulted": false,
          "is_implicit": false,
          "is_pure_virtual": false,
          "is_static": false,
          "is_virtual": true,
          "name": "display",
          "parameters": [],
          "type": "void"
        }
      ],
      "name": "Text",
      "namespace": "clanguml::t00027",
      "source_location": {
        "file": "../../tests/t00027/t00027.cc",
        "line": 25
      },
      "template_parameters": [
        {
          "is_variadic": true,
          "kind": "template_template_type",
          "name": "T<>...",
          "template_parameters": []
        }
      ],
      "type": "class"
    },
    {
      "bases": [],
      "display_name": "clanguml::t00027::ShapeDecorator",
      "id": "2049188825706164566",
      "is_abstract": true,
      "is_nested": false,
      "is_struct": true,
      "is_template": false,
      "is_union": false,
      "members": [],
      "methods": [
        {
          "access": "public",
          "is_const": false,
          "is_defaulted": false,
          "is_implicit": false,
          "is_pure_virtual": true,
          "is_static": false,
          "is_virtual": true,
          "name": "display",
          "parameters": [],
          "type": "void"
        }
      ],
      "name": "ShapeDecorator",
      "namespace": "clanguml::t00027",
      "source_location": {
        "file": "../../tests/t00027/t00027.cc",
        "line": 34
      },
      "template_parameters": [],
      "type": "class"
    },
    {
      "bases": [
        {
          "access": "public",
          "id": "2049188825706164566",
          "is_virtual": false,
          "name": "clanguml::t00027::ShapeDecorator"
        }
      ],
      "display_name": "clanguml::t00027::Color<T>",
      "id": "1473536569433029444",
      "is_abstract": false,
      "is_nested": false,
      "is_struct": false,
      "is_template": true,
      "is_union": false,
      "members": [],
      "methods": [
        {
          "access": "public",
          "is_const": false,
          "is_defaulted": false,
          "is_implicit": false,
          "is_pure_virtual": false,
          "is_static": false,
          "is_virtual": true,
          "name": "display",
          "parameters": [],
          "type": "void"
        }
      ],
      "name": "Color",
      "namespace": "clanguml::t00027",
      "source_location": {
        "file": "../../tests/t00027/t00027.cc",
        "line": 38
      },
      "template_parameters": [
        {
          "is_variadic": false,
          "kind": "template_type",
          "name": "T",
          "template_parameters": []
        }
      ],
      "type": "class"
    },
    {
      "bases": [
        {
          "access": "public",
          "id": "2049188825706164566",
          "is_virtual": false,
          "name": "clanguml::t00027::ShapeDecorator"
        }
      ],
      "display_name": "clanguml::t00027::Weight<T>",
      "id": "2049455532387561338",
      "is_abstract": false,
      "is_nested": false,
      "is_struct": false,
      "is_template": true,
      "is_union": false,
      "members": [],
      "methods": [
        {
          "access": "public",
          "is_const": false,
          "is_defaulted": false,
          "is_implicit": false,
          "is_pure_virtual": false,
          "is_static": false,
          "is_virtual": true,
          "name": "display",
          "parameters": [],
          "type": "void"
        }
      ],
      "name": "Weight",
      "namespace": "clanguml::t00027",
      "source_location": {
        "file": "../../tests/t00027/t00027.cc",
        "line": 43
      },
      "template_parameters": [
        {
          "is_variadic": false,
          "kind": "template_type",
          "name": "T",
          "template_parameters": []
        }
      ],
      "type": "class"
    },
    {
      "bases": [],
      "display_name": "clanguml::t00027::Line<clanguml::t00027::Color,clanguml::t00027::Weight>",
      "id": "2082936326417164202",
      "is_abstract": false,
      "is_nested": false,
      "is_struct": false,
      "is_template": true,
      "is_union": false,
      "members": [],
      "methods": [],
      "name": "Line",
      "namespace": "clanguml::t00027",
      "source_location": {
        "file": "../../tests/t00027/t00027.cc",
        "line": 15
      },
      "template_parameters": [
        {
          "is_variadic": false,
          "kind": "template_type",
          "name": "clanguml::t00027::Color",
          "template_parameters": []
        },
        {
          "is_variadic": false,
          "kind": "template_type",
          "name": "clanguml::t00027::Weight",
          "template_parameters": []
        }
      ],
      "type": "class"
    },
    {
      "bases": [],
      "display_name": "clanguml::t00027::Line<clanguml::t00027::Color>",
      "id": "675132943535054947",
      "is_abstract": false,
      "is_nested": false,
      "is_struct": false,
      "is_template": true,
      "is_union": false,
      "members": [],
      "methods": [],
      "name": "Line",
      "namespace": "clanguml::t00027",
      "source_location": {
        "file": "../../tests/t00027/t00027.cc",
        "line": 15
      },
      "template_parameters": [
        {
          "is_variadic": false,
          "kind": "template_type",
          "name": "clanguml::t00027::Color",
          "template_parameters": []
        }
      ],
      "type": "class"
    },
    {
      "bases": [],
      "display_name": "clanguml::t00027::Text<clanguml::t00027::Color,clanguml::t00027::Weight>",
      "id": "1678874302644303776",
      "is_abstract": false,
      "is_nested": false,
      "is_struct": false,
      "is_template": true,
      "is_union": false,
      "members": [],
      "methods": [],
      "name": "Text",
      "namespace": "clanguml::t00027",
      "source_location": {
        "file": "../../tests/t00027/t00027.cc",
        "line": 25
      },
      "template_parameters": [
        {
          "is_variadic": false,
          "kind": "template_type",
          "name": "clanguml::t00027::Color",
          "template_parameters": []
        },
        {
          "is_variadic": false,
          "kind": "template_type",
          "name": "clanguml::t00027::Weight",
          "template_parameters": []
        }
      ],
      "type": "class"
    },
    {
      "bases": [],
      "display_name": "clanguml::t00027::Text<clanguml::t00027::Color>",
      "id": "1887786688778664182",
      "is_abstract": false,
      "is_nested": false,
      "is_struct": false,
      "is_template": true,
      "is_union": false,
      "members": [],
      "methods": [],
      "name": "Text",
      "namespace": "clanguml::t00027",
      "source_location": {
        "file": "../../tests/t00027/t00027.cc",
        "line": 25
      },
      "template_parameters": [
        {
          "is_variadic": false,
          "kind": "template_type",
          "name": "clanguml::t00027::Color",
          "template_parameters": []
        }
      ],
      "type": "class"
    },
    {
      "bases": [],
      "display_name": "clanguml::t00027::Window",
      "id": "1373544984027721472",
      "is_abstract": false,
      "is_nested": false,
      "is_struct": true,
      "is_template": false,
      "is_union": false,
      "members": [
        {
          "access": "public",
          "is_static": false,
          "name": "border",
          "source_location": {
            "file": "../../tests/t00027/t00027.cc",
            "line": 49
          },
          "type": "Line<clanguml::t00027::Color,clanguml::t00027::Weight>"
        },
        {
          "access": "public",
          "is_static": false,
          "name": "divider",
          "source_location": {
            "file": "../../tests/t00027/t00027.cc",
            "line": 50
          },
          "type": "Line<clanguml::t00027::Color>"
        },
        {
          "access": "public",
          "is_static": false,
          "name": "title",
          "source_location": {
            "file": "../../tests/t00027/t00027.cc",
            "line": 51
          },
          "type": "Text<clanguml::t00027::Color,clanguml::t00027::Weight>"
        },
        {
          "access": "public",
          "is_static": false,
          "name": "description",
          "source_location": {
            "file": "../../tests/t00027/t00027.cc",
            "line": 52
          },
          "type": "Text<clanguml::t00027::Color>"
        }
      ],
      "methods": [],
      "name": "Window",
      "namespace": "clanguml::t00027",
      "source_location": {
        "file": "../../tests/t00027/t00027.cc",
        "line": 48
      },
      "template_parameters": [],
      "type": "class"
    }
  ],
  "metadata": {
    "clang_uml_version": "0.3.5-27-g81c7ce7",
    "llvm_version": "Ubuntu clang version 15.0.6",
    "schema_version": 1
  },
  "name": "t00027_class",
  "relationships": [
    {
      "access": "public",
      "destination": "1593092483959332221",
      "source": "142374082478337852",
      "type": "extension"
    },
    {
      "access": "public",
      "destination": "2184609081997324211",
      "source": "142374082478337852",
      "type": "extension"
    },
    {
      "access": "public",
      "destination": "1593092483959332221",
      "source": "1114634647721878603",
      "type": "extension"
    },
    {
      "access": "public",
      "destination": "2247508827463056747",
      "source": "1114634647721878603",
      "type": "extension"
    },
    {
      "access": "public",
      "destination": "2049188825706164566",
      "source": "1473536569433029444",
      "type": "extension"
    },
    {
      "access": "public",
      "destination": "2049188825706164566",
      "source": "2049455532387561338",
      "type": "extension"
    },
    {
      "access": "public",
      "destination": "142374082478337852",
      "source": "2082936326417164202",
      "type": "instantiation"
    },
    {
      "access": "public",
      "destination": "142374082478337852",
      "source": "675132943535054947",
      "type": "instantiation"
    },
    {
      "access": "public",
      "destination": "1114634647721878603",
      "source": "1678874302644303776",
      "type": "instantiation"
    },
    {
      "access": "public",
      "destination": "1114634647721878603",
      "source": "1887786688778664182",
      "type": "instantiation"
    },
    {
      "access": "public",
      "destination": "2082936326417164202",
      "label": "border",
      "source": "1373544984027721472",
      "type": "aggregation"
    },
    {
      "access": "public",
      "destination": "675132943535054947",
      "label": "divider",
      "source": "1373544984027721472",
      "type": "aggregation"
    },
    {
      "access": "public",
      "destination": "1678874302644303776",
      "label": "title",
      "source": "1373544984027721472",
      "type": "aggregation"
    },
    {
      "access": "public",
      "destination": "1887786688778664182",
      "label": "description",
      "source": "1373544984027721472",
      "type": "aggregation"
    }
  ],
  "using_namespace": "clanguml::t00027"
}
```
