| 657 | } |
| 658 | |
| 659 | void sugoi_storage_t::query_groups(const sugoi_query_t* q, sugoi_group_callback_t callback, void* u) |
| 660 | { |
| 661 | using namespace sugoi; |
| 662 | bool mainThread = true; |
| 663 | if (scheduler) |
| 664 | { |
| 665 | mainThread = scheduler->is_main_thread(this); |
| 666 | } |
| 667 | if (mainThread) |
| 668 | { |
| 669 | build_queries(); |
| 670 | } |
| 671 | else |
| 672 | SKR_ASSERT(queriesBuilt); |
| 673 | |
| 674 | fixed_stack_scope_t _(localStack); |
| 675 | bool filterShared = (q->filter.all_shared.length + q->filter.none_shared.length) != 0; |
| 676 | sugoi_meta_filter_t* validatedMeta = nullptr; |
| 677 | if (q->meta.all_meta.length > 0 || q->meta.any_meta.length > 0 || q->meta.none_meta.length > 0) |
| 678 | { |
| 679 | validatedMeta = localStack.allocate<sugoi_meta_filter_t>(); |
| 680 | auto data = (char*)localStack.allocate(data_size(q->meta)); |
| 681 | *validatedMeta = sugoi::clone(q->meta, data); |
| 682 | validate(validatedMeta->all_meta); |
| 683 | validate(validatedMeta->any_meta); |
| 684 | validate(validatedMeta->none_meta); |
| 685 | } |
| 686 | else |
| 687 | { |
| 688 | validatedMeta = (sugoi_meta_filter_t*)&q->meta; |
| 689 | } |
| 690 | bool filterMeta = (validatedMeta->all_meta.length + validatedMeta->any_meta.length + validatedMeta->none_meta.length) != 0; |
| 691 | for (auto& group : q->groups) |
| 692 | { |
| 693 | if (filterShared) |
| 694 | { |
| 695 | fixed_stack_scope_t _(localStack); |
| 696 | sugoi_type_set_t shared; |
| 697 | shared.length = 0; |
| 698 | // todo: is 256 enough? |
| 699 | shared.data = localStack.allocate<sugoi_type_index_t>(256); |
| 700 | group->get_shared_type(shared, localStack.allocate<sugoi_type_index_t>(256)); |
| 701 | // check(shared.length < 256); |
| 702 | if (!match_group_shared(shared, q->filter)) |
| 703 | continue; |
| 704 | } |
| 705 | if (filterMeta) |
| 706 | { |
| 707 | if (!match_group_meta(group->type, *validatedMeta)) |
| 708 | continue; |
| 709 | } |
| 710 | callback(u, group); |
| 711 | } |
| 712 | } |
| 713 | |
| 714 | void sugoi_storage_t::query_groups(const sugoi_filter_t& filter, const sugoi_meta_filter_t& meta, sugoi_group_callback_t callback, void* u) |
| 715 | { |
no test coverage detected