MCPcopy Create free account
hub / github.com/BYVoid/OpenCC / LoadByPath

Method LoadByPath

src/PluginSegmentation.cpp:384–400  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

382 }
383
384 std::shared_ptr<PluginLibrary> LoadByPath(const std::string& path,
385 const std::string& type) {
386 if (IsTruthy(std::getenv("OPENCC_DISABLE_PLUGINS"))) {
387 throw Exception("Segmentation plugin loading is disabled.");
388 }
389
390 std::lock_guard<std::mutex> lock(mutex_);
391 // Use the explicit path as cache key (not type) to avoid collisions
392 // when the same plugin type is loaded from different library paths.
393 auto it = cache_.find(path);
394 if (it != cache_.end()) {
395 return it->second;
396 }
397 std::shared_ptr<PluginLibrary> plugin = LoadFromPath(path, type);
398 cache_[path] = plugin;
399 return plugin;
400 }
401
402private:
403 static std::vector<std::string> GetPluginFileNames(const std::string& type) {

Callers 1

CreatePluginSegmentationFunction · 0.80

Calls 4

IsTruthyFunction · 0.85
findMethod · 0.80
ExceptionFunction · 0.70
endMethod · 0.45

Tested by

no test coverage detected