| 688 | } |
| 689 | |
| 690 | std::shared_ptr<Model> ExternalManager::modelFromObject(const Py::Object& entry, |
| 691 | const QString& uuid) |
| 692 | { |
| 693 | if (!checkModelObjectType(entry)) { |
| 694 | throw InvalidModel(); |
| 695 | } |
| 696 | |
| 697 | Py::String pyName(entry.getAttr("libraryName")); |
| 698 | Py::Object modelObject(entry.getAttr("model")); |
| 699 | |
| 700 | QString libraryName; |
| 701 | if (!pyName.isNone()) { |
| 702 | libraryName = QString::fromStdString(pyName.as_string()); |
| 703 | } |
| 704 | |
| 705 | // Using this call will use caching, whereas using our class function will not |
| 706 | auto library = ModelManager::getManager().getLibrary(libraryName); |
| 707 | |
| 708 | Model* model = static_cast<ModelPy*>(*modelObject)->getModelPtr(); |
| 709 | model->setUUID(uuid); |
| 710 | model->setLibrary(library); |
| 711 | auto shared = std::make_shared<Model>(*model); |
| 712 | |
| 713 | return shared; |
| 714 | } |
| 715 | |
| 716 | std::shared_ptr<Model> ExternalManager::getModel(const QString& uuid) |
| 717 | { |
nothing calls this directly
no test coverage detected