* Get selected agents with preservation of order. */
| 623 | * Get selected agents with preservation of order. |
| 624 | */ |
| 625 | std::list<StateRef<Agent>> AgentAssignment::getSelectedAgents() const |
| 626 | { |
| 627 | std::set<sp<Agent>> agentControlSet; |
| 628 | |
| 629 | auto agentSelectBox = findControlTyped<MultilistBox>(AGENT_SELECT_BOX); |
| 630 | |
| 631 | for (auto &doubleListControl : agentSelectBox->Controls) |
| 632 | { |
| 633 | // left side |
| 634 | if (auto leftList = |
| 635 | doubleListControl->findControlTyped<MultilistBox>(ControlGenerator::LEFT_LIST_NAME)) |
| 636 | { |
| 637 | if (auto agentList = leftList->findControlTyped<MultilistBox>(AGENT_LIST_NAME)) |
| 638 | { |
| 639 | for (auto &sel : agentList->getSelectedSet()) |
| 640 | { |
| 641 | if (auto a = sel->getData<Agent>()) |
| 642 | { |
| 643 | agentControlSet.insert(a); |
| 644 | } |
| 645 | } |
| 646 | } |
| 647 | } |
| 648 | |
| 649 | // right side |
| 650 | if (auto rightList = doubleListControl->findControlTyped<MultilistBox>( |
| 651 | ControlGenerator::RIGHT_LIST_NAME)) |
| 652 | { |
| 653 | if (auto vehicleList = rightList->findControlTyped<MultilistBox>(VEHICLE_LIST_NAME)) |
| 654 | { |
| 655 | for (auto &vehicleControl : vehicleList->Controls) |
| 656 | { |
| 657 | if (auto agentList = |
| 658 | vehicleControl->findControlTyped<MultilistBox>(AGENT_LIST_NAME)) |
| 659 | { |
| 660 | for (auto &sel : agentList->getSelectedSet()) |
| 661 | { |
| 662 | if (auto a = sel->getData<Agent>()) |
| 663 | { |
| 664 | agentControlSet.insert(a); |
| 665 | } |
| 666 | } |
| 667 | } |
| 668 | } |
| 669 | } |
| 670 | } |
| 671 | } |
| 672 | |
| 673 | std::list<StateRef<Agent>> agents; |
| 674 | for (auto &a : state->agents) |
| 675 | { |
| 676 | if (agentControlSet.find(a.second) != agentControlSet.end()) |
| 677 | { |
| 678 | agents.emplace_back(state.get(), a.second); |
| 679 | } |
| 680 | } |
| 681 | |
| 682 | return agents; |
no test coverage detected