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.

129 lines
4.7KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-11 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. PluginDescription::PluginDescription()
  19. : uid (0),
  20. isInstrument (false),
  21. numInputChannels (0),
  22. numOutputChannels (0)
  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. {
  42. }
  43. PluginDescription& PluginDescription::operator= (const PluginDescription& other)
  44. {
  45. name = other.name;
  46. descriptiveName = other.descriptiveName;
  47. pluginFormatName = other.pluginFormatName;
  48. category = other.category;
  49. manufacturerName = other.manufacturerName;
  50. version = other.version;
  51. fileOrIdentifier = other.fileOrIdentifier;
  52. uid = other.uid;
  53. isInstrument = other.isInstrument;
  54. lastFileModTime = other.lastFileModTime;
  55. numInputChannels = other.numInputChannels;
  56. numOutputChannels = other.numOutputChannels;
  57. return *this;
  58. }
  59. bool PluginDescription::isDuplicateOf (const PluginDescription& other) const
  60. {
  61. return fileOrIdentifier == other.fileOrIdentifier
  62. && uid == other.uid;
  63. }
  64. String PluginDescription::createIdentifierString() const
  65. {
  66. return pluginFormatName
  67. + "-" + name
  68. + "-" + String::toHexString (fileOrIdentifier.hashCode())
  69. + "-" + String::toHexString (uid);
  70. }
  71. XmlElement* PluginDescription::createXml() const
  72. {
  73. XmlElement* const e = new XmlElement ("PLUGIN");
  74. e->setAttribute ("name", name);
  75. if (descriptiveName != name)
  76. e->setAttribute ("descriptiveName", descriptiveName);
  77. e->setAttribute ("format", pluginFormatName);
  78. e->setAttribute ("category", category);
  79. e->setAttribute ("manufacturer", manufacturerName);
  80. e->setAttribute ("version", version);
  81. e->setAttribute ("file", fileOrIdentifier);
  82. e->setAttribute ("uid", String::toHexString (uid));
  83. e->setAttribute ("isInstrument", isInstrument);
  84. e->setAttribute ("fileTime", String::toHexString (lastFileModTime.toMilliseconds()));
  85. e->setAttribute ("numInputs", numInputChannels);
  86. e->setAttribute ("numOutputs", numOutputChannels);
  87. return e;
  88. }
  89. bool PluginDescription::loadFromXml (const XmlElement& xml)
  90. {
  91. if (xml.hasTagName ("PLUGIN"))
  92. {
  93. name = xml.getStringAttribute ("name");
  94. descriptiveName = xml.getStringAttribute ("descriptiveName", name);
  95. pluginFormatName = xml.getStringAttribute ("format");
  96. category = xml.getStringAttribute ("category");
  97. manufacturerName = xml.getStringAttribute ("manufacturer");
  98. version = xml.getStringAttribute ("version");
  99. fileOrIdentifier = xml.getStringAttribute ("file");
  100. uid = xml.getStringAttribute ("uid").getHexValue32();
  101. isInstrument = xml.getBoolAttribute ("isInstrument", false);
  102. lastFileModTime = Time (xml.getStringAttribute ("fileTime").getHexValue64());
  103. numInputChannels = xml.getIntAttribute ("numInputs");
  104. numOutputChannels = xml.getIntAttribute ("numOutputs");
  105. return true;
  106. }
  107. return false;
  108. }