fx_slot_index.h 1019 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #ifndef EAX_FX_SLOT_INDEX_INCLUDED
  2. #define EAX_FX_SLOT_INDEX_INCLUDED
  3. #include <cstddef>
  4. #include <optional>
  5. #include "api.h"
  6. using EaxFxSlotIndexValue = std::size_t;
  7. class EaxFxSlotIndex : public std::optional<EaxFxSlotIndexValue> {
  8. public:
  9. using std::optional<EaxFxSlotIndexValue>::optional;
  10. EaxFxSlotIndex& operator=(const EaxFxSlotIndexValue &value) { set(value); return *this; }
  11. EaxFxSlotIndex& operator=(const GUID &guid) { set(guid); return *this; }
  12. void set(EaxFxSlotIndexValue index);
  13. void set(const GUID& guid);
  14. private:
  15. [[noreturn]]
  16. static void fail(const char *message);
  17. }; // EaxFxSlotIndex
  18. inline bool operator==(const EaxFxSlotIndex& lhs, const EaxFxSlotIndex& rhs) noexcept
  19. {
  20. if(lhs.has_value() != rhs.has_value())
  21. return false;
  22. if(lhs.has_value())
  23. return *lhs == *rhs;
  24. return true;
  25. }
  26. inline bool operator!=(const EaxFxSlotIndex& lhs, const EaxFxSlotIndex& rhs) noexcept
  27. { return !(lhs == rhs); }
  28. #endif // !EAX_FX_SLOT_INDEX_INCLUDED