| 147 | } |
| 148 | |
| 149 | Result load(StringView identifier) |
| 150 | { |
| 151 | const PluginDynamicLibrary* exampleLibrary = registry.findPlugin(identifier); |
| 152 | |
| 153 | Buffer serializedModelState, serializedViewState; |
| 154 | if (exampleLibrary) |
| 155 | { |
| 156 | ISCExample* example = nullptr; |
| 157 | if (exampleLibrary->queryInterface(example) and example->serialize.isValid()) |
| 158 | { |
| 159 | SC_TRY(example->serialize(serializedModelState, serializedViewState)); |
| 160 | } |
| 161 | if (example and example->closeAsync.isValid()) |
| 162 | { |
| 163 | SC_TRY(example->closeAsync(*eventLoop)); |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | SC_TRY(registry.loadPlugin(identifier, compiler, sysroot, state.executablePath.view(), |
| 168 | PluginRegistry::LoadMode::Reload)); |
| 169 | |
| 170 | ISCExample* example = nullptr; |
| 171 | SC_TRY(exampleLibrary->queryInterface(example)); |
| 172 | if (example) |
| 173 | { |
| 174 | if (example->deserialize.isValid() and not serializedModelState.isEmpty()) |
| 175 | { |
| 176 | SC_TRY(example->deserialize(serializedModelState.toSpanConst(), serializedViewState.toSpanConst())); |
| 177 | } |
| 178 | if (example->initAsync.isValid()) |
| 179 | { |
| 180 | SC_TRY(example->initAsync(*eventLoop)); |
| 181 | } |
| 182 | } |
| 183 | return Result(true); |
| 184 | } |
| 185 | |
| 186 | void unload(StringView identifier) { (void)registry.unloadPlugin(identifier); } |
| 187 |
no test coverage detected