The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

141 lines
5.0KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. PluginDescription::PluginDescription()
  18. : uid (0),
  19. isInstrument (false),
  20. numInputChannels (0),
  21. numOutputChannels (0),
  22. hasSharedContainer (false)
  23. {
  24. }
  25. PluginDescription::~PluginDescription()
  26. {
  27. }
  28. PluginDescription::PluginDescription (const PluginDescription& other)
  29. : name (other.name),
  30. descriptiveName (other.descriptiveName),
  31. pluginFormatName (other.pluginFormatName),
  32. category (other.category),
  33. manufacturerName (other.manufacturerName),
  34. version (other.version),
  35. fileOrIdentifier (other.fileOrIdentifier),
  36. lastFileModTime (other.lastFileModTime),
  37. uid (other.uid),
  38. isInstrument (other.isInstrument),
  39. numInputChannels (other.numInputChannels),
  40. numOutputChannels (other.numOutputChannels),
  41. hasSharedContainer (other.hasSharedContainer)
  42. {
  43. }
  44. PluginDescription& PluginDescription::operator= (const PluginDescription& other)
  45. {
  46. name = other.name;
  47. descriptiveName = other.descriptiveName;
  48. pluginFormatName = other.pluginFormatName;
  49. category = other.category;
  50. manufacturerName = other.manufacturerName;
  51. version = other.version;
  52. fileOrIdentifier = other.fileOrIdentifier;
  53. uid = other.uid;
  54. isInstrument = other.isInstrument;
  55. lastFileModTime = other.lastFileModTime;
  56. numInputChannels = other.numInputChannels;
  57. numOutputChannels = other.numOutputChannels;
  58. hasSharedContainer = other.hasSharedContainer;
  59. return *this;
  60. }
  61. bool PluginDescription::isDuplicateOf (const PluginDescription& other) const noexcept
  62. {
  63. return fileOrIdentifier == other.fileOrIdentifier
  64. && uid == other.uid;
  65. }
  66. static String getPluginDescSuffix (const PluginDescription& d)
  67. {
  68. return "-" + String::toHexString (d.fileOrIdentifier.hashCode())
  69. + "-" + String::toHexString (d.uid);
  70. }
  71. bool PluginDescription::matchesIdentifierString (const String& identifierString) const
  72. {
  73. return identifierString.endsWithIgnoreCase (getPluginDescSuffix (*this));
  74. }
  75. String PluginDescription::createIdentifierString() const
  76. {
  77. return pluginFormatName + "-" + name + getPluginDescSuffix (*this);
  78. }
  79. XmlElement* PluginDescription::createXml() const
  80. {
  81. XmlElement* const e = new XmlElement ("PLUGIN");
  82. e->setAttribute ("name", name);
  83. if (descriptiveName != name)
  84. e->setAttribute ("descriptiveName", descriptiveName);
  85. e->setAttribute ("format", pluginFormatName);
  86. e->setAttribute ("category", category);
  87. e->setAttribute ("manufacturer", manufacturerName);
  88. e->setAttribute ("version", version);
  89. e->setAttribute ("file", fileOrIdentifier);
  90. e->setAttribute ("uid", String::toHexString (uid));
  91. e->setAttribute ("isInstrument", isInstrument);
  92. e->setAttribute ("fileTime", String::toHexString (lastFileModTime.toMilliseconds()));
  93. e->setAttribute ("numInputs", numInputChannels);
  94. e->setAttribute ("numOutputs", numOutputChannels);
  95. e->setAttribute ("isShell", hasSharedContainer);
  96. return e;
  97. }
  98. bool PluginDescription::loadFromXml (const XmlElement& xml)
  99. {
  100. if (xml.hasTagName ("PLUGIN"))
  101. {
  102. name = xml.getStringAttribute ("name");
  103. descriptiveName = xml.getStringAttribute ("descriptiveName", name);
  104. pluginFormatName = xml.getStringAttribute ("format");
  105. category = xml.getStringAttribute ("category");
  106. manufacturerName = xml.getStringAttribute ("manufacturer");
  107. version = xml.getStringAttribute ("version");
  108. fileOrIdentifier = xml.getStringAttribute ("file");
  109. uid = xml.getStringAttribute ("uid").getHexValue32();
  110. isInstrument = xml.getBoolAttribute ("isInstrument", false);
  111. lastFileModTime = Time (xml.getStringAttribute ("fileTime").getHexValue64());
  112. numInputChannels = xml.getIntAttribute ("numInputs");
  113. numOutputChannels = xml.getIntAttribute ("numOutputs");
  114. hasSharedContainer = xml.getBoolAttribute ("isShell", false);
  115. return true;
  116. }
  117. return false;
  118. }