Lv2UridCache.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Lv2UridCache.h - Lv2UridCache definition
  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 LV2URIDCACHE_H
  25. #define LV2URIDCACHE_H
  26. #include "lmmsconfig.h"
  27. #ifdef LMMS_HAVE_LV2
  28. #include <QtGlobal>
  29. #include <cstdint>
  30. //! Cached URIDs for fast access (for use in real-time code)
  31. class Lv2UridCache
  32. {
  33. public:
  34. enum class Id //!< ID for m_uridCache array
  35. {
  36. // keep it alphabetically (except "size" at the end)
  37. atom_Float,
  38. atom_Int,
  39. bufsz_minBlockLength,
  40. bufsz_maxBlockLength,
  41. bufsz_nominalBlockLength,
  42. bufsz_sequenceSize,
  43. midi_MidiEvent,
  44. param_sampleRate,
  45. // exception to alphabetic ordering - keep at the end:
  46. size
  47. };
  48. template<typename T>
  49. struct IdForType;
  50. //! Return URID for a cache ID
  51. uint32_t operator[](Id id) const;
  52. Lv2UridCache(class UridMap& mapper);
  53. private:
  54. uint32_t m_cache[static_cast<int>(Id::size)];
  55. };
  56. template<> struct Lv2UridCache::IdForType<float> { static constexpr auto value = Id::atom_Float; };
  57. template<> struct Lv2UridCache::IdForType<std::int32_t> { static constexpr auto value = Id::atom_Int; };
  58. #endif // LMMS_HAVE_LV2
  59. #endif // LV2URIDCACHE_H