manager.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Copyright 2019 yuzu emulator team
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include "core/hle/service/glue/errors.h"
  5. #include "core/hle/service/glue/manager.h"
  6. namespace Service::Glue {
  7. ARPManager::ARPManager() = default;
  8. ARPManager::~ARPManager() = default;
  9. ResultVal<ApplicationLaunchProperty> ARPManager::GetLaunchProperty(u64 title_id) const {
  10. if (title_id == 0) {
  11. return ERR_TITLE_ID_ZERO;
  12. }
  13. const auto iter = entries.find(title_id);
  14. if (iter == entries.end()) {
  15. return ERR_NONEXISTENT;
  16. }
  17. return MakeResult<ApplicationLaunchProperty>(iter->second.launch);
  18. }
  19. ResultVal<std::vector<u8>> ARPManager::GetControlProperty(u64 title_id) const {
  20. if (title_id == 0) {
  21. return ERR_TITLE_ID_ZERO;
  22. }
  23. const auto iter = entries.find(title_id);
  24. if (iter == entries.end()) {
  25. return ERR_NONEXISTENT;
  26. }
  27. return MakeResult<std::vector<u8>>(iter->second.control);
  28. }
  29. ResultCode ARPManager::Register(u64 title_id, ApplicationLaunchProperty launch,
  30. std::vector<u8> control) {
  31. if (title_id == 0) {
  32. return ERR_TITLE_ID_ZERO;
  33. }
  34. const auto iter = entries.find(title_id);
  35. if (iter != entries.end()) {
  36. return ERR_ALREADY_ISSUED;
  37. }
  38. entries.insert_or_assign(title_id, MapEntry{launch, std::move(control)});
  39. return RESULT_SUCCESS;
  40. }
  41. ResultCode ARPManager::Unregister(u64 title_id) {
  42. if (title_id == 0) {
  43. return ERR_TITLE_ID_ZERO;
  44. }
  45. const auto iter = entries.find(title_id);
  46. if (iter == entries.end()) {
  47. return ERR_NONEXISTENT;
  48. }
  49. entries.erase(iter);
  50. return RESULT_SUCCESS;
  51. }
  52. void ARPManager::ResetAll() {
  53. entries.clear();
  54. }
  55. } // namespace Service::Glue