🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
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.

97 lines
2.5 KiB

  1. #ifndef EAX_EAX_CALL_INCLUDED
  2. #define EAX_EAX_CALL_INCLUDED
  3. #include "AL/al.h"
  4. #include "alnumeric.h"
  5. #include "alspan.h"
  6. #include "api.h"
  7. #include "fx_slot_index.h"
  8. enum class EaxCallType {
  9. none,
  10. get,
  11. set,
  12. }; // EaxCallType
  13. enum class EaxCallPropertySetId {
  14. none,
  15. context,
  16. fx_slot,
  17. source,
  18. fx_slot_effect,
  19. }; // EaxCallPropertySetId
  20. class EaxCall {
  21. public:
  22. EaxCall(
  23. EaxCallType type,
  24. const GUID& property_set_guid,
  25. ALuint property_id,
  26. ALuint property_source_id,
  27. ALvoid* property_buffer,
  28. ALuint property_size);
  29. bool is_get() const noexcept { return type_ == EaxCallType::get; }
  30. int get_version() const noexcept { return version_; }
  31. EaxCallPropertySetId get_property_set_id() const noexcept { return property_set_id_; }
  32. ALuint get_property_id() const noexcept { return property_id_; }
  33. ALuint get_property_al_name() const noexcept { return property_source_id_; }
  34. EaxFxSlotIndex get_fx_slot_index() const noexcept { return fx_slot_index_; }
  35. template<typename TException, typename TValue>
  36. TValue& get_value() const
  37. {
  38. if (property_size_ < static_cast<ALuint>(sizeof(TValue)))
  39. {
  40. fail_too_small();
  41. }
  42. return *static_cast<TValue*>(property_buffer_);
  43. }
  44. template<typename TValue>
  45. al::span<TValue> get_values(size_t max_count) const
  46. {
  47. if (max_count == 0 || property_size_ < static_cast<ALuint>(sizeof(TValue)))
  48. fail_too_small();
  49. const auto count = minz(property_size_ / sizeof(TValue), max_count);
  50. return al::span<TValue>{static_cast<TValue*>(property_buffer_), count};
  51. }
  52. template<typename TValue>
  53. al::span<TValue> get_values() const
  54. {
  55. return get_values<TValue>(~size_t{});
  56. }
  57. template<typename TException, typename TValue>
  58. void set_value(const TValue& value) const
  59. {
  60. get_value<TException, TValue>() = value;
  61. }
  62. private:
  63. EaxCallType type_;
  64. int version_;
  65. EaxFxSlotIndex fx_slot_index_;
  66. EaxCallPropertySetId property_set_id_;
  67. ALuint property_id_;
  68. ALuint property_source_id_;
  69. ALvoid*property_buffer_;
  70. ALuint property_size_;
  71. [[noreturn]] static void fail(const char* message);
  72. [[noreturn]] static void fail_too_small();
  73. }; // EaxCall
  74. EaxCall create_eax_call(
  75. EaxCallType type,
  76. const GUID* property_set_id,
  77. ALuint property_id,
  78. ALuint property_source_id,
  79. ALvoid* property_buffer,
  80. ALuint property_size);
  81. #endif // !EAX_EAX_CALL_INCLUDED