# t20029 - Combined feature sequence diagram test case ## Config ```yaml compilation_database_dir: .. output_directory: diagrams add_compile_flags: - -fparse-all-comments diagrams: t20029_sequence: type: sequence glob: - ../../tests/t20029/t20029.cc include: namespaces: - clanguml::t20029 exclude: access: - private using_namespace: - clanguml::t20029 from: - function: clanguml::t20029::tmain() generate_message_comments: true participants_order: - clanguml::t20029::tmain() - clanguml::t20029::Encoder> - clanguml::t20029::Retrier - clanguml::t20029::ConnectionPool - clanguml::t20029::encode_b64(std::string &&) ``` ## Source code File t20029.cc ```cpp #include #include #include #include #include namespace clanguml { namespace t20029 { std::string encode_b64(std::string &&content) { return std::move(content); } template class Encoder : public T { public: bool send(std::string &&msg) { return T::send(std::move( // Encode the message using Base64 encoding and pass it to the next // layer encode(std::move(msg)))); } protected: std::string encode(std::string &&msg) { return encode_b64(std::move(msg)); } }; template class Retrier : public T { public: bool send(std::string &&msg) { std::string buffer{std::move(msg)}; int retryCount = 5; // Repeat until send() succeeds or retry count is exceeded while (retryCount--) { if (T::send(buffer)) return true; } return false; } }; class ConnectionPool { public: void connect() { if (!is_connected_.load()) connect_impl(); } bool send(const std::string &msg) { return true; } private: void connect_impl() { is_connected_ = true; } std::atomic is_connected_; }; int tmain() { auto pool = std::make_shared>>(); // Establish connection to the remote server synchronously pool->connect(); // Repeat for each line in the input stream for (std::string line; std::getline(std::cin, line);) { if (!pool->send(std::move(line))) break; } return 0; } } } ``` ## Generated PlantUML diagrams ![t20029_sequence](./t20029_sequence.svg "Combined feature sequence diagram test case") ## Generated Mermaid diagrams ![t20029_sequence](./t20029_sequence_mermaid.svg "Combined feature sequence diagram test case") ## Generated JSON models ```json { "diagram_type": "sequence", "metadata": { "clang_uml_version": "0.4.0-32-g701b2c5", "llvm_version": "Ubuntu clang version 16.0.6 (++20230710042027+7cbf1a259152-1~exp1~20230710162048.105)", "schema_version": 1 }, "name": "t20029_sequence", "participants": [ { "id": "2091374738808319642", "name": "clanguml::t20029::tmain()", "source_location": { "column": 5, "file": "../../tests/t20029/t20029.cc", "line": 59, "translation_unit": "../../tests/t20029/t20029.cc" }, "type": "function" }, { "id": "1673261195873192383", "name": "clanguml::t20029::Encoder>", "source_location": { "column": 29, "file": "../../tests/t20029/t20029.cc", "line": 11, "translation_unit": "../../tests/t20029/t20029.cc" }, "type": "class" }, { "id": "658058855590948094", "name": "clanguml::t20029::Retrier", "source_location": { "column": 29, "file": "../../tests/t20029/t20029.cc", "line": 25, "translation_unit": "../../tests/t20029/t20029.cc" }, "type": "class" }, { "id": "1896406205097618937", "name": "clanguml::t20029::ConnectionPool", "source_location": { "column": 7, "file": "../../tests/t20029/t20029.cc", "line": 43, "translation_unit": "../../tests/t20029/t20029.cc" }, "type": "class" }, { "id": "1362646431260879440", "name": "clanguml::t20029::encode_b64(std::string &&)", "source_location": { "column": 13, "file": "../../tests/t20029/t20029.cc", "line": 9, "translation_unit": "../../tests/t20029/t20029.cc" }, "type": "function" } ], "sequences": [ { "messages": [ { "comment": "Establish connection to the remote server synchronously", "from": { "activity_id": "2091374738808319642", "activity_name": "clanguml::t20029::tmain()", "participant_id": "2091374738808319642", "participant_name": "clanguml::t20029::tmain()" }, "name": "connect()", "return_type": "void", "scope": "normal", "source_location": { "column": 5, "file": "../../tests/t20029/t20029.cc", "line": 64, "translation_unit": "../../tests/t20029/t20029.cc" }, "to": { "activity_id": "940428568182104530", "activity_name": "clanguml::t20029::ConnectionPool::connect()", "participant_id": "1896406205097618937" }, "type": "message" }, { "activity_id": "2091374738808319642", "messages": [ { "activity_id": "2091374738808319642", "branches": [ { "messages": [ { "from": { "activity_id": "2091374738808319642", "activity_name": "clanguml::t20029::tmain()", "participant_id": "2091374738808319642", "participant_name": "clanguml::t20029::tmain()" }, "name": "send(std::string &&)", "return_type": "bool", "scope": "condition", "source_location": { "column": 14, "file": "../../tests/t20029/t20029.cc", "line": 68, "translation_unit": "../../tests/t20029/t20029.cc" }, "to": { "activity_id": "2026763864005979273", "activity_name": "clanguml::t20029::Encoder>::send(std::string &&)", "participant_id": "1673261195873192383" }, "type": "message" }, { "comment": "Encode the message using Base64 encoding and pass it to the next\nlayer", "from": { "activity_id": "2026763864005979273", "activity_name": "clanguml::t20029::Encoder>::send(std::string &&)", "participant_id": "1673261195873192383" }, "name": "encode(std::string &&)", "return_type": "std::string", "scope": "normal", "source_location": { "column": 13, "file": "../../tests/t20029/t20029.cc", "line": 18, "translation_unit": "../../tests/t20029/t20029.cc" }, "to": { "activity_id": "1468258269466480773", "activity_name": "clanguml::t20029::Encoder>::encode(std::string &&)", "participant_id": "1673261195873192383" }, "type": "message" }, { "from": { "activity_id": "1468258269466480773", "activity_name": "clanguml::t20029::Encoder>::encode(std::string &&)", "participant_id": "1673261195873192383" }, "name": "", "return_type": "std::string", "scope": "normal", "source_location": { "column": 52, "file": "../../tests/t20029/t20029.cc", "line": 22, "translation_unit": "../../tests/t20029/t20029.cc" }, "to": { "activity_id": "1362646431260879440", "activity_name": "clanguml::t20029::encode_b64(std::string &&)", "participant_id": "1362646431260879440" }, "type": "message" }, { "from": { "activity_id": "2026763864005979273", "activity_name": "clanguml::t20029::Encoder>::send(std::string &&)", "participant_id": "1673261195873192383" }, "name": "send(std::string &&)", "return_type": "bool", "scope": "normal", "source_location": { "column": 16, "file": "../../tests/t20029/t20029.cc", "line": 15, "translation_unit": "../../tests/t20029/t20029.cc" }, "to": { "activity_id": "30515971485361302", "activity_name": "clanguml::t20029::Retrier::send(std::string &&)", "participant_id": "658058855590948094" }, "type": "message" }, { "activity_id": "30515971485361302", "messages": [ { "activity_id": "30515971485361302", "branches": [ { "messages": [ { "from": { "activity_id": "30515971485361302", "activity_name": "clanguml::t20029::Retrier::send(std::string &&)", "participant_id": "658058855590948094" }, "name": "send(const std::string &)", "return_type": "bool", "scope": "condition", "source_location": { "column": 17, "file": "../../tests/t20029/t20029.cc", "line": 35, "translation_unit": "../../tests/t20029/t20029.cc" }, "to": { "activity_id": "972625940114169157", "activity_name": "clanguml::t20029::ConnectionPool::send(const std::string &)", "participant_id": "1896406205097618937" }, "type": "message" } ], "type": "consequent" } ], "name": "if", "type": "alt" } ], "name": "while", "type": "loop" } ], "type": "consequent" } ], "name": "if", "type": "alt" } ], "name": "for", "type": "loop" } ], "start_from": { "id": 2091374738808319642, "location": "clanguml::t20029::tmain()" } } ], "using_namespace": "clanguml::t20029" } ```