# t00019 - Layercake pattern
## Config
```yaml
compilation_database_dir: ..
output_directory: puml
diagrams:
  t00019_class:
    type: class
    glob:
      - ../../tests/t00019/**.cc
    using_namespace:
      - clanguml::t00019
    include:
      namespaces:
        - clanguml::t00019

```
## Source code
File t00019_layer1.h
```cpp
#pragma once

#include <iostream>
#include <string>

namespace clanguml {
namespace t00019 {

template <typename LowerLayer> class Layer1 : public LowerLayer {

    using LowerLayer::LowerLayer;

    int m1() override
    {
        std::cout << "m1 called\n";
        return LowerLayer::m1();
    }

    std::string m2() override
    {
        std::cout << "m2 called\n";
        return LowerLayer::m2();
    }
};
}
}

```
File t00019.cc
```cpp
#include "t00019_base.h"
#include "t00019_layer1.h"
#include "t00019_layer2.h"
#include "t00019_layer3.h"

#include <memory>

namespace clanguml {
namespace t00019 {

class A {
public:
    std::unique_ptr<Layer1<Layer2<Layer3<Base>>>> layers;
};
}
}

```
File t00019_layer2.h
```cpp
#pragma once

namespace clanguml {
namespace t00019 {

template <typename LowerLayer> class Layer2 : public LowerLayer {

    using LowerLayer::LowerLayer;

    using LowerLayer::m1;

    using LowerLayer::m2;

    int all_calls_count() const
    {
        return LowerLayer::m1_calls() + LowerLayer::m2_calls();
    }
};
}
}

```
File t00019_layer3.h
```cpp
#pragma once

#include <string>

namespace clanguml {
namespace t00019 {

template <typename LowerLayer> class Layer3 : public LowerLayer {

    using LowerLayer::LowerLayer;

    virtual int m1() override
    {
        m_m1_calls++;
        return LowerLayer::m1();
    }

    virtual std::string m2() override
    {
        m_m2_calls++;
        return LowerLayer::m2();
    }

    int m1_calls() const { return m_m1_calls; }

    int m2_calls() const { return m_m2_calls; }

private:
    int m_m1_calls{};
    int m_m2_calls{};
};
}
}

```
File t00019_base.h
```cpp
#pragma once

#include <string>

namespace clanguml {
namespace t00019 {

class Base {

    Base() = default;

    virtual ~Base() = default;

    virtual int m1() { return 2; }

    virtual std::string m2() { return "two"; }
};
}
}

```
## Generated UML diagrams
![t00019_class](./t00019_class.svg "Layercake pattern")
## Generated JSON models
```json
{
  "diagram_type": "class",
  "elements": [
    {
      "bases": [],
      "display_name": "clanguml::t00019::Base",
      "id": "261668487476634123",
      "is_abstract": false,
      "is_nested": false,
      "is_struct": false,
      "is_template": false,
      "is_union": false,
      "members": [],
      "methods": [
        {
          "access": "private",
          "is_const": false,
          "is_defaulted": true,
          "is_implicit": false,
          "is_pure_virtual": false,
          "is_static": false,
          "is_virtual": false,
          "name": "Base",
          "parameters": [],
          "type": "void"
        },
        {
          "access": "private",
          "is_const": false,
          "is_defaulted": true,
          "is_implicit": false,
          "is_pure_virtual": false,
          "is_static": false,
          "is_virtual": true,
          "name": "~Base",
          "parameters": [],
          "type": "void"
        },
        {
          "access": "private",
          "is_const": false,
          "is_defaulted": false,
          "is_implicit": false,
          "is_pure_virtual": false,
          "is_static": false,
          "is_virtual": true,
          "name": "m1",
          "parameters": [],
          "type": "int"
        },
        {
          "access": "private",
          "is_const": false,
          "is_defaulted": false,
          "is_implicit": false,
          "is_pure_virtual": false,
          "is_static": false,
          "is_virtual": true,
          "name": "m2",
          "parameters": [],
          "type": "std::string"
        }
      ],
      "name": "Base",
      "namespace": "clanguml::t00019",
      "source_location": {
        "file": "../../tests/t00019/t00019_base.h",
        "line": 8
      },
      "template_parameters": [],
      "type": "class"
    },
    {
      "bases": [],
      "display_name": "clanguml::t00019::Layer1<LowerLayer>",
      "id": "902631298537519271",
      "is_abstract": false,
      "is_nested": false,
      "is_struct": false,
      "is_template": true,
      "is_union": false,
      "members": [],
      "methods": [
        {
          "access": "private",
          "is_const": false,
          "is_defaulted": false,
          "is_implicit": false,
          "is_pure_virtual": false,
          "is_static": false,
          "is_virtual": false,
          "name": "m1",
          "parameters": [],
          "type": "int"
        },
        {
          "access": "private",
          "is_const": false,
          "is_defaulted": false,
          "is_implicit": false,
          "is_pure_virtual": false,
          "is_static": false,
          "is_virtual": false,
          "name": "m2",
          "parameters": [],
          "type": "std::string"
        }
      ],
      "name": "Layer1",
      "namespace": "clanguml::t00019",
      "source_location": {
        "file": "../../tests/t00019/t00019_layer1.h",
        "line": 9
      },
      "template_parameters": [
        {
          "is_variadic": false,
          "kind": "template_type",
          "name": "LowerLayer",
          "template_parameters": []
        }
      ],
      "type": "class"
    },
    {
      "bases": [],
      "display_name": "clanguml::t00019::Layer2<LowerLayer>",
      "id": "1115150925302580647",
      "is_abstract": false,
      "is_nested": false,
      "is_struct": false,
      "is_template": true,
      "is_union": false,
      "members": [],
      "methods": [
        {
          "access": "private",
          "is_const": true,
          "is_defaulted": false,
          "is_implicit": false,
          "is_pure_virtual": false,
          "is_static": false,
          "is_virtual": false,
          "name": "all_calls_count",
          "parameters": [],
          "type": "int"
        }
      ],
      "name": "Layer2",
      "namespace": "clanguml::t00019",
      "source_location": {
        "file": "../../tests/t00019/t00019_layer2.h",
        "line": 6
      },
      "template_parameters": [
        {
          "is_variadic": false,
          "kind": "template_type",
          "name": "LowerLayer",
          "template_parameters": []
        }
      ],
      "type": "class"
    },
    {
      "bases": [],
      "display_name": "clanguml::t00019::Layer3<LowerLayer>",
      "id": "1853410560073854945",
      "is_abstract": false,
      "is_nested": false,
      "is_struct": false,
      "is_template": true,
      "is_union": false,
      "members": [
        {
          "access": "private",
          "is_static": false,
          "name": "m_m1_calls",
          "source_location": {
            "file": "../../tests/t00019/t00019_layer3.h",
            "line": 29
          },
          "type": "int"
        },
        {
          "access": "private",
          "is_static": false,
          "name": "m_m2_calls",
          "source_location": {
            "file": "../../tests/t00019/t00019_layer3.h",
            "line": 30
          },
          "type": "int"
        }
      ],
      "methods": [
        {
          "access": "private",
          "is_const": false,
          "is_defaulted": false,
          "is_implicit": false,
          "is_pure_virtual": false,
          "is_static": false,
          "is_virtual": true,
          "name": "m1",
          "parameters": [],
          "type": "int"
        },
        {
          "access": "private",
          "is_const": false,
          "is_defaulted": false,
          "is_implicit": false,
          "is_pure_virtual": false,
          "is_static": false,
          "is_virtual": true,
          "name": "m2",
          "parameters": [],
          "type": "std::string"
        },
        {
          "access": "private",
          "is_const": true,
          "is_defaulted": false,
          "is_implicit": false,
          "is_pure_virtual": false,
          "is_static": false,
          "is_virtual": false,
          "name": "m1_calls",
          "parameters": [],
          "type": "int"
        },
        {
          "access": "private",
          "is_const": true,
          "is_defaulted": false,
          "is_implicit": false,
          "is_pure_virtual": false,
          "is_static": false,
          "is_virtual": false,
          "name": "m2_calls",
          "parameters": [],
          "type": "int"
        }
      ],
      "name": "Layer3",
      "namespace": "clanguml::t00019",
      "source_location": {
        "file": "../../tests/t00019/t00019_layer3.h",
        "line": 8
      },
      "template_parameters": [
        {
          "is_variadic": false,
          "kind": "template_type",
          "name": "LowerLayer",
          "template_parameters": []
        }
      ],
      "type": "class"
    },
    {
      "bases": [
        {
          "access": "public",
          "id": "261668487476634123",
          "is_virtual": false,
          "name": "clanguml::t00019::Base"
        }
      ],
      "display_name": "clanguml::t00019::Layer3<clanguml::t00019::Base>",
      "id": "972890420743280319",
      "is_abstract": false,
      "is_nested": false,
      "is_struct": false,
      "is_template": true,
      "is_union": false,
      "members": [],
      "methods": [],
      "name": "Layer3",
      "namespace": "clanguml::t00019",
      "source_location": {
        "file": "../../tests/t00019/t00019_layer2.h",
        "line": 6
      },
      "template_parameters": [
        {
          "is_variadic": false,
          "kind": "argument",
          "template_parameters": [],
          "type": "clanguml::t00019::Base"
        }
      ],
      "type": "class"
    },
    {
      "bases": [
        {
          "access": "public",
          "id": "972890420743280319",
          "is_virtual": false,
          "name": "clanguml::t00019::Layer3<clanguml::t00019::Base>"
        }
      ],
      "display_name": "clanguml::t00019::Layer2<clanguml::t00019::Layer3<clanguml::t00019::Base>>",
      "id": "129784999866998870",
      "is_abstract": false,
      "is_nested": false,
      "is_struct": false,
      "is_template": true,
      "is_union": false,
      "members": [],
      "methods": [],
      "name": "Layer2",
      "namespace": "clanguml::t00019",
      "source_location": {
        "file": "../../tests/t00019/t00019_layer1.h",
        "line": 9
      },
      "template_parameters": [
        {
          "is_variadic": false,
          "kind": "argument",
          "template_parameters": [
            {
              "is_variadic": false,
              "kind": "argument",
              "template_parameters": [],
              "type": "clanguml::t00019::Base"
            }
          ],
          "type": "clanguml::t00019::Layer3"
        }
      ],
      "type": "class"
    },
    {
      "bases": [
        {
          "access": "public",
          "id": "129784999866998870",
          "is_virtual": false,
          "name": "clanguml::t00019::Layer2<clanguml::t00019::Layer3<clanguml::t00019::Base>>"
        }
      ],
      "display_name": "clanguml::t00019::Layer1<clanguml::t00019::Layer2<clanguml::t00019::Layer3<clanguml::t00019::Base>>>",
      "id": "659076058325663708",
      "is_abstract": false,
      "is_nested": false,
      "is_struct": false,
      "is_template": true,
      "is_union": false,
      "members": [],
      "methods": [],
      "name": "Layer1",
      "namespace": "clanguml::t00019",
      "source_location": {
        "file": "../../../../../../usr/include/c++/12/bits/unique_ptr.h",
        "line": 269
      },
      "template_parameters": [
        {
          "is_variadic": false,
          "kind": "argument",
          "template_parameters": [
            {
              "is_variadic": false,
              "kind": "argument",
              "template_parameters": [
                {
                  "is_variadic": false,
                  "kind": "argument",
                  "template_parameters": [],
                  "type": "clanguml::t00019::Base"
                }
              ],
              "type": "clanguml::t00019::Layer3"
            }
          ],
          "type": "clanguml::t00019::Layer2"
        }
      ],
      "type": "class"
    },
    {
      "bases": [],
      "display_name": "clanguml::t00019::A",
      "id": "1015164998787089197",
      "is_abstract": false,
      "is_nested": false,
      "is_struct": false,
      "is_template": false,
      "is_union": false,
      "members": [
        {
          "access": "public",
          "is_static": false,
          "name": "layers",
          "source_location": {
            "file": "../../tests/t00019/t00019.cc",
            "line": 13
          },
          "type": "std::unique_ptr<Layer1<Layer2<Layer3<Base>>>>"
        }
      ],
      "methods": [],
      "name": "A",
      "namespace": "clanguml::t00019",
      "source_location": {
        "file": "../../tests/t00019/t00019.cc",
        "line": 11
      },
      "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": "t00019_class",
  "relationships": [
    {
      "access": "public",
      "destination": "261668487476634123",
      "source": "972890420743280319",
      "type": "dependency"
    },
    {
      "access": "public",
      "destination": "1853410560073854945",
      "source": "972890420743280319",
      "type": "instantiation"
    },
    {
      "access": "public",
      "destination": "261668487476634123",
      "source": "972890420743280319",
      "type": "extension"
    },
    {
      "access": "public",
      "destination": "972890420743280319",
      "source": "129784999866998870",
      "type": "dependency"
    },
    {
      "access": "public",
      "destination": "1115150925302580647",
      "source": "129784999866998870",
      "type": "instantiation"
    },
    {
      "access": "public",
      "destination": "972890420743280319",
      "source": "129784999866998870",
      "type": "extension"
    },
    {
      "access": "public",
      "destination": "129784999866998870",
      "source": "659076058325663708",
      "type": "dependency"
    },
    {
      "access": "public",
      "destination": "902631298537519271",
      "source": "659076058325663708",
      "type": "instantiation"
    },
    {
      "access": "public",
      "destination": "129784999866998870",
      "source": "659076058325663708",
      "type": "extension"
    },
    {
      "access": "public",
      "destination": "659076058325663708",
      "source": "1015164998787089197",
      "type": "dependency"
    },
    {
      "access": "public",
      "destination": "659076058325663708",
      "label": "layers",
      "source": "1015164998787089197",
      "type": "aggregation"
    }
  ],
  "using_namespace": "clanguml::t00019"
}
```
