# t00023 - Strategy pattern
## Config
```yaml
compilation_database_dir: ..
output_directory: puml
diagrams:
  t00023_class:
    type: class
    glob:
      - ../../tests/t00023/t00023.cc
    using_namespace:
      - clanguml::t00023
    include:
      namespaces:
        - clanguml::t00023

```
## Source code
File t00023.cc
```cpp
#include <memory>

namespace clanguml {
namespace t00023 {

class Strategy {
public:
    virtual ~Strategy() = default;
    virtual void algorithm() = 0;
};

class StrategyA : public Strategy {
public:
    void algorithm() override { }
};

class StrategyB : public Strategy {
public:
    void algorithm() override { }
};

class StrategyC : public Strategy {
public:
    void algorithm() override { }
};

class Context {
public:
    Context(std::unique_ptr<Strategy> strategy)
        : m_strategy(std::move(strategy))
    {
    }

    void apply() { m_strategy->algorithm(); }

private:
    std::unique_ptr<Strategy> m_strategy;
};
} // namespace t00023
} // namespace clanguml

```
## Generated UML diagrams
![t00023_class](./t00023_class.svg "Strategy pattern")
## Generated JSON models
```json
{
  "diagram_type": "class",
  "elements": [
    {
      "bases": [],
      "display_name": "clanguml::t00023::Strategy",
      "id": "1469857696438841976",
      "is_abstract": true,
      "is_nested": false,
      "is_struct": false,
      "is_template": false,
      "is_union": false,
      "members": [],
      "methods": [
        {
          "access": "public",
          "is_const": false,
          "is_defaulted": true,
          "is_implicit": false,
          "is_pure_virtual": false,
          "is_static": false,
          "is_virtual": true,
          "name": "~Strategy",
          "parameters": [],
          "type": "void"
        },
        {
          "access": "public",
          "is_const": false,
          "is_defaulted": false,
          "is_implicit": false,
          "is_pure_virtual": true,
          "is_static": false,
          "is_virtual": true,
          "name": "algorithm",
          "parameters": [],
          "type": "void"
        }
      ],
      "name": "Strategy",
      "namespace": "clanguml::t00023",
      "source_location": {
        "file": "../../tests/t00023/t00023.cc",
        "line": 6
      },
      "template_parameters": [],
      "type": "class"
    },
    {
      "bases": [
        {
          "access": "public",
          "id": "1469857696438841976",
          "is_virtual": false,
          "name": "clanguml::t00023::Strategy"
        }
      ],
      "display_name": "clanguml::t00023::StrategyA",
      "id": "1245533075819635385",
      "is_abstract": false,
      "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": false,
          "is_static": false,
          "is_virtual": true,
          "name": "algorithm",
          "parameters": [],
          "type": "void"
        }
      ],
      "name": "StrategyA",
      "namespace": "clanguml::t00023",
      "source_location": {
        "file": "../../tests/t00023/t00023.cc",
        "line": 12
      },
      "template_parameters": [],
      "type": "class"
    },
    {
      "bases": [
        {
          "access": "public",
          "id": "1469857696438841976",
          "is_virtual": false,
          "name": "clanguml::t00023::Strategy"
        }
      ],
      "display_name": "clanguml::t00023::StrategyB",
      "id": "264986406899645",
      "is_abstract": false,
      "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": false,
          "is_static": false,
          "is_virtual": true,
          "name": "algorithm",
          "parameters": [],
          "type": "void"
        }
      ],
      "name": "StrategyB",
      "namespace": "clanguml::t00023",
      "source_location": {
        "file": "../../tests/t00023/t00023.cc",
        "line": 17
      },
      "template_parameters": [],
      "type": "class"
    },
    {
      "bases": [
        {
          "access": "public",
          "id": "1469857696438841976",
          "is_virtual": false,
          "name": "clanguml::t00023::Strategy"
        }
      ],
      "display_name": "clanguml::t00023::StrategyC",
      "id": "174795176193483089",
      "is_abstract": false,
      "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": false,
          "is_static": false,
          "is_virtual": true,
          "name": "algorithm",
          "parameters": [],
          "type": "void"
        }
      ],
      "name": "StrategyC",
      "namespace": "clanguml::t00023",
      "source_location": {
        "file": "../../tests/t00023/t00023.cc",
        "line": 22
      },
      "template_parameters": [],
      "type": "class"
    },
    {
      "bases": [],
      "display_name": "clanguml::t00023::Context",
      "id": "2038594012979479050",
      "is_abstract": false,
      "is_nested": false,
      "is_struct": false,
      "is_template": false,
      "is_union": false,
      "members": [
        {
          "access": "private",
          "is_static": false,
          "name": "m_strategy",
          "source_location": {
            "file": "../../tests/t00023/t00023.cc",
            "line": 37
          },
          "type": "std::unique_ptr<Strategy>"
        }
      ],
      "methods": [
        {
          "access": "public",
          "is_const": false,
          "is_defaulted": false,
          "is_implicit": false,
          "is_pure_virtual": false,
          "is_static": false,
          "is_virtual": false,
          "name": "Context",
          "parameters": [
            {
              "name": "strategy",
              "type": "std::unique_ptr<Strategy>"
            }
          ],
          "type": "void"
        },
        {
          "access": "public",
          "is_const": false,
          "is_defaulted": false,
          "is_implicit": false,
          "is_pure_virtual": false,
          "is_static": false,
          "is_virtual": false,
          "name": "apply",
          "parameters": [],
          "type": "void"
        }
      ],
      "name": "Context",
      "namespace": "clanguml::t00023",
      "source_location": {
        "file": "../../tests/t00023/t00023.cc",
        "line": 27
      },
      "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": "t00023_class",
  "relationships": [
    {
      "access": "public",
      "destination": "1469857696438841976",
      "source": "1245533075819635385",
      "type": "extension"
    },
    {
      "access": "public",
      "destination": "1469857696438841976",
      "source": "264986406899645",
      "type": "extension"
    },
    {
      "access": "public",
      "destination": "1469857696438841976",
      "source": "174795176193483089",
      "type": "extension"
    },
    {
      "access": "public",
      "destination": "1469857696438841976",
      "source": "2038594012979479050",
      "type": "dependency"
    },
    {
      "access": "private",
      "destination": "1469857696438841976",
      "label": "m_strategy",
      "source": "2038594012979479050",
      "type": "aggregation"
    }
  ],
  "using_namespace": "clanguml::t00023"
}
```
