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.

plugin.hpp 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #pragma once
  2. #include <string>
  3. #include <list>
  4. #include "tags.hpp"
  5. namespace rack {
  6. struct ModuleWidget;
  7. struct Module;
  8. struct Model;
  9. // Subclass this and return a pointer to a new one when init() is called
  10. struct Plugin {
  11. /** A list of the models available by this plugin, add with addModel() */
  12. std::list<Model*> models;
  13. /** The file path of the plugin's directory */
  14. std::string path;
  15. /** OS-dependent library handle */
  16. void *handle = NULL;
  17. /** Must be unique. Used for patch files and the VCV store API.
  18. To guarantee uniqueness, it is a good idea to prefix the slug by your "company name" if available, e.g. "MyCompany-MyPlugin"
  19. */
  20. std::string slug;
  21. /** The version of your plugin
  22. Plugins should follow the versioning scheme described at https://github.com/VCVRack/Rack/issues/266
  23. Do not include the "v" in "v1.0" for example.
  24. */
  25. std::string version;
  26. /** Deprecated, do not use. */
  27. std::string website;
  28. std::string manual;
  29. virtual ~Plugin();
  30. void addModel(Model *model);
  31. };
  32. struct Model {
  33. Plugin *plugin = NULL;
  34. /** An identifier for the model, e.g. "VCO". Used for saving patches. The slug, manufacturerSlug pair must be unique. */
  35. std::string slug;
  36. /** Human readable name for your model, e.g. "Voltage Controlled Oscillator" */
  37. std::string name;
  38. /** The name of the manufacturer group of the module.
  39. This might be different than the plugin slug. For example, if you create multiple plugins but want them to be branded similarly, you may use the same manufacturer name in multiple plugins.
  40. You may even have multiple manufacturers in one plugin, although this would be unusual.
  41. */
  42. std::string manufacturer;
  43. /** List of tags representing the function(s) of the module (optional) */
  44. std::list<ModelTag> tags;
  45. virtual ~Model() {}
  46. virtual Module *createModule() { return NULL; }
  47. virtual ModuleWidget *createModuleWidget() { return NULL; }
  48. };
  49. void pluginInit();
  50. void pluginDestroy();
  51. void pluginLogIn(std::string email, std::string password);
  52. void pluginLogOut();
  53. /** Returns whether a new plugin is available, and downloads it unless doing a dry run */
  54. bool pluginSync(bool dryRun);
  55. void pluginCancelDownload();
  56. bool pluginIsLoggedIn();
  57. bool pluginIsDownloading();
  58. float pluginGetDownloadProgress();
  59. std::string pluginGetDownloadName();
  60. std::string pluginGetLoginStatus();
  61. extern std::list<Plugin*> gPlugins;
  62. extern std::string gToken;
  63. } // namespace rack
  64. ////////////////////
  65. // Implemented by plugin
  66. ////////////////////
  67. /** Called once to initialize and return the Plugin instance.
  68. You must implement this in your plugin
  69. */
  70. extern "C"
  71. void init(rack::Plugin *plugin);