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.

ipersistent.h 7.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. class IPersistent: public FUnknown
  41. {
  42. public:
  43. //------------------------------------------------------------------------
  44. /** The class ID must be a 16 bytes unique id that is used to create the object.
  45. This ID is also used to identify the preset list when used with presets. */
  46. virtual tresult PLUGIN_API getClassID (char8* uid) = 0;
  47. /** Store all members/data in the passed IAttributes. */
  48. virtual tresult PLUGIN_API saveAttributes (IAttributes* ) = 0;
  49. /** Restore all members/data from the passed IAttributes. */
  50. virtual tresult PLUGIN_API loadAttributes (IAttributes* ) = 0;
  51. //------------------------------------------------------------------------
  52. static const FUID iid;
  53. };
  54. DECLARE_CLASS_IID (IPersistent, 0xBA1A4637, 0x3C9F46D0, 0xA65DBA0E, 0xB85DA829)
  55. typedef FIDString IAttrID;
  56. //------------------------------------------------------------------------
  57. /** Object Data Archive Interface.
  58. - [host imp]
  59. - store data/objects/binary/subattributes in the archive
  60. - read stored data from the archive
  61. All data stored to the archive are identified by a string (IAttrID), which must be unique on each
  62. IAttribute level.
  63. The basic set/get methods make use of the FVariant class defined in 'funknown.h'.
  64. For a more convenient usage of this interface, you should use the functions defined
  65. in namespace PAttributes (public.sdk/source/common/pattributes.h+cpp) !!
  66. \ingroup frameworkHostClasses
  67. */
  68. class IAttributes: public FUnknown
  69. {
  70. public:
  71. //------------------------------------------------------------------------
  72. /*! \name Methods to write attributes
  73. ******************************************************************************************************** */
  74. //@{
  75. /** Store any data in the archive. It is even possible to store sub-attributes by creating
  76. a new IAttributes instance via the IHostClasses interface and pass it to the parent in the
  77. FVariant. In this case the archive must take the ownership of the newly created object, which
  78. is true for all objects that have been created only for storing. You tell the archive to take
  79. ownership by adding the FVariant::kOwner flag to the FVariant::type member (data.type |= FVariant::kOwner).
  80. When using the PAttributes functions, this is done through a function parameter.*/
  81. virtual tresult PLUGIN_API set (IAttrID attrID, const FVariant& data) = 0;
  82. /** Store a list of data in the archive. Please note that the type of data is not mixable! So
  83. you can only store a list of integers or a list of doubles/strings/etc. You can also store a list
  84. of subattributes or other objects that implement the IPersistent interface.*/
  85. virtual tresult PLUGIN_API queue (IAttrID listID, const FVariant& data) = 0;
  86. /** Store binary data in the archive. Parameter 'copyBytes' specifies if the passed data should be copied.
  87. The archive cannot take the ownership of binary data. Either it just references a buffer in order
  88. to write it to a file (copyBytes = false) or it copies the data to its own buffers (copyBytes = true).
  89. When binary data should be stored in the default pool for example, you must always copy it!*/
  90. virtual tresult PLUGIN_API setBinaryData (IAttrID attrID, void* data, uint32 bytes, bool copyBytes) = 0;
  91. //@}
  92. /*! \name Methods to read attributes
  93. ******************************************************************************************************** */
  94. //@{
  95. /** Get data previously stored to the archive. */
  96. virtual tresult PLUGIN_API get (IAttrID attrID, FVariant& data) = 0;
  97. /** Get list of data previously stored to the archive. As long as there are queue members the method
  98. will return kResultTrue. When the queue is empty, the methods returns kResultFalse. All lists except from
  99. object lists can be reset which means that the items can be read once again. \see IAttributes::resetQueue */
  100. virtual tresult PLUGIN_API unqueue (IAttrID listID, FVariant& data) = 0;
  101. /** Get the amount of items in a queue. */
  102. virtual int32 PLUGIN_API getQueueItemCount (IAttrID) = 0;
  103. /** Reset a queue. If you need to restart reading a queue, you have to reset it. You can reset a queue at any time.*/
  104. virtual tresult PLUGIN_API resetQueue (IAttrID attrID) = 0;
  105. /** Reset all queues in the archive.*/
  106. virtual tresult PLUGIN_API resetAllQueues () = 0;
  107. /** Read binary data from the archive. The data is copied into the passed buffer. The size of that buffer
  108. must fit the size of data stored in the archive which can be queried via IAttributes::getBinaryDataSize */
  109. virtual tresult PLUGIN_API getBinaryData (IAttrID attrID, void* data, uint32 bytes) = 0;
  110. /** Get the size in bytes of binary data in the archive. */
  111. virtual uint32 PLUGIN_API getBinaryDataSize (IAttrID attrID) = 0;
  112. //@}
  113. //------------------------------------------------------------------------
  114. static const FUID iid;
  115. };
  116. DECLARE_CLASS_IID (IAttributes, 0xFA1E32F9, 0xCA6D46F5, 0xA982F956, 0xB1191B58)
  117. //------------------------------------------------------------------------
  118. /** Extended access to Attributes; supports Attribute retrieval via iteration.
  119. - [host imp]
  120. - [released] C7/N6
  121. \ingroup frameworkHostClasses
  122. */
  123. class IAttributes2 : public IAttributes
  124. {
  125. public:
  126. /** Returns the number of existing attributes. */
  127. virtual int32 PLUGIN_API countAttributes () const = 0;
  128. /** Returns the attribute's ID for the given index. */
  129. virtual IAttrID PLUGIN_API getAttributeID (int32 index) const = 0;
  130. //------------------------------------------------------------------------
  131. static const FUID iid;
  132. };
  133. DECLARE_CLASS_IID (IAttributes2, 0x1382126A, 0xFECA4871, 0x97D52A45, 0xB042AE99)
  134. //------------------------------------------------------------------------
  135. } // namespace Steinberg