Files
clang-uml/docs/test_cases/t20031.md
2023-10-08 17:24:30 +02:00

6.2 KiB

t20031 - Callee type sequence diagram filter test case

Config

compilation_database_dir: ..
output_directory: diagrams
diagrams:
  t20031_sequence:
    type: sequence
    glob:
      - ../../tests/t20031/t20031.cc
    include:
      namespaces:
        - clanguml::t20031
    exclude:
      callee_types:
        - constructor
        - operator
        - lambda
    using_namespace:
      - clanguml::t20031
    from:
      - function: "clanguml::t20031::tmain(int)"
      - function: "clanguml::t20031::tmain(bool,int)"

Source code

File t20031.cc

#include <functional>

namespace clanguml {
namespace t20031 {
int magic() { return 42; }
int zero() { return 0; }
int one() { return 1; }
int execute(std::function<int()> f) { return f(); }

class A {
public:
    A() { create(); }

    A(int v) { a_ = v; }

    A &operator=(const A &a)
    {
        set(a.a_);
        return *this;
    }

    A &operator+=(int a)
    {
        add(a);
        return *this;
    }

    int value() const { return a_; }

private:
    void create() { a_ = 0; }

    void add(int a) { a_ += a; }
    void set(int a) { a_ = a; }

    int a_;
};

void tmain(int a)
{
    A an_a{magic()};
    an_a += 1;
}

int tmain(bool f, int a)
{
    auto generate_zero = []() { return zero(); };
    auto an_a = A();
    auto an_b = A();

    an_a += generate_zero();

    // @todo #168
    an_a += execute([]() { return one(); });

    an_b = an_a;

    return an_b.value();
};

}
}

Generated PlantUML diagrams

t20031_sequence

Generated Mermaid diagrams

t20031_sequence

Generated JSON models

{
  "diagram_type": "sequence",
  "metadata": {
    "clang_uml_version": "0.4.0-2-g4ab0d29",
    "llvm_version": "Ubuntu clang version 16.0.6 (++20230710042027+7cbf1a259152-1~exp1~20230710162048.105)",
    "schema_version": 1
  },
  "name": "t20031_sequence",
  "participants": [
    {
      "id": "1045973591033429178",
      "name": "clanguml::t20031::tmain(int)",
      "source_location": {
        "column": 6,
        "file": "../../tests/t20031/t20031.cc",
        "line": 39,
        "translation_unit": "../../tests/t20031/t20031.cc"
      },
      "type": "function"
    },
    {
      "id": "2265790048300959619",
      "name": "clanguml::t20031::magic()",
      "source_location": {
        "column": 5,
        "file": "../../tests/t20031/t20031.cc",
        "line": 5,
        "translation_unit": "../../tests/t20031/t20031.cc"
      },
      "type": "function"
    },
    {
      "id": "2189754495514350927",
      "name": "clanguml::t20031::tmain(bool,int)",
      "source_location": {
        "column": 5,
        "file": "../../tests/t20031/t20031.cc",
        "line": 45,
        "translation_unit": "../../tests/t20031/t20031.cc"
      },
      "type": "function"
    },
    {
      "id": "2230160420908832598",
      "name": "clanguml::t20031::execute(std::function<int ()>)",
      "source_location": {
        "column": 5,
        "file": "../../tests/t20031/t20031.cc",
        "line": 8,
        "translation_unit": "../../tests/t20031/t20031.cc"
      },
      "type": "function"
    },
    {
      "id": "1081580052625775404",
      "name": "clanguml::t20031::A",
      "source_location": {
        "column": 7,
        "file": "../../tests/t20031/t20031.cc",
        "line": 10,
        "translation_unit": "../../tests/t20031/t20031.cc"
      },
      "type": "class"
    }
  ],
  "sequences": [
    {
      "messages": [
        {
          "from": {
            "activity_id": "1045973591033429178",
            "activity_name": "clanguml::t20031::tmain(int)",
            "participant_id": "1045973591033429178",
            "participant_name": "clanguml::t20031::tmain(int)"
          },
          "name": "",
          "return_type": "int",
          "scope": "normal",
          "source_location": {
            "column": 12,
            "file": "../../tests/t20031/t20031.cc",
            "line": 41,
            "translation_unit": "../../tests/t20031/t20031.cc"
          },
          "to": {
            "activity_id": "2265790048300959619",
            "activity_name": "clanguml::t20031::magic()",
            "participant_id": "2265790048300959619"
          },
          "type": "message"
        }
      ],
      "start_from": {
        "id": 1045973591033429178,
        "location": "clanguml::t20031::tmain(int)"
      }
    },
    {
      "messages": [
        {
          "from": {
            "activity_id": "2189754495514350927",
            "activity_name": "clanguml::t20031::tmain(bool,int)",
            "participant_id": "2189754495514350927",
            "participant_name": "clanguml::t20031::tmain(bool,int)"
          },
          "name": "",
          "return_type": "int",
          "scope": "normal",
          "source_location": {
            "column": 13,
            "file": "../../tests/t20031/t20031.cc",
            "line": 54,
            "translation_unit": "../../tests/t20031/t20031.cc"
          },
          "to": {
            "activity_id": "2230160420908832598",
            "activity_name": "clanguml::t20031::execute(std::function<int ()>)",
            "participant_id": "2230160420908832598"
          },
          "type": "message"
        },
        {
          "from": {
            "activity_id": "2189754495514350927",
            "activity_name": "clanguml::t20031::tmain(bool,int)",
            "participant_id": "2189754495514350927",
            "participant_name": "clanguml::t20031::tmain(bool,int)"
          },
          "name": "value() const",
          "return_type": "int",
          "scope": "normal",
          "source_location": {
            "column": 12,
            "file": "../../tests/t20031/t20031.cc",
            "line": 58,
            "translation_unit": "../../tests/t20031/t20031.cc"
          },
          "to": {
            "activity_id": "1089278431155817348",
            "activity_name": "clanguml::t20031::A::value() const",
            "participant_id": "1081580052625775404"
          },
          "type": "message"
        }
      ],
      "start_from": {
        "id": 2189754495514350927,
        "location": "clanguml::t20031::tmain(bool,int)"
      }
    }
  ],
  "using_namespace": "clanguml::t20031"
}