Beispiel #1
0
 bool built_in() const {
   NERVE_ASSERT(plugin_id() != plug_id::unset, "plugin must be set before testing");
   return stages::is_built_in(this->plugin_id());
 }
  //----------------------------------------------------------------
  // TPluginRegistry::load
  //
  bool
  TPluginRegistry::load(const char * pluginsFolder)
  {
    try
    {
      TOpenFolder folder(pluginsFolder);

      bool foundPlugins = false;
      do
      {
        std::string srcName = folder.itemName();
        std::string srcPath = folder.itemPath();

        if (folder.itemIsFolder())
        {
          if (strcmp(srcName.c_str(), ".") == 0 ||
              strcmp(srcName.c_str(), "..") == 0)
          {
            continue;
          }

          if (this->load(srcPath.c_str()))
          {
            foundPlugins = true;
          }

          continue;
        }

        if (!boost::algorithm::ends_with(srcName, ".yae"))
        {
          continue;
        }

        void * module = loadLibrary(srcPath.c_str());
        if (!module)
        {
          continue;
        }

        TPluginFactory factory =
          (TPluginFactory)getSymbol(module, "yae_create_plugin");
        if (!factory)
        {
          continue;
        }

        for (std::size_t i = 0; ; i++)
        {
          IPluginPtr plugin(factory(i), IPlugin::Deallocator());

          if (!plugin)
          {
            break;
          }

          std::string plugin_id(plugin->guid());
          (*this)[plugin_id] = plugin;
          foundPlugins = true;
        }

      } while (folder.parseNextItem());

      return foundPlugins;
    }
    catch (const std::exception & e)
    {}

    return false;
  }