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.

88 lines
4.0KB

  1. //------------------------------------------------------------------------
  2. // Project : SDK Base
  3. // Version : 1.0
  4. //
  5. // Category : Helpers
  6. // Filename : base/source/classfactoryhelpers.h
  7. // Created by : Steinberg, 03/2017
  8. // Description : Class factory
  9. //
  10. //-----------------------------------------------------------------------------
  11. // LICENSE
  12. // (c) 2017, Steinberg Media Technologies GmbH, All Rights Reserved
  13. //-----------------------------------------------------------------------------
  14. // Redistribution and use in source and binary forms, with or without modification,
  15. // are permitted provided that the following conditions are met:
  16. //
  17. // * Redistributions of source code must retain the above copyright notice,
  18. // this list of conditions and the following disclaimer.
  19. // * Redistributions in binary form must reproduce the above copyright notice,
  20. // this list of conditions and the following disclaimer in the documentation
  21. // and/or other materials provided with the distribution.
  22. // * Neither the name of the Steinberg Media Technologies nor the names of its
  23. // contributors may be used to endorse or promote products derived from this
  24. // software without specific prior written permission.
  25. //
  26. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  27. // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  28. // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  29. // IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  30. // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  31. // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  32. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  33. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  34. // OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  35. // OF THE POSSIBILITY OF SUCH DAMAGE.
  36. //-----------------------------------------------------------------------------
  37. #pragma once
  38. //------------------------------------------------------------------------------
  39. // Helper Macros. Not intended for direct use.
  40. // Use:
  41. // META_CLASS(className),
  42. // META_CLASS_IFACE(className,Interface),
  43. // META_CLASS_SINGLE(className,Interface)
  44. // instead.
  45. //------------------------------------------------------------------------------
  46. #define META_CREATE_FUNC(funcName) static FUnknown* funcName ()
  47. #define CLASS_CREATE_FUNC(className) \
  48. namespace Meta { \
  49. META_CREATE_FUNC (make##className) { return (NEW className)->unknownCast (); } \
  50. }
  51. #define SINGLE_CREATE_FUNC(className) \
  52. namespace Meta { \
  53. META_CREATE_FUNC (make##className) { return className::instance ()->unknownCast (); } \
  54. }
  55. #define _META_CLASS(className) \
  56. namespace Meta { \
  57. static Steinberg::MetaClass meta##className ((#className), Meta::make##className); \
  58. }
  59. #define _META_CLASS_IFACE(className, Interface) \
  60. namespace Meta { \
  61. static Steinberg::MetaClass meta##Interface##className ((#className), Meta::make##className, \
  62. Interface##_iid); \
  63. }
  64. /** TODO
  65. */
  66. #define META_CLASS(className) \
  67. CLASS_CREATE_FUNC (className) \
  68. _META_CLASS (className)
  69. /** TODO
  70. */
  71. #define META_CLASS_IFACE(className, Interface) \
  72. CLASS_CREATE_FUNC (className) \
  73. _META_CLASS_IFACE (className, Interface)
  74. /** TODO
  75. */
  76. #define META_CLASS_SINGLE(className, Interface) \
  77. SINGLE_CREATE_FUNC (className) \
  78. _META_CLASS_IFACE (className, Interface)