| 494 | } |
| 495 | |
| 496 | recompui::Style* recompui::ContextId::add_resource_impl(std::unique_ptr<Style>&& resource) { |
| 497 | // Ensure a context is currently opened by this thread. |
| 498 | if (opened_context_id == ContextId::null()) { |
| 499 | context_error(*this, ContextErrorType::AddResourceWithoutOpen); |
| 500 | } |
| 501 | |
| 502 | // Check that the context that was specified is the same one that's currently open. |
| 503 | if (*this != opened_context_id) { |
| 504 | context_error(*this, ContextErrorType::AddResourceToWrongContext); |
| 505 | } |
| 506 | |
| 507 | bool is_element = resource->is_element(); |
| 508 | Style* resource_ptr = resource.get(); |
| 509 | auto key = opened_context->resources.emplace(std::move(resource)); |
| 510 | |
| 511 | if (is_element) { |
| 512 | Element* element_ptr = static_cast<Element*>(resource_ptr); |
| 513 | element_ptr->set_id(std::string{element_ptr->get_type_name()} + "-" + std::to_string(key.raw)); |
| 514 | key.set_tag(static_cast<uint8_t>(SlotTag::Element)); |
| 515 | // Send one update to the element. |
| 516 | opened_context->to_update.emplace(ResourceId{ key.raw }); |
| 517 | } |
| 518 | else { |
| 519 | key.set_tag(static_cast<uint8_t>(SlotTag::Style)); |
| 520 | } |
| 521 | |
| 522 | resource_ptr->resource_id = { key.raw }; |
| 523 | return resource_ptr; |
| 524 | } |
| 525 | |
| 526 | void recompui::ContextId::add_loose_element(Element* element) { |
| 527 | // Ensure a context is currently opened by this thread. |
nothing calls this directly
no test coverage detected