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.

pluginclass.c 2.8KB

12 years ago
9 years ago
12 years ago
12 years ago
9 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. Copyright 2007-2015 David Robillard <http://drobilla.net>
  3. Permission to use, copy, modify, and/or distribute this software for any
  4. purpose with or without fee is hereby granted, provided that the above
  5. copyright notice and this permission notice appear in all copies.
  6. THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  7. WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  8. MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  9. ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  10. WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  11. ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  12. OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  13. */
  14. #include <stdlib.h>
  15. #include <string.h>
  16. #include "lilv_internal.h"
  17. LilvPluginClass*
  18. lilv_plugin_class_new(LilvWorld* world,
  19. const SordNode* parent_node,
  20. const SordNode* uri,
  21. const char* label)
  22. {
  23. LilvPluginClass* pc = (LilvPluginClass*)malloc(sizeof(LilvPluginClass));
  24. pc->world = world;
  25. pc->uri = lilv_node_new_from_node(world, uri);
  26. pc->label = lilv_node_new(world, LILV_VALUE_STRING, label);
  27. pc->parent_uri = (parent_node
  28. ? lilv_node_new_from_node(world, parent_node)
  29. : NULL);
  30. return pc;
  31. }
  32. void
  33. lilv_plugin_class_free(LilvPluginClass* plugin_class)
  34. {
  35. if (!plugin_class) {
  36. return;
  37. }
  38. lilv_node_free(plugin_class->uri);
  39. lilv_node_free(plugin_class->parent_uri);
  40. lilv_node_free(plugin_class->label);
  41. free(plugin_class);
  42. }
  43. LILV_API const LilvNode*
  44. lilv_plugin_class_get_parent_uri(const LilvPluginClass* plugin_class)
  45. {
  46. return plugin_class->parent_uri ? plugin_class->parent_uri : NULL;
  47. }
  48. LILV_API const LilvNode*
  49. lilv_plugin_class_get_uri(const LilvPluginClass* plugin_class)
  50. {
  51. return plugin_class->uri;
  52. }
  53. LILV_API const LilvNode*
  54. lilv_plugin_class_get_label(const LilvPluginClass* plugin_class)
  55. {
  56. return plugin_class->label;
  57. }
  58. LILV_API LilvPluginClasses*
  59. lilv_plugin_class_get_children(const LilvPluginClass* plugin_class)
  60. {
  61. // Returned list doesn't own categories
  62. LilvPluginClasses* all = plugin_class->world->plugin_classes;
  63. LilvPluginClasses* result = zix_tree_new(false, lilv_ptr_cmp, NULL, NULL);
  64. for (ZixTreeIter* i = zix_tree_begin((ZixTree*)all);
  65. i != zix_tree_end((ZixTree*)all);
  66. i = zix_tree_iter_next(i)) {
  67. const LilvPluginClass* c = (LilvPluginClass*)zix_tree_get(i);
  68. const LilvNode* parent = lilv_plugin_class_get_parent_uri(c);
  69. if (parent && lilv_node_equals(lilv_plugin_class_get_uri(plugin_class),
  70. parent))
  71. zix_tree_insert((ZixTree*)result, (LilvPluginClass*)c, NULL);
  72. }
  73. return result;
  74. }