You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
1.9KB

  1. #pragma once
  2. #include <string>
  3. #include <list>
  4. namespace rack {
  5. struct ModuleWidget;
  6. struct Model;
  7. // Subclass this and return a pointer to a new one when init() is called
  8. struct Plugin {
  9. /** A list of the models available by this plugin, add with addModel() */
  10. std::list<Model*> models;
  11. /** The file path of the plugin's directory */
  12. std::string path;
  13. /** OS-dependent library handle */
  14. void *handle = NULL;
  15. /** Used when syncing plugins with the API */
  16. std::string slug;
  17. /** The version of your plugin
  18. Plugins should follow the versioning scheme described at https://github.com/VCVRack/Rack/issues/266
  19. Do not include the "v" in "v1.0" for example.
  20. */
  21. std::string version;
  22. virtual ~Plugin();
  23. void addModel(Model *model);
  24. };
  25. struct Model {
  26. Plugin *plugin = NULL;
  27. /** An identifier for the model, e.g. "VCO". Used for saving patches. The slug, manufacturerSlug pair must be unique. */
  28. std::string slug;
  29. /** Human readable name for your model, e.g. "Voltage Controlled Oscillator" */
  30. std::string name;
  31. /** An identifier for the manufacturer, e.g. "foo". Used for saving patches. */
  32. std::string manufacturerSlug;
  33. /** Human readable name for the manufacturer, e.g. "Foo Modular" */
  34. std::string manufacturerName;
  35. virtual ~Model() {}
  36. virtual ModuleWidget *createModuleWidget() { return NULL; }
  37. };
  38. extern std::list<Plugin*> gPlugins;
  39. extern std::string gToken;
  40. void pluginInit();
  41. void pluginDestroy();
  42. void pluginLogIn(std::string email, std::string password);
  43. void pluginLogOut();
  44. void pluginRefresh();
  45. void pluginCancelDownload();
  46. bool pluginIsLoggedIn();
  47. bool pluginIsDownloading();
  48. float pluginGetDownloadProgress();
  49. std::string pluginGetDownloadName();
  50. std::string pluginGetLoginStatus();
  51. } // namespace rack
  52. ////////////////////
  53. // Implemented by plugin
  54. ////////////////////
  55. /** Called once to initialize and return the Plugin instance.
  56. You must implement this in your plugin
  57. */
  58. extern "C"
  59. void init(rack::Plugin *plugin);