Audio plugin host https://kx.studio/carla
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.

162 lines
7.5KB

  1. //-----------------------------------------------------------------------------
  2. // Project : SDK Core
  3. //
  4. // Category : SDK Core Interfaces
  5. // Filename : pluginterfaces/base/ipersistent.h
  6. // Created by : Steinberg, 09/2004
  7. // Description : Plug-In Storage Interfaces
  8. //
  9. //-----------------------------------------------------------------------------
  10. // This file is part of a Steinberg SDK. It is subject to the license terms
  11. // in the LICENSE file found in the top-level directory of this distribution
  12. // and at www.steinberg.net/sdklicenses.
  13. // No part of the SDK, including this file, may be copied, modified, propagated,
  14. // or distributed except according to the terms contained in the LICENSE file.
  15. //-----------------------------------------------------------------------------
  16. #pragma once
  17. #include "pluginterfaces/base/funknown.h"
  18. namespace Steinberg {
  19. class FVariant;
  20. class IAttributes;
  21. //------------------------------------------------------------------------
  22. /** Persistent Object Interface.
  23. [plug imp] \n
  24. This interface is used to store/restore attributes of an object.
  25. An IPlugController can implement this interface to handle presets.
  26. The gui-xml for a preset control looks like this:
  27. \code
  28. ....
  29. <view name="PresetView" data="Preset"/>
  30. ....
  31. <template name="PresetView">
  32. <view name="preset control" size="0, 0, 100, 20"/>
  33. <switch name="store preset" size="125,0,80,20" style="push|immediate" title="Store" />
  34. <switch name="remove preset" size="220,0,80,20" style="push|immediate" title="Delete" />
  35. </template>
  36. \endcode
  37. The tag data="Preset" tells the host to create a preset controller that handles the
  38. 3 values named "preset control", "store preset", and "remove preset".
  39. */
  40. //------------------------------------------------------------------------
  41. class IPersistent: public FUnknown
  42. {
  43. public:
  44. //------------------------------------------------------------------------
  45. /** The class ID must be a 16 bytes unique id that is used to create the object.
  46. This ID is also used to identify the preset list when used with presets. */
  47. virtual tresult PLUGIN_API getClassID (char8* uid) = 0;
  48. /** Store all members/data in the passed IAttributes. */
  49. virtual tresult PLUGIN_API saveAttributes (IAttributes* ) = 0;
  50. /** Restore all members/data from the passed IAttributes. */
  51. virtual tresult PLUGIN_API loadAttributes (IAttributes* ) = 0;
  52. //------------------------------------------------------------------------
  53. static const FUID iid;
  54. };
  55. DECLARE_CLASS_IID (IPersistent, 0xBA1A4637, 0x3C9F46D0, 0xA65DBA0E, 0xB85DA829)
  56. typedef FIDString IAttrID;
  57. //------------------------------------------------------------------------
  58. /** Object Data Archive Interface.
  59. [host imp] \n
  60. - store data/objects/binary/subattributes in the archive
  61. - read stored data from the archive
  62. All data stored to the archive are identified by a string (IAttrID), which must be unique on each
  63. IAttribute level.
  64. The basic set/get methods make use of the FVariant class defined in 'funknown.h'.
  65. For a more convenient usage of this interface, you should use the functions defined
  66. in namespace PAttributes (public.sdk/source/common/pattributes.h+cpp) !!
  67. \ingroup frameworkHostClasses
  68. */
  69. //------------------------------------------------------------------------
  70. class IAttributes: public FUnknown
  71. {
  72. public:
  73. //------------------------------------------------------------------------
  74. /*! \name Methods to write attributes
  75. ******************************************************************************************************** */
  76. //@{
  77. /** Store any data in the archive. It is even possible to store sub-attributes by creating
  78. a new IAttributes instance via the IHostClasses interface and pass it to the parent in the
  79. FVariant. In this case the archive must take the ownership of the newly created object, which
  80. is true for all objects that have been created only for storing. You tell the archive to take
  81. ownership by adding the FVariant::kOwner flag to the FVariant::type member (data.type |= FVariant::kOwner).
  82. When using the PAttributes functions, this is done through a function parameter.*/
  83. virtual tresult PLUGIN_API set (IAttrID attrID, const FVariant& data) = 0;
  84. /** Store a list of data in the archive. Please note that the type of data is not mixable! So
  85. you can only store a list of integers or a list of doubles/strings/etc. You can also store a list
  86. of subattributes or other objects that implement the IPersistent interface.*/
  87. virtual tresult PLUGIN_API queue (IAttrID listID, const FVariant& data) = 0;
  88. /** Store binary data in the archive. Parameter 'copyBytes' specifies if the passed data should be copied.
  89. The archive cannot take the ownership of binary data. Either it just references a buffer in order
  90. to write it to a file (copyBytes = false) or it copies the data to its own buffers (copyBytes = true).
  91. When binary data should be stored in the default pool for example, you must always copy it!*/
  92. virtual tresult PLUGIN_API setBinaryData (IAttrID attrID, void* data, uint32 bytes, bool copyBytes) = 0;
  93. //@}
  94. /*! \name Methods to read attributes
  95. ******************************************************************************************************** */
  96. //@{
  97. /** Get data previously stored to the archive. */
  98. virtual tresult PLUGIN_API get (IAttrID attrID, FVariant& data) = 0;
  99. /** Get list of data previously stored to the archive. As long as there are queue members the method
  100. will return kResultTrue. When the queue is empty, the methods returns kResultFalse. All lists except from
  101. object lists can be reset which means that the items can be read once again. \see IAttributes::resetQueue */
  102. virtual tresult PLUGIN_API unqueue (IAttrID listID, FVariant& data) = 0;
  103. /** Get the amount of items in a queue. */
  104. virtual int32 PLUGIN_API getQueueItemCount (IAttrID) = 0;
  105. /** Reset a queue. If you need to restart reading a queue, you have to reset it. You can reset a queue at any time.*/
  106. virtual tresult PLUGIN_API resetQueue (IAttrID attrID) = 0;
  107. /** Reset all queues in the archive.*/
  108. virtual tresult PLUGIN_API resetAllQueues () = 0;
  109. /** Read binary data from the archive. The data is copied into the passed buffer. The size of that buffer
  110. must fit the size of data stored in the archive which can be queried via IAttributes::getBinaryDataSize */
  111. virtual tresult PLUGIN_API getBinaryData (IAttrID attrID, void* data, uint32 bytes) = 0;
  112. /** Get the size in bytes of binary data in the archive. */
  113. virtual uint32 PLUGIN_API getBinaryDataSize (IAttrID attrID) = 0;
  114. //@}
  115. //------------------------------------------------------------------------
  116. static const FUID iid;
  117. };
  118. DECLARE_CLASS_IID (IAttributes, 0xFA1E32F9, 0xCA6D46F5, 0xA982F956, 0xB1191B58)
  119. //------------------------------------------------------------------------
  120. /** Extended access to Attributes; supports Attribute retrieval via iteration.
  121. [host imp] \n
  122. [released] C7/N6 \n
  123. \ingroup frameworkHostClasses
  124. */
  125. //------------------------------------------------------------------------
  126. class IAttributes2 : public IAttributes
  127. {
  128. public:
  129. /** Returns the number of existing attributes. */
  130. virtual int32 PLUGIN_API countAttributes () const = 0;
  131. /** Returns the attribute's ID for the given index. */
  132. virtual IAttrID PLUGIN_API getAttributeID (int32 index) const = 0;
  133. //------------------------------------------------------------------------
  134. static const FUID iid;
  135. };
  136. DECLARE_CLASS_IID (IAttributes2, 0x1382126A, 0xFECA4871, 0x97D52A45, 0xB042AE99)
  137. //------------------------------------------------------------------------
  138. } // namespace Steinberg