Lv2Features.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Lv2Features.h - Lv2Features class
  3. *
  4. * Copyright (c) 2020-2020 Johannes Lorenz <jlsf2013$users.sourceforge.net, $=@>
  5. *
  6. * This file is part of LMMS - https://lmms.io
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2 of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public
  19. * License along with this program (see COPYING); if not, write to the
  20. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  21. * Boston, MA 02110-1301 USA.
  22. *
  23. */
  24. #ifndef LV2FEATURES_H
  25. #define LV2FEATURES_H
  26. #include "lmmsconfig.h"
  27. #ifdef LMMS_HAVE_LV2
  28. #include <lv2.h>
  29. #include <map>
  30. #include <vector>
  31. #include "Lv2Manager.h"
  32. /**
  33. Feature container
  34. References all available features for a plugin and maps them to their URIs.
  35. The public member functions should be called in descending order:
  36. 1. initCommon: map plugin-common features
  37. 2. operator[]: map plugin-specific features
  38. 3. createFeatureVectors: create the feature vectors required for
  39. lilv_plugin_instantiate
  40. 4. access the latter
  41. */
  42. class Lv2Features
  43. {
  44. public:
  45. //! Return if a feature is supported by LMMS
  46. static bool isFeatureSupported(const char *featName);
  47. Lv2Features();
  48. //! Register only plugin-common features
  49. void initCommon();
  50. //! Return reference to feature data with given URI featName
  51. void*& operator[](const char* featName);
  52. //! Fill m_features and m_featurePointers with all features
  53. void createFeatureVectors();
  54. //! Return LV2_Feature pointer vector, suited for lilv_plugin_instantiate
  55. const LV2_Feature* const* featurePointers() const
  56. {
  57. return m_featurePointers.data();
  58. }
  59. private:
  60. //! feature storage
  61. std::vector<LV2_Feature> m_features;
  62. //! pointers to m_features, required for lilv_plugin_instantiate
  63. std::vector<const LV2_Feature*> m_featurePointers;
  64. //! features + data, ordered by URI
  65. std::map<const char*, void*, Lv2Manager::CmpStr> m_featureByUri;
  66. };
  67. #endif // LMMS_HAVE_LV2
  68. #endif // LV2FEATURES_H