//\r
////////////////////////////////////////////////////////////\r
\r
-\r
////////////////////////////////////////////////////////////\r
// Headers\r
////////////////////////////////////////////////////////////\r
#include <Pluma/DLibrary.hpp>\r
#include <Pluma/Dir.hpp>\r
#include <cstdio>\r
+#include <stdexcept>\r
\r
namespace pluma{\r
\r
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
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
return load(folder + '/' + pluginName);\r
}\r
\r
-\r
////////////////////////////////////////////////////////////\r
-int PluginManager::loadFromFolder(const std::string& folder, bool recursive){\r
- std::list<std::string> files;\r
+ std::list< std::string > PluginManager::loadFromFolder(const std::string& folder, bool recursive){\r
+ std::list<std::string> files, loaded_files;\r
dir::listFiles(files, folder, PLUMA_LIB_EXTENSION, recursive);\r
// try to load every library\r
- int res = 0;\r
std::list<std::string>::const_iterator it;\r
for (it = files.begin() ; it != files.end() ; ++it){\r
- if ( load(*it) ) ++res;\r
+ // *** LFV ***\r
+ try\r
+ {\r
+ if ( load(*it) ) loaded_files.push_back( *it );\r
+ }\r
+ catch( ... )\r
+ {\r
+ } // yrt\r
+ // *** LFV ***\r
}\r
- return res;\r
+ return loaded_files;\r
}\r
\r
\r
return false;\r
}\r
\r
-\r
////////////////////////////////////////////////////////////\r
void PluginManager::unloadAll(){\r
\r
////////////////////////////////////////////////////////////\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