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.

152 lines
5.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. namespace juce
  20. {
  21. PluginDescription::PluginDescription()
  22. : uid (0),
  23. isInstrument (false),
  24. numInputChannels (0),
  25. numOutputChannels (0),
  26. hasSharedContainer (false)
  27. {
  28. }
  29. PluginDescription::~PluginDescription()
  30. {
  31. }
  32. PluginDescription::PluginDescription (const PluginDescription& other)
  33. : name (other.name),
  34. descriptiveName (other.descriptiveName),
  35. pluginFormatName (other.pluginFormatName),
  36. category (other.category),
  37. manufacturerName (other.manufacturerName),
  38. version (other.version),
  39. fileOrIdentifier (other.fileOrIdentifier),
  40. lastFileModTime (other.lastFileModTime),
  41. lastInfoUpdateTime (other.lastInfoUpdateTime),
  42. uid (other.uid),
  43. isInstrument (other.isInstrument),
  44. numInputChannels (other.numInputChannels),
  45. numOutputChannels (other.numOutputChannels),
  46. hasSharedContainer (other.hasSharedContainer)
  47. {
  48. }
  49. PluginDescription& PluginDescription::operator= (const PluginDescription& other)
  50. {
  51. name = other.name;
  52. descriptiveName = other.descriptiveName;
  53. pluginFormatName = other.pluginFormatName;
  54. category = other.category;
  55. manufacturerName = other.manufacturerName;
  56. version = other.version;
  57. fileOrIdentifier = other.fileOrIdentifier;
  58. uid = other.uid;
  59. isInstrument = other.isInstrument;
  60. lastFileModTime = other.lastFileModTime;
  61. lastInfoUpdateTime = other.lastInfoUpdateTime;
  62. numInputChannels = other.numInputChannels;
  63. numOutputChannels = other.numOutputChannels;
  64. hasSharedContainer = other.hasSharedContainer;
  65. return *this;
  66. }
  67. bool PluginDescription::isDuplicateOf (const PluginDescription& other) const noexcept
  68. {
  69. return fileOrIdentifier == other.fileOrIdentifier
  70. && uid == other.uid;
  71. }
  72. static String getPluginDescSuffix (const PluginDescription& d)
  73. {
  74. return "-" + String::toHexString (d.fileOrIdentifier.hashCode())
  75. + "-" + String::toHexString (d.uid);
  76. }
  77. bool PluginDescription::matchesIdentifierString (const String& identifierString) const
  78. {
  79. return identifierString.endsWithIgnoreCase (getPluginDescSuffix (*this));
  80. }
  81. String PluginDescription::createIdentifierString() const
  82. {
  83. return pluginFormatName + "-" + name + getPluginDescSuffix (*this);
  84. }
  85. XmlElement* PluginDescription::createXml() const
  86. {
  87. XmlElement* const e = new XmlElement ("PLUGIN");
  88. e->setAttribute ("name", name);
  89. if (descriptiveName != name)
  90. e->setAttribute ("descriptiveName", descriptiveName);
  91. e->setAttribute ("format", pluginFormatName);
  92. e->setAttribute ("category", category);
  93. e->setAttribute ("manufacturer", manufacturerName);
  94. e->setAttribute ("version", version);
  95. e->setAttribute ("file", fileOrIdentifier);
  96. e->setAttribute ("uid", String::toHexString (uid));
  97. e->setAttribute ("isInstrument", isInstrument);
  98. e->setAttribute ("fileTime", String::toHexString (lastFileModTime.toMilliseconds()));
  99. e->setAttribute ("infoUpdateTime", String::toHexString (lastInfoUpdateTime.toMilliseconds()));
  100. e->setAttribute ("numInputs", numInputChannels);
  101. e->setAttribute ("numOutputs", numOutputChannels);
  102. e->setAttribute ("isShell", hasSharedContainer);
  103. return e;
  104. }
  105. bool PluginDescription::loadFromXml (const XmlElement& xml)
  106. {
  107. if (xml.hasTagName ("PLUGIN"))
  108. {
  109. name = xml.getStringAttribute ("name");
  110. descriptiveName = xml.getStringAttribute ("descriptiveName", name);
  111. pluginFormatName = xml.getStringAttribute ("format");
  112. category = xml.getStringAttribute ("category");
  113. manufacturerName = xml.getStringAttribute ("manufacturer");
  114. version = xml.getStringAttribute ("version");
  115. fileOrIdentifier = xml.getStringAttribute ("file");
  116. uid = xml.getStringAttribute ("uid").getHexValue32();
  117. isInstrument = xml.getBoolAttribute ("isInstrument", false);
  118. lastFileModTime = Time (xml.getStringAttribute ("fileTime").getHexValue64());
  119. lastInfoUpdateTime = Time (xml.getStringAttribute ("infoUpdateTime").getHexValue64());
  120. numInputChannels = xml.getIntAttribute ("numInputs");
  121. numOutputChannels = xml.getIntAttribute ("numOutputs");
  122. hasSharedContainer = xml.getBoolAttribute ("isShell", false);
  123. return true;
  124. }
  125. return false;
  126. }
  127. } // namespace juce