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