Main generator method.
This method is called first and coordinates the entire diagram generation.
496{
498
499 if (
config().participants_order.has_value) {
500 for (
const auto &p :
config().participants_order()) {
501 LOG_DBG(
"Pregenerating participant {}", p);
503 }
504 }
505
506 for (
const auto &ft :
config().from_to()) {
507
508
509 assert(ft.size() == 2);
510
511 const auto &from_location = ft.front();
512 const auto &to_location = ft.back();
513
514 auto from_activity_id =
model().get_from_activity_id(from_location);
515 auto to_activity_id =
model().get_to_activity_id(to_location);
516
517 if (!from_activity_id || !to_activity_id)
518 continue;
519
520 if (
model().participants().count(*from_activity_id) == 0)
521 continue;
522
523 if (
model().participants().count(*to_activity_id) == 0)
524 continue;
525
526 auto message_chains_unique =
model().get_all_from_to_message_chains(
527 *from_activity_id, *to_activity_id);
528
529 bool first_separator_skipped{false};
530 for (const auto &mc : message_chains_unique) {
531 if (!first_separator_skipped)
532 first_separator_skipped = true;
533 else
534 ostr << "====\n";
535
536 const auto &from =
537 model().get_participant<model::function>(*from_activity_id);
538
539 if (from.value().type_name() == "method" ||
540 config().combine_free_functions_into_file_participants()) {
542 ostr << "[->"
544 << from.value().message_name(
546 << '\n';
547 }
548
549 for (const auto &m : mc) {
551 }
552 }
553 }
554
555 for (
const auto &to_location :
config().to()) {
556 auto to_activity_id =
model().get_to_activity_id(to_location);
557
558 if (!to_activity_id)
559 continue;
560
561 auto message_chains_unique =
562 model().get_all_from_to_message_chains(eid_t{}, *to_activity_id);
563
564 bool first_separator_skipped{false};
565 for (const auto &mc : message_chains_unique) {
566 if (!first_separator_skipped)
567 first_separator_skipped = true;
568 else
569 ostr << "====\n";
570
571 const auto from_activity_id = mc.front().from();
572
573 if (
model().participants().count(from_activity_id) == 0)
574 continue;
575
576 const auto &from =
577 model().get_participant<model::function>(from_activity_id);
578
579 if (from.value().type_name() == "method" ||
580 config().combine_free_functions_into_file_participants()) {
582 ostr << "[->"
584 << from.value().message_name(
586 << '\n';
587 }
588
589 for (const auto &m : mc) {
591 }
592 }
593 }
594
595 for (
const auto &sf :
config().from()) {
596 if (sf.location_type == location_t::function) {
597 eid_t start_from{};
598 for (
const auto &[k, v] :
model().sequences()) {
599 if (
model().participants().count(v.from()) == 0)
600 continue;
601
602 const auto &caller = *
model().participants().at(v.from());
603 std::string vfrom = caller.full_name(false);
604 if (vfrom == sf.location) {
605 LOG_DBG(
"Found sequence diagram start point: {}", k);
606 start_from = k;
607 break;
608 }
609 }
610
611 if (start_from == 0) {
612 LOG_WARN(
"Failed to find participant with {} for start_from "
613 "condition",
614 sf.location);
615 continue;
616 }
617
618 if (
model().participants().count(start_from) == 0)
619 continue;
620
621
622 std::vector<eid_t> visited_participants;
623
624 const auto &from =
625 model().get_participant<model::function>(start_from);
626
627 if (!from.has_value()) {
628 LOG_WARN(
"Failed to find participant {} for start_from "
629 "condition",
630 sf.location);
631 continue;
632 }
633
635
637
640
641
642
643
644
645 if (from.value().type_name() == "method" ||
646 config().combine_free_functions_into_file_participants()) {
647 ostr << "[->"
648 << " " << from_alias << " : "
649 << from.value().message_name(render_mode) << '\n';
650 }
651
652 ostr << "activate " << from_alias << '\n';
653
655 model().get_activity(start_from), ostr, visited_participants);
656
657 if (from.value().type_name() == "method" ||
658 config().combine_free_functions_into_file_participants()) {
659
660 if (!from.value().is_void()) {
661 ostr << "[<--"
662 << " " << from_alias;
663
664 if (
config().generate_return_types())
665 ostr << " : //" << from.value().return_type() << "//";
666
667 ostr << '\n';
668 }
669 }
670
671 ostr << "deactivate " << from_alias << '\n';
672 }
673 else {
674
675 continue;
676 }
677 }
678}