irda-app-remote-manager.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #pragma once
  2. #include "irda-app-signal.h"
  3. #include <irda_worker.h>
  4. #include <irda.h>
  5. #include <cstdint>
  6. #include <string>
  7. #include <memory>
  8. #include <vector>
  9. class IrdaAppRemoteButton {
  10. friend class IrdaAppRemoteManager;
  11. std::string name;
  12. IrdaAppSignal signal;
  13. public:
  14. IrdaAppRemoteButton(const char* name, const IrdaAppSignal& signal)
  15. : name(name)
  16. , signal(signal) {
  17. }
  18. ~IrdaAppRemoteButton() {
  19. }
  20. };
  21. class IrdaAppRemote {
  22. friend class IrdaAppRemoteManager;
  23. std::vector<IrdaAppRemoteButton> buttons;
  24. std::string name;
  25. public:
  26. IrdaAppRemote(const std::string& name)
  27. : name(name) {
  28. }
  29. IrdaAppRemote& operator=(std::string& new_name) noexcept {
  30. name = new_name;
  31. buttons.clear();
  32. return *this;
  33. }
  34. };
  35. class IrdaAppRemoteManager {
  36. std::unique_ptr<IrdaAppRemote> remote;
  37. std::string make_full_name(const std::string& remote_name) const;
  38. std::string make_remote_name(const std::string& full_name) const;
  39. public:
  40. static inline const uint32_t max_button_name_length = 22;
  41. static inline const uint32_t max_remote_name_length = 22;
  42. bool add_remote_with_button(const char* button_name, const IrdaAppSignal& signal);
  43. bool add_button(const char* button_name, const IrdaAppSignal& signal);
  44. int find_remote_name(const std::vector<std::string>& strings);
  45. bool rename_button(uint32_t index, const char* str);
  46. bool rename_remote(const char* str);
  47. std::string find_vacant_remote_name(const std::string& name);
  48. std::vector<std::string> get_button_list() const;
  49. std::string get_button_name(uint32_t index);
  50. std::string get_remote_name();
  51. size_t get_number_of_buttons();
  52. const IrdaAppSignal& get_button_data(size_t index) const;
  53. bool delete_button(uint32_t index);
  54. bool delete_remote();
  55. void reset_remote();
  56. bool store();
  57. bool load(const std::string& name);
  58. };