]> Creatis software - cpPlugins.git/blobdiff - lib/third_party/Pluma/PluginManager.cpp
Parameters are now part of the pipeline update process
[cpPlugins.git] / lib / third_party / Pluma / PluginManager.cpp
index 9579da2f2fe4ff59f408e2757adb9e5b5aea03a3..491a1a9f5a9b653b3f939573f01d24f92f1834cf 100644 (file)
@@ -30,6 +30,7 @@
 #include <Pluma/DLibrary.hpp>\r
 #include <Pluma/Dir.hpp>\r
 #include <cstdio>\r
+#include <stdexcept>\r
 \r
 namespace pluma{\r
 \r
@@ -56,16 +57,26 @@ bool PluginManager::load(const std::string& path){
     registerFunction = reinterpret_cast<fnRegisterPlugin*>(lib->getSymbol("connect"));\r
 \r
     if(!registerFunction){\r
-        fprintf(stderr, "Failed to initialize plugin \"%s\": connect function not found\n", plugName.c_str());\r
+      //fprintf(stderr, "Failed to initialize plugin \"%s\": connect function not found\n", plugName.c_str());\r
         delete lib;\r
+        throw std::runtime_error(\r
+          std::string( "Failed to initialize plugin \"" ) +\r
+          plugName +\r
+          std::string( "\": connect function not found" )\r
+          );\r
         return false;\r
     }\r
     // try to initialize plugin:\r
     if (!registerFunction(host)){\r
         // plugin decided to fail\r
-        fprintf(stderr, "Self registry failed on plugin \"%s\".\n", plugName.c_str());\r
+      // fprintf(stderr, "Self registry failed on plugin \"%s\".\n", plugName.c_str());\r
         host.cancelAddictions();\r
         delete lib;\r
+        throw std::runtime_error(\r
+          std::string( "Self registry failed on plugin \"" ) +\r
+          plugName +\r
+          std::string( "\"" )\r
+          );\r
         return false;\r
     }\r
     // Store the library if addictions are confirmed\r
@@ -73,8 +84,13 @@ bool PluginManager::load(const std::string& path){
         libraries[plugName] = lib;\r
     else{\r
         // otherwise nothing was registered\r
-        fprintf(stderr, "Nothing registered by plugin \"%s\".\n", plugName.c_str());\r
+      // fprintf(stderr, "Nothing registered by plugin \"%s\".\n", plugName.c_str());\r
         delete lib;\r
+        throw std::runtime_error(\r
+          std::string( "Nothing registered by plugin \"" ) +\r
+          plugName +\r
+          std::string( "\"." )\r
+          );\r
         return false;\r
     }\r
     return true;\r
@@ -166,7 +182,8 @@ void PluginManager::registerType(const std::string& type, unsigned int version,
 ////////////////////////////////////////////////////////////\r
 bool PluginManager::addProvider(Provider* provider){\r
     if (provider == NULL){\r
-        fprintf(stderr, "Trying to add null provider\n");\r
+      // fprintf(stderr, "Trying to add null provider\n");\r
+      throw std::runtime_error( "Trying to add null provider." );\r
         return false;\r
     }\r
     return host.registerProvider(provider);\r